Core - Added ColorGradient type to use for.. gradients!

Core - Initialisation process no longer takes place in core constructor and is no longer async
UI - Fixed exceptions during init not being shown
Gradient editor - Started work on this
This commit is contained in:
Robert committed 2020-02-28 13:03:30 +01:00
1 parent 2bcee30e11
commit 15bac30362
29 files changed
+1517 -113

No files matched your search

+19 -12
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
@@ -10,6 +9,7 @@ using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject;
using Artemis.UI.Screens;
using Artemis.UI.Screens.Splash;
using Artemis.UI.Shared.Services.Interfaces;
using Artemis.UI.Stylet;
using Ninject;
using Serilog;
@@ -32,35 +32,38 @@ namespace Artemis.UI
protected override void Launch()
{
StartupArguments = Args.ToList();
var logger = Kernel.Get<ILogger>();
var windowManager = Kernel.Get<IWindowManager>();
var viewManager = Kernel.Get<IViewManager>();
// Create the Artemis core
_core = Kernel.Get<ICoreService>();
// Create and bind the root view, this is a tray icon so don't show it with the window manager
Execute.OnUIThread(() => viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel));
// Initialize the core async so the UI can show the progress
Task.Run(async () =>
{
try
{
StartupArguments = Args.ToList();
if (StartupArguments.Contains("-autorun"))
{
logger.Information("Sleeping for 15 seconds on auto run to allow applications like iCUE and LGS to start");
await Task.Delay(TimeSpan.FromSeconds(15));
}
// Create and bind the root view, this is a tray icon so don't show it with the window manager
Execute.OnUIThread(() => viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel));
// Start the Artemis core
_core = Kernel.Get<ICoreService>();
_core.Initialize();
}
catch (Exception e)
{
logger.Fatal(e, "Fatal exception during initialization, shutting down.");
// TODO: A proper exception viewer
// Can't use a pretty exception dialog here since the UI might not even be visible
Execute.OnUIThread(() =>
{
windowManager.ShowMessageBox(e.Message + "\n\n Please refer the log file for more details.",
Kernel.Get<IWindowManager>().ShowMessageBox(e.Message + "\n\n Please refer the log file for more details.",
"Fatal exception during initialization",
MessageBoxButton.OK,
MessageBoxImage.Error
@@ -87,9 +90,13 @@ namespace Artemis.UI
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{
var logger = Kernel.Get<ILogger>();
logger.Fatal(e.Exception, "Fatal exception, shutting down.");
logger.Fatal(e.Exception, "Unhandled exception");
base.OnUnhandledException(e);
var dialogService = Kernel.Get<IDialogService>();
dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception);
// Don't shut down, is that a good idea? Depends on the exception of course..
e.Handled = true;
}
private void ShowMainWindow(IWindowManager windowManager, SplashViewModel splashViewModel)
+11
View File
@@ -5,6 +5,7 @@ using Artemis.UI.Screens.Module.ProfileEditor;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Shared.Services.Interfaces;
using Artemis.UI.Stylet;
using FluentValidation;
using Ninject.Extensions.Conventions;
@@ -86,6 +87,16 @@ namespace Artemis.UI.Ninject
.InheritedFrom<IValidator>()
.BindAllInterfaces();
});
// Bind all shared UI services as singletons
Kernel.Bind(x =>
{
x.FromAssemblyContaining<IArtemisSharedUIService>()
.SelectAllClasses()
.InheritedFrom<IArtemisSharedUIService>()
.BindAllInterfaces()
.Configure(c => c.InSingletonScope());
});
}
}
}
@@ -1,16 +0,0 @@
<mde:MaterialWindow x:Class="Artemis.UI.Screens.GradientEditor.GradientEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:gradientEditor="clr-namespace:Artemis.UI.Screens.GradientEditor"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
mc:Ignorable="d"
Title="Gradient Editor"
Height="450" Width="800"
d:DataContext="{d:DesignInstance {x:Type gradientEditor:GradientEditorViewModel}}">
<Grid>
<materialDesign:ColorPicker Color="{Binding CurrentColor}" />
</Grid>
</mde:MaterialWindow>
@@ -1,10 +0,0 @@
using System.Windows.Media;
using Stylet;
namespace Artemis.UI.Screens.GradientEditor
{
public class GradientEditorViewModel : Screen
{
public Color CurrentColor { get; set; }
}
}
@@ -95,7 +95,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
base.OnDeactivate();
}
private void ProfileEditorServiceOnProfileElementSelected(object? sender, ProfileElementEventArgs e)
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
{
PopulateProperties(e.ProfileElement, e.PreviousProfileElement);
}
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for BrushPropertyInputView.xaml
/// </summary>
public partial class BrushPropertyInputView : UserControl
{
public BrushPropertyInputView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,20 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.ColorGradientPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:artemis="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:ColorGradientPropertyInputViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<artemis:GradientPicker Width="132"
Margin="0 2"
Padding="0 -1"
ColorGradient="{Binding ColorGradientInputValue}" />
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class ColorGradientPropertyInputViewModel : PropertyInputViewModel
{
public ColorGradientPropertyInputViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{
}
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(ColorGradient)};
public ColorGradient ColorGradientInputValue
{
get => (ColorGradient) InputValue ?? new ColorGradient();
set => InputValue = value;
}
public override void Update()
{
NotifyOfPropertyChange(() => ColorGradientInputValue);
}
}
}
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for EnumPropertyInputView.xaml
/// </summary>
public partial class EnumPropertyInputView : UserControl
{
public EnumPropertyInputView()
{
InitializeComponent();
}
}
}
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for SKColorPropertyInputView.xaml
/// </summary>
public partial class SKColorPropertyInputView : UserControl
{
public SKColorPropertyInputView()
{
InitializeComponent();
}
}
}
@@ -85,12 +85,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
parent?.RaiseEvent(eventArg);
}
private void OnCurrentTimeChanged(object? sender, EventArgs e)
private void OnCurrentTimeChanged(object sender, EventArgs e)
{
Update(false);
}
private void OnSelectedProfileElementUpdated(object? sender, ProfileElementEventArgs e)
private void OnSelectedProfileElementUpdated(object sender, ProfileElementEventArgs e)
{
Update(true);
}
@@ -102,12 +102,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
UpdateEndTime();
}
private void OnSelectedProfileElementUpdated(object? sender, ProfileElementEventArgs e)
private void OnSelectedProfileElementUpdated(object sender, ProfileElementEventArgs e)
{
Update();
}
private void OnPixelsPerSecondChanged(object? sender, EventArgs e)
private void OnPixelsPerSecondChanged(object sender, EventArgs e)
{
UpdateKeyframePositions();
}
@@ -47,22 +47,22 @@ namespace Artemis.UI.Screens.Splash
base.OnClose();
}
private void OnPluginServiceOnPluginLoaded(object? sender, PluginEventArgs args)
private void OnPluginServiceOnPluginLoaded(object sender, PluginEventArgs args)
{
Status = "Initializing UI";
}
private void OnPluginServiceOnPluginLoading(object? sender, PluginEventArgs args)
private void OnPluginServiceOnPluginLoading(object sender, PluginEventArgs args)
{
Status = "Loading plugin: " + args.PluginInfo.Name;
}
private void OnPluginServiceOnCopyingBuildInPlugins(object? sender, EventArgs args)
private void OnPluginServiceOnCopyingBuildInPlugins(object sender, EventArgs args)
{
Status = "Updating built-in plugins";
}
private void OnCoreServiceOnInitialized(object? sender, EventArgs args)
private void OnCoreServiceOnInitialized(object sender, EventArgs args)
{
Execute.OnUIThread(() => RequestClose());
}