From 68efa4885efe2138d0c1536032c73056567e0ca2 Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Fri, 6 May 2016 23:20:48 +0200 Subject: [PATCH] Implemented Ninject, removed AutoFac, updated Caliburn.Micro to v3 --- Artemis/Artemis/Artemis.csproj | 43 +- Artemis/Artemis/ArtemisBootstrapper.cs | 49 +- Artemis/Artemis/Models/OverlaySettings.cs | 7 + .../VolumeDisplay/VolumeDisplaySettings.cs | 3 +- .../VolumeDisplay/VolumeDisplayView.xaml | 10 +- .../VolumeDisplay/VolumeDisplayViewModel.cs | 50 +- Artemis/Artemis/NLog.config | 34 +- .../Artemis/NinjectModules/ArtemisModules.cs | 40 + .../Artemis/NinjectModules/ManagerModules.cs | 15 + Artemis/Artemis/Resources/Icons.xaml | 2529 ++++---- Artemis/Artemis/Resources/IconsNonShared.xaml | 5138 +++++++++++++++++ .../ViewModels/Abstract/OverlayViewModel.cs | 51 + .../ViewModels/ProfileEditorViewModel.cs | 11 +- Artemis/Artemis/packages.config | 14 +- 14 files changed, 6632 insertions(+), 1362 deletions(-) create mode 100644 Artemis/Artemis/Models/OverlaySettings.cs create mode 100644 Artemis/Artemis/NinjectModules/ArtemisModules.cs create mode 100644 Artemis/Artemis/NinjectModules/ManagerModules.cs create mode 100644 Artemis/Artemis/Resources/IconsNonShared.xaml create mode 100644 Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 9bb8498db..948cf327a 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -120,20 +120,16 @@ - - ..\packages\Autofac.4.0.0-rc1-177\lib\net45\Autofac.dll + + ..\packages\Caliburn.Micro.Core.3.0.1\lib\net45\Caliburn.Micro.dll True - - ..\packages\Caliburn.Micro.Core.2.0.2\lib\net45\Caliburn.Micro.dll + + ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.dll True - - ..\packages\Caliburn.Micro.AutofacBootstrap.2.0.9-beta\lib\net40\Caliburn.Micro.Autofac.dll - True - - - ..\packages\Caliburn.Micro.2.0.2\lib\net45\Caliburn.Micro.Platform.dll + + ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True @@ -175,8 +171,12 @@ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True + + ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll + True + - ..\packages\NLog.4.3.2\lib\net45\NLog.dll + ..\packages\NLog.4.3.3\lib\net45\NLog.dll True @@ -202,7 +202,10 @@ - + + ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll + True + @@ -223,10 +226,6 @@ - - ..\packages\XamlAnimatedGif.1.1.2\lib\net45\XamlAnimatedGif.dll - True - ..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.AvalonDock.dll True @@ -286,6 +285,7 @@ + @@ -371,6 +371,8 @@ + + True @@ -414,6 +416,7 @@ + @@ -561,12 +564,12 @@ - - + + @@ -594,6 +597,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs index 80ef08c50..31c692957 100644 --- a/Artemis/Artemis/ArtemisBootstrapper.cs +++ b/Artemis/Artemis/ArtemisBootstrapper.cs @@ -1,27 +1,33 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Windows; using System.Windows.Controls; using System.Windows.Forms; using Artemis.ViewModels; -using Autofac; using Caliburn.Micro; -using Caliburn.Micro.Autofac; +using Ninject; using Application = System.Windows.Application; using MessageBox = System.Windows.Forms.MessageBox; using MouseEventArgs = System.Windows.Input.MouseEventArgs; namespace Artemis { - public class ArtemisBootstrapper : AutofacBootstrapper + public class ArtemisBootstrapper : BootstrapperBase { + private IKernel _kernel; + public ArtemisBootstrapper() { CheckDuplicateInstances(); - Initialize(); + BindSpecialValues(); + } + private void BindSpecialValues() + { MessageBinder.SpecialValues.Add("$scaledmousex", ctx => { var img = ctx.Source as Image; @@ -64,14 +70,35 @@ namespace Artemis }); } - protected override void ConfigureContainer(ContainerBuilder builder) + protected override void Configure() { - base.ConfigureContainer(builder); + _kernel = new StandardKernel(); + _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); + } - // create a window manager instance to be used by everyone asking for one (including Caliburn.Micro) - builder.RegisterInstance(new WindowManager()); - builder.RegisterType(); - builder.RegisterType(); + protected override void OnExit(object sender, EventArgs e) + { + _kernel.Dispose(); + base.OnExit(sender, e); + } + + protected override object GetInstance(Type service, string key) + { + if (service == null) + throw new ArgumentNullException(nameof(service)); + + return _kernel.Get(service); + } + + protected override IEnumerable GetAllInstances(Type service) + { + return _kernel.GetAll(service); + } + + protected override void BuildUp(object instance) + { + _kernel.Inject(instance); } protected override void OnStartup(object sender, StartupEventArgs e) diff --git a/Artemis/Artemis/Models/OverlaySettings.cs b/Artemis/Artemis/Models/OverlaySettings.cs new file mode 100644 index 000000000..e05df3d2a --- /dev/null +++ b/Artemis/Artemis/Models/OverlaySettings.cs @@ -0,0 +1,7 @@ +namespace Artemis.Models +{ + public abstract class OverlaySettings : EffectSettings + { + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs index 74339cdae..c84c530cf 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs @@ -3,14 +3,13 @@ using Artemis.Models; namespace Artemis.Modules.Overlays.VolumeDisplay { - public class VolumeDisplaySettings : EffectSettings + public class VolumeDisplaySettings : OverlaySettings { public VolumeDisplaySettings() { Load(); } - public bool Enabled { get; set; } public Color MainColor { get; set; } public Color SecondaryColor { get; set; } diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml index bfa1cef00..51226f2cc 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml @@ -30,10 +30,10 @@ @@ -43,7 +43,7 @@ Main volume display color @@ -53,7 +53,7 @@ Secondary volume display color diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs index 8d662f10e..dd4d30a82 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs @@ -1,60 +1,20 @@ using Artemis.Managers; -using Caliburn.Micro; +using Artemis.ViewModels.Abstract; namespace Artemis.Modules.Overlays.VolumeDisplay { - public class VolumeDisplayViewModel : Screen + public class VolumeDisplayViewModel : OverlayViewModel { - private VolumeDisplaySettings _volumeDisplaySettings; - public VolumeDisplayViewModel(MainManager mainManager) { MainManager = mainManager; // Settings are loaded from file by class - VolumeDisplaySettings = new VolumeDisplaySettings(); + OverlaySettings = new VolumeDisplaySettings(); // Create effect model and add it to MainManager - VolumeDisplayModel = new VolumeDisplayModel(mainManager, VolumeDisplaySettings); - MainManager.EffectManager.EffectModels.Add(VolumeDisplayModel); - } - - public static string Name => "Volume Display"; - - public MainManager MainManager { get; set; } - public VolumeDisplayModel VolumeDisplayModel { get; set; } - - public VolumeDisplaySettings VolumeDisplaySettings - { - get { return _volumeDisplaySettings; } - set - { - if (Equals(value, _volumeDisplaySettings)) return; - _volumeDisplaySettings = value; - NotifyOfPropertyChange(() => VolumeDisplaySettings); - } - } - - public void ToggleEffect() - { - VolumeDisplayModel.Enabled = _volumeDisplaySettings.Enabled; - } - - public void SaveSettings() - { - if (VolumeDisplayModel == null) - return; - - VolumeDisplaySettings.Save(); - } - - public void ResetSettings() - { - // TODO: Confirmation dialog (Generic MVVM approach) - VolumeDisplaySettings.ToDefault(); - NotifyOfPropertyChange(() => VolumeDisplaySettings); - - SaveSettings(); + OverlayModel = new VolumeDisplayModel(mainManager, (VolumeDisplaySettings) OverlaySettings); + MainManager.EffectManager.EffectModels.Add(OverlayModel); } } } \ No newline at end of file diff --git a/Artemis/Artemis/NLog.config b/Artemis/Artemis/NLog.config index d32c52835..a5fc24d5d 100644 --- a/Artemis/Artemis/NLog.config +++ b/Artemis/Artemis/NLog.config @@ -2,17 +2,41 @@ + + + + + - - + + + + - - + + + \ No newline at end of file diff --git a/Artemis/Artemis/NinjectModules/ArtemisModules.cs b/Artemis/Artemis/NinjectModules/ArtemisModules.cs new file mode 100644 index 000000000..3a37d773e --- /dev/null +++ b/Artemis/Artemis/NinjectModules/ArtemisModules.cs @@ -0,0 +1,40 @@ +using Artemis.Modules.Effects.AmbientLightning; +using Artemis.Modules.Effects.AudioVisualizer; +using Artemis.Modules.Effects.Debug; +using Artemis.Modules.Effects.TypeWave; +using Artemis.Modules.Games.CounterStrike; +using Artemis.Modules.Games.Dota2; +using Artemis.Modules.Games.RocketLeague; +using Artemis.Modules.Games.TheDivision; +using Artemis.Modules.Games.Witcher3; +using Artemis.Modules.Overlays.VolumeDisplay; +using Artemis.ViewModels.Abstract; +using Caliburn.Micro; +using Ninject.Modules; + +namespace Artemis.NinjectModules +{ + public class ArtemisModules : NinjectModule + { + public override void Load() + { + // Effects + //Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); + + // Games + Bind().To(typeof(GameViewModel<>)); // TODO: Needed? + Bind>().To().InSingletonScope(); + Bind>().To().InSingletonScope(); + Bind>().To().InSingletonScope(); + Bind>().To().InSingletonScope(); + Bind>().To().InSingletonScope(); + + // Overlays + Bind().To().InSingletonScope(); + + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/NinjectModules/ManagerModules.cs b/Artemis/Artemis/NinjectModules/ManagerModules.cs new file mode 100644 index 000000000..b36e5c897 --- /dev/null +++ b/Artemis/Artemis/NinjectModules/ManagerModules.cs @@ -0,0 +1,15 @@ +using Artemis.Managers; +using Ninject.Modules; + +namespace Artemis.NinjectModules +{ + internal class ManagerModules : NinjectModule + { + public override void Load() + { + Bind().ToSelf().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Resources/Icons.xaml b/Artemis/Artemis/Resources/Icons.xaml index be35c7a5f..04d8bc864 100644 --- a/Artemis/Artemis/Resources/Icons.xaml +++ b/Artemis/Artemis/Resources/Icons.xaml @@ -1,2641 +1,2640 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2648,275 +2647,275 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2929,507 +2928,507 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3450,507 +3449,507 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3960,1180 +3959,1180 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Artemis/Artemis/Resources/IconsNonShared.xaml b/Artemis/Artemis/Resources/IconsNonShared.xaml new file mode 100644 index 000000000..9fbaf491c --- /dev/null +++ b/Artemis/Artemis/Resources/IconsNonShared.xaml @@ -0,0 +1,5138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs new file mode 100644 index 000000000..50b25b728 --- /dev/null +++ b/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs @@ -0,0 +1,51 @@ +using Artemis.Managers; +using Artemis.Models; +using Caliburn.Micro; + +namespace Artemis.ViewModels.Abstract +{ + public abstract class OverlayViewModel : Screen + { + private OverlaySettings _overlaySettings; + + public OverlayModel OverlayModel { get; set; } + public MainManager MainManager { get; set; } + + public OverlaySettings OverlaySettings + { + get { return _overlaySettings; } + set + { + if (Equals(value, _overlaySettings)) return; + _overlaySettings = value; + NotifyOfPropertyChange(() => OverlaySettings); + } + } + + public void ToggleOverlay() + { + OverlayModel.Enabled = OverlaySettings.Enabled; + } + + public void SaveSettings() + { + OverlaySettings?.Save(); + } + + public async void ResetSettings() + { + var resetConfirm = await + MainManager.DialogService.ShowQuestionMessageBox("Reset overlay settings", + "Are you sure you wish to reset this overlay's settings? \nAny changes you made will be lost."); + + if (!resetConfirm.Value) + return; + + OverlaySettings.ToDefault(); + NotifyOfPropertyChange(() => OverlaySettings); + + OverlayModel.Enabled = OverlaySettings.Enabled; + SaveSettings(); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs index 9d88f954c..8b23c5e9f 100644 --- a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs +++ b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs @@ -141,7 +141,7 @@ namespace Artemis.ViewModels var pen = new Pen(new SolidColorBrush(color), 0.4); // Draw the selection outline and resize indicator - if (SelectedLayer != null && SelectedLayer.Enabled) + if (SelectedLayer != null && ShouldDrawLayer(SelectedLayer)) { var layerRect = SelectedLayer.UserProps.GetRect(); // Deflate the rect so that the border is drawn on the inside @@ -390,7 +390,7 @@ namespace Artemis.ViewModels var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width); var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height); - var hoverLayer = SelectedProfile.Layers.OrderBy(l => l.Order).Where(l => l.Enabled) + var hoverLayer = SelectedProfile.Layers.OrderBy(l => l.Order).Where(ShouldDrawLayer) .FirstOrDefault(l => l.UserProps.GetRect(1).Contains(x, y)); SelectedLayer = hoverLayer; } @@ -404,7 +404,7 @@ namespace Artemis.ViewModels var pos = e.GetPosition((Image) e.OriginalSource); var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width); var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height); - var hoverLayer = SelectedProfile.Layers.OrderBy(l => l.Order).Where(l => l.Enabled) + var hoverLayer = SelectedProfile.Layers.OrderBy(l => l.Order).Where(ShouldDrawLayer) .FirstOrDefault(l => l.UserProps.GetRect(1).Contains(x, y)); HandleDragging(e, x, y, hoverLayer); @@ -482,5 +482,10 @@ namespace Artemis.ViewModels } NotifyOfPropertyChange(() => KeyboardPreview); } + + private bool ShouldDrawLayer(LayerModel layer) + { + return layer.Enabled && (layer.LayerType == LayerType.Keyboard || layer.LayerType == LayerType.KeyboardGif); + } } } \ No newline at end of file diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config index 66f9759d0..4aa4622c8 100644 --- a/Artemis/Artemis/packages.config +++ b/Artemis/Artemis/packages.config @@ -1,9 +1,7 @@  - - - - + + @@ -11,11 +9,12 @@ - + - - + + + @@ -23,5 +22,4 @@ - \ No newline at end of file