mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Moving to Ninject dependency injection WIP
This commit is contained in:
parent
68efa4885e
commit
b01ab9b135
@ -2,21 +2,50 @@
|
||||
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<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" />
|
||||
<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.Overlays.VolumeDisplay.VolumeDisplay" 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" 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 name="userSettings"
|
||||
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<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" />
|
||||
<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.Overlays.VolumeDisplay.VolumeDisplay"
|
||||
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"
|
||||
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>
|
||||
</configSections>
|
||||
<connectionStrings />
|
||||
|
||||
@ -308,7 +308,6 @@
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
|
||||
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
|
||||
<Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
||||
<DependentUpon>TypeWave.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -372,6 +371,7 @@
|
||||
<Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" />
|
||||
<Compile Include="NinjectModules\ArtemisModules.cs" />
|
||||
<Compile Include="NinjectModules\BaseModules.cs" />
|
||||
<Compile Include="NinjectModules\ManagerModules.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
@ -416,13 +416,13 @@
|
||||
<Compile Include="Utilities\StickyValue.cs" />
|
||||
<Compile Include="Utilities\Updater.cs" />
|
||||
<Compile Include="Utilities\ValueConverters.cs" />
|
||||
<Compile Include="ViewModels\Abstract\BaseViewModel.cs" />
|
||||
<Compile Include="ViewModels\Abstract\OverlayViewModel.cs" />
|
||||
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
|
||||
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
|
||||
<Compile Include="ViewModels\EffectsViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
|
||||
<Compile Include="ViewModels\FlyoutBaseViewModel.cs" />
|
||||
<Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" />
|
||||
@ -452,9 +452,6 @@
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml.cs">
|
||||
<DependentUpon>AudioVisualizerView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleView.xaml.cs">
|
||||
<DependentUpon>TypeHoleView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
|
||||
<DependentUpon>TypeWaveView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -621,10 +618,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Modules\Effects\TypeHole\TypeHoleView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Modules\Effects\TypeWave\TypeWaveView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@ -6,6 +6,7 @@ using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.NinjectModules;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
@ -72,7 +73,7 @@ namespace Artemis
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
_kernel = new StandardKernel();
|
||||
_kernel = new StandardKernel(new BaseModules(), new ArtemisModules(), new ManagerModules());
|
||||
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
|
||||
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Artemis.DAL
|
||||
if (!Directory.Exists(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"))
|
||||
{
|
||||
serializer.Serialize(file, prof);
|
||||
@ -64,7 +64,7 @@ namespace Artemis.DAL
|
||||
|
||||
// Parse the JSON files into objects and add them if they are valid
|
||||
// TODO: Invalid file handling
|
||||
var deserializer = new XmlSerializer(typeof (ProfileModel));
|
||||
var deserializer = new XmlSerializer(typeof(ProfileModel));
|
||||
foreach (var path in profilePaths)
|
||||
{
|
||||
using (var file = new StreamReader(path))
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Artemis.ItemBehaviours
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@ -7,6 +7,7 @@ using Artemis.Models;
|
||||
using Artemis.Modules.Effects.ProfilePreview;
|
||||
using Artemis.Settings;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using LogManager = NLog.LogManager;
|
||||
|
||||
@ -16,21 +17,22 @@ namespace Artemis.Managers
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IEventAggregator _events;
|
||||
private readonly MainManager _mainManager;
|
||||
private EffectModel _activeEffect;
|
||||
private bool _clearing;
|
||||
|
||||
public EffectManager(MainManager mainManager, IEventAggregator events)
|
||||
public EffectManager(IEventAggregator events)
|
||||
{
|
||||
Logger.Info("Intializing EffectManager");
|
||||
_mainManager = mainManager;
|
||||
_events = events;
|
||||
|
||||
EffectModels = new List<EffectModel>();
|
||||
ProfilePreviewModel = new ProfilePreviewModel(_mainManager);
|
||||
//ProfilePreviewModel = new ProfilePreviewModel(MainManager.Value);
|
||||
Logger.Info("Intialized EffectManager");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public Lazy<MainManager> MainManager { get; set; }
|
||||
|
||||
public EffectModel PauseEffect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -107,14 +109,14 @@ namespace Artemis.Managers
|
||||
|
||||
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 (_mainManager.Running)
|
||||
if (MainManager.Value.Running)
|
||||
{
|
||||
ChangeEffectWithPause(effectModel);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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)
|
||||
@ -137,13 +139,13 @@ namespace Artemis.Managers
|
||||
Logger.Debug("Changing effect with pause: {0}", effectModel?.Name);
|
||||
|
||||
PauseEffect = effectModel;
|
||||
_mainManager.Pause();
|
||||
_mainManager.PauseCallback += ChangeEffectPauseCallback;
|
||||
MainManager.Value.Pause();
|
||||
MainManager.Value.PauseCallback += ChangeEffectPauseCallback;
|
||||
}
|
||||
|
||||
private void ChangeEffectPauseCallback()
|
||||
{
|
||||
_mainManager.PauseCallback -= ChangeEffectPauseCallback;
|
||||
MainManager.Value.PauseCallback -= ChangeEffectPauseCallback;
|
||||
|
||||
// Change effect logic
|
||||
ActiveEffect?.Dispose();
|
||||
@ -151,7 +153,7 @@ namespace Artemis.Managers
|
||||
ActiveEffect = PauseEffect;
|
||||
ActiveEffect?.Enable();
|
||||
|
||||
_mainManager.Unpause();
|
||||
MainManager.Value.Unpause();
|
||||
PauseEffect = null;
|
||||
|
||||
Logger.Debug("Finishing change effect with pause");
|
||||
@ -180,13 +182,13 @@ namespace Artemis.Managers
|
||||
|
||||
_clearing = true;
|
||||
Logger.Debug("Clearing active effect");
|
||||
_mainManager.Pause();
|
||||
_mainManager.PauseCallback += ClearEffectPauseCallback;
|
||||
MainManager.Value.Pause();
|
||||
MainManager.Value.PauseCallback += ClearEffectPauseCallback;
|
||||
}
|
||||
|
||||
private void ClearEffectPauseCallback()
|
||||
{
|
||||
_mainManager.PauseCallback -= ClearEffectPauseCallback;
|
||||
MainManager.Value.PauseCallback -= ClearEffectPauseCallback;
|
||||
if (PauseEffect != null)
|
||||
{
|
||||
Logger.Debug("Cancelling clearing effect");
|
||||
@ -202,7 +204,7 @@ namespace Artemis.Managers
|
||||
_clearing = false;
|
||||
|
||||
Logger.Debug("Finishing clearing active effect");
|
||||
_mainManager.Unpause();
|
||||
MainManager.Value.Unpause();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Events;
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.Settings;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using LogManager = NLog.LogManager;
|
||||
|
||||
@ -13,18 +15,21 @@ namespace Artemis.Managers
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IEventAggregator _events;
|
||||
private readonly MainManager _mainManager;
|
||||
private KeyboardProvider _activeKeyboard;
|
||||
|
||||
public KeyboardManager(MainManager mainManager, IEventAggregator events)
|
||||
public KeyboardManager(IEventAggregator events)
|
||||
{
|
||||
Logger.Info("Intializing KeyboardManager");
|
||||
_mainManager = mainManager;
|
||||
|
||||
_events = events;
|
||||
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
|
||||
|
||||
Logger.Info("Intialized KeyboardManager");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public Lazy<MainManager> MainManager { get; set; }
|
||||
|
||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||
|
||||
public KeyboardProvider ActiveKeyboard
|
||||
@ -74,7 +79,7 @@ namespace Artemis.Managers
|
||||
// Disable everything if there's no active keyboard found
|
||||
if (!keyboardProvider.CanEnable())
|
||||
{
|
||||
_mainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
||||
MainManager.Value.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
||||
General.Default.LastKeyboard = null;
|
||||
General.Default.Save();
|
||||
return;
|
||||
@ -116,7 +121,7 @@ namespace Artemis.Managers
|
||||
General.Default.Save();
|
||||
|
||||
Logger.Debug("Restarting for keyboard change");
|
||||
_mainManager.Restart();
|
||||
MainManager.Value.Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -8,7 +9,9 @@ using Artemis.Services;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using Artemis.Utilities.LogitechDll;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using LogManager = NLog.LogManager;
|
||||
|
||||
@ -19,23 +22,26 @@ namespace Artemis.Managers
|
||||
public delegate void PauseCallbackHandler();
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly EffectManager _effectManager;
|
||||
private readonly IEventAggregator _events;
|
||||
|
||||
private readonly int _fps;
|
||||
private readonly KeyboardManager _keyboardManager;
|
||||
private bool _paused;
|
||||
private bool _restarting;
|
||||
|
||||
public MainManager(IEventAggregator events, MetroDialogService dialogService)
|
||||
public MainManager(IEventAggregator events, KeyboardManager keyboardManager, EffectManager effectManager)
|
||||
{
|
||||
Logger.Info("Intializing MainManager");
|
||||
|
||||
Events = events;
|
||||
DialogService = dialogService;
|
||||
_events = events;
|
||||
_keyboardManager = keyboardManager;
|
||||
_effectManager = effectManager;
|
||||
_fps = 25;
|
||||
|
||||
KeyboardManager = new KeyboardManager(this, Events);
|
||||
EffectManager = new EffectManager(this, Events);
|
||||
//DialogService = dialogService;
|
||||
KeyboardHook = new KeyboardHook();
|
||||
|
||||
_fps = 25;
|
||||
UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||
ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||
|
||||
@ -62,18 +68,18 @@ namespace Artemis.Managers
|
||||
Logger.Info("Intialized MainManager");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
||||
|
||||
public PipeServer PipeServer { get; set; }
|
||||
public BackgroundWorker UpdateWorker { get; set; }
|
||||
public BackgroundWorker ProcessWorker { get; set; }
|
||||
|
||||
public KeyboardManager KeyboardManager { get; set; }
|
||||
public EffectManager EffectManager { get; set; }
|
||||
public MetroDialogService DialogService { get; set; }
|
||||
|
||||
public KeyboardHook KeyboardHook { 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 Suspended { get; set; }
|
||||
@ -98,13 +104,13 @@ namespace Artemis.Managers
|
||||
return true;
|
||||
|
||||
// Only continue if a keyboard was loaded
|
||||
KeyboardManager.EnableLastKeyboard();
|
||||
if (KeyboardManager.ActiveKeyboard == null)
|
||||
_keyboardManager.EnableLastKeyboard();
|
||||
if (_keyboardManager.ActiveKeyboard == null)
|
||||
return false;
|
||||
|
||||
Running = true;
|
||||
if (effect != null)
|
||||
EffectManager.ChangeEffect(effect);
|
||||
_effectManager.ChangeEffect(effect);
|
||||
|
||||
// Start the update worker
|
||||
if (!UpdateWorker.IsBusy)
|
||||
@ -130,7 +136,7 @@ namespace Artemis.Managers
|
||||
private void FinishStop(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
UpdateWorker.RunWorkerCompleted -= FinishStop;
|
||||
KeyboardManager.ReleaseActiveKeyboard();
|
||||
_keyboardManager.ReleaseActiveKeyboard();
|
||||
Running = false;
|
||||
|
||||
Logger.Debug("Stopped MainManager");
|
||||
@ -192,8 +198,8 @@ namespace Artemis.Managers
|
||||
{
|
||||
Logger.Debug("Enabling program");
|
||||
ProgramEnabled = true;
|
||||
Start(EffectManager.GetLastEffect());
|
||||
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||
Start(_effectManager.GetLastEffect());
|
||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -204,7 +210,7 @@ namespace Artemis.Managers
|
||||
Logger.Debug("Disabling program");
|
||||
Stop();
|
||||
ProgramEnabled = false;
|
||||
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||
}
|
||||
|
||||
#region Workers
|
||||
@ -223,12 +229,12 @@ namespace Artemis.Managers
|
||||
}
|
||||
|
||||
// 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);
|
||||
Logger.Debug("No active effect/keyboard, stopping");
|
||||
|
||||
if (EffectManager.PauseEffect != null)
|
||||
if (_effectManager.PauseEffect != null)
|
||||
{
|
||||
PauseCallback?.Invoke();
|
||||
Thread.Sleep(1000/_fps);
|
||||
@ -239,7 +245,7 @@ namespace Artemis.Managers
|
||||
}
|
||||
|
||||
// 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);
|
||||
continue;
|
||||
@ -248,28 +254,28 @@ namespace Artemis.Managers
|
||||
sw.Start();
|
||||
|
||||
// Update the current effect
|
||||
if (EffectManager.ActiveEffect.Initialized)
|
||||
EffectManager.ActiveEffect.Update();
|
||||
if (_effectManager.ActiveEffect.Initialized)
|
||||
_effectManager.ActiveEffect.Update();
|
||||
|
||||
// Get ActiveEffect's bitmap
|
||||
var bitmap = EffectManager.ActiveEffect.Initialized
|
||||
? EffectManager.ActiveEffect.GenerateBitmap()
|
||||
var bitmap = _effectManager.ActiveEffect.Initialized
|
||||
? _effectManager.ActiveEffect.GenerateBitmap()
|
||||
: null;
|
||||
|
||||
// Draw enabled overlays on top
|
||||
foreach (var overlayModel in EffectManager.EnabledOverlays)
|
||||
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
||||
{
|
||||
overlayModel.Update();
|
||||
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
|
||||
}
|
||||
|
||||
// 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
|
||||
Events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
||||
_events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
||||
}
|
||||
|
||||
// Sleep according to time left this frame
|
||||
@ -302,23 +308,23 @@ namespace Artemis.Managers
|
||||
var runningProcesses = Process.GetProcesses();
|
||||
|
||||
// If the currently active effect is a disabled game, get rid of it.
|
||||
if (EffectManager.ActiveEffect != null)
|
||||
EffectManager.DisableInactiveGame();
|
||||
if (_effectManager.ActiveEffect != null)
|
||||
_effectManager.DisableInactiveGame();
|
||||
|
||||
// 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 (!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.
|
||||
var newGame = EffectManager.EnabledGames
|
||||
var newGame = _effectManager.EnabledGames
|
||||
.FirstOrDefault(
|
||||
g => runningProcesses.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
|
||||
|
||||
// If it's not already enabled, do so.
|
||||
if (newGame != null && EffectManager.ActiveEffect != newGame)
|
||||
EffectManager.ChangeEffect(newGame);
|
||||
if (newGame != null && _effectManager.ActiveEffect != newGame)
|
||||
_effectManager.ChangeEffect(newGame);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
@ -10,12 +10,15 @@ namespace Artemis.Models
|
||||
|
||||
public bool Initialized;
|
||||
|
||||
protected KeyboardManager KeyboardManager;
|
||||
|
||||
public MainManager MainManager;
|
||||
public string Name;
|
||||
|
||||
protected EffectModel(MainManager mainManager)
|
||||
protected EffectModel(MainManager mainManager, KeyboardManager keyboardManager)
|
||||
{
|
||||
MainManager = mainManager;
|
||||
KeyboardManager = keyboardManager;
|
||||
}
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
@ -6,7 +6,8 @@ namespace Artemis.Models
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -8,7 +8,8 @@ namespace Artemis.Models
|
||||
private bool _enabled;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -47,8 +47,8 @@ namespace Artemis.Models.Profiles
|
||||
if (layerProp == null || userProp == null)
|
||||
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
|
||||
if (LayerProperty == "Opacity")
|
||||
{
|
||||
|
||||
@ -5,10 +5,10 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace Artemis.Models.Profiles
|
||||
{
|
||||
[XmlInclude(typeof (SolidColorBrush))]
|
||||
[XmlInclude(typeof (LinearGradientBrush))]
|
||||
[XmlInclude(typeof (RadialGradientBrush))]
|
||||
[XmlInclude(typeof (MatrixTransform))]
|
||||
[XmlInclude(typeof(SolidColorBrush))]
|
||||
[XmlInclude(typeof(LinearGradientBrush))]
|
||||
[XmlInclude(typeof(RadialGradientBrush))]
|
||||
[XmlInclude(typeof(MatrixTransform))]
|
||||
public class LayerPropertiesModel
|
||||
{
|
||||
public int X { get; set; }
|
||||
|
||||
@ -20,8 +20,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
||||
private ScreenCapture _screenCapturer;
|
||||
private KeyboardRectangle _topRect;
|
||||
|
||||
public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings)
|
||||
: base(mainManager)
|
||||
public AmbientLightningEffectModel(MainManager mainManager, KeyboardManager keyboardManager,
|
||||
AmbientLightningEffectSettings settings) : base(mainManager, keyboardManager)
|
||||
{
|
||||
Name = "Ambient Lightning";
|
||||
Settings = settings;
|
||||
@ -49,9 +49,9 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
||||
|
||||
_colors = new List<Color>();
|
||||
_screenCapturer = new ScreenCapture();
|
||||
_topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
||||
_botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
_topRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
LinearGradientMode.Horizontal) {Height = KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
||||
_botRect = new KeyboardRectangle(KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
LinearGradientMode.Horizontal);
|
||||
|
||||
Initialized = true;
|
||||
@ -102,8 +102,8 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
||||
}
|
||||
|
||||
// Put the resulting colors in 6 rectangles, their size differs per keyboard
|
||||
var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
||||
var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
||||
var rectWidth = KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
||||
var rectHeight = KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
||||
for (var row = 0; row < 2; row++)
|
||||
{
|
||||
for (var column = 0; column < 3; column++)
|
||||
@ -116,7 +116,7 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
@ -5,25 +5,20 @@ using Caliburn.Micro;
|
||||
|
||||
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
|
||||
MainManager = mainManager;
|
||||
MainManager.Events.Subscribe(this);
|
||||
DisplayName = "Ambient Lightning";
|
||||
|
||||
// Settings are loaded from file by class
|
||||
EffectSettings = new AmbientLightningEffectSettings();
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
EffectModel = new AmbientLightningEffectModel(mainManager, (AmbientLightningEffectSettings) EffectSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
events.Subscribe(this);
|
||||
EffectManager.EffectModels.Add(EffectModel);
|
||||
}
|
||||
|
||||
|
||||
public static string Name => "Ambient Lightning";
|
||||
|
||||
public void Handle(ActiveEffectChanged message)
|
||||
{
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
|
||||
@ -18,10 +18,10 @@ namespace Artemis.Modules.Effects.AmbientLightning
|
||||
internal class ScreenCapture : IDisposable
|
||||
{
|
||||
private readonly Device _device;
|
||||
private readonly OutputDuplication _duplicatedOutput;
|
||||
private readonly Factory1 _factory;
|
||||
private readonly Texture2D _screenTexture;
|
||||
private DataStream _dataStream;
|
||||
private readonly OutputDuplication _duplicatedOutput;
|
||||
private Resource _screenResource;
|
||||
private Surface _screenSurface;
|
||||
|
||||
|
||||
@ -22,7 +22,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
private int _sensitivity;
|
||||
private IWaveIn _waveIn;
|
||||
|
||||
public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager)
|
||||
public AudioVisualizerModel(MainManager mainManager, KeyboardManager keyboardManager,
|
||||
AudioVisualizerSettings settings) : base(mainManager, keyboardManager)
|
||||
{
|
||||
Settings = settings;
|
||||
Name = "Audiovisualizer";
|
||||
@ -57,7 +58,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
public override void Enable()
|
||||
{
|
||||
Initialized = false;
|
||||
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width;
|
||||
Lines = KeyboardManager.ActiveKeyboard.Width;
|
||||
|
||||
// TODO: Device selection
|
||||
SelectedDeviceId = new MMDeviceEnumerator()
|
||||
@ -69,7 +70,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
for (var i = 0; i < Lines; i++)
|
||||
{
|
||||
SoundRectangles.Add(new KeyboardRectangle(
|
||||
MainManager.KeyboardManager.ActiveKeyboard,
|
||||
KeyboardManager.ActiveKeyboard,
|
||||
0, 0, new List<Color>
|
||||
{
|
||||
ColorHelpers.ToDrawingColor(Settings.TopColor),
|
||||
@ -121,7 +122,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
// Apply Sensitivity setting
|
||||
height = height*_sensitivity;
|
||||
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)
|
||||
SoundRectangles[i].Height = keyboardHeight;
|
||||
else
|
||||
@ -131,7 +132,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
SoundRectangles[i].Width = Scale;
|
||||
|
||||
if (_fromBottom)
|
||||
SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale -
|
||||
SoundRectangles[i].Y = KeyboardManager.ActiveKeyboard.Height*Scale -
|
||||
SoundRectangles[i].Height;
|
||||
}
|
||||
_generating = false;
|
||||
@ -145,7 +146,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
// Lock the _spectrumData array while busy with it
|
||||
_generating = true;
|
||||
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
foreach (var soundRectangle in SoundRectangles)
|
||||
|
||||
@ -5,24 +5,20 @@ using Caliburn.Micro;
|
||||
|
||||
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
|
||||
MainManager = mainManager;
|
||||
MainManager.Events.Subscribe(this);
|
||||
DisplayName = "Audio Visualization";
|
||||
|
||||
// Settings are loaded from file by class
|
||||
EffectSettings = new AudioVisualizerSettings();
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
events.Subscribe(this);
|
||||
EffectManager.EffectModels.Add(EffectModel);
|
||||
}
|
||||
|
||||
public static string Name => "Audio Visualizer";
|
||||
|
||||
public void Handle(ActiveEffectChanged message)
|
||||
{
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
|
||||
@ -10,7 +10,8 @@ namespace Artemis.Modules.Effects.Debug
|
||||
// TODO: Remove
|
||||
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";
|
||||
Settings = settings;
|
||||
@ -33,7 +34,7 @@ namespace Artemis.Modules.Effects.Debug
|
||||
{
|
||||
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.OrangeRed,
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Utilities;
|
||||
@ -12,30 +9,25 @@ using Caliburn.Micro;
|
||||
|
||||
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 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
|
||||
MainManager = mainManager;
|
||||
MainManager.Events.Subscribe(this);
|
||||
DisplayName = "Debug Effect";
|
||||
|
||||
// Settings are loaded from file by class
|
||||
EffectSettings = new DebugEffectSettings();
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
events.Subscribe(this);
|
||||
EffectManager.EffectModels.Add(EffectModel);
|
||||
}
|
||||
|
||||
|
||||
public static string Name => "Debug Effect";
|
||||
|
||||
public BindableCollection<string> RectangleTypes
|
||||
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode)));
|
||||
=> new BindableCollection<string>(Enum.GetNames(typeof(LinearGradientMode)));
|
||||
|
||||
public string SelectedRectangleType
|
||||
{
|
||||
@ -47,7 +39,7 @@ namespace Artemis.Modules.Effects.Debug
|
||||
NotifyOfPropertyChange(() => SelectedRectangleType);
|
||||
|
||||
((DebugEffectSettings) EffectSettings).Type =
|
||||
(LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value);
|
||||
(LinearGradientMode) Enum.Parse(typeof(LinearGradientMode), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
||||
{
|
||||
private readonly ProfilePreviewDataModel _previewDataModel;
|
||||
|
||||
public ProfilePreviewModel(MainManager mainManager) : base(mainManager)
|
||||
public ProfilePreviewModel(MainManager mainManager, KeyboardManager keyboardManager)
|
||||
: base(mainManager, keyboardManager)
|
||||
{
|
||||
Name = "Profile Preview";
|
||||
_previewDataModel = new ProfilePreviewDataModel();
|
||||
@ -40,12 +41,12 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
|
||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(4);
|
||||
|
||||
if (SelectedProfile == null)
|
||||
return bitmap;
|
||||
|
||||
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||
var image = SelectedProfile.GenerateBitmap<ProfilePreviewDataModel>(keyboardRect, _previewDataModel, true);
|
||||
|
||||
// Draw on top of everything else
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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>
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,8 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
private readonly List<Wave> _waves;
|
||||
private Color _randomColor;
|
||||
|
||||
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager)
|
||||
public TypeWaveModel(MainManager mainManager, KeyboardManager keyboardManager, TypeWaveSettings settings)
|
||||
: base(mainManager, keyboardManager)
|
||||
{
|
||||
Name = "TypeWave";
|
||||
_waves = new List<Wave>();
|
||||
@ -96,7 +97,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
if (_waves.Count == 0)
|
||||
return null;
|
||||
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
@ -113,7 +114,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
_waves[i].Size, _waves[i].Size);
|
||||
|
||||
Color fillColor;
|
||||
if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB)
|
||||
if (KeyboardManager.ActiveKeyboard is CorsairRGB)
|
||||
fillColor = Color.Black;
|
||||
else
|
||||
fillColor = Color.Transparent;
|
||||
|
||||
@ -5,24 +5,18 @@ using Caliburn.Micro;
|
||||
|
||||
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
|
||||
MainManager = mainManager;
|
||||
MainManager.Events.Subscribe(this);
|
||||
DisplayName = "Type Waves";
|
||||
|
||||
// Settings are loaded from file by class
|
||||
EffectSettings = new TypeWaveSettings();
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
events.Subscribe(this);
|
||||
EffectManager.EffectModels.Add(EffectModel);
|
||||
}
|
||||
|
||||
public static string Name => "Type Waves";
|
||||
|
||||
public void Handle(ActiveEffectChanged message)
|
||||
{
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
|
||||
@ -8,7 +8,8 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
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";
|
||||
ProcessName = "csgo";
|
||||
@ -49,7 +50,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
if (Profile == null || GameDataModel == null)
|
||||
return null;
|
||||
|
||||
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||
return Profile.GenerateBitmap<CounterStrikeDataModel>(keyboardRect, GameDataModel);
|
||||
}
|
||||
|
||||
|
||||
@ -6,19 +6,21 @@ using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
|
||||
public sealed class CounterStrikeViewModel : GameViewModel<CounterStrikeDataModel>
|
||||
{
|
||||
public CounterStrikeViewModel(MainManager mainManager)
|
||||
: base(mainManager, new CounterStrikeModel(mainManager, new CounterStrikeSettings()))
|
||||
public CounterStrikeViewModel(MainManager mainManager, EffectManager effectManager,
|
||||
KeyboardManager keyboardManager)
|
||||
: base(
|
||||
mainManager, effectManager,
|
||||
new CounterStrikeModel(mainManager, new CounterStrikeSettings(), keyboardManager))
|
||||
{
|
||||
DisplayName = "CS:GO";
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
EffectManager.EffectModels.Add(GameModel);
|
||||
PlaceConfigFile();
|
||||
}
|
||||
|
||||
public static string Name => "CS:GO";
|
||||
public string Content => "Counter-Strike: GO Content";
|
||||
|
||||
public void BrowseDirectory()
|
||||
{
|
||||
var dialog = new FolderBrowserDialog {SelectedPath = ((CounterStrikeSettings) GameSettings).GameDirectory};
|
||||
|
||||
@ -15,12 +15,15 @@ namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
internal class Dota2Model : GameModel
|
||||
{
|
||||
private readonly KeyboardManager _keyboardManager;
|
||||
private KeyboardRegion _abilityKeys;
|
||||
private KeyboardRegion _keyPad;
|
||||
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";
|
||||
ProcessName = "dota2";
|
||||
Settings = settings;
|
||||
@ -40,35 +43,35 @@ namespace Artemis.Modules.Games.Dota2
|
||||
public override void Enable()
|
||||
{
|
||||
Initialized = false;
|
||||
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
|
||||
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
|
||||
_abilityKeys = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
|
||||
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||
_topRow = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
|
||||
_keyPad = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
|
||||
_abilityKeys = _keyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "QWER");
|
||||
HealthRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
||||
, 0
|
||||
, _topRow.BottomRight.Y*Scale
|
||||
, new List<Color>()
|
||||
, LinearGradientMode.Horizontal)
|
||||
{Height = Scale, ContainedBrush = false};
|
||||
|
||||
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||
ManaRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
||||
, 0
|
||||
, (_topRow.BottomRight.Y + 1)*Scale
|
||||
, new List<Color>()
|
||||
, LinearGradientMode.Horizontal)
|
||||
{Height = Scale, ContainedBrush = false};
|
||||
|
||||
EventRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||
EventRectangle = new KeyboardRectangle(_keyboardManager.ActiveKeyboard
|
||||
, 0
|
||||
, _topRow.TopLeft.X + 3
|
||||
, new List<Color>()
|
||||
, 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.Y*Scale
|
||||
, new List<Color>()
|
||||
@ -96,7 +99,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
case "3": //League of Legends
|
||||
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.Y*Scale,
|
||||
new List<Color>(),
|
||||
@ -108,7 +111,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
AbilityKeysRectangles[0] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||
AbilityKeysRectangles[0] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
||||
_abilityKeys.TopLeft.X*Scale - 2,
|
||||
_abilityKeys.TopLeft.Y*Scale,
|
||||
new List<Color>(),
|
||||
@ -117,7 +120,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
Height = Scale,
|
||||
Width = Scale
|
||||
};
|
||||
AbilityKeysRectangles[1] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||
AbilityKeysRectangles[1] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
||||
(_abilityKeys.TopLeft.X + 2)*Scale - 2,
|
||||
_abilityKeys.TopLeft.Y*Scale,
|
||||
new List<Color>(),
|
||||
@ -126,7 +129,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
Height = Scale,
|
||||
Width = Scale
|
||||
};
|
||||
AbilityKeysRectangles[2] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||
AbilityKeysRectangles[2] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
||||
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
||||
_abilityKeys.TopLeft.Y*Scale,
|
||||
new List<Color>(),
|
||||
@ -135,7 +138,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
Height = Scale,
|
||||
Width = Scale
|
||||
};
|
||||
AbilityKeysRectangles[3] = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard,
|
||||
AbilityKeysRectangles[3] = new KeyboardRectangle(_keyboardManager.ActiveKeyboard,
|
||||
(_abilityKeys.TopLeft.X + 3)*Scale - 2,
|
||||
(_abilityKeys.TopLeft.Y + 1)*Scale,
|
||||
new List<Color>(),
|
||||
@ -149,7 +152,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
case "5": //Smite
|
||||
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.Y - 1)*Scale,
|
||||
new List<Color>(),
|
||||
@ -294,7 +297,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
|
||||
@ -7,12 +7,14 @@ using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
public class Dota2ViewModel : GameViewModel<Dota2DataModel>
|
||||
public sealed class Dota2ViewModel : GameViewModel<Dota2DataModel>
|
||||
{
|
||||
public Dota2ViewModel(MainManager mainManager)
|
||||
: base(mainManager, new Dota2Model(mainManager, new Dota2Settings()))
|
||||
public Dota2ViewModel(MainManager mainManager, EffectManager effectManager, KeyboardManager keyboardManager)
|
||||
: base(mainManager, effectManager, new Dota2Model(mainManager, keyboardManager, new Dota2Settings()))
|
||||
{
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
DisplayName = "Dota 2";
|
||||
|
||||
EffectManager.EffectModels.Add(GameModel);
|
||||
PlaceConfigFile();
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,8 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
private Memory _memory;
|
||||
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";
|
||||
ProcessName = "RocketLeague";
|
||||
@ -72,7 +73,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
if (Profile == null || GameDataModel == null)
|
||||
return null;
|
||||
|
||||
var keyboardRect = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||
var keyboardRect = KeyboardManager.ActiveKeyboard.KeyboardRectangle(Scale);
|
||||
return Profile.GenerateBitmap<RocketLeagueDataModel>(keyboardRect, GameDataModel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,19 +7,22 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
public class RocketLeagueViewModel : GameViewModel<RocketLeagueDataModel>
|
||||
public sealed class RocketLeagueViewModel : GameViewModel<RocketLeagueDataModel>
|
||||
{
|
||||
private string _versionText;
|
||||
|
||||
public RocketLeagueViewModel(MainManager mainManager)
|
||||
: base(mainManager, new RocketLeagueModel(mainManager, new RocketLeagueSettings()))
|
||||
public RocketLeagueViewModel(MainManager mainManager, KeyboardManager keyboardManager,
|
||||
EffectManager effectManager)
|
||||
: base(
|
||||
mainManager, effectManager,
|
||||
new RocketLeagueModel(mainManager, keyboardManager, new RocketLeagueSettings()))
|
||||
{
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
DisplayName = "Rocket League";
|
||||
|
||||
EffectManager.EffectModels.Add(GameModel);
|
||||
SetVersionText();
|
||||
}
|
||||
|
||||
public static string Name => "Rocket League";
|
||||
|
||||
public string VersionText
|
||||
{
|
||||
get { return _versionText; }
|
||||
|
||||
@ -12,6 +12,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
{
|
||||
public class TheDivisionModel : GameModel
|
||||
{
|
||||
private readonly KeyboardManager _keyboardManager;
|
||||
private Wave _ammoWave;
|
||||
private TheDivisionDataModel _dataModel;
|
||||
private KeyboardRectangle _hpRect;
|
||||
@ -22,8 +23,10 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
private StickyValue<bool> _stickyHp;
|
||||
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";
|
||||
ProcessName = "TheDivision";
|
||||
Scale = 4;
|
||||
@ -47,7 +50,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
Initialized = false;
|
||||
|
||||
_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>(),
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
@ -57,7 +60,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
ContainedBrush = false
|
||||
};
|
||||
|
||||
_p2 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
|
||||
_p2 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
|
||||
new List<Color>(),
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
@ -66,7 +69,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
Rotate = true,
|
||||
ContainedBrush = false
|
||||
};
|
||||
_p3 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
|
||||
_p3 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
|
||||
new List<Color>(),
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
@ -75,7 +78,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
Rotate = true,
|
||||
ContainedBrush = false
|
||||
};
|
||||
_p4 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
|
||||
_p4 = new KeyboardRectangle(_keyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
|
||||
new List<Color>(),
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
@ -204,7 +207,7 @@ namespace Artemis.Modules.Games.TheDivision
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = _keyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
|
||||
@ -3,14 +3,16 @@ using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.TheDivision
|
||||
{
|
||||
public class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
|
||||
public sealed class TheDivisionViewModel : GameViewModel<TheDivisionDataModel>
|
||||
{
|
||||
public TheDivisionViewModel(MainManager mainManager)
|
||||
: base(mainManager, new TheDivisionModel(mainManager, new TheDivisionSettings()))
|
||||
public TheDivisionViewModel(MainManager mainManager, EffectManager effectManager,
|
||||
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";
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,8 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
private KeyboardRectangle _signRect;
|
||||
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";
|
||||
ProcessName = "witcher3";
|
||||
@ -44,7 +45,7 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
{
|
||||
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)
|
||||
{
|
||||
Rotate = true,
|
||||
@ -106,7 +107,7 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
var bitmap = KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
|
||||
@ -10,19 +10,13 @@ using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.Witcher3
|
||||
{
|
||||
public class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
|
||||
public sealed class Witcher3ViewModel : GameViewModel<Witcher3DataModel>
|
||||
{
|
||||
public Witcher3ViewModel(MainManager mainManager)
|
||||
: base(mainManager, new Witcher3Model(mainManager, new Witcher3Settings()))
|
||||
public Witcher3ViewModel(MainManager mainManager, KeyboardManager keyboardManager, EffectManager effectManager)
|
||||
: base(mainManager, effectManager, new Witcher3Model(mainManager, keyboardManager, new Witcher3Settings()))
|
||||
{
|
||||
MainManager = mainManager;
|
||||
|
||||
// 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);
|
||||
DisplayName = "The Witcher 3";
|
||||
EffectManager.EffectModels.Add(GameModel);
|
||||
}
|
||||
|
||||
public static string Name => "The Witcher 3";
|
||||
|
||||
@ -9,16 +9,16 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
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;
|
||||
Transparancy = 255;
|
||||
Scale = 4;
|
||||
}
|
||||
|
||||
public MainManager MainManager { get; set; }
|
||||
|
||||
public VolumeDisplaySettings Settings { get; set; }
|
||||
|
||||
public int Scale { get; set; }
|
||||
@ -30,14 +30,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
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.SecondaryColor)
|
||||
},
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
|
||||
Width = (int) (_keyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
|
||||
ContainedBrush = false
|
||||
};
|
||||
volumeRect.Draw(g);
|
||||
|
||||
@ -9,13 +9,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
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;
|
||||
Name = "VolumeDisplay";
|
||||
Enabled = Settings.Enabled;
|
||||
|
||||
VolumeDisplay = new VolumeBar(mainManager, settings);
|
||||
VolumeDisplay = new VolumeBar(keyboardManager, settings);
|
||||
}
|
||||
|
||||
public VolumeBar VolumeDisplay { get; set; }
|
||||
@ -63,7 +64,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
public override Bitmap GenerateBitmap()
|
||||
{
|
||||
return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
|
||||
return GenerateBitmap(KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
|
||||
}
|
||||
|
||||
public override Bitmap GenerateBitmap(Bitmap bitmap)
|
||||
|
||||
@ -3,18 +3,20 @@ using Artemis.ViewModels.Abstract;
|
||||
|
||||
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
|
||||
OverlaySettings = new VolumeDisplaySettings();
|
||||
|
||||
// Create effect model and add it to MainManager
|
||||
OverlayModel = new VolumeDisplayModel(mainManager, (VolumeDisplaySettings) OverlaySettings);
|
||||
MainManager.EffectManager.EffectModels.Add(OverlayModel);
|
||||
OverlayModel = new VolumeDisplayModel(mainManager, keyboardManager, (VolumeDisplaySettings) OverlaySettings);
|
||||
EffectManager.EffectModels.Add(OverlayModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.TypeWave;
|
||||
using Artemis.Modules.Games.CounterStrike;
|
||||
@ -19,10 +18,11 @@ namespace Artemis.NinjectModules
|
||||
public override void Load()
|
||||
{
|
||||
// Effects
|
||||
//Bind<EffectViewModel>().To<AmbientLightningEffectViewModel>().InSingletonScope();
|
||||
Bind<Screen>().To<EffectViewModel>(); // TODO: Needed?
|
||||
Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope();
|
||||
Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope();
|
||||
Bind<EffectViewModel>().To<TypeWaveViewModel>().InSingletonScope();
|
||||
//Bind<EffectViewModel>().To<AmbientLightningEffectViewModel>().InSingletonScope();
|
||||
|
||||
// Games
|
||||
Bind<Screen>().To(typeof(GameViewModel<>)); // TODO: Needed?
|
||||
@ -33,8 +33,8 @@ namespace Artemis.NinjectModules
|
||||
Bind<GameViewModel<Witcher3DataModel>>().To<Witcher3ViewModel>().InSingletonScope();
|
||||
|
||||
// Overlays
|
||||
Bind<Screen>().To<OverlayViewModel>(); // TODO: Needed?
|
||||
Bind<OverlayViewModel>().To<VolumeDisplayViewModel>().InSingletonScope();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Artemis/Artemis/NinjectModules/BaseModules.cs
Normal file
20
Artemis/Artemis/NinjectModules/BaseModules.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -344,7 +344,7 @@ namespace Artemis.Annotations
|
||||
/// </code>
|
||||
/// </example>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
[BaseTypeRequired(typeof (Attribute))]
|
||||
[BaseTypeRequired(typeof(Attribute))]
|
||||
public sealed class BaseTypeRequiredAttribute : Attribute
|
||||
{
|
||||
public BaseTypeRequiredAttribute([NotNull] Type baseType)
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using MahApps.Metro.Controls;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
|
||||
@ -66,7 +66,7 @@ namespace Artemis.Utilities
|
||||
if (ReferenceEquals(source, null))
|
||||
return default(T);
|
||||
|
||||
var serializer = new XmlSerializer(typeof (T));
|
||||
var serializer = new XmlSerializer(typeof(T));
|
||||
Stream stream = new MemoryStream();
|
||||
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<T>() => GenerateTypeMap(typeof (T).GetProperties());
|
||||
public static List<PropertyCollection> GenerateTypeMap<T>() => GenerateTypeMap(typeof(T).GetProperties());
|
||||
|
||||
private static List<PropertyCollection> GenerateTypeMap(IEnumerable<PropertyInfo> getProperties,
|
||||
string path = "")
|
||||
|
||||
@ -130,12 +130,13 @@ namespace Artemis.Utilities
|
||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.folder), thumbnailRect);
|
||||
else if (_layerModel.LayerType == LayerType.Headset)
|
||||
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);
|
||||
else if(_layerModel.LayerType == LayerType.KeyboardGif)
|
||||
else if (_layerModel.LayerType == LayerType.KeyboardGif)
|
||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.gif), thumbnailRect);
|
||||
else if(_layerModel.LayerType == LayerType.Keyboard && _layerModel.UserProps.Brush != null)
|
||||
c.DrawRectangle(_layerModel.UserProps.Brush, new Pen(new SolidColorBrush(Colors.White), 1), thumbnailRect);
|
||||
else if (_layerModel.LayerType == LayerType.Keyboard && _layerModel.UserProps.Brush != null)
|
||||
c.DrawRectangle(_layerModel.UserProps.Brush, new Pen(new SolidColorBrush(Colors.White), 1),
|
||||
thumbnailRect);
|
||||
}
|
||||
|
||||
var image = new DrawingImage(visual.Drawing);
|
||||
@ -176,7 +177,7 @@ namespace Artemis.Utilities
|
||||
return;
|
||||
if (!File.Exists(_layerModel.GifFile))
|
||||
return;
|
||||
|
||||
|
||||
if (_layerModel.GifFile != _gifSource || _gifSource == null)
|
||||
{
|
||||
_gifImage = new GifImage(_layerModel.GifFile);
|
||||
|
||||
8
Artemis/Artemis/ViewModels/Abstract/BaseViewModel.cs
Normal file
8
Artemis/Artemis/ViewModels/Abstract/BaseViewModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.ViewModels.Abstract
|
||||
{
|
||||
public abstract class BaseViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -6,11 +6,18 @@ namespace Artemis.ViewModels.Abstract
|
||||
{
|
||||
public abstract class EffectViewModel : Screen
|
||||
{
|
||||
protected readonly EffectModel EffectModel;
|
||||
private EffectSettings _effectSettings;
|
||||
private bool _showDisabledPopup;
|
||||
protected EffectManager EffectManager;
|
||||
protected MainManager MainManager;
|
||||
|
||||
public EffectModel EffectModel { get; set; }
|
||||
public MainManager MainManager { get; set; }
|
||||
protected EffectViewModel(MainManager mainManager, EffectManager effectManager, EffectModel effectModel)
|
||||
{
|
||||
MainManager = mainManager;
|
||||
EffectManager = effectManager;
|
||||
EffectModel = effectModel;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@ -46,9 +53,9 @@ namespace Artemis.ViewModels.Abstract
|
||||
}
|
||||
|
||||
if (EffectEnabled)
|
||||
MainManager.EffectManager.ClearEffect();
|
||||
EffectManager.ClearEffect();
|
||||
else
|
||||
MainManager.EffectManager.ChangeEffect(EffectModel);
|
||||
EffectManager.ChangeEffect(EffectModel);
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
@ -58,7 +65,7 @@ namespace Artemis.ViewModels.Abstract
|
||||
return;
|
||||
|
||||
// Restart the effect if it's currently running to apply settings.
|
||||
MainManager.EffectManager.ChangeEffect(EffectModel, true);
|
||||
EffectManager.ChangeEffect(EffectModel, true);
|
||||
}
|
||||
|
||||
public async void ResetSettings()
|
||||
|
||||
@ -15,14 +15,16 @@ namespace Artemis.ViewModels.Abstract
|
||||
private bool _editorShown;
|
||||
private GameSettings _gameSettings;
|
||||
private EffectModel _lastEffect;
|
||||
protected EffectManager EffectManager;
|
||||
|
||||
protected GameViewModel(MainManager mainManager, GameModel gameModel)
|
||||
protected GameViewModel(MainManager mainManager, EffectManager effectManager, GameModel gameModel)
|
||||
{
|
||||
MainManager = mainManager;
|
||||
EffectManager = effectManager;
|
||||
GameModel = gameModel;
|
||||
GameSettings = gameModel.Settings;
|
||||
|
||||
ProfileEditor = new ProfileEditorViewModel<T>(MainManager, GameModel);
|
||||
//ProfileEditor = new ProfileEditorViewModel<T>(MainManager, GameModel);
|
||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||
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()
|
||||
{
|
||||
@ -57,14 +59,15 @@ namespace Artemis.ViewModels.Abstract
|
||||
return;
|
||||
|
||||
// Restart the game if it's currently running to apply settings.
|
||||
MainManager.EffectManager.ChangeEffect(GameModel, true);
|
||||
EffectManager.ChangeEffect(GameModel, true);
|
||||
}
|
||||
|
||||
public async void ResetSettings()
|
||||
{
|
||||
var resetConfirm = await
|
||||
MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings",
|
||||
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
||||
var resetConfirm =
|
||||
await
|
||||
MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings",
|
||||
"Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost.");
|
||||
|
||||
if (!resetConfirm.Value)
|
||||
return;
|
||||
@ -106,11 +109,11 @@ namespace Artemis.ViewModels.Abstract
|
||||
if (enable)
|
||||
{
|
||||
// Store the current effect so it can be restored later
|
||||
if (!(MainManager.EffectManager.ActiveEffect is ProfilePreviewModel))
|
||||
_lastEffect = MainManager.EffectManager.ActiveEffect;
|
||||
if (!(EffectManager.ActiveEffect is ProfilePreviewModel))
|
||||
_lastEffect = EffectManager.ActiveEffect;
|
||||
|
||||
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||
MainManager.EffectManager.ChangeEffect(MainManager.EffectManager.ProfilePreviewModel);
|
||||
EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||
EffectManager.ChangeEffect(EffectManager.ProfilePreviewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -120,12 +123,12 @@ namespace Artemis.ViewModels.Abstract
|
||||
var gameModel = _lastEffect as GameModel;
|
||||
if (gameModel != null)
|
||||
if (!gameModel.Enabled)
|
||||
MainManager.EffectManager.GetLastEffect();
|
||||
EffectManager.GetLastEffect();
|
||||
else
|
||||
MainManager.EffectManager.ChangeEffect(_lastEffect, true);
|
||||
EffectManager.ChangeEffect(_lastEffect, true);
|
||||
}
|
||||
else
|
||||
MainManager.EffectManager.ClearEffect();
|
||||
EffectManager.ClearEffect();
|
||||
}
|
||||
|
||||
_editorShown = enable;
|
||||
@ -137,7 +140,7 @@ namespace Artemis.ViewModels.Abstract
|
||||
return;
|
||||
|
||||
GameModel.Profile = ProfileEditor.SelectedProfile;
|
||||
MainManager.EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||
EffectManager.ProfilePreviewModel.SelectedProfile = ProfileEditor.SelectedProfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,17 @@ namespace Artemis.ViewModels.Abstract
|
||||
{
|
||||
public abstract class OverlayViewModel : Screen
|
||||
{
|
||||
protected readonly EffectManager EffectManager;
|
||||
protected readonly MainManager MainManager;
|
||||
private OverlaySettings _overlaySettings;
|
||||
|
||||
protected OverlayViewModel(MainManager mainManager, EffectManager effectManager)
|
||||
{
|
||||
EffectManager = effectManager;
|
||||
MainManager = mainManager;
|
||||
}
|
||||
|
||||
public OverlayModel OverlayModel { get; set; }
|
||||
public MainManager MainManager { get; set; }
|
||||
|
||||
public OverlaySettings OverlaySettings
|
||||
{
|
||||
|
||||
@ -1,38 +1,23 @@
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Effects.AudioVisualizer;
|
||||
using Artemis.Modules.Effects.Debug;
|
||||
using Artemis.Modules.Effects.TypeHole;
|
||||
using Artemis.Modules.Effects.TypeWave;
|
||||
using Caliburn.Micro;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
public sealed class EffectsViewModel : BaseViewModel
|
||||
{
|
||||
private readonly AudioVisualizerViewModel _audioVisualizerVm;
|
||||
private readonly DebugEffectViewModel _debugVm;
|
||||
private readonly TypeHoleViewModel _typeHoleVm;
|
||||
private readonly TypeWaveViewModel _typeWaveVm;
|
||||
//private readonly AmbientLightningEffectViewModel _ambientLightningVm;
|
||||
private readonly EffectViewModel[] _effectViewModels;
|
||||
|
||||
public EffectsViewModel(MainManager mainManager)
|
||||
public EffectsViewModel(EffectViewModel[] effectViewModels)
|
||||
{
|
||||
_typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"};
|
||||
//_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"};
|
||||
_audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"};
|
||||
//_ambientLightningVm = new AmbientLightningEffectViewModel(mainManager) {DisplayName = "Ambient Lightning"};
|
||||
_debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"};
|
||||
DisplayName = "Effects";
|
||||
_effectViewModels = effectViewModels;
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
ActivateItem(_typeWaveVm);
|
||||
//ActivateItem(_typeHoleVm);
|
||||
ActivateItem(_audioVisualizerVm);
|
||||
//ActivateItem(_ambientLightningVm);
|
||||
ActivateItem(_debugVm);
|
||||
foreach (var effectViewModel in _effectViewModels)
|
||||
ActivateItem(effectViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,18 +10,20 @@ namespace Artemis.ViewModels.Flyouts
|
||||
{
|
||||
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
|
||||
{
|
||||
private readonly KeyboardManager _keyboardManager;
|
||||
private string _activeEffectName;
|
||||
private GeneralSettings _generalSettings;
|
||||
private string _selectedKeyboardProvider;
|
||||
|
||||
public FlyoutSettingsViewModel(MainManager mainManager)
|
||||
public FlyoutSettingsViewModel(MainManager mainManager, KeyboardManager keyboardManager, IEventAggregator events)
|
||||
{
|
||||
_keyboardManager = keyboardManager;
|
||||
MainManager = mainManager;
|
||||
Header = "Settings";
|
||||
Position = Position.Right;
|
||||
GeneralSettings = new GeneralSettings();
|
||||
|
||||
MainManager.Events.Subscribe(this);
|
||||
events.Subscribe(this);
|
||||
}
|
||||
|
||||
public GeneralSettings GeneralSettings
|
||||
@ -41,8 +43,7 @@ namespace Artemis.ViewModels.Flyouts
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders
|
||||
.Select(k => k.Name));
|
||||
var collection = new BindableCollection<string>(_keyboardManager.KeyboardProviders.Select(k => k.Name));
|
||||
collection.Insert(0, "None");
|
||||
return collection;
|
||||
}
|
||||
@ -59,8 +60,8 @@ namespace Artemis.ViewModels.Flyouts
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
MainManager.KeyboardManager.ChangeKeyboard(
|
||||
MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault(
|
||||
_keyboardManager.ChangeKeyboard(
|
||||
_keyboardManager.KeyboardProviders.FirstOrDefault(
|
||||
k => k.Name == _selectedKeyboardProvider));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,39 +1,17 @@
|
||||
using Artemis.Managers;
|
||||
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;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class GamesViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
public sealed class GamesViewModel : BaseViewModel
|
||||
{
|
||||
private readonly CounterStrikeViewModel _counterStrikeVm;
|
||||
private readonly TheDivisionViewModel _divisionVm;
|
||||
private readonly Dota2ViewModel _dota2Vm;
|
||||
private readonly RocketLeagueViewModel _rocketLeagueVm;
|
||||
private readonly Witcher3ViewModel _witcher3Vm;
|
||||
|
||||
public GamesViewModel(MainManager mainManager)
|
||||
public GamesViewModel()
|
||||
{
|
||||
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
|
||||
_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"};
|
||||
DisplayName = "Games";
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
ActivateItem(_rocketLeagueVm);
|
||||
ActivateItem(_counterStrikeVm);
|
||||
ActivateItem(_dota2Vm);
|
||||
ActivateItem(_witcher3Vm);
|
||||
ActivateItem(_divisionVm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,13 +17,13 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
public class LayerEditorViewModel<T> : Screen
|
||||
{
|
||||
private readonly KeyboardProvider _activeKeyboard;
|
||||
private readonly MetroDialogService _dialogService;
|
||||
private readonly BackgroundWorker _previewWorker;
|
||||
private readonly bool _wasEnabled;
|
||||
private LayerModel _layer;
|
||||
private LayerType _layerType;
|
||||
private LayerModel _proposedLayer;
|
||||
private LayerPropertiesModel _proposedProperties;
|
||||
private LayerType _layerType;
|
||||
private MetroDialogService _dialogService;
|
||||
|
||||
public LayerEditorViewModel(KeyboardProvider activeKeyboard, LayerModel layer)
|
||||
{
|
||||
@ -52,7 +52,7 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
PropertyChanged += GridDisplayHandler;
|
||||
PreSelect();
|
||||
}
|
||||
|
||||
|
||||
public LayerDynamicPropertiesViewModel OpacityProperties { get; set; }
|
||||
|
||||
public LayerDynamicPropertiesViewModel WidthProperties { get; set; }
|
||||
@ -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)
|
||||
{
|
||||
while (!_previewWorker.CancellationPending)
|
||||
@ -141,17 +152,6 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
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)
|
||||
{
|
||||
if (e.PropertyName != "LayerType")
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Overlays.VolumeDisplay;
|
||||
using Caliburn.Micro;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
public sealed class OverlaysViewModel : BaseViewModel
|
||||
{
|
||||
private readonly MainManager _mainManager;
|
||||
private readonly OverlayViewModel[] _overlayViewModels;
|
||||
private VolumeDisplayViewModel _volumeDisplayVm;
|
||||
|
||||
public OverlaysViewModel(MainManager mainManager)
|
||||
public OverlaysViewModel(MainManager mainManager, OverlayViewModel[] overlayViewModels)
|
||||
{
|
||||
DisplayName = "Overlays";
|
||||
|
||||
_mainManager = mainManager;
|
||||
_overlayViewModels = overlayViewModels;
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
Items.Clear();
|
||||
|
||||
// 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;
|
||||
foreach (var overlayViewModel in _overlayViewModels)
|
||||
ActivateItem(overlayViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,9 +19,10 @@ using MahApps.Metro;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class ProfileEditorViewModel<T> : Screen, IHandle<ActiveKeyboardChanged>
|
||||
public sealed class ProfileEditorViewModel<T> : Screen, IHandle<ActiveKeyboardChanged>
|
||||
{
|
||||
private readonly GameModel _gameModel;
|
||||
private readonly KeyboardManager _keyboardManager;
|
||||
private readonly MainManager _mainManager;
|
||||
private DateTime _downTime;
|
||||
private LayerModel _draggingLayer;
|
||||
@ -34,14 +35,16 @@ namespace Artemis.ViewModels
|
||||
private LayerModel _selectedLayer;
|
||||
private ProfileModel _selectedProfile;
|
||||
|
||||
public ProfileEditorViewModel(MainManager mainManager, GameModel gameModel)
|
||||
public ProfileEditorViewModel(MainManager mainManager, KeyboardManager keyboardManager, GameModel gameModel,
|
||||
IEventAggregator events)
|
||||
{
|
||||
_mainManager = mainManager;
|
||||
_keyboardManager = keyboardManager;
|
||||
_gameModel = gameModel;
|
||||
|
||||
Profiles = new BindableCollection<ProfileModel>();
|
||||
Layers = new BindableCollection<LayerModel>();
|
||||
_mainManager.Events.Subscribe(this);
|
||||
events.Subscribe(this);
|
||||
|
||||
PropertyChanged += PropertyChangeHandler;
|
||||
LoadProfiles();
|
||||
@ -177,7 +180,7 @@ namespace Artemis.ViewModels
|
||||
public bool CanAddLayer => _selectedProfile != null;
|
||||
public bool CanRemoveLayer => _selectedProfile != null && _selectedLayer != null;
|
||||
|
||||
private KeyboardProvider ActiveKeyboard => _mainManager.KeyboardManager.ActiveKeyboard;
|
||||
private KeyboardProvider ActiveKeyboard => _keyboardManager.ActiveKeyboard;
|
||||
|
||||
/// <summary>
|
||||
/// Handles chaning the active keyboard, updating the preview image and profiles collection
|
||||
|
||||
@ -1,49 +1,36 @@
|
||||
using System.Linq;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Services;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Artemis.ViewModels.Flyouts;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
{
|
||||
private readonly EffectsViewModel _effectsVm;
|
||||
private readonly GamesViewModel _gamesVm;
|
||||
private readonly OverlaysViewModel _overlaysVm;
|
||||
private readonly WelcomeViewModel _welcomeVm;
|
||||
private readonly BaseViewModel[] _viewModels;
|
||||
|
||||
public ShellViewModel()
|
||||
public ShellViewModel(BaseViewModel[] viewModels, IKernel kernel)
|
||||
{
|
||||
var dialogService = new MetroDialogService(this);
|
||||
IEventAggregator events = new EventAggregator();
|
||||
_viewModels = viewModels;
|
||||
|
||||
MainManager = new MainManager(events, dialogService);
|
||||
// Setup UI
|
||||
DisplayName = "Artemis";
|
||||
|
||||
_welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"};
|
||||
_effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"};
|
||||
_gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"};
|
||||
_overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"};
|
||||
|
||||
Flyouts.Add(new FlyoutSettingsViewModel(MainManager));
|
||||
Flyouts = new BindableCollection<FlyoutBaseViewModel>
|
||||
{
|
||||
kernel.Get<FlyoutSettingsViewModel>()
|
||||
};
|
||||
}
|
||||
|
||||
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
|
||||
new BindableCollection<FlyoutBaseViewModel>();
|
||||
|
||||
public MainManager MainManager { get; set; }
|
||||
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
foreach (var screen in _viewModels)
|
||||
ActivateItem(screen);
|
||||
|
||||
ActivateItem(_welcomeVm);
|
||||
ActivateItem(_effectsVm);
|
||||
ActivateItem(_gamesVm);
|
||||
ActivateItem(_overlaysVm);
|
||||
|
||||
ActiveItem = _welcomeVm;
|
||||
ActiveItem = _viewModels.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Settings()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Caliburn.Micro;
|
||||
@ -10,25 +11,30 @@ namespace Artemis.ViewModels
|
||||
public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled>
|
||||
{
|
||||
private readonly ShellViewModel _shellViewModel;
|
||||
|
||||
private readonly IWindowManager _windowManager;
|
||||
private string _activeIcon;
|
||||
private bool _checkedForUpdate;
|
||||
private bool _enabled;
|
||||
private string _toggleText;
|
||||
|
||||
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel)
|
||||
public SystemTrayViewModel(IWindowManager windowManager, IEventAggregator events, ShellViewModel shellViewModel,
|
||||
MainManager mainManager)
|
||||
{
|
||||
_windowManager = windowManager;
|
||||
_shellViewModel = shellViewModel;
|
||||
_shellViewModel.MainManager.Events.Subscribe(this);
|
||||
_shellViewModel.MainManager.EnableProgram();
|
||||
_checkedForUpdate = false;
|
||||
|
||||
MainManager = mainManager;
|
||||
|
||||
events.Subscribe(this);
|
||||
MainManager.EnableProgram();
|
||||
|
||||
if (General.Default.ShowOnStartup)
|
||||
ShowWindow();
|
||||
}
|
||||
|
||||
public MainManager MainManager { get; set; }
|
||||
|
||||
public bool CanShowWindow => !_shellViewModel.IsActive;
|
||||
|
||||
public bool CanHideWindow => _shellViewModel.IsActive;
|
||||
@ -76,9 +82,9 @@ namespace Artemis.ViewModels
|
||||
public void ToggleEnabled()
|
||||
{
|
||||
if (Enabled)
|
||||
_shellViewModel.MainManager.DisableProgram();
|
||||
MainManager.DisableProgram();
|
||||
else
|
||||
_shellViewModel.MainManager.EnableProgram();
|
||||
MainManager.EnableProgram();
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
@ -104,7 +110,7 @@ namespace Artemis.ViewModels
|
||||
return;
|
||||
|
||||
_checkedForUpdate = true;
|
||||
Updater.CheckForUpdate(_shellViewModel.MainManager.DialogService);
|
||||
Updater.CheckForUpdate(MainManager.DialogService);
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +127,7 @@ namespace Artemis.ViewModels
|
||||
|
||||
public void ExitApplication()
|
||||
{
|
||||
_shellViewModel.MainManager.Shutdown();
|
||||
MainManager.Shutdown();
|
||||
Application.Current.Shutdown();
|
||||
|
||||
// Sometimes you need to be rough.
|
||||
|
||||
@ -3,8 +3,13 @@ using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class WelcomeViewModel : Screen
|
||||
public sealed class WelcomeViewModel : Screen
|
||||
{
|
||||
public WelcomeViewModel()
|
||||
{
|
||||
DisplayName = "Welcome";
|
||||
}
|
||||
|
||||
public void NavigateTo(string url)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(url));
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user