From 06f014a2945343c8cc656bcf35ae0b8d255d01ac Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 26 Nov 2019 23:31:41 +0100 Subject: [PATCH] Added a Material-styled scrollbar Cleaned up reorder code Reorganised profile editor layout and added panel titles --- src/Artemis.Core/Models/Profile/Layer.cs | 2 +- src/Artemis.Core/Services/RgbService.cs | 4 +- .../Services/Storage/SurfaceService.cs | 2 +- .../Interfaces/IPluginSettingRepository.cs | 1 - src/Artemis.UI/App.xaml | 2 + src/Artemis.UI/Artemis.UI.csproj | 19 +- src/Artemis.UI/Bootstrapper.cs | 46 +++- .../DebugTriggers/TriggerTracing.cs | 208 ++++++++++++++++++ .../Exceptions/ArtemisCoreException.cs | 20 ++ .../ResourceDictionaries/Scrollbar.xaml | 142 ++++++++++++ .../DisplayConditionsView.xaml | 9 +- .../ElementPropertiesView.xaml | 9 +- .../LayerElements/LayerElementsView.xaml | 9 +- .../ProfileEditor/ProfileEditorView.xaml | 173 +++++++++------ .../ProfileEditor/ProfileEditorViewModel.cs | 37 +++- .../Abstract/ProfileElementViewModel.cs | 95 -------- .../ProfileElements/FolderView.xaml.cs | 15 -- .../ProfileElements/FolderViewModel.cs | 75 ------- .../ProfileElements/LayerViewModel.cs | 15 -- .../{ => ProfileElement}/FolderView.xaml | 13 +- .../ProfileElement/FolderViewModel.cs | 12 + .../{ => ProfileElement}/LayerView.xaml | 8 +- .../ProfileElement/LayerViewModel.cs | 12 + .../ProfileElement/ProfileElementViewModel.cs | 163 ++++++++++++++ .../ProfileElements/ProfileElementsView.xaml | 21 +- .../ProfileElementsViewModel.cs | 63 +++--- .../Visualization/ProfileLedView.xaml | 16 +- .../Visualization/ProfileView.xaml | 47 +++- .../Visualization/ProfileViewModel.cs | 8 +- .../Screens/Settings/SettingsViewModel.cs | 12 +- src/Artemis.UI/Stylet/NinjectBootstrapper.cs | 8 - 31 files changed, 897 insertions(+), 369 deletions(-) create mode 100644 src/Artemis.UI/DebugTriggers/TriggerTracing.cs create mode 100644 src/Artemis.UI/Exceptions/ArtemisCoreException.cs create mode 100644 src/Artemis.UI/ResourceDictionaries/Scrollbar.xaml delete mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/Abstract/ProfileElementViewModel.cs delete mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml.cs delete mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderViewModel.cs delete mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerViewModel.cs rename src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/{ => ProfileElement}/FolderView.xaml (69%) create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderViewModel.cs rename src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/{ => ProfileElement}/LayerView.xaml (79%) create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerViewModel.cs create mode 100644 src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/ProfileElementViewModel.cs diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 4d8e1b847..45870c7f2 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.Models.Profile { public sealed class Layer : ProfileElement { - internal Layer(Profile profile, ProfileElement parent, string name) + public Layer(Profile profile, ProfileElement parent, string name) { LayerEntity = new LayerEntity(); EntityId = Guid.NewGuid(); diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs index da6095db0..34ef7ff62 100644 --- a/src/Artemis.Core/Services/RgbService.cs +++ b/src/Artemis.Core/Services/RgbService.cs @@ -26,8 +26,8 @@ namespace Artemis.Core.Services internal RgbService(ILogger logger, ISettingsService settingsService) { _logger = logger; - _renderScaleSetting = settingsService.GetSetting("RenderScale", 1.0); - _targetFrameRateSetting = settingsService.GetSetting("TargetFrameRate", 25); + _renderScaleSetting = settingsService.GetSetting("Core.RenderScale", 1.0); + _targetFrameRateSetting = settingsService.GetSetting("Core.TargetFrameRate", 25); Surface = RGBSurface.Instance; diff --git a/src/Artemis.Core/Services/Storage/SurfaceService.cs b/src/Artemis.Core/Services/Storage/SurfaceService.cs index 1853e701f..08bf0d9b4 100644 --- a/src/Artemis.Core/Services/Storage/SurfaceService.cs +++ b/src/Artemis.Core/Services/Storage/SurfaceService.cs @@ -31,7 +31,7 @@ namespace Artemis.Core.Services.Storage _rgbService = rgbService; _pluginService = pluginService; _surfaceConfigurations = new List(); - _renderScaleSetting = settingsService.GetSetting("RenderScale", 1.0); + _renderScaleSetting = settingsService.GetSetting("Core.RenderScale", 1.0); LoadFromRepository(); diff --git a/src/Artemis.Storage/Repositories/Interfaces/IPluginSettingRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IPluginSettingRepository.cs index 838ff60a6..3cf79cae1 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IPluginSettingRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IPluginSettingRepository.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Threading.Tasks; using Artemis.Storage.Entities; namespace Artemis.Storage.Repositories.Interfaces diff --git a/src/Artemis.UI/App.xaml b/src/Artemis.UI/App.xaml index 64de19b04..a41e55ad4 100644 --- a/src/Artemis.UI/App.xaml +++ b/src/Artemis.UI/App.xaml @@ -30,6 +30,8 @@ + + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 7b8c0726f..297a268e2 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -153,6 +153,8 @@ + + @@ -176,14 +178,11 @@ - - FolderView.xaml - - - + + - + @@ -219,6 +218,10 @@ Code + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -251,11 +254,11 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/src/Artemis.UI/Bootstrapper.cs b/src/Artemis.UI/Bootstrapper.cs index a87d9b3cd..cffac4f69 100644 --- a/src/Artemis.UI/Bootstrapper.cs +++ b/src/Artemis.UI/Bootstrapper.cs @@ -1,5 +1,7 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using System.Windows; +using System.Windows.Threading; using Artemis.Core.Ninject; using Artemis.Core.Services.Interfaces; using Artemis.UI.Ninject; @@ -7,6 +9,7 @@ using Artemis.UI.Screens; using Artemis.UI.Screens.Splash; using Artemis.UI.Stylet; using Ninject; +using Serilog; using Stylet; namespace Artemis.UI @@ -31,12 +34,33 @@ namespace Artemis.UI Task.Run(() => { - // Start the Artemis core - _core = Kernel.Get(); - // When the core is done, hide the splash and show the main window - _core.Initialized += (sender, args) => ShowMainWindow(windowManager, splashViewModel); - // While the core is instantiated, start listening for events on the splash - splashViewModel.ListenToEvents(); + try + { + // Start the Artemis core + _core = Kernel.Get(); + // When the core is done, hide the splash and show the main window + _core.Initialized += (sender, args) => ShowMainWindow(windowManager, splashViewModel); + // While the core is instantiated, start listening for events on the splash + splashViewModel.ListenToEvents(); + } + catch (Exception e) + { + var logger = Kernel.Get(); + logger.Fatal(e, "Fatal exception during initialization, shutting down."); + + // TODO: A proper exception viewer + Execute.OnUIThread(() => + { + windowManager.ShowMessageBox(e.Message + "\n\n Please refer the log file for more details.", + "Fatal exception during initialization", + MessageBoxButton.OK, + MessageBoxImage.Error + ); + Environment.Exit(1); + }); + + throw; + } }); } @@ -59,5 +83,13 @@ namespace Artemis.UI kernel.Load(); base.ConfigureIoC(kernel); } + + protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) + { + var logger = Kernel.Get(); + logger.Fatal(e.Exception, "Fatal exception, shutting down."); + + base.OnUnhandledException(e); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/DebugTriggers/TriggerTracing.cs b/src/Artemis.UI/DebugTriggers/TriggerTracing.cs new file mode 100644 index 000000000..fd66ceab2 --- /dev/null +++ b/src/Artemis.UI/DebugTriggers/TriggerTracing.cs @@ -0,0 +1,208 @@ +using System.Diagnostics; +using System.Windows; +using System.Windows.Markup; +using System.Windows.Media.Animation; + +// Code from http://www.wpfmentor.com/2009/01/how-to-debug-triggers-using-trigger.html +// No license specified - this code is trimmed out from Release build anyway so it should be ok using it this way + +// HOWTO: add the following attached property to any trigger and you will see when it is activated/deactivated in the output window +// TriggerTracing.TriggerName="your debug name" +// TriggerTracing.TraceEnabled="True" + +// Example: +// +// +// +// +// As this works on anything that inherits from TriggerBase, it will also work on . + +namespace Artemis.UI.DebugTriggers +{ + #if DEBUG + + /// + /// Contains attached properties to activate Trigger Tracing on the specified Triggers. + /// This file alone should be dropped into your app. + /// + public static class TriggerTracing + { + static TriggerTracing() + { + // Initialise WPF Animation tracing and add a TriggerTraceListener + PresentationTraceSources.Refresh(); + PresentationTraceSources.AnimationSource.Listeners.Clear(); + PresentationTraceSources.AnimationSource.Listeners.Add(new TriggerTraceListener()); + PresentationTraceSources.AnimationSource.Switch.Level = SourceLevels.All; + } + + private enum TriggerTraceStoryboardType + { + Enter, + Exit + } + + /// + /// A dummy storyboard for tracing purposes + /// + private class TriggerTraceStoryboard : Storyboard + { + public TriggerTraceStoryboard(TriggerBase triggerBase, TriggerTraceStoryboardType storyboardType) + { + TriggerBase = triggerBase; + StoryboardType = storyboardType; + } + + public TriggerTraceStoryboardType StoryboardType { get; } + public TriggerBase TriggerBase { get; } + } + + /// + /// A custom tracelistener. + /// + private class TriggerTraceListener : TraceListener + { + public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args) + { + base.TraceEvent(eventCache, source, eventType, id, format, args); + + if (format.StartsWith("Storyboard has begun;")) + { + var storyboard = args[1] as TriggerTraceStoryboard; + if (storyboard != null) + { + // add a breakpoint here to see when your trigger has been + // entered or exited + + // the element being acted upon + var targetElement = args[5]; + + // the namescope of the element being acted upon + var namescope = (INameScope) args[7]; + + var triggerBase = storyboard.TriggerBase; + var triggerName = GetTriggerName(storyboard.TriggerBase); + + Debug.WriteLine("Element: {0}, {1}: {2}: {3}", targetElement, triggerBase.GetType().Name, triggerName, storyboard.StoryboardType); + } + } + } + + public override void Write(string message) + { + } + + public override void WriteLine(string message) + { + } + } + + #region TriggerName attached property + + /// + /// Gets the trigger name for the specified trigger. This will be used + /// to identify the trigger in the debug output. + /// + /// The trigger. + /// + public static string GetTriggerName(TriggerBase trigger) + { + return (string) trigger.GetValue(TriggerNameProperty); + } + + /// + /// Sets the trigger name for the specified trigger. This will be used + /// to identify the trigger in the debug output. + /// + /// The trigger. + /// + public static void SetTriggerName(TriggerBase trigger, string value) + { + trigger.SetValue(TriggerNameProperty, value); + } + + public static readonly DependencyProperty TriggerNameProperty = + DependencyProperty.RegisterAttached( + "TriggerName", + typeof(string), + typeof(TriggerTracing), + new UIPropertyMetadata(string.Empty)); + + #endregion + + #region TraceEnabled attached property + + /// + /// Gets a value indication whether trace is enabled for the specified trigger. + /// + /// The trigger. + /// + public static bool GetTraceEnabled(TriggerBase trigger) + { + return (bool) trigger.GetValue(TraceEnabledProperty); + } + + /// + /// Sets a value specifying whether trace is enabled for the specified trigger + /// + /// + /// + public static void SetTraceEnabled(TriggerBase trigger, bool value) + { + trigger.SetValue(TraceEnabledProperty, value); + } + + public static readonly DependencyProperty TraceEnabledProperty = + DependencyProperty.RegisterAttached( + "TraceEnabled", + typeof(bool), + typeof(TriggerTracing), + new UIPropertyMetadata(false, OnTraceEnabledChanged)); + + private static void OnTraceEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var triggerBase = d as TriggerBase; + + if (triggerBase == null) + return; + + if (!(e.NewValue is bool)) + return; + + if ((bool) e.NewValue) + { + // insert dummy story-boards which can later be traced using WPF animation tracing + + var storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Enter); + triggerBase.EnterActions.Insert(0, new BeginStoryboard {Storyboard = storyboard}); + + storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Exit); + triggerBase.ExitActions.Insert(0, new BeginStoryboard {Storyboard = storyboard}); + } + else + { + // remove the dummy storyboards + + foreach (var actionCollection in new[] {triggerBase.EnterActions, triggerBase.ExitActions}) + { + foreach (var triggerAction in actionCollection) + { + var bsb = triggerAction as BeginStoryboard; + + if (bsb != null && bsb.Storyboard != null && bsb.Storyboard is TriggerTraceStoryboard) + { + actionCollection.Remove(bsb); + break; + } + } + } + } + } + + #endregion + } + #endif +} \ No newline at end of file diff --git a/src/Artemis.UI/Exceptions/ArtemisCoreException.cs b/src/Artemis.UI/Exceptions/ArtemisCoreException.cs new file mode 100644 index 000000000..2d7c6c97b --- /dev/null +++ b/src/Artemis.UI/Exceptions/ArtemisCoreException.cs @@ -0,0 +1,20 @@ +using System; + +namespace Artemis.UI.Exceptions +{ + // ReSharper disable once InconsistentNaming + public class ArtemisUIException : Exception + { + public ArtemisUIException() + { + } + + public ArtemisUIException(string message) : base(message) + { + } + + public ArtemisUIException(string message, Exception inner) : base(message, inner) + { + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/ResourceDictionaries/Scrollbar.xaml b/src/Artemis.UI/ResourceDictionaries/Scrollbar.xaml new file mode 100644 index 000000000..4b3d642af --- /dev/null +++ b/src/Artemis.UI/ResourceDictionaries/Scrollbar.xaml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml index c625e1b6c..7755f64f2 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/DisplayConditions/DisplayConditionsView.xaml @@ -6,5 +6,12 @@ xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + + + + Display conditions + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml index bfefd1796..09f674252 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ElementProperties/ElementPropertiesView.xaml @@ -6,5 +6,12 @@ xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ElementProperties" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + + + + Layer element properties + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml index 33b04f8c3..9053f62a0 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerElements/LayerElementsView.xaml @@ -6,5 +6,12 @@ xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerElements" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + + + + Layer elements + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml index 3014abef4..76debb152 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorView.xaml @@ -8,7 +8,7 @@ xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" - d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileEditorViewModel}}"> + d:DataContext="{x:Type profileEditor:ProfileEditorViewModel}"> @@ -22,64 +22,113 @@ - + - + + - - - + - - - The profile defines what colors the LEDs will have. Multiple groups of LEDs are defined into layers. On these layers you can apply effects. - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + The profile defines what colors the LEDs will have. Multiple groups of LEDs are defined into layers. On these layers you can apply effects. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - @@ -88,7 +137,7 @@ - + @@ -102,24 +151,8 @@ - + - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs index b9890d9d3..7f1fb234a 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs @@ -2,8 +2,11 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Windows; using Artemis.Core.Models.Profile; using Artemis.Core.Plugins.Abstract; +using Artemis.Core.Plugins.Models; +using Artemis.Core.Services; using Artemis.Core.Services.Storage.Interfaces; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions; @@ -19,10 +22,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor public class ProfileEditorViewModel : Conductor.Collection.AllActive { private readonly IProfileService _profileService; + private readonly ISettingsService _settingsService; - public ProfileEditorViewModel(ProfileModule module, ICollection viewModels, IProfileService profileService, IDialogService dialogService) + public ProfileEditorViewModel(ProfileModule module, ICollection viewModels, IProfileService profileService, + IDialogService dialogService, ISettingsService settingsService) { _profileService = profileService; + _settingsService = settingsService; DisplayName = "Profile editor"; Module = module; @@ -47,9 +53,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor public LayerElementsViewModel LayerElementsViewModel { get; } public ProfileElementsViewModel ProfileElementsViewModel { get; } public ProfileViewModel ProfileViewModel { get; } - public BindableCollection Profiles { get; set; } + public PluginSetting ProfileElementsWidth { get; set; } + public PluginSetting DisplayConditionsHeight { get; set; } + public PluginSetting LayerElementsHeight { get; set; } + public PluginSetting ElementPropertiesWidth { get; set; } + public Profile SelectedProfile { get => Module.ActiveProfile; @@ -126,6 +136,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor protected override void OnActivate() { + LoadWorkspaceSettings(); Task.Run(() => { LoadProfiles(); @@ -138,6 +149,28 @@ namespace Artemis.UI.Screens.Module.ProfileEditor base.OnActivate(); } + protected override void OnDeactivate() + { + SaveWorkspaceSettings(); + base.OnDeactivate(); + } + + private void LoadWorkspaceSettings() + { + ProfileElementsWidth = _settingsService.GetSetting("ProfileEditor.ProfileElementsWidth", new GridLength(550)); + DisplayConditionsHeight = _settingsService.GetSetting("ProfileEditor.DisplayConditionsHeight", new GridLength(320)); + LayerElementsHeight = _settingsService.GetSetting("ProfileEditor.LayerElementsHeight", new GridLength(350)); + ElementPropertiesWidth = _settingsService.GetSetting("ProfileEditor.ElementPropertiesWidth", new GridLength(920)); + } + + private void SaveWorkspaceSettings() + { + ProfileElementsWidth.Save(); + DisplayConditionsHeight.Save(); + LayerElementsHeight.Save(); + ElementPropertiesWidth.Save(); + } + private void LoadProfiles() { // Get all profiles from the database diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/Abstract/ProfileElementViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/Abstract/ProfileElementViewModel.cs deleted file mode 100644 index dbde3e20f..000000000 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/Abstract/ProfileElementViewModel.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Artemis.Core.Models.Profile.Abstract; -using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; -using Stylet; - -namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.Abstract -{ - public abstract class ProfileElementViewModel : PropertyChangedBase - { - protected ProfileElementViewModel(FolderViewModel parent, ProfileElement profileElement, ProfileEditorViewModel profileEditorViewModel) - { - Parent = parent; - ProfileElement = profileElement; - ProfileEditorViewModel = profileEditorViewModel; - - Children = new BindableCollection(); - } - - public FolderViewModel Parent { get; set; } - public ProfileEditorViewModel ProfileEditorViewModel { get; set; } - - public ProfileElement ProfileElement { get; set; } - public BindableCollection Children { get; set; } - - public virtual void UpdateProfileElements() - { - // Order the children - var vmsList = Children.OrderBy(v => v.ProfileElement.Order).ToList(); - for (var index = 0; index < vmsList.Count; index++) - { - var profileElementViewModel = vmsList[index]; - Children.Move(Children.IndexOf(profileElementViewModel), index); - } - } - - public void SetElementInFront(ProfileElementViewModel source) - { - if (source.Parent != Parent) - { - source.Parent.RemoveExistingElement(source); - Parent.AddExistingElement(source); - } - - Parent.Folder.RemoveChild(source.ProfileElement); - Parent.Folder.AddChild(source.ProfileElement, ProfileElement.Order); - Parent.UpdateProfileElements(); - } - - public void SetElementBehind(ProfileElementViewModel source) - { - if (source.Parent != Parent) - { - source.Parent.RemoveExistingElement(source); - Parent.AddExistingElement(source); - } - - Parent.Folder.RemoveChild(source.ProfileElement); - Parent.Folder.AddChild(source.ProfileElement, ProfileElement.Order + 1); - Parent.UpdateProfileElements(); - } - - public async Task RenameElement() - { - var result = await ProfileEditorViewModel.DialogService.ShowDialog( - new Dictionary {{"profileElement", ProfileElement}} - ); - if (result is string newName) - { - ProfileElement.Name = newName; - ProfileEditorViewModel.OnProfileUpdated(); - } - } - - public async Task DeleteElement() - { - var result = await ProfileEditorViewModel.DialogService.ShowConfirmDialog( - "Delete profile element", - "Are you sure you want to delete this element? This cannot be undone." - ); - - if (!result) - return; - - // Farewell, cruel world - var parent = Parent; - ProfileElement.Parent.RemoveChild(ProfileElement); - parent.RemoveExistingElement(this); - parent.UpdateProfileElements(); - - ProfileEditorViewModel.OnProfileUpdated(); - } - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml.cs deleted file mode 100644 index 8113a2212..000000000 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Windows.Controls; - -namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements -{ - /// - /// Interaction logic for FolderView.xaml - /// - public partial class FolderView : UserControl - { - public FolderView() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderViewModel.cs deleted file mode 100644 index 9130a34ff..000000000 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderViewModel.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Linq; -using Artemis.Core.Models.Profile; -using Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.Abstract; - -namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements -{ - public class FolderViewModel : ProfileElementViewModel - { - public FolderViewModel(FolderViewModel parent, Folder folder, ProfileEditorViewModel profileEditorViewModel) : base(parent, folder, profileEditorViewModel) - { - Folder = folder; - UpdateProfileElements(); - } - - public Folder Folder { get; } - - public void AddFolder() - { - Folder.AddFolder("New folder"); - UpdateProfileElements(); - - ProfileEditorViewModel.OnProfileUpdated(); - } - - public void AddLayer() - { - Folder.AddLayer("New layer"); - UpdateProfileElements(); - - ProfileEditorViewModel.OnProfileUpdated(); - } - - public void RemoveExistingElement(ProfileElementViewModel element) - { - Folder.RemoveChild(element.ProfileElement); - Children.Remove(element); - element.Parent = null; - } - - public void AddExistingElement(ProfileElementViewModel element) - { - Folder.AddChild(element.ProfileElement); - Children.Add(element); - element.Parent = this; - } - - public sealed override void UpdateProfileElements() - { - // Ensure every child element has an up-to-date VM - if (Folder.Children != null) - { - foreach (var profileElement in Folder.Children.OrderBy(c => c.Order)) - { - ProfileElementViewModel existing = null; - if (profileElement is Folder folder) - { - existing = Children.FirstOrDefault(p => p is FolderViewModel vm && vm.Folder == folder); - if (existing == null) - Children.Add(new FolderViewModel(this, folder, ProfileEditorViewModel)); - } - else if (profileElement is Layer layer) - { - existing = Children.FirstOrDefault(p => p is LayerViewModel vm && vm.Layer == layer); - if (existing == null) - Children.Add(new LayerViewModel(this, layer, ProfileEditorViewModel)); - } - - existing?.UpdateProfileElements(); - } - } - - base.UpdateProfileElements(); - } - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerViewModel.cs deleted file mode 100644 index 550849d69..000000000 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Artemis.Core.Models.Profile; -using Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.Abstract; - -namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements -{ - public class LayerViewModel : ProfileElementViewModel - { - public LayerViewModel(FolderViewModel parent, Layer layer, ProfileEditorViewModel profileEditorViewModel) : base(parent, layer, profileEditorViewModel) - { - Layer = layer; - } - - public Layer Layer { get; } - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderView.xaml similarity index 69% rename from src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml rename to src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderView.xaml index fd75af474..f49d47378 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/FolderView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderView.xaml @@ -1,4 +1,4 @@ - - + d:DataContext="{d:DesignInstance {x:Type profileElement:FolderViewModel}}"> + @@ -37,8 +38,10 @@ - - + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderViewModel.cs new file mode 100644 index 000000000..7dbb257de --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/FolderViewModel.cs @@ -0,0 +1,12 @@ +namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.ProfileElement +{ + public class FolderViewModel : ProfileElementViewModel + { + public FolderViewModel(ProfileElementViewModel parent, Core.Models.Profile.Abstract.ProfileElement folder, ProfileEditorViewModel profileEditorViewModel) + : base(parent, folder, profileEditorViewModel) + { + } + + public override bool SupportsChildren => true; + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerView.xaml similarity index 79% rename from src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerView.xaml rename to src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerView.xaml index 9ec32b929..08a0cac47 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/LayerView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerView.xaml @@ -1,4 +1,4 @@ - + d:DataContext="{d:DesignInstance {x:Type profileElement:LayerViewModel}}"> + @@ -26,7 +28,7 @@ - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerViewModel.cs new file mode 100644 index 000000000..57101e0f1 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/LayerViewModel.cs @@ -0,0 +1,12 @@ +namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.ProfileElement +{ + public class LayerViewModel : ProfileElementViewModel + { + public LayerViewModel(ProfileElementViewModel parent, Core.Models.Profile.Abstract.ProfileElement layer, ProfileEditorViewModel profileEditorViewModel) + : base(parent, layer, profileEditorViewModel) + { + } + + public override bool SupportsChildren => false; + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/ProfileElementViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/ProfileElementViewModel.cs new file mode 100644 index 000000000..e381637e6 --- /dev/null +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElement/ProfileElementViewModel.cs @@ -0,0 +1,163 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Artemis.Core.Models.Profile; +using Artemis.UI.Exceptions; +using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; +using Stylet; + +namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.ProfileElement +{ + public abstract class ProfileElementViewModel : PropertyChangedBase + { + protected ProfileElementViewModel(ProfileElementViewModel parent, Core.Models.Profile.Abstract.ProfileElement profileElement, ProfileEditorViewModel profileEditorViewModel) + { + Parent = parent; + ProfileElement = profileElement; + ProfileEditorViewModel = profileEditorViewModel; + + Children = new BindableCollection(); + UpdateProfileElements(); + } + + public abstract bool SupportsChildren { get; } + public ProfileElementViewModel Parent { get; set; } + public ProfileEditorViewModel ProfileEditorViewModel { get; set; } + + public Core.Models.Profile.Abstract.ProfileElement ProfileElement { get; set; } + public BindableCollection Children { get; set; } + + public void SetElementInFront(ProfileElementViewModel source) + { + if (source.Parent != Parent) + { + source.Parent.RemoveExistingElement(source); + Parent.AddExistingElement(source); + } + + Parent.ProfileElement.RemoveChild(source.ProfileElement); + Parent.ProfileElement.AddChild(source.ProfileElement, ProfileElement.Order); + Parent.UpdateProfileElements(); + } + + public void SetElementBehind(ProfileElementViewModel source) + { + if (source.Parent != Parent) + { + source.Parent.RemoveExistingElement(source); + Parent.AddExistingElement(source); + } + + Parent.ProfileElement.RemoveChild(source.ProfileElement); + Parent.ProfileElement.AddChild(source.ProfileElement, ProfileElement.Order + 1); + Parent.UpdateProfileElements(); + } + + public void RemoveExistingElement(ProfileElementViewModel element) + { + if (!SupportsChildren) + throw new ArtemisUIException("Cannot remove a child from a profile element of type " + ProfileElement.GetType().Name); + + ProfileElement.RemoveChild(element.ProfileElement); + Children.Remove(element); + element.Parent = null; + } + + public void AddExistingElement(ProfileElementViewModel element) + { + if (!SupportsChildren) + throw new ArtemisUIException("Cannot add a child to a profile element of type " + ProfileElement.GetType().Name); + + ProfileElement.AddChild(element.ProfileElement); + Children.Add(element); + element.Parent = this; + } + + public void AddFolder() + { + if (!SupportsChildren) + throw new ArtemisUIException("Cannot add a folder to a profile element of type " + ProfileElement.GetType().Name); + + ProfileElement.AddChild(new Folder(ProfileElement.Profile, ProfileElement, "New folder")); + UpdateProfileElements(); + ProfileEditorViewModel.OnProfileUpdated(); + } + + public void AddLayer() + { + if (!SupportsChildren) + throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name); + + ProfileElement.AddChild(new Layer(ProfileElement.Profile, ProfileElement, "New layer")); + UpdateProfileElements(); + ProfileEditorViewModel.OnProfileUpdated(); + } + + // ReSharper disable once UnusedMember.Global - Called from view + public async Task RenameElement() + { + var result = await ProfileEditorViewModel.DialogService.ShowDialog( + new Dictionary {{"profileElement", ProfileElement}} + ); + if (result is string newName) + { + ProfileElement.Name = newName; + ProfileEditorViewModel.OnProfileUpdated(); + } + } + + // ReSharper disable once UnusedMember.Global - Called from view + public async Task DeleteElement() + { + var result = await ProfileEditorViewModel.DialogService.ShowConfirmDialog( + "Delete profile element", + "Are you sure you want to delete this element? This cannot be undone." + ); + + if (!result) + return; + + // Farewell, cruel world + var parent = Parent; + ProfileElement.Parent.RemoveChild(ProfileElement); + parent.RemoveExistingElement(this); + parent.UpdateProfileElements(); + + ProfileEditorViewModel.OnProfileUpdated(); + } + + private void UpdateProfileElements() + { + // Order the children + var vmsList = Children.OrderBy(v => v.ProfileElement.Order).ToList(); + for (var index = 0; index < vmsList.Count; index++) + { + var profileElementViewModel = vmsList[index]; + Children.Move(Children.IndexOf(profileElementViewModel), index); + } + + // Ensure every child element has an up-to-date VM + if (ProfileElement.Children != null) + { + foreach (var profileElement in ProfileElement.Children.OrderBy(c => c.Order)) + { + ProfileElementViewModel existing = null; + if (profileElement is Folder folder) + { + existing = Children.FirstOrDefault(p => p is FolderViewModel vm && vm.ProfileElement == folder); + if (existing == null) + Children.Add(new FolderViewModel(this, folder, ProfileEditorViewModel)); + } + else if (profileElement is Layer layer) + { + existing = Children.FirstOrDefault(p => p is LayerViewModel vm && vm.ProfileElement == layer); + if (existing == null) + Children.Add(new LayerViewModel(this, layer, ProfileEditorViewModel)); + } + + existing?.UpdateProfileElements(); + } + } + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsView.xaml index 102f6ee73..5e37f9a0b 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsView.xaml @@ -9,36 +9,45 @@ xmlns:s="https://github.com/canton7/Stylet" xmlns:dd="urn:gong-wpf-dragdrop" xmlns:profileElements="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ProfileElements" + xmlns:profileElement="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.ProfileElement" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance {x:Type profileElements:ProfileElementsViewModel}}"> + - + + Profile elements + + + + + - + - + - + @@ -46,7 +55,7 @@ Width="30" Padding="2 0 2 0" materialDesign:RippleAssist.IsCentered="True" - ToolTip="Add new layer" + ToolTip="Add new layer to root" Command="{s:Action AddLayer}"> diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsViewModel.cs index 2a6481410..14cd2c6ff 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileElements/ProfileElementsViewModel.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Windows; using Artemis.Core.Models.Profile; -using Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.Abstract; +using Artemis.UI.Screens.Module.ProfileEditor.ProfileElements.ProfileElement; using GongSolutions.Wpf.DragDrop; namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements @@ -21,14 +21,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements switch (dragDropType) { - case DragDropType.FolderAdd: + case DragDropType.Add: dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight; dropInfo.Effects = DragDropEffects.Move; break; - case DragDropType.FolderInsertBefore: - case DragDropType.FolderInsertAfter: - case DragDropType.LayerInsertBefore: - case DragDropType.LayerInsertAfter: + case DragDropType.InsertBefore: + case DragDropType.InsertAfter: dropInfo.DropTargetAdorner = DropTargetAdorners.Insert; dropInfo.Effects = DragDropEffects.Move; break; @@ -39,20 +37,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements { var source = (ProfileElementViewModel) dropInfo.Data; var target = (ProfileElementViewModel) dropInfo.TargetItem; - + var dragDropType = GetDragDropType(dropInfo); switch (dragDropType) { - case DragDropType.FolderAdd: + case DragDropType.Add: source.Parent.RemoveExistingElement(source); - ((FolderViewModel) target).AddExistingElement(source); + target.AddExistingElement(source); break; - case DragDropType.FolderInsertBefore: - case DragDropType.LayerInsertBefore: + case DragDropType.InsertBefore: target.SetElementInFront(source); break; - case DragDropType.FolderInsertAfter: - case DragDropType.LayerInsertAfter: + case DragDropType.InsertAfter: target.SetElementBehind(source); break; } @@ -60,11 +56,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements ProfileEditorViewModel.OnProfileUpdated(); } + // ReSharper disable once UnusedMember.Global - Called from view public void AddFolder() { RootFolder?.AddFolder(); } + // ReSharper disable once UnusedMember.Global - Called from view public void AddLayer() { RootFolder?.AddLayer(); @@ -89,8 +87,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements private static DragDropType GetDragDropType(IDropInfo dropInfo) { - var source = dropInfo.Data as ProfileElementViewModel; - var target = dropInfo.TargetItem as ProfileElementViewModel; + var source = (ProfileElementViewModel) dropInfo.Data; + var target = (ProfileElementViewModel) dropInfo.TargetItem; if (source == target) return DragDropType.None; @@ -102,35 +100,26 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileElements parent = parent.Parent; } - if (target is FolderViewModel) + switch (dropInfo.InsertPosition) { - if (dropInfo.InsertPosition >= RelativeInsertPosition.TargetItemCenter) - return DragDropType.FolderAdd; - if (dropInfo.InsertPosition == RelativeInsertPosition.BeforeTargetItem) - return DragDropType.FolderInsertBefore; - return DragDropType.FolderInsertAfter; + case RelativeInsertPosition.AfterTargetItem | RelativeInsertPosition.TargetItemCenter: + case RelativeInsertPosition.BeforeTargetItem | RelativeInsertPosition.TargetItemCenter: + return target.SupportsChildren ? DragDropType.Add : DragDropType.None; + case RelativeInsertPosition.BeforeTargetItem: + return DragDropType.InsertBefore; + case RelativeInsertPosition.AfterTargetItem: + return DragDropType.InsertAfter; + default: + return DragDropType.None; } - - if (target is LayerViewModel) - { - if (dropInfo.InsertPosition == RelativeInsertPosition.BeforeTargetItem) - return DragDropType.LayerInsertBefore; - if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem) - return DragDropType.LayerInsertAfter; - return DragDropType.None; - } - - return DragDropType.None; } } public enum DragDropType { None, - FolderAdd, - FolderInsertBefore, - FolderInsertAfter, - LayerInsertBefore, - LayerInsertAfter + Add, + InsertBefore, + InsertAfter } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml index bc6affc51..d4abe3b4c 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml @@ -68,14 +68,22 @@ - + + + + + - + + + + + @@ -84,10 +92,10 @@ - + - + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileView.xaml index 01fcff67b..d321c27c0 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileView.xaml @@ -43,6 +43,7 @@ MouseDown="{s:Action EditorGridMouseClick}" MouseMove="{s:Action EditorGridMouseMove}" Cursor="{Binding Cursor}"> + @@ -81,6 +82,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -119,8 +151,21 @@ + + + + + Highlight selected layer + + + Pause visualization on focus loss + + + + + + Margin="10" ZIndex="1"> _settingsService.GetSetting("RenderScale", 1.0).Value; + get => _settingsService.GetSetting("Core.RenderScale", 1.0).Value; set { - _settingsService.GetSetting("RenderScale", 1.0).Value = value; - _settingsService.GetSetting("RenderScale", 1.0).Save(); + _settingsService.GetSetting("Core.RenderScale", 1.0).Value = value; + _settingsService.GetSetting("Core.RenderScale", 1.0).Save(); } } public int TargetFrameRate { - get => _settingsService.GetSetting("TargetFrameRate", 25).Value; + get => _settingsService.GetSetting("Core.TargetFrameRate", 25).Value; set { - _settingsService.GetSetting("TargetFrameRate", 25).Value = value; - _settingsService.GetSetting("TargetFrameRate", 25).Save(); + _settingsService.GetSetting("Core.TargetFrameRate", 25).Value = value; + _settingsService.GetSetting("Core.TargetFrameRate", 25).Save(); } } diff --git a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs index bd448ab5e..1478aeb0e 100644 --- a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs +++ b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs @@ -67,13 +67,5 @@ namespace Artemis.UI.Stylet if (Kernel != null) Kernel.Dispose(); } - - protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) - { - var logger = Kernel.Get(); - logger.Fatal(e.Exception, "Fatal exception, shutting down."); - - base.OnUnhandledException(e); - } } } \ No newline at end of file