1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Moving to Ninject dependency injection WIP

This commit is contained in:
Robert Beekman 2016-05-08 00:53:56 +02:00
parent 68efa4885e
commit b01ab9b135
60 changed files with 454 additions and 551 deletions

View File

@ -2,21 +2,50 @@
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings"
<section name="Artemis.Modules.Games.TheDivision.TheDivision" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Artemis.Modules.Games.Dota2.Dota2" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.TheDivision.TheDivision"
<section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.Dota2.Dota2"
<section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay"
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.RocketLeague.RocketLeague"
<section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Settings.Offsets"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<connectionStrings /> <connectionStrings />

View File

@ -308,7 +308,6 @@
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" /> <Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" /> <Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
<Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" /> <Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" />
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs"> <Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
<DependentUpon>TypeWave.settings</DependentUpon> <DependentUpon>TypeWave.settings</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@ -372,6 +371,7 @@
<Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" /> <Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" /> <Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" />
<Compile Include="NinjectModules\ArtemisModules.cs" /> <Compile Include="NinjectModules\ArtemisModules.cs" />
<Compile Include="NinjectModules\BaseModules.cs" />
<Compile Include="NinjectModules\ManagerModules.cs" /> <Compile Include="NinjectModules\ManagerModules.cs" />
<Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
@ -416,13 +416,13 @@
<Compile Include="Utilities\StickyValue.cs" /> <Compile Include="Utilities\StickyValue.cs" />
<Compile Include="Utilities\Updater.cs" /> <Compile Include="Utilities\Updater.cs" />
<Compile Include="Utilities\ValueConverters.cs" /> <Compile Include="Utilities\ValueConverters.cs" />
<Compile Include="ViewModels\Abstract\BaseViewModel.cs" />
<Compile Include="ViewModels\Abstract\OverlayViewModel.cs" /> <Compile Include="ViewModels\Abstract\OverlayViewModel.cs" />
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" /> <Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
<Compile Include="ViewModels\Abstract\GameViewModel.cs" /> <Compile Include="ViewModels\Abstract\GameViewModel.cs" />
<Compile Include="ViewModels\EffectsViewModel.cs" /> <Compile Include="ViewModels\EffectsViewModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" /> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" /> <Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
<Compile Include="Modules\Effects\TypeHole\TypeHoleViewModel.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" /> <Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
<Compile Include="ViewModels\FlyoutBaseViewModel.cs" /> <Compile Include="ViewModels\FlyoutBaseViewModel.cs" />
<Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" /> <Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" />
@ -452,9 +452,6 @@
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml.cs"> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml.cs">
<DependentUpon>AudioVisualizerView.xaml</DependentUpon> <DependentUpon>AudioVisualizerView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Modules\Effects\TypeHole\TypeHoleView.xaml.cs">
<DependentUpon>TypeHoleView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs"> <Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
<DependentUpon>TypeWaveView.xaml</DependentUpon> <DependentUpon>TypeWaveView.xaml</DependentUpon>
</Compile> </Compile>
@ -621,10 +618,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Modules\Effects\TypeHole\TypeHoleView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Modules\Effects\TypeWave\TypeWaveView.xaml"> <Page Include="Modules\Effects\TypeWave\TypeWaveView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -6,6 +6,7 @@ using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.NinjectModules;
using Artemis.ViewModels; using Artemis.ViewModels;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject; using Ninject;
@ -72,7 +73,7 @@ namespace Artemis
protected override void Configure() protected override void Configure()
{ {
_kernel = new StandardKernel(); _kernel = new StandardKernel(new BaseModules(), new ArtemisModules(), new ManagerModules());
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope(); _kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope(); _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
} }

View File

@ -47,7 +47,7 @@ namespace Artemis.DAL
if (!Directory.Exists(path)) if (!Directory.Exists(path))
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
var serializer = new XmlSerializer(typeof (ProfileModel)); var serializer = new XmlSerializer(typeof(ProfileModel));
using (var file = new StreamWriter(path + $@"\{prof.Name}.xml")) using (var file = new StreamWriter(path + $@"\{prof.Name}.xml"))
{ {
serializer.Serialize(file, prof); serializer.Serialize(file, prof);
@ -64,7 +64,7 @@ namespace Artemis.DAL
// Parse the JSON files into objects and add them if they are valid // Parse the JSON files into objects and add them if they are valid
// TODO: Invalid file handling // TODO: Invalid file handling
var deserializer = new XmlSerializer(typeof (ProfileModel)); var deserializer = new XmlSerializer(typeof(ProfileModel));
foreach (var path in profilePaths) foreach (var path in profilePaths)
{ {
using (var file = new StreamReader(path)) using (var file = new StreamReader(path))

View File

@ -39,7 +39,7 @@ namespace Artemis.ItemBehaviours
} }
public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem",
typeof (object), typeof (BindableSelectedItemBehavior), new UIPropertyMetadata(null, OnSelectedItemChanged)); typeof(object), typeof(BindableSelectedItemBehavior), new UIPropertyMetadata(null, OnSelectedItemChanged));
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{ {

View File

@ -7,6 +7,7 @@ using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview; using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Settings; using Artemis.Settings;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject;
using NLog; using NLog;
using LogManager = NLog.LogManager; using LogManager = NLog.LogManager;
@ -16,21 +17,22 @@ namespace Artemis.Managers
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IEventAggregator _events; private readonly IEventAggregator _events;
private readonly MainManager _mainManager;
private EffectModel _activeEffect; private EffectModel _activeEffect;
private bool _clearing; private bool _clearing;
public EffectManager(MainManager mainManager, IEventAggregator events) public EffectManager(IEventAggregator events)
{ {
Logger.Info("Intializing EffectManager"); Logger.Info("Intializing EffectManager");
_mainManager = mainManager;
_events = events; _events = events;
EffectModels = new List<EffectModel>(); EffectModels = new List<EffectModel>();
ProfilePreviewModel = new ProfilePreviewModel(_mainManager); //ProfilePreviewModel = new ProfilePreviewModel(MainManager.Value);
Logger.Info("Intialized EffectManager"); Logger.Info("Intialized EffectManager");
} }
[Inject]
public Lazy<MainManager> MainManager { get; set; }
public EffectModel PauseEffect { get; set; } public EffectModel PauseEffect { get; set; }
/// <summary> /// <summary>
@ -107,14 +109,14 @@ namespace Artemis.Managers
Logger.Debug("Changing effect to: {0}, force: {1}", effectModel?.Name, force); Logger.Debug("Changing effect to: {0}, force: {1}", effectModel?.Name, force);
// If the main manager is running, pause it and safely change the effect // If the main manager is running, pause it and safely change the effect
if (_mainManager.Running) if (MainManager.Value.Running)
{ {
ChangeEffectWithPause(effectModel); ChangeEffectWithPause(effectModel);
return; return;
} }
// If it's not running start it, and let the next recursion handle changing the effect // If it's not running start it, and let the next recursion handle changing the effect
_mainManager.Start(effectModel); MainManager.Value.Start(effectModel);
} }
private void ChangeEffectWithPause(EffectModel effectModel) private void ChangeEffectWithPause(EffectModel effectModel)
@ -137,13 +139,13 @@ namespace Artemis.Managers
Logger.Debug("Changing effect with pause: {0}", effectModel?.Name); Logger.Debug("Changing effect with pause: {0}", effectModel?.Name);
PauseEffect = effectModel; PauseEffect = effectModel;
_mainManager.Pause(); MainManager.Value.Pause();
_mainManager.PauseCallback += ChangeEffectPauseCallback; MainManager.Value.PauseCallback += ChangeEffectPauseCallback;
} }
private void ChangeEffectPauseCallback() private void ChangeEffectPauseCallback()
{ {
_mainManager.PauseCallback -= ChangeEffectPauseCallback; MainManager.Value.PauseCallback -= ChangeEffectPauseCallback;
// Change effect logic // Change effect logic
ActiveEffect?.Dispose(); ActiveEffect?.Dispose();
@ -151,7 +153,7 @@ namespace Artemis.Managers
ActiveEffect = PauseEffect; ActiveEffect = PauseEffect;
ActiveEffect?.Enable(); ActiveEffect?.Enable();
_mainManager.Unpause(); MainManager.Value.Unpause();
PauseEffect = null; PauseEffect = null;
Logger.Debug("Finishing change effect with pause"); Logger.Debug("Finishing change effect with pause");
@ -180,13 +182,13 @@ namespace Artemis.Managers
_clearing = true; _clearing = true;
Logger.Debug("Clearing active effect"); Logger.Debug("Clearing active effect");
_mainManager.Pause(); MainManager.Value.Pause();
_mainManager.PauseCallback += ClearEffectPauseCallback; MainManager.Value.PauseCallback += ClearEffectPauseCallback;
} }
private void ClearEffectPauseCallback() private void ClearEffectPauseCallback()
{ {
_mainManager.PauseCallback -= ClearEffectPauseCallback; MainManager.Value.PauseCallback -= ClearEffectPauseCallback;
if (PauseEffect != null) if (PauseEffect != null)
{ {
Logger.Debug("Cancelling clearing effect"); Logger.Debug("Cancelling clearing effect");
@ -202,7 +204,7 @@ namespace Artemis.Managers
_clearing = false; _clearing = false;
Logger.Debug("Finishing clearing active effect"); Logger.Debug("Finishing clearing active effect");
_mainManager.Unpause(); MainManager.Value.Unpause();
} }
/// <summary> /// <summary>

View File

@ -1,9 +1,11 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Events; using Artemis.Events;
using Artemis.KeyboardProviders; using Artemis.KeyboardProviders;
using Artemis.Settings; using Artemis.Settings;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject;
using NLog; using NLog;
using LogManager = NLog.LogManager; using LogManager = NLog.LogManager;
@ -13,18 +15,21 @@ namespace Artemis.Managers
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IEventAggregator _events; private readonly IEventAggregator _events;
private readonly MainManager _mainManager;
private KeyboardProvider _activeKeyboard; private KeyboardProvider _activeKeyboard;
public KeyboardManager(MainManager mainManager, IEventAggregator events) public KeyboardManager(IEventAggregator events)
{ {
Logger.Info("Intializing KeyboardManager"); Logger.Info("Intializing KeyboardManager");
_mainManager = mainManager;
_events = events; _events = events;
KeyboardProviders = ProviderHelper.GetKeyboardProviders(); KeyboardProviders = ProviderHelper.GetKeyboardProviders();
Logger.Info("Intialized KeyboardManager"); Logger.Info("Intialized KeyboardManager");
} }
[Inject]
public Lazy<MainManager> MainManager { get; set; }
public List<KeyboardProvider> KeyboardProviders { get; set; } public List<KeyboardProvider> KeyboardProviders { get; set; }
public KeyboardProvider ActiveKeyboard public KeyboardProvider ActiveKeyboard
@ -74,7 +79,7 @@ namespace Artemis.Managers
// Disable everything if there's no active keyboard found // Disable everything if there's no active keyboard found
if (!keyboardProvider.CanEnable()) if (!keyboardProvider.CanEnable())
{ {
_mainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText); MainManager.Value.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
General.Default.LastKeyboard = null; General.Default.LastKeyboard = null;
General.Default.Save(); General.Default.Save();
return; return;
@ -116,7 +121,7 @@ namespace Artemis.Managers
General.Default.Save(); General.Default.Save();
Logger.Debug("Restarting for keyboard change"); Logger.Debug("Restarting for keyboard change");
_mainManager.Restart(); MainManager.Value.Restart();
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System.ComponentModel; using System;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -8,7 +9,9 @@ using Artemis.Services;
using Artemis.Utilities.GameState; using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
using Artemis.Utilities.LogitechDll; using Artemis.Utilities.LogitechDll;
using Artemis.ViewModels;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject;
using NLog; using NLog;
using LogManager = NLog.LogManager; using LogManager = NLog.LogManager;
@ -19,23 +22,26 @@ namespace Artemis.Managers
public delegate void PauseCallbackHandler(); public delegate void PauseCallbackHandler();
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly EffectManager _effectManager;
private readonly IEventAggregator _events;
private readonly int _fps; private readonly int _fps;
private readonly KeyboardManager _keyboardManager;
private bool _paused; private bool _paused;
private bool _restarting; private bool _restarting;
public MainManager(IEventAggregator events, MetroDialogService dialogService) public MainManager(IEventAggregator events, KeyboardManager keyboardManager, EffectManager effectManager)
{ {
Logger.Info("Intializing MainManager"); Logger.Info("Intializing MainManager");
Events = events; _events = events;
DialogService = dialogService; _keyboardManager = keyboardManager;
_effectManager = effectManager;
_fps = 25;
KeyboardManager = new KeyboardManager(this, Events); //DialogService = dialogService;
EffectManager = new EffectManager(this, Events);
KeyboardHook = new KeyboardHook(); KeyboardHook = new KeyboardHook();
_fps = 25;
UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
@ -62,18 +68,18 @@ namespace Artemis.Managers
Logger.Info("Intialized MainManager"); Logger.Info("Intialized MainManager");
} }
[Inject]
public Lazy<ShellViewModel> ShellViewModel { get; set; }
public PipeServer PipeServer { get; set; } public PipeServer PipeServer { get; set; }
public BackgroundWorker UpdateWorker { get; set; } public BackgroundWorker UpdateWorker { get; set; }
public BackgroundWorker ProcessWorker { get; set; } public BackgroundWorker ProcessWorker { get; set; }
public KeyboardManager KeyboardManager { get; set; } public MetroDialogService DialogService { get; set; }
public EffectManager EffectManager { get; set; }
public KeyboardHook KeyboardHook { get; set; } public KeyboardHook KeyboardHook { get; set; }
public GameStateWebServer GameStateWebServer { get; set; } public GameStateWebServer GameStateWebServer { get; set; }
public IEventAggregator Events { get; set; }
public MetroDialogService DialogService { get; set; }
public bool ProgramEnabled { get; private set; } public bool ProgramEnabled { get; private set; }
public bool Suspended { get; set; } public bool Suspended { get; set; }
@ -98,13 +104,13 @@ namespace Artemis.Managers
return true; return true;
// Only continue if a keyboard was loaded // Only continue if a keyboard was loaded
KeyboardManager.EnableLastKeyboard(); _keyboardManager.EnableLastKeyboard();
if (KeyboardManager.ActiveKeyboard == null) if (_keyboardManager.ActiveKeyboard == null)
return false; return false;
Running = true; Running = true;
if (effect != null) if (effect != null)
EffectManager.ChangeEffect(effect); _effectManager.ChangeEffect(effect);
// Start the update worker // Start the update worker
if (!UpdateWorker.IsBusy) if (!UpdateWorker.IsBusy)
@ -130,7 +136,7 @@ namespace Artemis.Managers
private void FinishStop(object sender, RunWorkerCompletedEventArgs e) private void FinishStop(object sender, RunWorkerCompletedEventArgs e)
{ {
UpdateWorker.RunWorkerCompleted -= FinishStop; UpdateWorker.RunWorkerCompleted -= FinishStop;
KeyboardManager.ReleaseActiveKeyboard(); _keyboardManager.ReleaseActiveKeyboard();
Running = false; Running = false;
Logger.Debug("Stopped MainManager"); Logger.Debug("Stopped MainManager");
@ -192,8 +198,8 @@ namespace Artemis.Managers
{ {
Logger.Debug("Enabling program"); Logger.Debug("Enabling program");
ProgramEnabled = true; ProgramEnabled = true;
Start(EffectManager.GetLastEffect()); Start(_effectManager.GetLastEffect());
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled)); _events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
} }
/// <summary> /// <summary>
@ -204,7 +210,7 @@ namespace Artemis.Managers
Logger.Debug("Disabling program"); Logger.Debug("Disabling program");
Stop(); Stop();
ProgramEnabled = false; ProgramEnabled = false;
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled)); _events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
} }
#region Workers #region Workers
@ -223,12 +229,12 @@ namespace Artemis.Managers
} }
// Stop if no keyboard/effect are present // Stop if no keyboard/effect are present
if (KeyboardManager.ActiveKeyboard == null || EffectManager.ActiveEffect == null) if (_keyboardManager.ActiveKeyboard == null || _effectManager.ActiveEffect == null)
{ {
Thread.Sleep(1000/_fps); Thread.Sleep(1000/_fps);
Logger.Debug("No active effect/keyboard, stopping"); Logger.Debug("No active effect/keyboard, stopping");
if (EffectManager.PauseEffect != null) if (_effectManager.PauseEffect != null)
{ {
PauseCallback?.Invoke(); PauseCallback?.Invoke();
Thread.Sleep(1000/_fps); Thread.Sleep(1000/_fps);
@ -239,7 +245,7 @@ namespace Artemis.Managers
} }
// Don't stop when the effect is still initialized, just skip this frame // Don't stop when the effect is still initialized, just skip this frame
if (!EffectManager.ActiveEffect.Initialized) if (!_effectManager.ActiveEffect.Initialized)
{ {
Thread.Sleep(1000/_fps); Thread.Sleep(1000/_fps);
continue; continue;
@ -248,28 +254,28 @@ namespace Artemis.Managers
sw.Start(); sw.Start();
// Update the current effect // Update the current effect
if (EffectManager.ActiveEffect.Initialized) if (_effectManager.ActiveEffect.Initialized)
EffectManager.ActiveEffect.Update(); _effectManager.ActiveEffect.Update();
// Get ActiveEffect's bitmap // Get ActiveEffect's bitmap
var bitmap = EffectManager.ActiveEffect.Initialized var bitmap = _effectManager.ActiveEffect.Initialized
? EffectManager.ActiveEffect.GenerateBitmap() ? _effectManager.ActiveEffect.GenerateBitmap()
: null; : null;
// Draw enabled overlays on top // Draw enabled overlays on top
foreach (var overlayModel in EffectManager.EnabledOverlays) foreach (var overlayModel in _effectManager.EnabledOverlays)
{ {
overlayModel.Update(); overlayModel.Update();
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap(); bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
} }
// If it exists, send bitmap to the device // If it exists, send bitmap to the device
if (bitmap != null && KeyboardManager.ActiveKeyboard != null) if (bitmap != null && _keyboardManager.ActiveKeyboard != null)
{ {
KeyboardManager.ActiveKeyboard.DrawBitmap(bitmap); _keyboardManager.ActiveKeyboard.DrawBitmap(bitmap);
// debugging TODO: Disable when window isn't shown // debugging TODO: Disable when window isn't shown
Events.PublishOnUIThread(new ChangeBitmap(bitmap)); _events.PublishOnUIThread(new ChangeBitmap(bitmap));
} }
// Sleep according to time left this frame // Sleep according to time left this frame
@ -302,23 +308,23 @@ namespace Artemis.Managers
var runningProcesses = Process.GetProcesses(); var runningProcesses = Process.GetProcesses();
// If the currently active effect is a disabled game, get rid of it. // If the currently active effect is a disabled game, get rid of it.
if (EffectManager.ActiveEffect != null) if (_effectManager.ActiveEffect != null)
EffectManager.DisableInactiveGame(); _effectManager.DisableInactiveGame();
// If the currently active effect is a no longer running game, get rid of it. // If the currently active effect is a no longer running game, get rid of it.
var activeGame = EffectManager.ActiveEffect as GameModel; var activeGame = _effectManager.ActiveEffect as GameModel;
if (activeGame != null) if (activeGame != null)
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false)) if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
EffectManager.DisableGame(activeGame); _effectManager.DisableGame(activeGame);
// Look for running games, stopping on the first one that's found. // Look for running games, stopping on the first one that's found.
var newGame = EffectManager.EnabledGames var newGame = _effectManager.EnabledGames
.FirstOrDefault( .FirstOrDefault(
g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false)); g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
// If it's not already enabled, do so. // If it's not already enabled, do so.
if (newGame != null && EffectManager.ActiveEffect != newGame) if (newGame != null && _effectManager.ActiveEffect != newGame)
EffectManager.ChangeEffect(newGame); _effectManager.ChangeEffect(newGame);
Thread.Sleep(1000); Thread.Sleep(1000);
} }

View File

@ -10,12 +10,15 @@ namespace Artemis.Models
public bool Initialized; public bool Initialized;
protected KeyboardManager KeyboardManager;
public MainManager MainManager; public MainManager MainManager;
public string Name; public string Name;
protected EffectModel(MainManager mainManager) protected EffectModel(MainManager mainManager, KeyboardManager keyboardManager)
{ {
MainManager = mainManager; MainManager = mainManager;
KeyboardManager = keyboardManager;
} }
public abstract void Dispose(); public abstract void Dispose();

View File

@ -6,7 +6,8 @@ namespace Artemis.Models
{ {
public abstract class GameModel : EffectModel public abstract class GameModel : EffectModel
{ {
protected GameModel(MainManager mainManager, GameSettings settings) : base(mainManager) protected GameModel(MainManager mainManager, KeyboardManager keyboardManager, GameSettings settings)
: base(mainManager, keyboardManager)
{ {
Settings = settings; Settings = settings;
} }

View File

@ -8,7 +8,8 @@ namespace Artemis.Models
private bool _enabled; private bool _enabled;
public string ProcessName; public string ProcessName;
protected OverlayModel(MainManager mainManager) : base(mainManager) protected OverlayModel(MainManager mainManager, KeyboardManager keyboardManager)
: base(mainManager, keyboardManager)
{ {
} }
@ -28,19 +29,6 @@ namespace Artemis.Models
} }
} }
public void SetEnabled(bool enabled)
{
if (Enabled == enabled)
return;
if (enabled)
Enable();
else
Dispose();
Enabled = enabled;
}
public abstract Bitmap GenerateBitmap(Bitmap bitmap); public abstract Bitmap GenerateBitmap(Bitmap bitmap);
} }
} }

View File

@ -47,7 +47,7 @@ namespace Artemis.Models.Profiles
if (layerProp == null || userProp == null) if (layerProp == null || userProp == null)
return; return;
var percentage = ToDouble(gameProperty) / percentageSource; var percentage = ToDouble(gameProperty)/percentageSource;
// Opacity requires some special treatment as it causes an exception if it's < 0.0 or > 1.0 // Opacity requires some special treatment as it causes an exception if it's < 0.0 or > 1.0
if (LayerProperty == "Opacity") if (LayerProperty == "Opacity")

View File

@ -5,10 +5,10 @@ using System.Xml.Serialization;
namespace Artemis.Models.Profiles namespace Artemis.Models.Profiles
{ {
[XmlInclude(typeof (SolidColorBrush))] [XmlInclude(typeof(SolidColorBrush))]
[XmlInclude(typeof (LinearGradientBrush))] [XmlInclude(typeof(LinearGradientBrush))]
[XmlInclude(typeof (RadialGradientBrush))] [XmlInclude(typeof(RadialGradientBrush))]
[XmlInclude(typeof (MatrixTransform))] [XmlInclude(typeof(MatrixTransform))]
public class LayerPropertiesModel public class LayerPropertiesModel
{ {
public int X { get; set; } public int X { get; set; }

View File

@ -20,8 +20,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
private ScreenCapture _screenCapturer; private ScreenCapture _screenCapturer;
private KeyboardRectangle _topRect; private KeyboardRectangle _topRect;
public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings) public AmbientLightningEffectModel(MainManager mainManager, KeyboardManager keyboardManager,
: base(mainManager) AmbientLightningEffectSettings settings) : base(mainManager, keyboardManager)
{ {
Name = "Ambient Lightning"; Name = "Ambient Lightning";
Settings = settings; Settings = settings;
@ -49,9 +49,9 @@ namespace Artemis.Modules.Effects.AmbientLightning
_colors = new List<Color>(); _colors = new List<Color>();
_screenCapturer = new ScreenCapture(); _screenCapturer = new ScreenCapture();
_topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(), _topRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2}; LinearGradientMode.Horizontal) {Height = KeyboardManager.ActiveKeyboard.Height*Scale/2};
_botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(), _botRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal); LinearGradientMode.Horizontal);
Initialized = true; Initialized = true;
@ -102,8 +102,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
} }
// Put the resulting colors in 6 rectangles, their size differs per keyboard // Put the resulting colors in 6 rectangles, their size differs per keyboard
var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale; var rectWidth = KeyboardManager.ActiveKeyboard.Width/3*Scale;
var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale; var rectHeight = KeyboardManager.ActiveKeyboard.Height/2*Scale;
for (var row = 0; row < 2; row++) for (var row = 0; row < 2; row++)
{ {
for (var column = 0; column < 3; column++) for (var column = 0; column < 3; column++)
@ -116,7 +116,7 @@ namespace Artemis.Modules.Effects.AmbientLightning
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
var i = 0; var i = 0;

View File

@ -5,25 +5,20 @@ using Caliburn.Micro;
namespace Artemis.Modules.Effects.AmbientLightning namespace Artemis.Modules.Effects.AmbientLightning
{ {
internal class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged> public sealed class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
public AmbientLightningEffectViewModel(MainManager mainManager) public AmbientLightningEffectViewModel(MainManager mainManager, KeyboardManager keyboardManager,
EffectManager effectManager, IEventAggregator events)
: base(
mainManager, effectManager,
new AmbientLightningEffectModel(mainManager, keyboardManager, new AmbientLightningEffectSettings()))
{ {
// Subscribe to main model DisplayName = "Ambient Lightning";
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class events.Subscribe(this);
EffectSettings = new AmbientLightningEffectSettings(); EffectManager.EffectModels.Add(EffectModel);
// Create effect model and add it to MainManager
EffectModel = new AmbientLightningEffectModel(mainManager, (AmbientLightningEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public static string Name => "Ambient Lightning";
public void Handle(ActiveEffectChanged message) public void Handle(ActiveEffectChanged message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);

View File

@ -18,10 +18,10 @@ namespace Artemis.Modules.Effects.AmbientLightning
internal class ScreenCapture : IDisposable internal class ScreenCapture : IDisposable
{ {
private readonly Device _device; private readonly Device _device;
private readonly OutputDuplication _duplicatedOutput;
private readonly Factory1 _factory; private readonly Factory1 _factory;
private readonly Texture2D _screenTexture; private readonly Texture2D _screenTexture;
private DataStream _dataStream; private DataStream _dataStream;
private readonly OutputDuplication _duplicatedOutput;
private Resource _screenResource; private Resource _screenResource;
private Surface _screenSurface; private Surface _screenSurface;

View File

@ -22,7 +22,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
private int _sensitivity; private int _sensitivity;
private IWaveIn _waveIn; private IWaveIn _waveIn;
public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager) public AudioVisualizerModel(MainManager mainManager, KeyboardManager keyboardManager,
AudioVisualizerSettings settings) : base(mainManager, keyboardManager)
{ {
Settings = settings; Settings = settings;
Name = "Audiovisualizer"; Name = "Audiovisualizer";
@ -57,7 +58,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public override void Enable() public override void Enable()
{ {
Initialized = false; Initialized = false;
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width; Lines = KeyboardManager.ActiveKeyboard.Width;
// TODO: Device selection // TODO: Device selection
SelectedDeviceId = new MMDeviceEnumerator() SelectedDeviceId = new MMDeviceEnumerator()
@ -69,7 +70,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
for (var i = 0; i < Lines; i++) for (var i = 0; i < Lines; i++)
{ {
SoundRectangles.Add(new KeyboardRectangle( SoundRectangles.Add(new KeyboardRectangle(
MainManager.KeyboardManager.ActiveKeyboard, KeyboardManager.ActiveKeyboard,
0, 0, new List<Color> 0, 0, new List<Color>
{ {
ColorHelpers.ToDrawingColor(Settings.TopColor), ColorHelpers.ToDrawingColor(Settings.TopColor),
@ -121,7 +122,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
// Apply Sensitivity setting // Apply Sensitivity setting
height = height*_sensitivity; height = height*_sensitivity;
var keyboardHeight = var keyboardHeight =
(int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale); (int) Math.Round(KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
if (keyboardHeight > SoundRectangles[i].Height) if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight; SoundRectangles[i].Height = keyboardHeight;
else else
@ -131,7 +132,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SoundRectangles[i].Width = Scale; SoundRectangles[i].Width = Scale;
if (_fromBottom) if (_fromBottom)
SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - SoundRectangles[i].Y = KeyboardManager.ActiveKeyboard.Height*Scale -
SoundRectangles[i].Height; SoundRectangles[i].Height;
} }
_generating = false; _generating = false;
@ -145,7 +146,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
// Lock the _spectrumData array while busy with it // Lock the _spectrumData array while busy with it
_generating = true; _generating = true;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
foreach (var soundRectangle in SoundRectangles) foreach (var soundRectangle in SoundRectangles)

View File

@ -5,24 +5,20 @@ using Caliburn.Micro;
namespace Artemis.Modules.Effects.AudioVisualizer namespace Artemis.Modules.Effects.AudioVisualizer
{ {
public class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged> public sealed class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
public AudioVisualizerViewModel(MainManager mainManager) public AudioVisualizerViewModel(MainManager mainManager, KeyboardManager keyboardManager,
EffectManager effectManager, IEventAggregator events)
: base(
mainManager, effectManager,
new AudioVisualizerModel(mainManager, keyboardManager, new AudioVisualizerSettings()))
{ {
// Subscribe to main model DisplayName = "Audio Visualization";
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class events.Subscribe(this);
EffectSettings = new AudioVisualizerSettings(); EffectManager.EffectModels.Add(EffectModel);
// Create effect model and add it to MainManager
EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public static string Name => "Audio Visualizer";
public void Handle(ActiveEffectChanged message) public void Handle(ActiveEffectChanged message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);

View File

@ -10,7 +10,8 @@ namespace Artemis.Modules.Effects.Debug
// TODO: Remove // TODO: Remove
internal class DebugEffectModel : EffectModel internal class DebugEffectModel : EffectModel
{ {
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager) public DebugEffectModel(MainManager mainManager, KeyboardManager keyboardManager, DebugEffectSettings settings)
: base(mainManager, keyboardManager)
{ {
Name = "Debug Effect"; Name = "Debug Effect";
Settings = settings; Settings = settings;
@ -33,7 +34,7 @@ namespace Artemis.Modules.Effects.Debug
{ {
Initialized = false; Initialized = false;
KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color> KeyboardRectangle = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{ {
Color.Red, Color.Red,
Color.OrangeRed, Color.OrangeRed,

View File

@ -1,9 +1,6 @@
using System; using System;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Events; using Artemis.Events;
using Artemis.Managers; using Artemis.Managers;
using Artemis.Utilities; using Artemis.Utilities;
@ -12,30 +9,25 @@ using Caliburn.Micro;
namespace Artemis.Modules.Effects.Debug namespace Artemis.Modules.Effects.Debug
{ {
internal class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged> internal sealed class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged>
{ {
private ImageSource _imageSource; private ImageSource _imageSource;
private string _selectedRectangleType; private string _selectedRectangleType;
public DebugEffectViewModel(MainManager mainManager) public DebugEffectViewModel(MainManager mainManager, KeyboardManager keyboardManager,
EffectManager effectManager, IEventAggregator events)
: base(
mainManager, effectManager,
new DebugEffectModel(mainManager, keyboardManager, new DebugEffectSettings()))
{ {
// Subscribe to main model DisplayName = "Debug Effect";
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class events.Subscribe(this);
EffectSettings = new DebugEffectSettings(); EffectManager.EffectModels.Add(EffectModel);
// Create effect model and add it to MainManager
EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public static string Name => "Debug Effect";
public BindableCollection<string> RectangleTypes public BindableCollection<string> RectangleTypes
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode))); => new BindableCollection<string>(Enum.GetNames(typeof(LinearGradientMode)));
public string SelectedRectangleType public string SelectedRectangleType
{ {
@ -47,7 +39,7 @@ namespace Artemis.Modules.Effects.Debug
NotifyOfPropertyChange(() => SelectedRectangleType); NotifyOfPropertyChange(() => SelectedRectangleType);
((DebugEffectSettings) EffectSettings).Type = ((DebugEffectSettings) EffectSettings).Type =
(LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value); (LinearGradientMode) Enum.Parse(typeof(LinearGradientMode), value);
} }
} }

View File

@ -10,7 +10,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
{ {
private readonly ProfilePreviewDataModel _previewDataModel; private readonly ProfilePreviewDataModel _previewDataModel;
public ProfilePreviewModel(MainManager mainManager) : base(mainManager) public ProfilePreviewModel(MainManager mainManager, KeyboardManager keyboardManager)
: base(mainManager, keyboardManager)
{ {
Name = "Profile Preview"; Name = "Profile Preview";
_previewDataModel = new ProfilePreviewDataModel(); _previewDataModel = new ProfilePreviewDataModel();
@ -40,12 +41,12 @@ namespace Artemis.Modules.Effects.ProfilePreview
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4); var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
if (SelectedProfile == null) if (SelectedProfile == null)
return bitmap; return bitmap;
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(4); var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true); var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true);
// Draw on top of everything else // Draw on top of everything else

View File

@ -1,40 +0,0 @@
using System.Drawing;
using Artemis.Managers;
using Artemis.Models;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleModel : EffectModel
{
public TypeHoleModel(MainManager mainManager) : base(mainManager)
{
Name = "TypeHole";
Initialized = false;
}
public override void Dispose()
{
Initialized = false;
// Disable logic
}
public override void Enable()
{
Initialized = false;
// Enable logic
Initialized = true;
}
public override void Update()
{
}
public override Bitmap GenerateBitmap()
{
return null;
}
}
}

View File

@ -1,49 +0,0 @@
<UserControl x:Class="Artemis.Modules.Effects.TypeHole.TypeHoleView"
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:cal="http://www.caliburnproject.org"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="407.812" d:DesignWidth="671.484"
cal:Bind.AtDesignTime="True">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid Margin="15, 5, 15, 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Label FontSize="20" HorizontalAlignment="Left">
<Label.Content>
<AccessText TextWrapping="Wrap"
Text="Creates holes in the keyboard's lightning as you press keys." />
</Label.Content>
</Label>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}"
Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel>
</StackPanel>
</Grid>
</ScrollViewer>
</UserControl>

View File

@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.Modules.Effects.TypeHole
{
/// <summary>
/// Interaction logic for TypeHoleView.xaml
/// </summary>
public partial class TypeHoleView : UserControl
{
public TypeHoleView()
{
InitializeComponent();
}
}
}

View File

@ -1,28 +0,0 @@
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public TypeHoleViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Create effect model and add it to MainManager
EffectModel = new TypeHoleModel(mainManager);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Type Holes (NYI)";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
}

View File

@ -16,7 +16,8 @@ namespace Artemis.Modules.Effects.TypeWave
private readonly List<Wave> _waves; private readonly List<Wave> _waves;
private Color _randomColor; private Color _randomColor;
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager) public TypeWaveModel(MainManager mainManager, KeyboardManager keyboardManager, TypeWaveSettings settings)
: base(mainManager, keyboardManager)
{ {
Name = "TypeWave"; Name = "TypeWave";
_waves = new List<Wave>(); _waves = new List<Wave>();
@ -96,7 +97,7 @@ namespace Artemis.Modules.Effects.TypeWave
if (_waves.Count == 0) if (_waves.Count == 0)
return null; return null;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);
@ -113,7 +114,7 @@ namespace Artemis.Modules.Effects.TypeWave
_waves[i].Size, _waves[i].Size); _waves[i].Size, _waves[i].Size);
Color fillColor; Color fillColor;
if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB) if (KeyboardManager.ActiveKeyboard is CorsairRGB)
fillColor = Color.Black; fillColor = Color.Black;
else else
fillColor = Color.Transparent; fillColor = Color.Transparent;

View File

@ -5,24 +5,18 @@ using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeWave namespace Artemis.Modules.Effects.TypeWave
{ {
public class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged> public sealed class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
public TypeWaveViewModel(MainManager mainManager) public TypeWaveViewModel(MainManager mainManager, KeyboardManager keyboardManager, EffectManager effectManager,
IEventAggregator events)
: base(mainManager, effectManager, new TypeWaveModel(mainManager, keyboardManager, new TypeWaveSettings()))
{ {
// Subscribe to main model DisplayName = "Type Waves";
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class events.Subscribe(this);
EffectSettings = new TypeWaveSettings(); EffectManager.EffectModels.Add(EffectModel);
// Create effect model and add it to MainManager
EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public static string Name => "Type Waves";
public void Handle(ActiveEffectChanged message) public void Handle(ActiveEffectChanged message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);

View File

@ -8,7 +8,8 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeModel : GameModel public class CounterStrikeModel : GameModel
{ {
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings) public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings,
KeyboardManager keyboardManager) : base(mainManager, keyboardManager, settings)
{ {
Name = "CounterStrike"; Name = "CounterStrike";
ProcessName = "csgo"; ProcessName = "csgo";
@ -49,7 +50,7 @@ namespace Artemis.Modules.Games.CounterStrike
if (Profile == null || GameDataModel == null) if (Profile == null || GameDataModel == null)
return null; return null;
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale); var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
return Profile.GenerateBitmap<CounterStrikeDataModel>(keyboardRect, GameDataModel); return Profile.GenerateBitmap<CounterStrikeDataModel>(keyboardRect, GameDataModel);
} }

View File

@ -6,19 +6,21 @@ using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.CounterStrike namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel> public sealed class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
{ {
public CounterStrikeViewModel(MainManager mainManager) public CounterStrikeViewModel(MainManager mainManager, EffectManager effectManager,
: base(mainManager, new CounterStrikeModel(mainManager, new CounterStrikeSettings())) KeyboardManager keyboardManager)
: base(
mainManager, effectManager,
new CounterStrikeModel(mainManager, new CounterStrikeSettings(), keyboardManager))
{ {
DisplayName = "CS:GO";
// Create effect model and add it to MainManager // Create effect model and add it to MainManager
MainManager.EffectManager.EffectModels.Add(GameModel); EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile(); PlaceConfigFile();
} }
public static string Name => "CS:GO";
public string Content => "Counter-Strike: GO Content";
public void BrowseDirectory() public void BrowseDirectory()
{ {
var dialog = new FolderBrowserDialog {SelectedPath = ((CounterStrikeSettings) GameSettings).GameDirectory}; var dialog = new FolderBrowserDialog {SelectedPath = ((CounterStrikeSettings) GameSettings).GameDirectory};

View File

@ -15,12 +15,15 @@ namespace Artemis.Modules.Games.Dota2
{ {
internal class Dota2Model : GameModel internal class Dota2Model : GameModel
{ {
private readonly KeyboardManager _keyboardManager;
private KeyboardRegion _abilityKeys; private KeyboardRegion _abilityKeys;
private KeyboardRegion _keyPad; private KeyboardRegion _keyPad;
private KeyboardRegion _topRow; private KeyboardRegion _topRow;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager, settings) public Dota2Model(MainManager mainManager, KeyboardManager keyboardManager, Dota2Settings settings)
: base(mainManager, keyboardManager, settings)
{ {
_keyboardManager = keyboardManager;
Name = "Dota2"; Name = "Dota2";
ProcessName = "dota2"; ProcessName = "dota2";
Settings = settings; Settings = settings;
@ -40,35 +43,35 @@ namespace Artemis.Modules.Games.Dota2
public override void Enable() public override void Enable()
{ {
Initialized = false; Initialized = false;
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); _topRow = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad"); _keyPad = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
_abilityKeys = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER"); _abilityKeys = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard HealthRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
, 0 , 0
, _topRow.BottomRight.Y*Scale , _topRow.BottomRight.Y*Scale
, new List<Color>() , new List<Color>()
, LinearGradientMode.Horizontal) , LinearGradientMode.Horizontal)
{Height = Scale, ContainedBrush = false}; {Height = Scale, ContainedBrush = false};
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard ManaRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
, 0 , 0
, (_topRow.BottomRight.Y + 1)*Scale , (_topRow.BottomRight.Y + 1)*Scale
, new List<Color>() , new List<Color>()
, LinearGradientMode.Horizontal) , LinearGradientMode.Horizontal)
{Height = Scale, ContainedBrush = false}; {Height = Scale, ContainedBrush = false};
EventRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard EventRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
, 0 , 0
, _topRow.TopLeft.X + 3 , _topRow.TopLeft.X + 3
, new List<Color>() , new List<Color>()
, LinearGradientMode.Horizontal) , LinearGradientMode.Horizontal)
{ {
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale Height = _keyboardManager.ActiveKeyboard.Height*Scale - Scale
, ,
Width = MainManager.KeyboardManager.ActiveKeyboard.Width*Scale - Scale - 12 Width = _keyboardManager.ActiveKeyboard.Width*Scale - Scale - 12
}; };
DayCycleRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard DayCycleRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
, _keyPad.TopLeft.X*Scale , _keyPad.TopLeft.X*Scale
, _keyPad.TopLeft.Y*Scale , _keyPad.TopLeft.Y*Scale
, new List<Color>() , new List<Color>()
@ -96,7 +99,7 @@ namespace Artemis.Modules.Games.Dota2
case "3": //League of Legends case "3": //League of Legends
for (var i = 0; i < AbilityKeysRectangles.Length; i++) for (var i = 0; i < AbilityKeysRectangles.Length; i++)
{ {
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[i] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + i)*Scale - 2, (_abilityKeys.TopLeft.X + i)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale, _abilityKeys.TopLeft.Y*Scale,
new List<Color>(), new List<Color>(),
@ -108,7 +111,7 @@ namespace Artemis.Modules.Games.Dota2
} }
break; break;
case "2": case "2":
AbilityKeysRectangles[0] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[0] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
_abilityKeys.TopLeft.X*Scale - 2, _abilityKeys.TopLeft.X*Scale - 2,
_abilityKeys.TopLeft.Y*Scale, _abilityKeys.TopLeft.Y*Scale,
new List<Color>(), new List<Color>(),
@ -117,7 +120,7 @@ namespace Artemis.Modules.Games.Dota2
Height = Scale, Height = Scale,
Width = Scale Width = Scale
}; };
AbilityKeysRectangles[1] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[1] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 2)*Scale - 2, (_abilityKeys.TopLeft.X + 2)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale, _abilityKeys.TopLeft.Y*Scale,
new List<Color>(), new List<Color>(),
@ -126,7 +129,7 @@ namespace Artemis.Modules.Games.Dota2
Height = Scale, Height = Scale,
Width = Scale Width = Scale
}; };
AbilityKeysRectangles[2] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[2] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 3)*Scale - 2, (_abilityKeys.TopLeft.X + 3)*Scale - 2,
_abilityKeys.TopLeft.Y*Scale, _abilityKeys.TopLeft.Y*Scale,
new List<Color>(), new List<Color>(),
@ -135,7 +138,7 @@ namespace Artemis.Modules.Games.Dota2
Height = Scale, Height = Scale,
Width = Scale Width = Scale
}; };
AbilityKeysRectangles[3] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[3] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + 3)*Scale - 2, (_abilityKeys.TopLeft.X + 3)*Scale - 2,
(_abilityKeys.TopLeft.Y + 1)*Scale, (_abilityKeys.TopLeft.Y + 1)*Scale,
new List<Color>(), new List<Color>(),
@ -149,7 +152,7 @@ namespace Artemis.Modules.Games.Dota2
case "5": //Smite case "5": //Smite
for (var i = 0; i < AbilityKeysRectangles.Length; i++) for (var i = 0; i < AbilityKeysRectangles.Length; i++)
{ {
AbilityKeysRectangles[i] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, AbilityKeysRectangles[i] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
(_abilityKeys.TopLeft.X + i)*Scale - 3, (_abilityKeys.TopLeft.X + i)*Scale - 3,
(_abilityKeys.TopLeft.Y - 1)*Scale, (_abilityKeys.TopLeft.Y - 1)*Scale,
new List<Color>(), new List<Color>(),
@ -294,7 +297,7 @@ namespace Artemis.Modules.Games.Dota2
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {

View File

@ -7,12 +7,14 @@ using Caliburn.Micro;
namespace Artemis.Modules.Games.Dota2 namespace Artemis.Modules.Games.Dota2
{ {
public class Dota2ViewModel : GameViewModel<Dota2DataModel> public sealed class Dota2ViewModel : GameViewModel<Dota2DataModel>
{ {
public Dota2ViewModel(MainManager mainManager) public Dota2ViewModel(MainManager mainManager, EffectManager effectManager, KeyboardManager keyboardManager)
: base(mainManager, new Dota2Model(mainManager, new Dota2Settings())) : base(mainManager, effectManager, new Dota2Model(mainManager, keyboardManager, new Dota2Settings()))
{ {
MainManager.EffectManager.EffectModels.Add(GameModel); DisplayName = "Dota 2";
EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile(); PlaceConfigFile();
} }

View File

@ -15,7 +15,8 @@ namespace Artemis.Modules.Games.RocketLeague
private Memory _memory; private Memory _memory;
private GamePointersCollection _pointer; private GamePointersCollection _pointer;
public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager, settings) public RocketLeagueModel(MainManager mainManager, KeyboardManager keyboardManager, RocketLeagueSettings settings)
: base(mainManager, keyboardManager, settings)
{ {
Name = "RocketLeague"; Name = "RocketLeague";
ProcessName = "RocketLeague"; ProcessName = "RocketLeague";
@ -72,7 +73,7 @@ namespace Artemis.Modules.Games.RocketLeague
if (Profile == null || GameDataModel == null) if (Profile == null || GameDataModel == null)
return null; return null;
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale); var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel); return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel);
} }
} }

View File

@ -7,19 +7,22 @@ using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague namespace Artemis.Modules.Games.RocketLeague
{ {
public class RocketLeagueViewModel : GameViewModel<RocketLeagueDataModel> public sealed class RocketLeagueViewModel : GameViewModel<RocketLeagueDataModel>
{ {
private string _versionText; private string _versionText;
public RocketLeagueViewModel(MainManager mainManager) public RocketLeagueViewModel(MainManager mainManager, KeyboardManager keyboardManager,
: base(mainManager, new RocketLeagueModel(mainManager, new RocketLeagueSettings())) EffectManager effectManager)
: base(
mainManager, effectManager,
new RocketLeagueModel(mainManager, keyboardManager, new RocketLeagueSettings()))
{ {
MainManager.EffectManager.EffectModels.Add(GameModel); DisplayName = "Rocket League";
EffectManager.EffectModels.Add(GameModel);
SetVersionText(); SetVersionText();
} }
public static string Name => "Rocket League";
public string VersionText public string VersionText
{ {
get { return _versionText; } get { return _versionText; }

View File

@ -12,6 +12,7 @@ namespace Artemis.Modules.Games.TheDivision
{ {
public class TheDivisionModel : GameModel public class TheDivisionModel : GameModel
{ {
private readonly KeyboardManager _keyboardManager;
private Wave _ammoWave; private Wave _ammoWave;
private TheDivisionDataModel _dataModel; private TheDivisionDataModel _dataModel;
private KeyboardRectangle _hpRect; private KeyboardRectangle _hpRect;
@ -22,8 +23,10 @@ namespace Artemis.Modules.Games.TheDivision
private StickyValue<bool> _stickyHp; private StickyValue<bool> _stickyHp;
private int _trans; private int _trans;
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager, settings) public TheDivisionModel(MainManager mainManager, KeyboardManager keyboardManager, TheDivisionSettings settings)
: base(mainManager, keyboardManager, settings)
{ {
_keyboardManager = keyboardManager;
Name = "TheDivision"; Name = "TheDivision";
ProcessName = "TheDivision"; ProcessName = "TheDivision";
Scale = 4; Scale = 4;
@ -47,7 +50,7 @@ namespace Artemis.Modules.Games.TheDivision
Initialized = false; Initialized = false;
_ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent); _ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent);
_hpRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 3*Scale, 0*Scale, _hpRect = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 3*Scale, 0*Scale,
new List<Color>(), new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
@ -57,7 +60,7 @@ namespace Artemis.Modules.Games.TheDivision
ContainedBrush = false ContainedBrush = false
}; };
_p2 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 1*Scale, _p2 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
new List<Color>(), new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
@ -66,7 +69,7 @@ namespace Artemis.Modules.Games.TheDivision
Rotate = true, Rotate = true,
ContainedBrush = false ContainedBrush = false
}; };
_p3 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 3*Scale, _p3 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
new List<Color>(), new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
@ -75,7 +78,7 @@ namespace Artemis.Modules.Games.TheDivision
Rotate = true, Rotate = true,
ContainedBrush = false ContainedBrush = false
}; };
_p4 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 5*Scale, _p4 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
new List<Color>(), new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
@ -204,7 +207,7 @@ namespace Artemis.Modules.Games.TheDivision
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);

View File

@ -3,14 +3,16 @@ using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.TheDivision namespace Artemis.Modules.Games.TheDivision
{ {
public class TheDivisionViewModel : GameViewModel<TheDivisionDataModel> public sealed class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
{ {
public TheDivisionViewModel(MainManager mainManager) public TheDivisionViewModel(MainManager mainManager, EffectManager effectManager,
: base(mainManager, new TheDivisionModel(mainManager, new TheDivisionSettings())) KeyboardManager keyboardManager)
: base(
mainManager, effectManager,
new TheDivisionModel(mainManager, keyboardManager, new TheDivisionSettings()))
{ {
MainManager.EffectManager.EffectModels.Add(GameModel); DisplayName = "The Division";
EffectManager.EffectModels.Add(GameModel);
} }
public static string Name => "The Division";
} }
} }

View File

@ -18,7 +18,8 @@ namespace Artemis.Modules.Games.Witcher3
private KeyboardRectangle _signRect; private KeyboardRectangle _signRect;
private string _witcherSettings; private string _witcherSettings;
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager, settings) public Witcher3Model(MainManager mainManager, KeyboardManager keyboardManager, Witcher3Settings settings)
: base(mainManager, keyboardManager, settings)
{ {
Name = "Witcher3"; Name = "Witcher3";
ProcessName = "witcher3"; ProcessName = "witcher3";
@ -44,7 +45,7 @@ namespace Artemis.Modules.Games.Witcher3
{ {
Initialized = false; Initialized = false;
_signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(), _signRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Rotate = true, Rotate = true,
@ -106,7 +107,7 @@ namespace Artemis.Modules.Games.Witcher3
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);

View File

@ -10,19 +10,13 @@ using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.Witcher3 namespace Artemis.Modules.Games.Witcher3
{ {
public class Witcher3ViewModel : GameViewModel<Witcher3DataModel> public sealed class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
{ {
public Witcher3ViewModel(MainManager mainManager) public Witcher3ViewModel(MainManager mainManager, KeyboardManager keyboardManager, EffectManager effectManager)
: base(mainManager, new Witcher3Model(mainManager, new Witcher3Settings())) : base(mainManager, effectManager, new Witcher3Model(mainManager, keyboardManager, new Witcher3Settings()))
{ {
MainManager = mainManager; DisplayName = "The Witcher 3";
EffectManager.EffectModels.Add(GameModel);
// Settings are loaded from file by class
GameSettings = new Witcher3Settings();
// Create effect model and add it to MainManager
GameModel = new Witcher3Model(mainManager, (Witcher3Settings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
} }
public static string Name => "The Witcher 3"; public static string Name => "The Witcher 3";

View File

@ -9,16 +9,16 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeBar public class VolumeBar
{ {
public VolumeBar(MainManager mainManager, VolumeDisplaySettings settings) private readonly KeyboardManager _keyboardManager;
public VolumeBar(KeyboardManager keyboardManager, VolumeDisplaySettings settings)
{ {
MainManager = mainManager; _keyboardManager = keyboardManager;
Settings = settings; Settings = settings;
Transparancy = 255; Transparancy = 255;
Scale = 4; Scale = 4;
} }
public MainManager MainManager { get; set; }
public VolumeDisplaySettings Settings { get; set; } public VolumeDisplaySettings Settings { get; set; }
public int Scale { get; set; } public int Scale { get; set; }
@ -30,14 +30,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public void Draw(Graphics g) public void Draw(Graphics g)
{ {
var volumeRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color> var volumeRect = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{ {
ColorHelpers.ToDrawingColor(Settings.MainColor), ColorHelpers.ToDrawingColor(Settings.MainColor),
ColorHelpers.ToDrawingColor(Settings.SecondaryColor) ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
}, },
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume), Width = (int) (_keyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
ContainedBrush = false ContainedBrush = false
}; };
volumeRect.Draw(g); volumeRect.Draw(g);

View File

@ -9,13 +9,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeDisplayModel : OverlayModel public class VolumeDisplayModel : OverlayModel
{ {
public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager) public VolumeDisplayModel(MainManager mainManager, KeyboardManager keyboardManager,
VolumeDisplaySettings settings) : base(mainManager, keyboardManager)
{ {
Settings = settings; Settings = settings;
Name = "VolumeDisplay"; Name = "VolumeDisplay";
Enabled = Settings.Enabled; Enabled = Settings.Enabled;
VolumeDisplay = new VolumeBar(mainManager, settings); VolumeDisplay = new VolumeBar(keyboardManager, settings);
} }
public VolumeBar VolumeDisplay { get; set; } public VolumeBar VolumeDisplay { get; set; }
@ -63,7 +64,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4)); return GenerateBitmap(KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
} }
public override Bitmap GenerateBitmap(Bitmap bitmap) public override Bitmap GenerateBitmap(Bitmap bitmap)

View File

@ -3,18 +3,20 @@ using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Overlays.VolumeDisplay namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeDisplayViewModel : OverlayViewModel public sealed class VolumeDisplayViewModel : OverlayViewModel
{ {
public VolumeDisplayViewModel(MainManager mainManager) public VolumeDisplayViewModel(MainManager mainManager, KeyboardManager keyboardManager,
EffectManager effectManager)
: base(mainManager, effectManager)
{ {
MainManager = mainManager; DisplayName = "Volume Display";
// Settings are loaded from file by class // Settings are loaded from file by class
OverlaySettings = new VolumeDisplaySettings(); OverlaySettings = new VolumeDisplaySettings();
// Create effect model and add it to MainManager // Create effect model and add it to MainManager
OverlayModel = new VolumeDisplayModel(mainManager, (VolumeDisplaySettings) OverlaySettings); OverlayModel = new VolumeDisplayModel(mainManager, keyboardManager, (VolumeDisplaySettings) OverlaySettings);
MainManager.EffectManager.EffectModels.Add(OverlayModel); EffectManager.EffectModels.Add(OverlayModel);
} }
} }
} }

View File

@ -1,5 +1,4 @@
using Artemis.Modules.Effects.AmbientLightning; using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug; using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeWave; using Artemis.Modules.Effects.TypeWave;
using Artemis.Modules.Games.CounterStrike; using Artemis.Modules.Games.CounterStrike;
@ -19,10 +18,11 @@ namespace Artemis.NinjectModules
public override void Load() public override void Load()
{ {
// Effects // Effects
//Bind<EffectViewModel>().To<AmbientLightningEffectViewModel>().InSingletonScope(); Bind<Screen>().To<EffectViewModel>(); // TODO: Needed?
Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope(); Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope(); Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<TypeWaveViewModel>().InSingletonScope(); Bind<EffectViewModel>().To<TypeWaveViewModel>().InSingletonScope();
//Bind<EffectViewModel>().To<AmbientLightningEffectViewModel>().InSingletonScope();
// Games // Games
Bind<Screen>().To(typeof(GameViewModel<>)); // TODO: Needed? Bind<Screen>().To(typeof(GameViewModel<>)); // TODO: Needed?
@ -33,8 +33,8 @@ namespace Artemis.NinjectModules
Bind<GameViewModel<Witcher3DataModel>>().To<Witcher3ViewModel>().InSingletonScope(); Bind<GameViewModel<Witcher3DataModel>>().To<Witcher3ViewModel>().InSingletonScope();
// Overlays // Overlays
Bind<Screen>().To<OverlayViewModel>(); // TODO: Needed?
Bind<OverlayViewModel>().To<VolumeDisplayViewModel>().InSingletonScope(); Bind<OverlayViewModel>().To<VolumeDisplayViewModel>().InSingletonScope();
} }
} }
} }

View File

@ -0,0 +1,20 @@
using Artemis.ViewModels;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
using Ninject.Modules;
namespace Artemis.NinjectModules
{
internal class BaseModules : NinjectModule
{
public override void Load()
{
// ViewModels
Bind<IScreen>().To<ShellViewModel>().InSingletonScope();
Bind<BaseViewModel>().To<EffectsViewModel>().InSingletonScope();
Bind<BaseViewModel>().To<GamesViewModel>().InSingletonScope();
Bind<BaseViewModel>().To<OverlaysViewModel>().InSingletonScope();
}
}
}

View File

@ -344,7 +344,7 @@ namespace Artemis.Annotations
/// </code> /// </code>
/// </example> /// </example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof (Attribute))] [BaseTypeRequired(typeof(Attribute))]
public sealed class BaseTypeRequiredAttribute : Attribute public sealed class BaseTypeRequiredAttribute : Attribute
{ {
public BaseTypeRequiredAttribute([NotNull] Type baseType) public BaseTypeRequiredAttribute([NotNull] Type baseType)

View File

@ -23,7 +23,6 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using Artemis.ViewModels;
using Caliburn.Micro; using Caliburn.Micro;
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs; using MahApps.Metro.Controls.Dialogs;

View File

@ -66,7 +66,7 @@ namespace Artemis.Utilities
if (ReferenceEquals(source, null)) if (ReferenceEquals(source, null))
return default(T); return default(T);
var serializer = new XmlSerializer(typeof (T)); var serializer = new XmlSerializer(typeof(T));
Stream stream = new MemoryStream(); Stream stream = new MemoryStream();
using (stream) using (stream)
{ {
@ -87,7 +87,7 @@ namespace Artemis.Utilities
} }
public static List<PropertyCollection> GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties()); public static List<PropertyCollection> GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties());
public static List<PropertyCollection> GenerateTypeMap<T>() => GenerateTypeMap(typeof (T).GetProperties()); public static List<PropertyCollection> GenerateTypeMap<T>() => GenerateTypeMap(typeof(T).GetProperties());
private static List<PropertyCollection> GenerateTypeMap(IEnumerable<PropertyInfo> getProperties, private static List<PropertyCollection> GenerateTypeMap(IEnumerable<PropertyInfo> getProperties,
string path = "") string path = "")

View File

@ -130,12 +130,13 @@ namespace Artemis.Utilities
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.folder), thumbnailRect); c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.folder), thumbnailRect);
else if (_layerModel.LayerType == LayerType.Headset) else if (_layerModel.LayerType == LayerType.Headset)
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.headset), thumbnailRect); c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.headset), thumbnailRect);
else if(_layerModel.LayerType == LayerType.Mouse) else if (_layerModel.LayerType == LayerType.Mouse)
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.mouse), thumbnailRect); c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.mouse), thumbnailRect);
else if(_layerModel.LayerType == LayerType.KeyboardGif) else if (_layerModel.LayerType == LayerType.KeyboardGif)
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.gif), thumbnailRect); c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.gif), thumbnailRect);
else if(_layerModel.LayerType == LayerType.Keyboard && _layerModel.UserProps.Brush != null) else if (_layerModel.LayerType == LayerType.Keyboard && _layerModel.UserProps.Brush != null)
c.DrawRectangle(_layerModel.UserProps.Brush, new Pen(new SolidColorBrush(Colors.White), 1), thumbnailRect); c.DrawRectangle(_layerModel.UserProps.Brush, new Pen(new SolidColorBrush(Colors.White), 1),
thumbnailRect);
} }
var image = new DrawingImage(visual.Drawing); var image = new DrawingImage(visual.Drawing);

View File

@ -0,0 +1,8 @@
using Caliburn.Micro;
namespace Artemis.ViewModels.Abstract
{
public abstract class BaseViewModel : Conductor<IScreen>.Collection.OneActive
{
}
}

View File

@ -6,11 +6,18 @@ namespace Artemis.ViewModels.Abstract
{ {
public abstract class EffectViewModel : Screen public abstract class EffectViewModel : Screen
{ {
protected readonly EffectModel EffectModel;
private EffectSettings _effectSettings; private EffectSettings _effectSettings;
private bool _showDisabledPopup; private bool _showDisabledPopup;
protected EffectManager EffectManager;
protected MainManager MainManager;
public EffectModel EffectModel { get; set; } protected EffectViewModel(MainManager mainManager, EffectManager effectManager, EffectModel effectModel)
public MainManager MainManager { get; set; } {
MainManager = mainManager;
EffectManager = effectManager;
EffectModel = effectModel;
}
public EffectSettings EffectSettings public EffectSettings EffectSettings
{ {
@ -23,7 +30,7 @@ namespace Artemis.ViewModels.Abstract
} }
} }
public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel; public bool EffectEnabled => EffectManager.ActiveEffect == EffectModel;
public bool ShowDisabledPopup public bool ShowDisabledPopup
{ {
@ -46,9 +53,9 @@ namespace Artemis.ViewModels.Abstract
} }
if (EffectEnabled) if (EffectEnabled)
MainManager.EffectManager.ClearEffect(); EffectManager.ClearEffect();
else else
MainManager.EffectManager.ChangeEffect(EffectModel); EffectManager.ChangeEffect(EffectModel);
} }
public void SaveSettings() public void SaveSettings()
@ -58,7 +65,7 @@ namespace Artemis.ViewModels.Abstract
return; return;
// Restart the effect if it's currently running to apply settings. // Restart the effect if it's currently running to apply settings.
MainManager.EffectManager.ChangeEffect(EffectModel, true); EffectManager.ChangeEffect(EffectModel, true);
} }
public async void ResetSettings() public async void ResetSettings()

View File

@ -15,14 +15,16 @@ namespace Artemis.ViewModels.Abstract
private bool _editorShown; private bool _editorShown;
private GameSettings _gameSettings; private GameSettings _gameSettings;
private EffectModel _lastEffect; private EffectModel _lastEffect;
protected EffectManager EffectManager;
protected GameViewModel(MainManager mainManager, GameModel gameModel) protected GameViewModel(MainManager mainManager, EffectManager effectManager, GameModel gameModel)
{ {
MainManager = mainManager; MainManager = mainManager;
EffectManager = effectManager;
GameModel = gameModel; GameModel = gameModel;
GameSettings = gameModel.Settings; GameSettings = gameModel.Settings;
ProfileEditor = new ProfileEditorViewModel<T>(MainManager, GameModel); //ProfileEditor = new ProfileEditorViewModel<T>(MainManager, GameModel);
GameModel.Profile = ProfileEditor.SelectedProfile; GameModel.Profile = ProfileEditor.SelectedProfile;
ProfileEditor.PropertyChanged += ProfileUpdater; ProfileEditor.PropertyChanged += ProfileUpdater;
} }
@ -43,7 +45,7 @@ namespace Artemis.ViewModels.Abstract
} }
} }
public bool GameEnabled => MainManager.EffectManager.ActiveEffect == GameModel; public bool GameEnabled => EffectManager.ActiveEffect == GameModel;
public void ToggleEffect() public void ToggleEffect()
{ {
@ -57,12 +59,13 @@ namespace Artemis.ViewModels.Abstract
return; return;
// Restart the game if it's currently running to apply settings. // Restart the game if it's currently running to apply settings.
MainManager.EffectManager.ChangeEffect(GameModel, true); EffectManager.ChangeEffect(GameModel, true);
} }
public async void ResetSettings() public async void ResetSettings()
{ {
var resetConfirm = await var resetConfirm =
await
MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings", MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings",
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost."); "Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
@ -106,11 +109,11 @@ namespace Artemis.ViewModels.Abstract
if (enable) if (enable)
{ {
// Store the current effect so it can be restored later // Store the current effect so it can be restored later
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel)) if (!(EffectManager.ActiveEffect is ProfilePreviewModel))
_lastEffect = MainManager.EffectManager.ActiveEffect; _lastEffect = EffectManager.ActiveEffect;
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile; EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
MainManager.EffectManager.ChangeEffect(MainManager.EffectManager.ProfilePreviewModel); EffectManager.ChangeEffect(EffectManager.ProfilePreviewModel);
} }
else else
{ {
@ -120,12 +123,12 @@ namespace Artemis.ViewModels.Abstract
var gameModel = _lastEffect as GameModel; var gameModel = _lastEffect as GameModel;
if (gameModel != null) if (gameModel != null)
if (!gameModel.Enabled) if (!gameModel.Enabled)
MainManager.EffectManager.GetLastEffect(); EffectManager.GetLastEffect();
else else
MainManager.EffectManager.ChangeEffect(_lastEffect, true); EffectManager.ChangeEffect(_lastEffect, true);
} }
else else
MainManager.EffectManager.ClearEffect(); EffectManager.ClearEffect();
} }
_editorShown = enable; _editorShown = enable;
@ -137,7 +140,7 @@ namespace Artemis.ViewModels.Abstract
return; return;
GameModel.Profile = ProfileEditor.SelectedProfile; GameModel.Profile = ProfileEditor.SelectedProfile;
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile; EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
} }
} }

View File

@ -6,10 +6,17 @@ namespace Artemis.ViewModels.Abstract
{ {
public abstract class OverlayViewModel : Screen public abstract class OverlayViewModel : Screen
{ {
protected readonly EffectManager EffectManager;
protected readonly MainManager MainManager;
private OverlaySettings _overlaySettings; private OverlaySettings _overlaySettings;
protected OverlayViewModel(MainManager mainManager, EffectManager effectManager)
{
EffectManager = effectManager;
MainManager = mainManager;
}
public OverlayModel OverlayModel { get; set; } public OverlayModel OverlayModel { get; set; }
public MainManager MainManager { get; set; }
public OverlaySettings OverlaySettings public OverlaySettings OverlaySettings
{ {

View File

@ -1,38 +1,23 @@
using Artemis.Managers; using Artemis.ViewModels.Abstract;
using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeHole;
using Artemis.Modules.Effects.TypeWave;
using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive public sealed class EffectsViewModel : BaseViewModel
{ {
private readonly AudioVisualizerViewModel _audioVisualizerVm; private readonly EffectViewModel[] _effectViewModels;
private readonly DebugEffectViewModel _debugVm;
private readonly TypeHoleViewModel _typeHoleVm;
private readonly TypeWaveViewModel _typeWaveVm;
//private readonly AmbientLightningEffectViewModel _ambientLightningVm;
public EffectsViewModel(MainManager mainManager) public EffectsViewModel(EffectViewModel[] effectViewModels)
{ {
_typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"}; DisplayName = "Effects";
//_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"}; _effectViewModels = effectViewModels;
_audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"};
//_ambientLightningVm = new AmbientLightningEffectViewModel(mainManager) {DisplayName = "Ambient Lightning"};
_debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"};
} }
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();
ActivateItem(_typeWaveVm); foreach (var effectViewModel in _effectViewModels)
//ActivateItem(_typeHoleVm); ActivateItem(effectViewModel);
ActivateItem(_audioVisualizerVm);
//ActivateItem(_ambientLightningVm);
ActivateItem(_debugVm);
} }
} }
} }

View File

@ -10,18 +10,20 @@ namespace Artemis.ViewModels.Flyouts
{ {
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged> public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
{ {
private readonly KeyboardManager _keyboardManager;
private string _activeEffectName; private string _activeEffectName;
private GeneralSettings _generalSettings; private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider; private string _selectedKeyboardProvider;
public FlyoutSettingsViewModel(MainManager mainManager) public FlyoutSettingsViewModel(MainManager mainManager, KeyboardManager keyboardManager, IEventAggregator events)
{ {
_keyboardManager = keyboardManager;
MainManager = mainManager; MainManager = mainManager;
Header = "Settings"; Header = "Settings";
Position = Position.Right; Position = Position.Right;
GeneralSettings = new GeneralSettings(); GeneralSettings = new GeneralSettings();
MainManager.Events.Subscribe(this); events.Subscribe(this);
} }
public GeneralSettings GeneralSettings public GeneralSettings GeneralSettings
@ -41,8 +43,7 @@ namespace Artemis.ViewModels.Flyouts
{ {
get get
{ {
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders var collection = new BindableCollection<string>(_keyboardManager.KeyboardProviders.Select(k => k.Name));
.Select(k => k.Name));
collection.Insert(0, "None"); collection.Insert(0, "None");
return collection; return collection;
} }
@ -59,8 +60,8 @@ namespace Artemis.ViewModels.Flyouts
if (value == null) if (value == null)
return; return;
MainManager.KeyboardManager.ChangeKeyboard( _keyboardManager.ChangeKeyboard(
MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault( _keyboardManager.KeyboardProviders.FirstOrDefault(
k => k.Name == _selectedKeyboardProvider)); k => k.Name == _selectedKeyboardProvider));
} }
} }

View File

@ -1,39 +1,17 @@
using Artemis.Managers; using Artemis.ViewModels.Abstract;
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 Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class GamesViewModel : Conductor<IScreen>.Collection.OneActive public sealed class GamesViewModel : BaseViewModel
{ {
private readonly CounterStrikeViewModel _counterStrikeVm; public GamesViewModel()
private readonly TheDivisionViewModel _divisionVm;
private readonly Dota2ViewModel _dota2Vm;
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm;
public GamesViewModel(MainManager mainManager)
{ {
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"}; DisplayName = "Games";
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
_divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
} }
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();
ActivateItem(_rocketLeagueVm);
ActivateItem(_counterStrikeVm);
ActivateItem(_dota2Vm);
ActivateItem(_witcher3Vm);
ActivateItem(_divisionVm);
} }
} }
} }

View File

@ -17,13 +17,13 @@ namespace Artemis.ViewModels.LayerEditor
public class LayerEditorViewModel<T> : Screen public class LayerEditorViewModel<T> : Screen
{ {
private readonly KeyboardProvider _activeKeyboard; private readonly KeyboardProvider _activeKeyboard;
private readonly MetroDialogService _dialogService;
private readonly BackgroundWorker _previewWorker; private readonly BackgroundWorker _previewWorker;
private readonly bool _wasEnabled; private readonly bool _wasEnabled;
private LayerModel _layer; private LayerModel _layer;
private LayerType _layerType;
private LayerModel _proposedLayer; private LayerModel _proposedLayer;
private LayerPropertiesModel _proposedProperties; private LayerPropertiesModel _proposedProperties;
private LayerType _layerType;
private MetroDialogService _dialogService;
public LayerEditorViewModel(KeyboardProvider activeKeyboard, LayerModel layer) public LayerEditorViewModel(KeyboardProvider activeKeyboard, LayerModel layer)
{ {
@ -126,6 +126,17 @@ namespace Artemis.ViewModels.LayerEditor
} }
} }
public LayerType LayerType
{
get { return _layerType; }
set
{
if (value == _layerType) return;
_layerType = value;
NotifyOfPropertyChange(() => LayerType);
}
}
private void PreviewWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs) private void PreviewWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
{ {
while (!_previewWorker.CancellationPending) while (!_previewWorker.CancellationPending)
@ -141,17 +152,6 @@ namespace Artemis.ViewModels.LayerEditor
LayerType = Layer.LayerType; LayerType = Layer.LayerType;
} }
public LayerType LayerType
{
get { return _layerType; }
set
{
if (value == _layerType) return;
_layerType = value;
NotifyOfPropertyChange(() => LayerType);
}
}
private void GridDisplayHandler(object sender, PropertyChangedEventArgs e) private void GridDisplayHandler(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName != "LayerType") if (e.PropertyName != "LayerType")

View File

@ -1,29 +1,29 @@
using Artemis.Managers; using Artemis.Managers;
using Artemis.Modules.Overlays.VolumeDisplay; using Artemis.Modules.Overlays.VolumeDisplay;
using Caliburn.Micro; using Artemis.ViewModels.Abstract;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive public sealed class OverlaysViewModel : BaseViewModel
{ {
private readonly MainManager _mainManager; private readonly MainManager _mainManager;
private readonly OverlayViewModel[] _overlayViewModels;
private VolumeDisplayViewModel _volumeDisplayVm; private VolumeDisplayViewModel _volumeDisplayVm;
public OverlaysViewModel(MainManager mainManager) public OverlaysViewModel(MainManager mainManager, OverlayViewModel[] overlayViewModels)
{ {
DisplayName = "Overlays";
_mainManager = mainManager; _mainManager = mainManager;
_overlayViewModels = overlayViewModels;
} }
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();
Items.Clear(); foreach (var overlayViewModel in _overlayViewModels)
ActivateItem(overlayViewModel);
// This VM appears to be going out of scope, so recreating it every time just to be sure.
_volumeDisplayVm = new VolumeDisplayViewModel(_mainManager) {DisplayName = "Volume Display"};
ActivateItem(_volumeDisplayVm);
ActiveItem = _volumeDisplayVm;
} }
} }
} }

View File

@ -19,9 +19,10 @@ using MahApps.Metro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class ProfileEditorViewModel<T> : Screen, IHandle<ActiveKeyboardChanged> public sealed class ProfileEditorViewModel<T> : Screen, IHandle<ActiveKeyboardChanged>
{ {
private readonly GameModel _gameModel; private readonly GameModel _gameModel;
private readonly KeyboardManager _keyboardManager;
private readonly MainManager _mainManager; private readonly MainManager _mainManager;
private DateTime _downTime; private DateTime _downTime;
private LayerModel _draggingLayer; private LayerModel _draggingLayer;
@ -34,14 +35,16 @@ namespace Artemis.ViewModels
private LayerModel _selectedLayer; private LayerModel _selectedLayer;
private ProfileModel _selectedProfile; private ProfileModel _selectedProfile;
public ProfileEditorViewModel(MainManager mainManager, GameModel gameModel) public ProfileEditorViewModel(MainManager mainManager, KeyboardManager keyboardManager, GameModel gameModel,
IEventAggregator events)
{ {
_mainManager = mainManager; _mainManager = mainManager;
_keyboardManager = keyboardManager;
_gameModel = gameModel; _gameModel = gameModel;
Profiles = new BindableCollection<ProfileModel>(); Profiles = new BindableCollection<ProfileModel>();
Layers = new BindableCollection<LayerModel>(); Layers = new BindableCollection<LayerModel>();
_mainManager.Events.Subscribe(this); events.Subscribe(this);
PropertyChanged += PropertyChangeHandler; PropertyChanged += PropertyChangeHandler;
LoadProfiles(); LoadProfiles();
@ -177,7 +180,7 @@ namespace Artemis.ViewModels
public bool CanAddLayer => _selectedProfile != null; public bool CanAddLayer => _selectedProfile != null;
public bool CanRemoveLayer => _selectedProfile != null && _selectedLayer != null; public bool CanRemoveLayer => _selectedProfile != null && _selectedLayer != null;
private KeyboardProvider ActiveKeyboard => _mainManager.KeyboardManager.ActiveKeyboard; private KeyboardProvider ActiveKeyboard => _keyboardManager.ActiveKeyboard;
/// <summary> /// <summary>
/// Handles chaning the active keyboard, updating the preview image and profiles collection /// Handles chaning the active keyboard, updating the preview image and profiles collection

View File

@ -1,49 +1,36 @@
using System.Linq; using System.Linq;
using Artemis.Managers; using Artemis.ViewModels.Abstract;
using Artemis.Services;
using Artemis.ViewModels.Flyouts; using Artemis.ViewModels.Flyouts;
using Caliburn.Micro; using Caliburn.Micro;
using Ninject;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
{ {
private readonly EffectsViewModel _effectsVm; private readonly BaseViewModel[] _viewModels;
private readonly GamesViewModel _gamesVm;
private readonly OverlaysViewModel _overlaysVm;
private readonly WelcomeViewModel _welcomeVm;
public ShellViewModel() public ShellViewModel(BaseViewModel[] viewModels, IKernel kernel)
{ {
var dialogService = new MetroDialogService(this); _viewModels = viewModels;
IEventAggregator events = new EventAggregator();
MainManager = new MainManager(events, dialogService); // Setup UI
DisplayName = "Artemis"; DisplayName = "Artemis";
Flyouts = new BindableCollection<FlyoutBaseViewModel>
_welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"}; {
_effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"}; kernel.Get<FlyoutSettingsViewModel>()
_gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"}; };
_overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel(MainManager));
} }
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } = public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; }
new BindableCollection<FlyoutBaseViewModel>();
public MainManager MainManager { get; set; }
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();
foreach (var screen in _viewModels)
ActivateItem(screen);
ActivateItem(_welcomeVm); ActiveItem = _viewModels.FirstOrDefault();
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
ActiveItem = _welcomeVm;
} }
public void Settings() public void Settings()

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Windows; using System.Windows;
using Artemis.Events; using Artemis.Events;
using Artemis.Managers;
using Artemis.Settings; using Artemis.Settings;
using Artemis.Utilities; using Artemis.Utilities;
using Caliburn.Micro; using Caliburn.Micro;
@ -10,25 +11,30 @@ namespace Artemis.ViewModels
public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled> public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled>
{ {
private readonly ShellViewModel _shellViewModel; private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager; private readonly IWindowManager _windowManager;
private string _activeIcon; private string _activeIcon;
private bool _checkedForUpdate; private bool _checkedForUpdate;
private bool _enabled; private bool _enabled;
private string _toggleText; private string _toggleText;
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel) public SystemTrayViewModel(IWindowManager windowManager, IEventAggregator events, ShellViewModel shellViewModel,
MainManager mainManager)
{ {
_windowManager = windowManager; _windowManager = windowManager;
_shellViewModel = shellViewModel; _shellViewModel = shellViewModel;
_shellViewModel.MainManager.Events.Subscribe(this);
_shellViewModel.MainManager.EnableProgram();
_checkedForUpdate = false; _checkedForUpdate = false;
MainManager = mainManager;
events.Subscribe(this);
MainManager.EnableProgram();
if (General.Default.ShowOnStartup) if (General.Default.ShowOnStartup)
ShowWindow(); ShowWindow();
} }
public MainManager MainManager { get; set; }
public bool CanShowWindow => !_shellViewModel.IsActive; public bool CanShowWindow => !_shellViewModel.IsActive;
public bool CanHideWindow => _shellViewModel.IsActive; public bool CanHideWindow => _shellViewModel.IsActive;
@ -76,9 +82,9 @@ namespace Artemis.ViewModels
public void ToggleEnabled() public void ToggleEnabled()
{ {
if (Enabled) if (Enabled)
_shellViewModel.MainManager.DisableProgram(); MainManager.DisableProgram();
else else
_shellViewModel.MainManager.EnableProgram(); MainManager.EnableProgram();
} }
protected override void OnActivate() protected override void OnActivate()
@ -104,7 +110,7 @@ namespace Artemis.ViewModels
return; return;
_checkedForUpdate = true; _checkedForUpdate = true;
Updater.CheckForUpdate(_shellViewModel.MainManager.DialogService); Updater.CheckForUpdate(MainManager.DialogService);
} }
@ -121,7 +127,7 @@ namespace Artemis.ViewModels
public void ExitApplication() public void ExitApplication()
{ {
_shellViewModel.MainManager.Shutdown(); MainManager.Shutdown();
Application.Current.Shutdown(); Application.Current.Shutdown();
// Sometimes you need to be rough. // Sometimes you need to be rough.

View File

@ -3,8 +3,13 @@ using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class WelcomeViewModel : Screen public sealed class WelcomeViewModel : Screen
{ {
public WelcomeViewModel()
{
DisplayName = "Welcome";
}
public void NavigateTo(string url) public void NavigateTo(string url)
{ {
Process.Start(new ProcessStartInfo(url)); Process.Start(new ProcessStartInfo(url));

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" /> <package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" /> <package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />