diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config
index 20723b413..3ccf6e7e5 100644
--- a/Artemis/Artemis/App.config
+++ b/Artemis/Artemis/App.config
@@ -1,304 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
- True
-
-
- Default
-
-
-
-
-
-
-
- True
-
-
- Default
-
-
-
-
-
-
-
- True
-
-
- Default
-
-
-
-
- Demo (Duplicate to keep changes)
-
-
-
-
- True
-
-
- Default
-
-
-
-
-
-
-
- True
-
-
-
-
- True
-
-
- Default
-
-
-
-
-
-
-
- True
-
-
- #FFFF2900
-
-
- #FF26F600
-
-
-
-
- True
-
-
- Default
-
-
-
-
- {"Game":"RocketLeague","GameVersion":"1.10","GameAddresses":[{"Description":"Boost","BasePointer":{"value":21998084},"Offsets":[88,1452,1780,540]}]}
-
-
- {"Game":"Witcher3","GameVersion":"1.11","GameAddresses":[{"Description":"Sign","BasePointer":{"value":42942304},"Offsets":[40,16,32,3008]}]}
-
-
-
-
- True
-
-
-
-
- 4
-
-
- 21
-
-
- True
-
-
- 3
-
-
- #FFF90000
-
-
- #FFFF761E
-
-
- #FF00DF00
-
-
-
-
- True
-
-
- Default
-
-
-
-
-
-
-
- C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive
-
-
- True
-
-
- #FFFF2900
-
-
- #FF26F600
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
-
-
- 4
-
-
- 21
-
-
- 1
-
-
- 3
-
-
- #FF0000FF
-
-
- #FF1E90FF
-
-
-
-
- False
-
-
- #FFFF5000
-
-
- #FFFF0000
-
-
-
-
- TypeWave
-
-
-
-
- True
-
-
- #FFFF0000
-
-
- True
-
-
- 20
-
-
- 500
-
-
- 4
-
-
-
-
- True
-
-
- #FFFF0000
-
-
- True
-
-
- 25
-
-
- 4
-
-
- 12
-
-
- 14
-
-
- 25
-
-
-
-
- WindowsProfile
-
-
-
-
-
- True
-
-
- 51364
-
-
- False
-
-
- False
-
-
- True
-
-
- True
-
-
- Light
-
-
- Info
-
-
-
@@ -337,7 +44,6 @@
-
-
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 6ee49f2d7..cc6e27133 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -131,24 +131,24 @@
..\packages\Betwixt.1.4.1\lib\net35\Betwixt.dll
True
-
- ..\packages\Caliburn.Micro.Core.3.0.1\lib\net45\Caliburn.Micro.dll
+
+ ..\packages\Caliburn.Micro.Core.3.0.2\lib\net45\Caliburn.Micro.dll
True
-
- ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.dll
+
+ ..\packages\Caliburn.Micro.3.0.2\lib\net45\Caliburn.Micro.Platform.dll
True
-
- ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll
+
+ ..\packages\Caliburn.Micro.3.0.2\lib\net45\Caliburn.Micro.Platform.Core.dll
True
..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll
True
-
- ..\packages\Colore.5.0.0\lib\net35\Corale.Colore.dll
+
+ ..\packages\Colore.5.1.0\lib\net35\Corale.Colore.dll
True
@@ -236,7 +236,7 @@
True
- ..\packages\NLog.4.3.10\lib\net45\NLog.dll
+ ..\packages\NLog.4.4.1\lib\net45\NLog.dll
True
@@ -255,8 +255,8 @@
..\packages\SharpDX.Direct3D9.3.1.1\lib\net45\SharpDX.Direct3D9.dll
True
-
- ..\packages\Splat.1.6.2\lib\Net45\Splat.dll
+
+ ..\packages\Splat.2.0.0\lib\Net45\Splat.dll
True
@@ -333,7 +333,7 @@
MarkdownDialog.xaml
-
+
@@ -349,16 +349,17 @@
-
+
-
-
-
-
+
+
+
+
+
@@ -454,6 +455,13 @@
+
+
+
+
+ OverlayProfileView.xaml
+
+
@@ -481,6 +489,8 @@
+
+
AudioPropertiesView.xaml
@@ -525,24 +535,20 @@
-
-
-
-
-
-
+
+
+
+
BubblesView.xaml
-
-
-
- WindowsProfileView.xaml
+
+
+
+ GeneralProfileView.xaml
-
-
-
-
-
+
+
+
@@ -568,15 +574,6 @@
-
-
-
- True
- True
- VolumeDisplay.settings
-
-
-
@@ -609,12 +606,9 @@
-
-
-
@@ -635,7 +629,6 @@
-
@@ -644,12 +637,8 @@
-
-
-
-
-
+
@@ -669,22 +658,18 @@
-
DebugView.xaml
-
- EffectsView.xaml
+
+ GeneralView.xaml
FlyoutSettingsView.xaml
-
- AudioVisualizerView.xaml
-
GamesView.xaml
@@ -727,9 +712,6 @@
OverlaysView.xaml
-
- VolumeDisplayView.xaml
-
LayerTweenView.xaml
@@ -750,13 +732,13 @@
Code
+
+ Designer
+
-
- Designer
-
@@ -771,10 +753,6 @@
Designer
Resources.Designer.cs
-
- SettingsSingleFileGenerator
- VolumeDisplay.Designer.cs
-
Designer
@@ -828,11 +806,11 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
@@ -868,6 +846,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
@@ -912,11 +894,7 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
-
+
Designer
MSBuild:Compile
@@ -980,10 +958,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
diff --git a/Artemis/Artemis/DAL/ProfileProvider.cs b/Artemis/Artemis/DAL/ProfileProvider.cs
index 5b757726e..2721ae7d6 100644
--- a/Artemis/Artemis/DAL/ProfileProvider.cs
+++ b/Artemis/Artemis/DAL/ProfileProvider.cs
@@ -6,7 +6,7 @@ using System.IO.Compression;
using System.Linq;
using System.Reflection;
using Artemis.DeviceProviders;
-using Artemis.Models;
+using Artemis.Modules.Abstract;
using Artemis.Profiles;
using Artemis.Profiles.Layers.Types.Keyboard;
using Artemis.Properties;
@@ -34,18 +34,18 @@ namespace Artemis.DAL
InstallDefaults();
}
- public static List GetProfileNames(KeyboardProvider keyboard, EffectModel effect)
+ public static List GetProfileNames(KeyboardProvider keyboard, ModuleModel module)
{
- if (keyboard == null || effect == null)
+ if (keyboard == null || module == null)
return null;
- return ReadProfiles(keyboard.Slug + "/" + effect.Name).Select(p => p.Name).ToList();
+ return ReadProfiles(keyboard.Slug + "/" + module.Name).Select(p => p.Name).ToList();
}
- public static ProfileModel GetProfile(KeyboardProvider keyboard, EffectModel effect, string name)
+ public static ProfileModel GetProfile(KeyboardProvider keyboard, ModuleModel module, string name)
{
- if (keyboard == null || effect == null)
+ if (keyboard == null || module == null)
return null;
- return ReadProfiles(keyboard.Slug + "/" + effect.Name).FirstOrDefault(p => p.Name == name);
+ return ReadProfiles(keyboard.Slug + "/" + module.Name).FirstOrDefault(p => p.Name == name);
}
public static bool IsProfileUnique(ProfileModel profileModel)
@@ -238,7 +238,7 @@ namespace Artemis.DAL
archive.ExtractToDirectory(ProfileFolder, true);
- InsertGif("WindowsProfile", "Demo (duplicate to keep changes)", "GIF", Resources.demo_gif, "demo-gif");
+ InsertGif("GeneralProfile", "Demo (duplicate to keep changes)", "GIF", Resources.demo_gif, "demo-gif");
}
catch (IOException e)
{
diff --git a/Artemis/Artemis/Events/EffectChangedEventArgs.cs b/Artemis/Artemis/Events/EffectChangedEventArgs.cs
deleted file mode 100644
index 9e9d4c9a9..000000000
--- a/Artemis/Artemis/Events/EffectChangedEventArgs.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using Artemis.Models;
-
-namespace Artemis.Events
-{
- public class EffectChangedEventArgs : EventArgs
- {
- public EffectChangedEventArgs(EffectModel effect)
- {
- Effect = effect;
- }
-
- public EffectModel Effect { get; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Events/ModuleChangedEventArgs.cs b/Artemis/Artemis/Events/ModuleChangedEventArgs.cs
new file mode 100644
index 000000000..ccb99f5a6
--- /dev/null
+++ b/Artemis/Artemis/Events/ModuleChangedEventArgs.cs
@@ -0,0 +1,15 @@
+using System;
+using Artemis.Modules.Abstract;
+
+namespace Artemis.Events
+{
+ public class ModuleChangedEventArgs : EventArgs
+ {
+ public ModuleChangedEventArgs(ModuleModel module)
+ {
+ Module = module;
+ }
+
+ public ModuleModel Module { get; }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Events/ProfileDeviceEventsArg.cs b/Artemis/Artemis/Events/ProfileDeviceEventsArg.cs
index 6a988f1bd..d6fb74424 100644
--- a/Artemis/Artemis/Events/ProfileDeviceEventsArg.cs
+++ b/Artemis/Artemis/Events/ProfileDeviceEventsArg.cs
@@ -1,21 +1,22 @@
using System;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
+using Artemis.Profiles.Layers.Interfaces;
namespace Artemis.Events
{
public class ProfileDeviceEventsArg : EventArgs
{
- public ProfileDeviceEventsArg(string updateType, IDataModel dataModel, bool preview, DrawingContext drawingContext)
+ public ProfileDeviceEventsArg(DrawType updateType, ModuleDataModel dataModel, bool preview, DrawingContext drawingContext)
{
- UpdateType = updateType;
+ UpdateType = updateType.ToString().ToLower();
DataModel = dataModel;
Preview = preview;
DrawingContext = drawingContext;
}
public string UpdateType { get; }
- public IDataModel DataModel { get; }
+ public ModuleDataModel DataModel { get; }
public bool Preview { get; }
public DrawingContext DrawingContext { get; }
}
diff --git a/Artemis/Artemis/InjectionModules/BaseModules.cs b/Artemis/Artemis/InjectionModules/BaseModules.cs
index 5c975f7f9..bd0108284 100644
--- a/Artemis/Artemis/InjectionModules/BaseModules.cs
+++ b/Artemis/Artemis/InjectionModules/BaseModules.cs
@@ -1,11 +1,7 @@
using Artemis.DeviceProviders;
-using Artemis.Models;
-using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Interfaces;
-using Artemis.Profiles.Layers.Types.AmbientLight;
-using Artemis.Profiles.Layers.Types.Audio;
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
-using Artemis.Profiles.Layers.Types.KeyPress;
using Artemis.Profiles.Lua;
using Artemis.Services;
using Artemis.Utilities.DataReaders;
@@ -36,12 +32,6 @@ namespace Artemis.InjectionModules
#endregion
- #region Models
-
- Bind().ToSelf().InSingletonScope();
-
- #endregion
-
#region Services
Bind().ToSelf().InSingletonScope();
@@ -71,25 +61,17 @@ namespace Artemis.InjectionModules
Kernel.Bind(x =>
x.FromThisAssembly()
.SelectAllClasses()
- .InheritedFrom()
+ .InheritedFrom()
.BindAllBaseClasses()
.Configure((b, c) => b.InSingletonScope().Named(c.Name))
);
Kernel.Bind(x =>
x.FromThisAssembly()
.SelectAllClasses()
- .InheritedFrom()
- .BindBase());
- Kernel.Bind(x =>
- x.FromThisAssembly()
- .SelectAllClasses()
- .InheritedFrom()
- .BindBase());
- Kernel.Bind(x =>
- x.FromThisAssembly()
- .SelectAllClasses()
- .InheritedFrom()
- .BindBase());
+ .InheritedFrom()
+ .BindAllBaseClasses()
+ .Configure(b => b.InSingletonScope())
+ );
#endregion
@@ -115,7 +97,7 @@ namespace Artemis.InjectionModules
.SelectAllClasses()
.InheritedFrom()
.BindToSelf());
-
+
// Type helpers
Bind().ToSelf().InSingletonScope();
diff --git a/Artemis/Artemis/InjectionModules/ManagerModules.cs b/Artemis/Artemis/InjectionModules/ManagerModules.cs
index c90727795..0d5870d63 100644
--- a/Artemis/Artemis/InjectionModules/ManagerModules.cs
+++ b/Artemis/Artemis/InjectionModules/ManagerModules.cs
@@ -10,7 +10,7 @@ namespace Artemis.InjectionModules
Bind().ToSelf().InSingletonScope();
Bind().ToSelf().InSingletonScope();
Bind().ToSelf().InSingletonScope();
- Bind().ToSelf().InSingletonScope();
+ Bind().ToSelf().InSingletonScope();
Bind().ToSelf().InSingletonScope();
Bind().ToSelf().InSingletonScope();
}
diff --git a/Artemis/Artemis/Managers/DeviceManager.cs b/Artemis/Artemis/Managers/DeviceManager.cs
index bc79efdb1..8535f712b 100644
--- a/Artemis/Artemis/Managers/DeviceManager.cs
+++ b/Artemis/Artemis/Managers/DeviceManager.cs
@@ -51,7 +51,7 @@ namespace Artemis.Managers
public bool ChangingKeyboard { get; private set; }
- public event EventHandler OnKeyboardChangedEvent;
+ public event EventHandler OnKeyboardChanged;
///
/// Enables the last keyboard according to the settings file
@@ -178,7 +178,7 @@ namespace Artemis.Managers
{
// I do this in all to avoid a possible race condition
// https://msdn.microsoft.com/en-us/library/w369ty8x.aspx
- var handler = OnKeyboardChangedEvent;
+ var handler = OnKeyboardChanged;
handler?.Invoke(this, e);
}
}
diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs
deleted file mode 100644
index 4088dbda8..000000000
--- a/Artemis/Artemis/Managers/EffectManager.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Artemis.Events;
-using Artemis.Models;
-using Artemis.Modules.Effects.ProfilePreview;
-using Artemis.Settings;
-using Ninject.Extensions.Logging;
-
-namespace Artemis.Managers
-{
- ///
- /// Manages the effects
- ///
- public class EffectManager
- {
- private readonly DeviceManager _deviceManager;
- private readonly ILogger _logger;
- private EffectModel _activeEffect;
- private LoopManager _waitLoopManager;
- private EffectModel _waitEffect;
- private readonly GeneralSettings _generalSettings;
-
- public EffectManager(ILogger logger, DeviceManager deviceManager, List effectModels,
- List gameModels, List overlayModels)
- {
- _generalSettings = DAL.SettingsProvider.Load();
- _logger = logger;
- _deviceManager = deviceManager;
-
- var models = new List();
- // Add regular effects
- models.AddRange(effectModels);
- // Add overlays
- models.AddRange(overlayModels);
- // Add games, exclude WoW if needed
- models.AddRange(_generalSettings.GamestatePort != 62575
- ? gameModels.Where(e => e.Name != "WoW")
- : gameModels);
-
- EffectModels = models;
- _logger.Info("Intialized EffectManager");
- }
-
- public ProfilePreviewModel ProfilePreviewModel { get; set; }
-
- ///
- /// Holds all the effects the program has
- ///
- public List EffectModels { get; set; }
-
- public EffectModel ActiveEffect
- {
- get { return _activeEffect; }
- private set
- {
- _activeEffect = value;
- RaiseEffectChangedEvent(new EffectChangedEventArgs(value));
- }
- }
-
- ///
- /// Returns all enabled overlays
- ///
- public IEnumerable EnabledOverlays
- {
- get { return EffectModels.OfType().Where(o => o.Enabled); }
- }
-
- ///
- /// Returns all enabled games
- ///
- public IEnumerable EnabledGames
- {
- get { return EffectModels.OfType().Where(g => g.Enabled && g.Settings.Enabled); }
- }
-
- public event EventHandler OnEffectChangedEvent;
-
- ///
- /// Loads the last active effect from settings and enables it.
- ///
- /// Whether enabling was successful or not.
- public EffectModel GetLastEffect()
- {
- _logger.Debug("Getting last effect: {0}", _generalSettings.LastEffect);
- return _generalSettings.LastEffect == null
- ? null
- : EffectModels.FirstOrDefault(e => e.Name == _generalSettings.LastEffect);
- }
-
- ///
- /// Disables the current effect and changes it to the provided effect.
- ///
- /// The effect to activate
- /// Optionally pass the LoopManager to automatically start it, if it's not running.
- public void ChangeEffect(EffectModel effectModel, LoopManager loopManager = null)
- {
- if (_waitEffect != null)
- {
- _logger.Debug("Stopping effect because a change is already queued");
- return;
- }
-
- if (effectModel == null)
- throw new ArgumentNullException(nameof(effectModel));
- if (effectModel is OverlayModel)
- throw new ArgumentException("Can't set an Overlay effect as the active effect");
-
- if (_deviceManager.ActiveKeyboard == null)
- {
- _logger.Debug("Stopping effect change until keyboard is enabled");
- _waitEffect = effectModel;
- _waitLoopManager = loopManager;
- _deviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;
- _deviceManager.EnableLastKeyboard();
- return;
- }
-
- // Game models are only used if they are enabled
- var gameModel = effectModel as GameModel;
- if (gameModel != null)
- if (!gameModel.Enabled)
- {
- _logger.Debug("Cancelling effect change, provided game not enabled");
- return;
- }
-
-
- var wasNull = false;
- if (ActiveEffect == null)
- {
- wasNull = true;
- ActiveEffect = effectModel;
- }
-
- lock (ActiveEffect)
- {
- if (!wasNull)
- ActiveEffect.Dispose();
- lock (effectModel)
- {
- ActiveEffect = effectModel;
- ActiveEffect.Enable();
- if (!ActiveEffect.Initialized)
- {
- _logger.Debug("Cancelling effect change, couldn't initialize the effect ({0})", effectModel.Name);
- ActiveEffect = null;
- return;
- }
- }
- }
-
- if (loopManager != null && !loopManager.Running)
- {
- _logger.Debug("Starting LoopManager for effect change");
- loopManager.StartAsync();
- }
-
- _logger.Debug("Changed active effect to: {0}", effectModel.Name);
-
- if (ActiveEffect is GameModel || ActiveEffect is ProfilePreviewModel)
- return;
-
- // Non-game effects are stored as the new LastEffect.
- _generalSettings.LastEffect = ActiveEffect?.Name;
- _generalSettings.Save();
- }
-
- private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs e)
- {
- _deviceManager.OnKeyboardChangedEvent -= DeviceManagerOnOnKeyboardChangedEvent;
- _logger.Debug("Resuming effect change");
-
- var effect = _waitEffect;
- _waitEffect = null;
- var loopManager = _waitLoopManager;
- _waitLoopManager = null;
-
- ChangeEffect(effect, loopManager);
- }
-
-
- ///
- /// Clears the current effect
- ///
- public void ClearEffect()
- {
- if (ActiveEffect == null)
- return;
-
- lock (ActiveEffect)
- {
- ActiveEffect.Dispose();
- ActiveEffect = null;
-
- _generalSettings.LastEffect = null;
- _generalSettings.Save();
- }
-
- _logger.Debug("Cleared active effect");
- }
-
- ///
- /// Disables the given game
- ///
- ///
- public void DisableGame(EffectModel activeEffect)
- {
- _logger.Debug("Disabling game: {0}", activeEffect?.Name);
- if (GetLastEffect() == null)
- ClearEffect();
- else
- ChangeEffect(GetLastEffect());
- }
-
- ///
- /// Disables the current ActiveEffect if it's a game that is disabled.
- ///
- public void DisableInactiveGame()
- {
- if (!(ActiveEffect is GameModel))
- return;
- if (EnabledGames.Contains(ActiveEffect))
- return;
-
- DisableGame(ActiveEffect);
- }
-
- protected virtual void RaiseEffectChangedEvent(EffectChangedEventArgs e)
- {
- var handler = OnEffectChangedEvent;
- handler?.Invoke(this, e);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs
index b0aefca54..cb1493b10 100644
--- a/Artemis/Artemis/Managers/LoopManager.cs
+++ b/Artemis/Artemis/Managers/LoopManager.cs
@@ -4,10 +4,11 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
+using System.Windows.Media;
using Artemis.DeviceProviders;
using Artemis.ViewModels;
-using Caliburn.Micro;
using Ninject.Extensions.Logging;
+using Color = System.Drawing.Color;
using Timer = System.Timers.Timer;
namespace Artemis.Managers
@@ -19,15 +20,15 @@ namespace Artemis.Managers
{
private readonly DebugViewModel _debugViewModel;
private readonly DeviceManager _deviceManager;
- private readonly EffectManager _effectManager;
private readonly ILogger _logger;
private readonly Timer _loopTimer;
+ private readonly ModuleManager _moduleManager;
- public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
+ public LoopManager(ILogger logger, ModuleManager moduleManager, DeviceManager deviceManager,
DebugViewModel debugViewModel)
{
_logger = logger;
- _effectManager = effectManager;
+ _moduleManager = moduleManager;
_deviceManager = deviceManager;
_debugViewModel = debugViewModel;
@@ -89,15 +90,15 @@ namespace Artemis.Managers
return;
}
- if (_effectManager.ActiveEffect == null)
+ if (_moduleManager.ActiveModule == null)
{
- var lastEffect = _effectManager.GetLastEffect();
- if (lastEffect == null)
+ var lastModule = _moduleManager.GetLastModule();
+ if (lastModule == null)
{
- _logger.Debug("Cancel LoopManager start, no effect");
+ _logger.Debug("Cancel LoopManager start, no module");
return;
}
- _effectManager.ChangeEffect(lastEffect);
+ _moduleManager.ChangeActiveModule(lastModule);
}
Running = true;
@@ -119,14 +120,14 @@ namespace Artemis.Managers
if (!Running || _deviceManager.ChangingKeyboard)
return;
- // Stop if no active effect
- if (_effectManager.ActiveEffect == null)
+ // Stop if no active module
+ if (_moduleManager.ActiveModule == null)
{
- _logger.Debug("No active effect, stopping");
+ _logger.Debug("No active module, stopping");
Stop();
return;
}
- var renderEffect = _effectManager.ActiveEffect;
+ var renderModule = _moduleManager.ActiveModule;
// Stop if no active keyboard
if (_deviceManager.ActiveKeyboard == null)
@@ -138,13 +139,13 @@ namespace Artemis.Managers
lock (_deviceManager.ActiveKeyboard)
{
- // Skip frame if effect is still initializing
- if (renderEffect.Initialized == false)
+ // Skip frame if module is still initializing
+ if (renderModule.IsInitialized == false)
return;
- // ApplyProperties the current effect
- if (renderEffect.Initialized)
- renderEffect.Update();
+ // ApplyProperties the current module
+ if (renderModule.IsInitialized)
+ renderModule.Update();
// Get the devices that must be rendered to
var mice = _deviceManager.MiceProviders.Where(m => m.CanUse).ToList();
@@ -156,14 +157,14 @@ namespace Artemis.Managers
// Setup the frame for this tick
using (var frame = new RenderFrame(_deviceManager.ActiveKeyboard))
{
- if (renderEffect.Initialized)
- renderEffect.Render(frame, keyboardOnly);
+ if (renderModule.IsInitialized)
+ renderModule.Render(frame, keyboardOnly);
- // Draw enabled overlays on top of the renderEffect
- foreach (var overlayModel in _effectManager.EnabledOverlays)
+ // Draw enabled overlays on top of the renderModule
+ foreach (var overlayModel in _moduleManager.OverlayModules.Where(o => o.Settings.IsEnabled))
{
overlayModel.Update();
- overlayModel.RenderOverlay(frame, keyboardOnly);
+ overlayModel.Render(frame, keyboardOnly);
}
// Update the keyboard
diff --git a/Artemis/Artemis/Managers/LuaManager.cs b/Artemis/Artemis/Managers/LuaManager.cs
index fbd499a8b..bae48462d 100644
--- a/Artemis/Artemis/Managers/LuaManager.cs
+++ b/Artemis/Artemis/Managers/LuaManager.cs
@@ -35,7 +35,7 @@ namespace Artemis.Managers
public void SetupLua(ProfileModel profileModel)
{
- _logger.Debug("Setting up LUA for {0}-{1}.", profileModel?.Name, profileModel?.GameName);
+ _logger.Debug("Setting up LUA for profile '{0}', module '{1}'", profileModel?.Name, profileModel?.GameName);
// Clear old state
ClearLua();
diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs
index 68a50fd42..2d716f77e 100644
--- a/Artemis/Artemis/Managers/MainManager.cs
+++ b/Artemis/Artemis/Managers/MainManager.cs
@@ -4,7 +4,6 @@ using System.Reflection;
using System.Threading.Tasks;
using System.Timers;
using Artemis.Events;
-using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.DataReaders;
using Artemis.Utilities.GameState;
@@ -23,13 +22,13 @@ namespace Artemis.Managers
private readonly Timer _processTimer;
public MainManager(ILogger logger, LoopManager loopManager, DeviceManager deviceManager,
- EffectManager effectManager, ProfileManager profileManager, PipeServer pipeServer,
+ ModuleManager moduleManager, ProfileManager profileManager, PipeServer pipeServer,
GameStateWebServer gameStateWebServer)
{
Logger = logger;
LoopManager = loopManager;
DeviceManager = deviceManager;
- EffectManager = effectManager;
+ ModuleManager = moduleManager;
ProfileManager = profileManager;
PipeServer = pipeServer;
@@ -64,7 +63,7 @@ namespace Artemis.Managers
public ILogger Logger { get; set; }
public LoopManager LoopManager { get; }
public DeviceManager DeviceManager { get; set; }
- public EffectManager EffectManager { get; set; }
+ public ModuleManager ModuleManager { get; set; }
public ProfileManager ProfileManager { get; set; }
public PipeServer PipeServer { get; set; }
@@ -79,12 +78,12 @@ namespace Artemis.Managers
_processTimer?.Stop();
_processTimer?.Dispose();
LoopManager?.Stop();
- EffectManager?.ActiveEffect?.Dispose();
+ ModuleManager?.ActiveModule?.Dispose();
GameStateWebServer?.Stop();
PipeServer?.Stop();
}
- public event EventHandler OnEnabledChangedEvent;
+ public event EventHandler EnabledChanged;
///
/// Restarts the loop manager when the system resumes
@@ -126,7 +125,7 @@ namespace Artemis.Managers
}
///
- /// Manages active games by keeping an eye on their processes
+ /// Manages active process bound modules by keeping an eye on their processes
///
///
///
@@ -135,36 +134,38 @@ namespace Artemis.Managers
if (!ProgramEnabled)
return;
- var runningProcesses = System.Diagnostics.Process.GetProcesses();
+ var processes = System.Diagnostics.Process.GetProcesses();
+ var module = ModuleManager.ActiveModule;
- // If the currently active effect is a disabled game, get rid of it.
- if (EffectManager.ActiveEffect != null)
- EffectManager.DisableInactiveGame();
+ // If the active module is a process bound module, make sure it should still be enabled
+ if (module != null && module.IsBoundToProcess)
+ {
+ if (!module.Settings.IsEnabled)
+ ModuleManager.DisableProcessBoundModule();
- // If the currently active effect is a no longer running game, get rid of it.
- var activeGame = EffectManager.ActiveEffect as GameModel;
- if (activeGame != null)
- if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
+ // If the currently active effect is a no longer running game, get rid of it.
+ if (!processes.Any(p => p.ProcessName == module.ProcessName && p.HasExited == false))
{
- Logger.Info("Disabling game: {0}", activeGame.Name);
- EffectManager.DisableGame(activeGame);
+ Logger.Info("Disabling process bound module because process stopped: {0}", module.Name);
+ ModuleManager.DisableProcessBoundModule();
}
+ }
// Look for running games, stopping on the first one that's found.
- var newGame = EffectManager.EnabledGames
- .FirstOrDefault(g => runningProcesses
- .Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
+ var newModule = ModuleManager.ProcessModules.Where(g => g.Settings.IsEnabled && g.Settings.IsEnabled)
+ .FirstOrDefault(g => processes.Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));
- if (newGame == null || EffectManager.ActiveEffect == newGame)
+ if (newModule == null || module == newModule)
return;
+
// If it's not already enabled, do so.
- Logger.Info("Detected and enabling game: {0}", newGame.Name);
- EffectManager.ChangeEffect(newGame, LoopManager);
+ Logger.Info("Detected and enabling process bound module: {0}", newModule.Name);
+ ModuleManager.ChangeActiveModule(newModule, LoopManager);
}
protected virtual void RaiseEnabledChangedEvent(EnabledChangedEventArgs e)
{
- var handler = OnEnabledChangedEvent;
+ var handler = EnabledChanged;
handler?.Invoke(this, e);
}
}
diff --git a/Artemis/Artemis/Managers/ModuleManager.cs b/Artemis/Artemis/Managers/ModuleManager.cs
new file mode 100644
index 000000000..61724e88a
--- /dev/null
+++ b/Artemis/Artemis/Managers/ModuleManager.cs
@@ -0,0 +1,204 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Artemis.Events;
+using Artemis.Modules.Abstract;
+using Artemis.Settings;
+using Ninject.Extensions.Logging;
+
+namespace Artemis.Managers
+{
+ public class ModuleManager
+ {
+ private readonly DeviceManager _deviceManager;
+ private readonly ILogger _logger;
+ private ModuleModel _activeModule;
+ private LoopManager _waitLoopManager;
+ private ModuleModel _waitEffect;
+ private readonly GeneralSettings _generalSettings;
+
+ public ModuleManager(ILogger logger, DeviceManager deviceManager, List moduleModels)
+ {
+ _generalSettings = DAL.SettingsProvider.Load();
+ _logger = logger;
+ _deviceManager = deviceManager;
+
+ Modules = new List(moduleModels.Where(m => !m.IsOverlay && !m.IsBoundToProcess));
+ OverlayModules = new List(moduleModels.Where(m => m.IsOverlay));
+ // Exclude WoW if needed
+ ProcessModules = _generalSettings.GamestatePort == 62575
+ ? new List(moduleModels.Where(m => m.IsBoundToProcess))
+ : new List(moduleModels.Where(m => m.IsBoundToProcess && m.Name != "WoW"));
+
+ _logger.Info("Intialized ModuleManager");
+ }
+
+ public List Modules { get; set; }
+ public List ProcessModules { get; set; }
+ public List OverlayModules { get; set; }
+
+ public ModuleModel ActiveModule
+ {
+ get { return _activeModule; }
+ private set
+ {
+ _activeModule = value;
+ RaiseEffectChangedEvent(new ModuleChangedEventArgs(value));
+ }
+ }
+
+ public event EventHandler EffectChanged;
+
+ ///
+ /// Loads the last active module from settings and enables it.
+ ///
+ public ModuleModel GetLastModule()
+ {
+ _logger.Debug("Getting last module: {0}", _generalSettings.LastModule);
+
+ if (_generalSettings.LastModule != null)
+ {
+ var lastModule = Modules.FirstOrDefault(e => e.Name == _generalSettings.LastModule);
+ if (lastModule != null)
+ return lastModule;
+ }
+
+ _logger.Debug("Getting last module not found, defaulting to GeneralProfile");
+ return Modules.First(e => e.Name == "GeneralProfile");
+ }
+
+ ///
+ /// Disables the current module and changes it to the provided module.
+ ///
+ /// The module to activate
+ /// Optionally pass the LoopManager to automatically start it, if it's not running.
+ public void ChangeActiveModule(ModuleModel moduleModel, LoopManager loopManager = null)
+ {
+ if (_waitEffect != null)
+ {
+ _logger.Debug("Stopping module change because a change is already queued");
+ return;
+ }
+
+ if (moduleModel == null)
+ throw new ArgumentNullException(nameof(moduleModel));
+ if (moduleModel.IsOverlay)
+ throw new ArgumentException("Can't set an General module as the active module");
+
+ if (_deviceManager.ActiveKeyboard == null)
+ {
+ _logger.Debug("Stopping module change until keyboard is enabled");
+ _waitEffect = moduleModel;
+ _waitLoopManager = loopManager;
+ _deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
+ _deviceManager.EnableLastKeyboard();
+ return;
+ }
+
+ // Process bound modules are only used if they are enabled
+ if (moduleModel.Settings != null && !moduleModel.Settings.IsEnabled && moduleModel.IsBoundToProcess)
+ {
+ _logger.Debug("Cancelling module change, provided module is process bound and not enabled");
+ return;
+ }
+
+
+ var wasNull = false;
+ if (ActiveModule == null)
+ {
+ wasNull = true;
+ ActiveModule = moduleModel;
+ }
+
+ lock (ActiveModule)
+ {
+ if (!wasNull)
+ ActiveModule.Dispose();
+ lock (moduleModel)
+ {
+ ActiveModule = moduleModel;
+ ActiveModule.Enable();
+ if (!ActiveModule.IsInitialized)
+ {
+ _logger.Debug("Cancelling module change, couldn't initialize the module ({0})", moduleModel.Name);
+ ActiveModule = null;
+ return;
+ }
+ }
+ }
+
+ if (loopManager != null && !loopManager.Running)
+ {
+ _logger.Debug("Starting LoopManager for module change");
+ loopManager.StartAsync();
+ }
+
+ _logger.Debug("Changed active module to: {0}", moduleModel.Name);
+
+ if (ActiveModule.IsBoundToProcess || ActiveModule.IsOverlay || ActiveModule.Name == "Profile preview")
+ return;
+
+ // Regular modules are stored as the last active module
+ _generalSettings.LastModule = ActiveModule?.Name;
+ _generalSettings.Save();
+ }
+
+ private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
+ {
+ _deviceManager.OnKeyboardChanged -= DeviceManagerOnOnKeyboardChanged;
+ _logger.Debug("Resuming module change");
+
+ var module = _waitEffect;
+ _waitEffect = null;
+ var loopManager = _waitLoopManager;
+ _waitLoopManager = null;
+
+ ChangeActiveModule(module, loopManager);
+ }
+
+
+ ///
+ /// Clears the current module
+ ///
+ public void ClearActiveModule()
+ {
+ if (ActiveModule == null)
+ return;
+
+ lock (ActiveModule)
+ {
+ ActiveModule.Dispose();
+ ActiveModule = null;
+
+ _generalSettings.LastModule = null;
+ _generalSettings.Save();
+ }
+
+ _logger.Debug("Cleared active module");
+ }
+
+ ///
+ /// Disables the currently active process bound module
+ ///
+ public void DisableProcessBoundModule()
+ {
+ if (!ActiveModule.IsBoundToProcess)
+ {
+ _logger.Warn("Active module {0} is not process bound but is being disabled as if it is.",
+ ActiveModule.Name);
+ return;
+ }
+
+ if (GetLastModule() == null)
+ ClearActiveModule();
+ else
+ ChangeActiveModule(GetLastModule());
+ }
+
+ protected virtual void RaiseEffectChangedEvent(ModuleChangedEventArgs e)
+ {
+ var handler = EffectChanged;
+ handler?.Invoke(this, e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Managers/ProfileManager.cs b/Artemis/Artemis/Managers/ProfileManager.cs
index 8d5c36836..2cc2e1dc9 100644
--- a/Artemis/Artemis/Managers/ProfileManager.cs
+++ b/Artemis/Artemis/Managers/ProfileManager.cs
@@ -2,32 +2,31 @@
using System.Linq;
using System.Timers;
using Artemis.DAL;
-using Artemis.Models;
-using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.Modules.Abstract;
using Artemis.Settings;
-using Artemis.ViewModels.Abstract;
+using Ninject;
using Ninject.Extensions.Logging;
namespace Artemis.Managers
{
public class ProfileManager
{
- private readonly DeviceManager _deviceManager;
- private readonly EffectManager _effectManager;
private readonly ILogger _logger;
+ private readonly ModuleManager _moduleManager;
+ private readonly DeviceManager _deviceManager;
private readonly LoopManager _loopManager;
- private GeneralSettings _generalSettings;
+ private readonly GeneralSettings _generalSettings;
- public ProfileManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
+ public ProfileManager(ILogger logger, ModuleManager moduleManager, DeviceManager deviceManager,
LoopManager loopManager)
{
_logger = logger;
- _effectManager = effectManager;
+ _moduleManager = moduleManager;
_deviceManager = deviceManager;
_loopManager = loopManager;
_generalSettings = SettingsProvider.Load();
- GameViewModels = new List();
+ PreviewViewModules = new List();
var profilePreviewTimer = new Timer(500);
profilePreviewTimer.Elapsed += SetupProfilePreview;
@@ -36,9 +35,7 @@ namespace Artemis.Managers
_logger.Info("Intialized ProfileManager");
}
- public ProfilePreviewModel ProfilePreviewModel { get; set; }
-
- public List GameViewModels { get; set; }
+ public List PreviewViewModules { get; set; }
///
/// Keeps track of profiles being previewed and sets up the active efffect accordingly
@@ -47,44 +44,39 @@ namespace Artemis.Managers
///
private void SetupProfilePreview(object sender, ElapsedEventArgs e)
{
- if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard ||
- ProfilePreviewModel == null)
- return;
-
- lock (GameViewModels)
- {
- var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive);
-
- if (activePreview == null)
- {
- // Should not be active if no selected profile is set
- if (_effectManager.ActiveEffect != ProfilePreviewModel)
- return;
-
- _logger.Debug("Loading last effect after profile preview");
- var lastEffect = _effectManager.GetLastEffect();
- if (lastEffect != null)
- _effectManager.ChangeEffect(lastEffect);
- else
- _effectManager.ClearEffect();
- }
- else
- {
- if (_effectManager.ActiveEffect != ProfilePreviewModel &&
- !(_effectManager.ActiveEffect is GameModel))
- {
- _logger.Debug("Activate profile preview");
- _effectManager.ChangeEffect(ProfilePreviewModel);
- }
-
- // LoopManager might be running, this method won't do any harm in that case.
- _loopManager.StartAsync();
-
- ProfilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel;
- if (!ReferenceEquals(ProfilePreviewModel.Profile, activePreview.ProfileEditor.SelectedProfile))
- ProfilePreviewModel.Profile = activePreview.ProfileEditor.SelectedProfile;
- }
- }
+// if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard)
+// return;
+//
+// var activePreview = PreviewViewModules.FirstOrDefault(vm => vm.IsActive);
+// if (activePreview == null)
+// {
+// // Should not be active if no selected profile is set
+// if (_moduleManager.ActiveModule != _profilePreviewModel)
+// return;
+//
+// _logger.Debug("Loading last module after profile preview");
+// var lastModule = _moduleManager.GetLastModule();
+// if (lastModule != null)
+// _moduleManager.ChangeActiveModule(lastModule);
+// else
+// _moduleManager.ClearActiveModule();
+// }
+// else
+// {
+// if (_moduleManager.ActiveModule != null && _moduleManager.ActiveModule != _profilePreviewModel &&
+// _moduleManager.ActiveModule != activePreview.ModuleModel)
+// {
+// _logger.Debug("Activate profile preview");
+// _moduleManager.ChangeActiveModule(_profilePreviewModel);
+// }
+//
+// // LoopManager might be running, this method won't do any harm in that case.
+// _loopManager.StartAsync();
+//
+// // Can safely spam this, it won't do anything if they are equal
+// _profilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel;
+// _profilePreviewModel.ChangeProfile(activePreview.ModuleModel.ProfileModel);
+// }
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Models/EffectModel.cs b/Artemis/Artemis/Models/EffectModel.cs
deleted file mode 100644
index a2dd083df..000000000
--- a/Artemis/Artemis/Models/EffectModel.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Windows;
-using Artemis.DAL;
-using Artemis.Events;
-using Artemis.Managers;
-using Artemis.Models.Interfaces;
-using Artemis.Profiles;
-using Artemis.Profiles.Layers.Interfaces;
-using Artemis.Profiles.Layers.Models;
-using Artemis.Settings;
-using Newtonsoft.Json;
-using Ninject;
-using Ninject.Extensions.Logging;
-
-namespace Artemis.Models
-{
- public abstract class EffectModel : IDisposable
- {
- public delegate void SettingsUpdateHandler(EffectSettings settings);
-
- protected DateTime LastTrace;
-
- protected EffectModel(DeviceManager deviceManager, LuaManager luaManager, EffectSettings settings,
- IDataModel dataModel)
- {
- DeviceManager = deviceManager;
- LuaManager = luaManager;
- Settings = settings;
- DataModel = dataModel;
-
- DeviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;
- }
-
- public bool Initialized { get; set; }
- public DeviceManager DeviceManager { get; set; }
- public LuaManager LuaManager { get; }
- public EffectSettings Settings { get; set; }
- public string Name { get; set; }
- public int KeyboardScale { get; set; } = 4;
- // Used by profile system
- public IDataModel DataModel { get; set; }
-
- public ProfileModel Profile { get; set; }
-
- [Inject]
- public ILogger Logger { get; set; }
-
- public virtual void Dispose()
- {
- Profile?.Deactivate(LuaManager);
- Profile = null;
- }
-
- private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs args)
- {
- if (!Initialized)
- return;
-
- if (!string.IsNullOrEmpty(Settings?.LastProfile))
- Profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, Settings.LastProfile);
- else
- Profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, "Default");
-
- Profile?.Activate(LuaManager);
- }
-
- // Called on creation
- public virtual void Enable()
- {
- // If set, load the last profile from settings
- if (!string.IsNullOrEmpty(Settings?.LastProfile))
- Profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, Settings.LastProfile);
- else
- Profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, "Default");
-
- Profile?.Activate(LuaManager);
- }
-
- // Called every frame
- public abstract void Update();
-
- // Called after every update
- ///
- /// Renders the currently active profile
- ///
- ///
- ///
- public virtual void Render(RenderFrame frame, bool keyboardOnly)
- {
- if (Profile == null || DataModel == null || DeviceManager.ActiveKeyboard == null)
- return;
-
- lock (DataModel)
- {
- lock (Profile)
- {
- // Get all enabled layers who's conditions are met
- var renderLayers = GetRenderLayers(keyboardOnly);
-
- // If the profile has no active LUA wrapper, create one
- if (!string.IsNullOrEmpty(Profile.LuaScript))
- Profile.Activate(LuaManager);
-
- // Render the keyboard layer-by-layer
- var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
- using (var g = Graphics.FromImage(frame.KeyboardBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard),
- DataModel, keyboardRect, false, true, "keyboard");
- }
- // Render mice layer-by-layer
- var devRec = new Rect(0, 0, 40, 40);
- using (var g = Graphics.FromImage(frame.MouseBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mouse),
- DataModel, devRec, false, true, "mouse");
- }
- // Render headsets layer-by-layer
- using (var g = Graphics.FromImage(frame.HeadsetBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Headset),
- DataModel, devRec, false, true, "headset");
- }
- // Render generic devices layer-by-layer
- using (var g = Graphics.FromImage(frame.GenericBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Generic),
- DataModel, devRec, false, true, "generic");
- }
- // Render mousemats layer-by-layer
- using (var g = Graphics.FromImage(frame.MousematBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mousemat),
- DataModel, devRec, false, true, "mousemat");
- }
-
- // Trace debugging
- if (DateTime.Now.AddSeconds(-2) <= LastTrace || Logger == null)
- return;
-
- LastTrace = DateTime.Now;
- var dmJson = JsonConvert.SerializeObject(DataModel, Formatting.Indented);
- Logger.Trace("Effect datamodel as JSON: \r\n{0}", dmJson);
- Logger.Trace("Effect {0} has to render {1} layers", Name, renderLayers.Count);
- foreach (var renderLayer in renderLayers)
- Logger.Trace("- Layer name: {0}, layer type: {1}", renderLayer.Name, renderLayer.LayerType);
- }
- }
- }
-
- public abstract List GetRenderLayers(bool keyboardOnly);
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Models/GameModel.cs b/Artemis/Artemis/Models/GameModel.cs
deleted file mode 100644
index 402669db8..000000000
--- a/Artemis/Artemis/Models/GameModel.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Artemis.Managers;
-using Artemis.Models.Interfaces;
-using Artemis.Settings;
-
-namespace Artemis.Models
-{
- public abstract class GameModel : EffectModel
- {
- protected GameModel(DeviceManager deviceManager, LuaManager luaManager, GameSettings settings,
- IDataModel dataModel) : base(deviceManager, luaManager, settings, dataModel)
- {
- // Override settings to the GameSettings type
- Settings = settings;
- }
-
- public new GameSettings Settings { get; set; }
- public bool Enabled { get; set; }
- public string ProcessName { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Models/Interfaces/IDataModel.cs b/Artemis/Artemis/Models/Interfaces/IDataModel.cs
deleted file mode 100644
index 4e5a0ec07..000000000
--- a/Artemis/Artemis/Models/Interfaces/IDataModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Artemis.Models.Interfaces
-{
- public interface IDataModel
- {
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Models/OverlayModel.cs b/Artemis/Artemis/Models/OverlayModel.cs
deleted file mode 100644
index 9935ab89b..000000000
--- a/Artemis/Artemis/Models/OverlayModel.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Artemis.Managers;
-using Artemis.Settings;
-
-namespace Artemis.Models
-{
- public abstract class OverlayModel : EffectModel
- {
- private bool _enabled;
- public string ProcessName;
-
- protected OverlayModel(DeviceManager deviceManager, LuaManager luaManager, OverlaySettings settings)
- : base(deviceManager, luaManager, settings, null)
- {
- Settings = settings;
- Enabled = settings.Enabled;
- }
-
- public bool Enabled
- {
- get { return _enabled; }
- set
- {
- if (_enabled == value)
- return;
-
- if (value)
- Enable();
- else
- Dispose();
- _enabled = value;
- }
- }
-
- public new OverlaySettings Settings { get; set; }
- public abstract void RenderOverlay(RenderFrame frame, bool keyboardOnly);
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Abstract/ModuleDataModel.cs b/Artemis/Artemis/Modules/Abstract/ModuleDataModel.cs
new file mode 100644
index 000000000..48fbf1135
--- /dev/null
+++ b/Artemis/Artemis/Modules/Abstract/ModuleDataModel.cs
@@ -0,0 +1,7 @@
+namespace Artemis.Modules.Abstract
+{
+ public abstract class ModuleDataModel
+ {
+ public ModuleDataModel ParentDataModel { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Abstract/ModuleModel.cs b/Artemis/Artemis/Modules/Abstract/ModuleModel.cs
new file mode 100644
index 000000000..8f70ba617
--- /dev/null
+++ b/Artemis/Artemis/Modules/Abstract/ModuleModel.cs
@@ -0,0 +1,189 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows;
+using Artemis.DAL;
+using Artemis.Events;
+using Artemis.Managers;
+using Artemis.Profiles;
+using Artemis.Profiles.Layers.Interfaces;
+using Artemis.Profiles.Layers.Models;
+using Newtonsoft.Json;
+using Ninject;
+using Ninject.Extensions.Logging;
+
+namespace Artemis.Modules.Abstract
+{
+ public abstract class ModuleModel : IDisposable
+ {
+ private readonly LuaManager _luaManager;
+ protected readonly DeviceManager DeviceManager;
+ private DateTime _lastTrace;
+
+ public ModuleModel(DeviceManager deviceManager, LuaManager luaManager)
+ {
+ _luaManager = luaManager;
+
+ DeviceManager = deviceManager;
+ PreviewLayers = new List();
+
+ DeviceManager.OnKeyboardChanged += OnKeyboardChanged;
+ }
+
+ #region Abstract properties
+
+ ///
+ /// The module's name, used in setting files and logging
+ ///
+ public abstract string Name { get; }
+
+ ///
+ /// Whether or not the module should be rendered as an overlay
+ ///
+ public abstract bool IsOverlay { get; }
+
+ ///
+ /// Whether or not the module is enabled by a certain process
+ ///
+ public abstract bool IsBoundToProcess { get; }
+
+ ///
+ /// The module's settings
+ ///
+ public ModuleSettings Settings { get; set; }
+
+ ///
+ /// The module's data model
+ ///
+ public ModuleDataModel DataModel { get; set; }
+
+ #endregion
+
+ #region Base properties
+
+ [Inject]
+ public ILogger Logger { get; set; }
+
+ ///
+ /// Whether or not the module is initialized and ready to be updated/rendered
+ ///
+ public bool IsInitialized { get; protected set; }
+
+ ///
+ /// If this collection contains any layers they will be drawn instead of the regular profile
+ ///
+ public List PreviewLayers { get; set; }
+
+ ///
+ /// The process the module is bound to
+ ///
+ public string ProcessName { get; protected set; }
+
+ ///
+ /// The currently active profile of the module
+ ///
+ public ProfileModel ProfileModel { get; protected set; }
+
+ #endregion
+
+ #region Base methods
+
+ public void ChangeProfile(ProfileModel profileModel)
+ {
+ if (!IsInitialized || Equals(profileModel, ProfileModel))
+ return;
+
+ ProfileModel = profileModel;
+ ProfileModel?.Activate(_luaManager);
+ }
+
+ public virtual void Enable()
+ {
+ IsInitialized = true;
+ ChangeToLastProfile();
+ }
+
+ public virtual void Dispose()
+ {
+ IsInitialized = false;
+
+ PreviewLayers.Clear();
+ ProfileModel?.Deactivate(_luaManager);
+ ProfileModel = null;
+ }
+
+ private void OnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
+ {
+ ChangeToLastProfile();
+ }
+
+ private void ChangeToLastProfile()
+ {
+ var profileName = !string.IsNullOrEmpty(Settings?.LastProfile) ? Settings.LastProfile : "Default";
+ ChangeProfile(ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, profileName));
+ }
+
+ public abstract void Update();
+
+ public virtual void Render(RenderFrame frame, bool keyboardOnly)
+ {
+ if (ProfileModel == null || DataModel == null || DeviceManager.ActiveKeyboard == null)
+ return;
+
+ lock (DataModel)
+ {
+ lock (ProfileModel)
+ {
+ // Get all enabled layers who's conditions are met
+ var layers = GetRenderLayers(keyboardOnly);
+
+ // Render the keyboard layer-by-layer
+ var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle();
+ using (var g = Graphics.FromImage(frame.KeyboardBitmap))
+ {
+ ProfileModel?.DrawLayers(g, layers, DrawType.Keyboard, DataModel, keyboardRect, false, true);
+ }
+ // Render mice layer-by-layer
+ var devRec = new Rect(0, 0, 40, 40);
+ using (var g = Graphics.FromImage(frame.MouseBitmap))
+ {
+ ProfileModel?.DrawLayers(g, layers, DrawType.Mouse, DataModel, devRec, false, true);
+ }
+ // Render headsets layer-by-layer
+ using (var g = Graphics.FromImage(frame.HeadsetBitmap))
+ {
+ ProfileModel?.DrawLayers(g, layers, DrawType.Headset, DataModel, devRec, false, true);
+ }
+ // Render generic devices layer-by-layer
+ using (var g = Graphics.FromImage(frame.GenericBitmap))
+ {
+ ProfileModel?.DrawLayers(g, layers, DrawType.Generic, DataModel, devRec, false, true);
+ }
+ // Render mousemats layer-by-layer
+ using (var g = Graphics.FromImage(frame.MousematBitmap))
+ {
+ ProfileModel?.DrawLayers(g, layers, DrawType.Mousemat, DataModel, devRec, false, true);
+ }
+
+ // Trace debugging
+ if (DateTime.Now.AddSeconds(-2) <= _lastTrace || Logger == null)
+ return;
+
+ _lastTrace = DateTime.Now;
+ var dmJson = JsonConvert.SerializeObject(DataModel, Formatting.Indented);
+ Logger.Trace("Effect datamodel as JSON: \r\n{0}", dmJson);
+ Logger.Trace("Effect {0} has to render {1} layers", Name, layers.Count);
+ foreach (var renderLayer in layers)
+ Logger.Trace("- Layer name: {0}, layer type: {1}", renderLayer.Name, renderLayer.LayerType);
+ }
+ }
+ }
+
+ public virtual List GetRenderLayers(bool keyboardOnly)
+ {
+ return ProfileModel?.GetRenderLayers(DataModel, keyboardOnly);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Settings/EffectSettings.cs b/Artemis/Artemis/Modules/Abstract/ModuleSettings.cs
similarity index 68%
rename from Artemis/Artemis/Settings/EffectSettings.cs
rename to Artemis/Artemis/Modules/Abstract/ModuleSettings.cs
index 82568e08f..76518ea44 100644
--- a/Artemis/Artemis/Settings/EffectSettings.cs
+++ b/Artemis/Artemis/Modules/Abstract/ModuleSettings.cs
@@ -1,29 +1,34 @@
-using System.ComponentModel;
-using Artemis.DAL;
-using Newtonsoft.Json;
-
-namespace Artemis.Settings
-{
- public class EffectSettings : IArtemisSettings
- {
- [DefaultValue("Default")]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public string LastProfile { get; set; }
-
- public void Save()
- {
- SettingsProvider.Save(this);
- }
-
- public void Reset(bool save = false)
- {
- JsonConvert.PopulateObject("{}", this, new JsonSerializerSettings
- {
- ObjectCreationHandling = ObjectCreationHandling.Reuse
- });
-
- if (save)
- SettingsProvider.Save(this);
- }
- }
+using System.ComponentModel;
+using Artemis.DAL;
+using Artemis.Settings;
+using Newtonsoft.Json;
+
+namespace Artemis.Modules.Abstract
+{
+ public abstract class ModuleSettings : IArtemisSettings
+ {
+ [DefaultValue(true)]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public bool IsEnabled { get; set; }
+
+ [DefaultValue("Default")]
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ public string LastProfile { get; set; }
+
+ public void Save()
+ {
+ SettingsProvider.Save(this);
+ }
+
+ public void Reset(bool save = false)
+ {
+ JsonConvert.PopulateObject("{}", this, new JsonSerializerSettings
+ {
+ ObjectCreationHandling = ObjectCreationHandling.Reuse
+ });
+
+ if (save)
+ SettingsProvider.Save(this);
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Abstract/ModuleViewModel.cs b/Artemis/Artemis/Modules/Abstract/ModuleViewModel.cs
new file mode 100644
index 000000000..697b328f7
--- /dev/null
+++ b/Artemis/Artemis/Modules/Abstract/ModuleViewModel.cs
@@ -0,0 +1,137 @@
+using Artemis.Events;
+using Artemis.Managers;
+using Artemis.Services;
+using Artemis.ViewModels.Profiles;
+using Caliburn.Micro;
+using Ninject;
+using Ninject.Extensions.Logging;
+using Ninject.Parameters;
+
+namespace Artemis.Modules.Abstract
+{
+ public abstract class ModuleViewModel : Screen
+ {
+ private readonly ModuleManager _moduleManager;
+ private readonly MainManager _mainManager;
+ private ModuleSettings _settings;
+
+ public ModuleViewModel(MainManager mainManager, ModuleModel moduleModel, IKernel kernel)
+ {
+ _mainManager = mainManager;
+ _moduleManager = mainManager.ModuleManager;
+ ModuleModel = moduleModel;
+
+ Settings = moduleModel.Settings;
+ IParameter[] args =
+ {
+ new ConstructorArgument("mainManager", _mainManager),
+ new ConstructorArgument("moduleModel", ModuleModel),
+ new ConstructorArgument("lastProfile", Settings.LastProfile)
+ };
+ ProfileEditor = kernel.Get(args);
+
+ _mainManager.EnabledChanged += MainManagerOnEnabledChanged;
+ _moduleManager.EffectChanged += ModuleManagerOnModuleChanged;
+ }
+
+ public ProfileEditorViewModel ProfileEditor { get; set; }
+ public ModuleModel ModuleModel { get; }
+
+ [Inject]
+ public ILogger Logger { get; set; }
+
+ [Inject]
+ public MetroDialogService DialogService { get; set; }
+
+ public ModuleSettings Settings
+ {
+ get { return _settings; }
+ set
+ {
+ if (Equals(value, _settings)) return;
+ _settings = value;
+ NotifyOfPropertyChange(() => Settings);
+ }
+ }
+
+ public virtual bool IsModuleActive => _moduleManager.ActiveModule == ModuleModel;
+ public abstract bool UsesProfileEditor { get; }
+
+ private void MainManagerOnEnabledChanged(object sender, EnabledChangedEventArgs e)
+ {
+ NotifyOfPropertyChange(() => IsModuleActive);
+ UpdateIsEnabled();
+ }
+
+ private void ModuleManagerOnModuleChanged(object sender, ModuleChangedEventArgs e)
+ {
+ NotifyOfPropertyChange(() => IsModuleActive);
+ UpdateIsEnabled();
+ }
+
+ private void UpdateIsEnabled()
+ {
+ if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
+ return;
+
+ Settings.IsEnabled = IsModuleActive;
+ Settings.Save();
+ NotifyOfPropertyChange(() => Settings);
+ }
+
+ public virtual void ToggleModule()
+ {
+ Settings.IsEnabled = !Settings.IsEnabled;
+ Settings.Save();
+ NotifyOfPropertyChange(() => Settings);
+
+ // On process-bound modules, only set the module model
+ if (ModuleModel.IsBoundToProcess || ModuleModel.IsOverlay)
+ return;
+
+ // On other modules, activate them if necessary
+ if (IsModuleActive && !Settings.IsEnabled)
+ _moduleManager.ClearActiveModule();
+ else if (!IsModuleActive && Settings.IsEnabled)
+ _moduleManager.ChangeActiveModule(ModuleModel, _mainManager.LoopManager);
+ }
+
+ public virtual void SaveSettings()
+ {
+ Settings?.Save();
+ if (UsesProfileEditor)
+ ProfileEditor.SaveSelectedProfile();
+ if (!IsModuleActive)
+ return;
+
+ // Restart the module if it's currently running to apply settings.
+ _moduleManager.ChangeActiveModule(ModuleModel);
+ }
+
+ public virtual async void ResetSettings()
+ {
+ var resetConfirm = await DialogService.ShowQuestionMessageBox("Reset module settings",
+ "Are you sure you wish to reset this module's settings? \nAny changes you made will be lost.");
+
+ if (!resetConfirm.Value)
+ return;
+
+ Settings.Reset(true);
+ NotifyOfPropertyChange(() => Settings);
+
+ SaveSettings();
+ }
+
+ protected override void OnActivate()
+ {
+ base.OnActivate();
+ ProfileEditor.Activate();
+ }
+
+ protected override void OnDeactivate(bool close)
+ {
+ base.OnDeactivate(close);
+ ProfileEditor.Deactivate();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml
deleted file mode 100644
index 826776468..000000000
--- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml.cs b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml.cs
deleted file mode 100644
index 48d3709e2..000000000
--- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerView.xaml.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace Artemis.Modules.Effects.AudioVisualizer
-{
- ///
- /// Interaction logic for AudioVisualizerView.xaml
- ///
- public partial class AudioVisualizerView : UserControl
- {
- public AudioVisualizerView()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/Bubbles.cs b/Artemis/Artemis/Modules/Effects/Bubbles/Bubbles.cs
deleted file mode 100644
index fceb0c983..000000000
--- a/Artemis/Artemis/Modules/Effects/Bubbles/Bubbles.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.ComponentModel;
-using System.Configuration;
-
-namespace Artemis.Modules.Effects.Bubbles
-{
- // This class allows you to handle specific events on the settings class:
- // The SettingChanging event is raised before a setting's value is changed.
- // The PropertyChanged event is raised after a setting's value is changed.
- // The SettingsLoaded event is raised after the setting values are loaded.
- // The SettingsSaving event is raised before the setting values are saved.
- internal sealed partial class Bubbles
- {
- private void SettingChangingEventHandler(object sender, SettingChangingEventArgs e)
- {
- // Add code to handle the SettingChangingEvent event here.
- }
-
- private void SettingsSavingEventHandler(object sender, CancelEventArgs e)
- {
- // Add code to handle the SettingsSaving event here.
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesModel.cs b/Artemis/Artemis/Modules/Effects/Bubbles/BubblesModel.cs
deleted file mode 100644
index 3eb0f1e43..000000000
--- a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesModel.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows;
-using Artemis.DAL;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
-using Artemis.Utilities;
-using Point = System.Windows.Point;
-
-namespace Artemis.Modules.Effects.Bubbles
-{
- public class BubblesModel : EffectModel
- {
- #region Constructors
-
- public BubblesModel(DeviceManager deviceManager, LuaManager luaManager)
- : base(deviceManager, luaManager, SettingsProvider.Load(), null)
- {
- Name = "Bubbles";
- Initialized = false;
- Settings = (BubblesSettings) base.Settings;
- }
-
- #endregion
-
- #region Properties & Fields
-
- private static readonly Random _random = new Random();
-
- private readonly List _bubbles = new List();
-
- public new BubblesSettings Settings { get; }
-
- #endregion
-
- #region Methods
-
- public override void Enable()
- {
- KeyboardScale = Settings.Smoothness;
-
- var rect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
- var scaleFactor = Settings.Smoothness / 25.0;
-
- for (var i = 0; i < Settings.BubbleCount; i++)
- {
- var color = Settings.IsRandomColors
- ? ColorHelpers.GetRandomRainbowColor()
- : ColorHelpers.ToDrawingColor(Settings.BubbleColor);
- // -Settings.MoveSpeed because we want to spawn at least one move away from borders
- var initialPositionX = (rect.Width - Settings.BubbleSize * scaleFactor * 2 -
- Settings.MoveSpeed * scaleFactor) *
- _random.NextDouble() + Settings.BubbleSize * scaleFactor;
- var initialPositionY = (rect.Height - Settings.BubbleSize * scaleFactor * 2 -
- Settings.MoveSpeed * scaleFactor) *
- _random.NextDouble() + Settings.BubbleSize * scaleFactor;
- var initialDirectionX = Settings.MoveSpeed * scaleFactor * _random.NextDouble() *
- (_random.Next(1) == 0 ? -1 : 1);
- var initialDirectionY = (Settings.MoveSpeed * scaleFactor - Math.Abs(initialDirectionX)) *
- (_random.Next(1) == 0 ? -1 : 1);
-
- _bubbles.Add(new Bubble(color, (int) Math.Round(Settings.BubbleSize * scaleFactor),
- new Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
- }
-
- Initialized = true;
- }
-
- public override void Dispose()
- {
- _bubbles.Clear();
- Initialized = false;
- }
-
- public override void Update()
- {
- var keyboardRectangle = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
- foreach (var bubble in _bubbles)
- {
- if (Settings.IsShiftColors)
- bubble.Color = ColorHelpers.ShiftColor(bubble.Color,
- Settings.IsRandomColors
- ? (int) Math.Round(Settings.ShiftColorSpeed * _random.NextDouble())
- : Settings.ShiftColorSpeed);
-
- bubble.CheckCollision(keyboardRectangle);
- bubble.Move();
- }
- }
-
- public override void Render(RenderFrame frame, bool keyboardOnly)
- {
- using (var g = Graphics.FromImage(frame.KeyboardBitmap))
- {
- foreach (var bubble in _bubbles)
- bubble.Draw(g);
- }
- }
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return null;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs b/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
deleted file mode 100644
index d30118099..000000000
--- a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Windows;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Models.Interfaces;
-using Artemis.Profiles.Layers.Interfaces;
-using Artemis.Profiles.Layers.Models;
-using Artemis.Profiles.Lua;
-using Artemis.ViewModels.Profiles;
-using Castle.Components.DictionaryAdapter;
-using MoonSharp.Interpreter;
-
-namespace Artemis.Modules.Effects.ProfilePreview
-{
- public class ProfilePreviewModel : EffectModel
- {
- public ProfilePreviewModel(DeviceManager deviceManager, LuaManager luaManager): base(deviceManager, luaManager, null, new ProfilePreviewDataModel())
- {
- Name = "Profile Preview";
- }
-
- public ProfileViewModel ProfileViewModel { get; set; }
-
- public override void Dispose()
- {
- Initialized = false;
- base.Dispose();
- }
-
- public override void Enable()
- {
- Initialized = true;
- }
-
- public override void Update()
- {
- }
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return ProfileViewModel != null ? ProfileViewModel.GetRenderLayers() : new EditableList();
- }
-
- public override void Render(RenderFrame frame, bool keyboardOnly)
- {
- if ((Profile == null) || (DataModel == null) || (DeviceManager.ActiveKeyboard == null))
- return;
-
- lock (DataModel)
- {
- // Get all enabled layers who's conditions are met
- var renderLayers = GetRenderLayers(keyboardOnly);
-
- // If the profile has no active LUA wrapper, create one
- if (!Equals(LuaManager.ProfileModel, Profile))
- Profile.Activate(LuaManager);
-
- // Render the keyboard layer-by-layer
- var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
- using (var g = Graphics.FromImage(frame.KeyboardBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard),
- DataModel, keyboardRect, true, true, "keyboard");
- }
- // Render mice layer-by-layer
- var devRec = new Rect(0, 0, 40, 40);
- using (var g = Graphics.FromImage(frame.MouseBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mouse), DataModel,
- devRec, true, true, "mouse");
- }
- // Render headsets layer-by-layer
- using (var g = Graphics.FromImage(frame.HeadsetBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Headset),
- DataModel, devRec, true, true, "headset");
- }
- // Render generic devices layer-by-layer
- using (var g = Graphics.FromImage(frame.GenericBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Generic),
- DataModel, devRec, true, true, "generic");
- }
- // Render mousemats layer-by-layer
- using (var g = Graphics.FromImage(frame.MousematBitmap))
- {
- Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mousemat),
- DataModel, devRec, true, true, "mousemat");
- }
- }
- }
- }
-
- [MoonSharpUserData]
- public class ProfilePreviewDataModel : IDataModel
- {
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileSettings.cs b/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileSettings.cs
deleted file mode 100644
index adff6e1e7..000000000
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileSettings.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Artemis.Settings;
-
-namespace Artemis.Modules.Effects.WindowsProfile
-{
- public class WindowsProfileSettings : GameSettings
- {
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileViewModel.cs b/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileViewModel.cs
deleted file mode 100644
index 1f16bd4b4..000000000
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileViewModel.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System.ComponentModel;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Modules.Effects.ProfilePreview;
-using Artemis.ViewModels.Abstract;
-using Artemis.ViewModels.Profiles;
-using Ninject;
-using Ninject.Parameters;
-
-namespace Artemis.Modules.Effects.WindowsProfile
-{
- // TODO: This effect is a hybrid between a regular effect and a game, may want to clean this up
- public sealed class WindowsProfileViewModel : EffectViewModel
- {
- public WindowsProfileViewModel(MainManager main, IKernel kernel, ProfilePreviewModel profilePreviewModel,
- [Named("WindowsProfileModel")] EffectModel model) : base(main, model)
- {
- DisplayName = "Windows Profile";
- ProfilePreviewModel = profilePreviewModel;
- EffectSettings = ((WindowsProfileModel) EffectModel).Settings;
-
- IParameter[] args =
- {
- new ConstructorArgument("mainManager", main),
- new ConstructorArgument("effectModel", (WindowsProfileModel) EffectModel),
- new ConstructorArgument("lastProfile", ((WindowsProfileSettings) EffectSettings).LastProfile)
- };
- ProfileEditor = kernel.Get(args);
- ProfileEditor.PropertyChanged += ProfileUpdater;
-
- EffectModel.Profile = ProfileEditor.SelectedProfile;
- ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
- }
-
- public ProfileEditorViewModel ProfileEditor { get; set; }
- public ProfilePreviewModel ProfilePreviewModel { get; set; }
-
- private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
- {
- if ((e.PropertyName != "SelectedProfile") && IsActive)
- return;
-
- EffectModel.Profile = ProfileEditor.SelectedProfile;
- ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
-
- if ((e.PropertyName != "SelectedProfile") || !ProfileEditor.ProfileViewModel.Activated ||
- (ProfileEditor.ProfileViewModel.SelectedProfile == null))
- return;
-
- ((WindowsProfileSettings) EffectSettings).LastProfile = ProfileEditor.ProfileViewModel.SelectedProfile.Name;
- EffectSettings.Save();
- }
-
- public override void SaveSettings()
- {
- ProfileEditor.SaveSelectedProfile();
- base.SaveSettings();
- }
-
- protected override void OnActivate()
- {
- base.OnActivate();
- ProfileEditor.Activate();
- }
-
- protected override void OnDeactivate(bool close)
- {
- base.OnDeactivate(close);
- ProfileEditor.Deactivate();
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs
index 546937029..769be1fc3 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs
@@ -1,11 +1,11 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.CounterStrike
{
[MoonSharpUserData]
- public class CounterStrikeDataModel : IDataModel
+ public class CounterStrikeDataModel : ModuleDataModel
{
public Provider provider { get; set; }
public Map map { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
index cb4ffe5a4..284436c60 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
@@ -1,10 +1,8 @@
using System;
-using System.Collections.Generic;
using System.IO;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
using Artemis.Properties;
using Artemis.Services;
using Artemis.Utilities;
@@ -13,7 +11,7 @@ using Newtonsoft.Json;
namespace Artemis.Modules.Games.CounterStrike
{
- public class CounterStrikeModel : GameModel
+ public class CounterStrikeModel : ModuleModel
{
private readonly MetroDialogService _dialogService;
private readonly GameStateWebServer _gameStateWebServer;
@@ -22,40 +20,34 @@ namespace Artemis.Modules.Games.CounterStrike
private DateTime _lastKill;
private int _lastKills;
- public CounterStrikeModel(DeviceManager deviceManager, LuaManager luaManager,
- GameStateWebServer gameStateWebServer, MetroDialogService dialogService)
- : base(deviceManager, luaManager, SettingsProvider.Load(),
- new CounterStrikeDataModel())
+ public CounterStrikeModel(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService,
+ GameStateWebServer gameStateWebServer) : base(deviceManager, luaManager)
{
_gameStateWebServer = gameStateWebServer;
_dialogService = dialogService;
- Name = "CounterStrike";
+ Settings = SettingsProvider.Load();
+ DataModel = new CounterStrikeDataModel();
ProcessName = "csgo";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
FindGameDir();
PlaceConfigFile();
}
- public int Scale { get; set; }
+ public override string Name => "CounterStrike";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
public override void Dispose()
{
- Initialized = false;
- _gameStateWebServer.GameDataReceived -= HandleGameData;
-
base.Dispose();
+ _gameStateWebServer.GameDataReceived -= HandleGameData;
}
public override void Enable()
{
- base.Enable();
-
_gameStateWebServer.GameDataReceived += HandleGameData;
- Initialized = true;
+ base.Enable();
}
public override void Update()
@@ -80,8 +72,10 @@ namespace Artemis.Modules.Games.CounterStrike
dm.player.state.made_kill = true;
_lastKill = DateTime.Now;
}
- else if (dm.player.state.made_kill && (DateTime.Now - _lastKill > TimeSpan.FromMilliseconds(500)))
+ else if (dm.player.state.made_kill && DateTime.Now - _lastKill > TimeSpan.FromMilliseconds(500))
+ {
dm.player.state.made_kill = false;
+ }
_lastKills = dm.player.state.round_kills;
// Detect a headshot
@@ -90,8 +84,10 @@ namespace Artemis.Modules.Games.CounterStrike
dm.player.state.made_headshot = true;
_lastHeadshot = DateTime.Now;
}
- else if (dm.player.state.made_headshot && (DateTime.Now - _lastHeadshot > TimeSpan.FromMilliseconds(500)))
+ else if (dm.player.state.made_headshot && DateTime.Now - _lastHeadshot > TimeSpan.FromMilliseconds(500))
+ {
dm.player.state.made_headshot = false;
+ }
_lastHeadshots = dm.player.state.round_killhs;
// Detect a round win
@@ -106,7 +102,7 @@ namespace Artemis.Modules.Games.CounterStrike
{
var gameSettings = (CounterStrikeSettings) Settings;
// If already propertly set up, don't do anything
- if ((gameSettings.GameDirectory != null) && File.Exists(gameSettings.GameDirectory + "csgo.exe") &&
+ if (gameSettings.GameDirectory != null && File.Exists(gameSettings.GameDirectory + "csgo.exe") &&
File.Exists(gameSettings.GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg"))
return;
@@ -159,11 +155,5 @@ namespace Artemis.Modules.Games.CounterStrike
throw;
}
}
-
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeSettings.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeSettings.cs
index cb5d20c9b..d0845801f 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeSettings.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeSettings.cs
@@ -1,8 +1,9 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
+using Artemis.Settings;
namespace Artemis.Modules.Games.CounterStrike
{
- public class CounterStrikeSettings : GameSettings
+ public class CounterStrikeSettings : ModuleSettings
{
public string GameDirectory { get; set; }
}
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
index 8cc599305..52f0ef258 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
@@ -28,11 +28,12 @@
-
-
+
+ ToolTip="Note: You can't enable an module when Artemis is disabled"
+ IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
+ cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
@@ -43,7 +44,7 @@
diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
index ce7fff67a..53608861b 100644
--- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
@@ -1,30 +1,31 @@
using System.Windows.Forms;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
+using Artemis.Modules.Abstract;
using Ninject;
namespace Artemis.Modules.Games.Overwatch
{
- public sealed class OverwatchViewModel : GameViewModel
+ public sealed class OverwatchViewModel : ModuleViewModel
{
- public OverwatchViewModel(MainManager main, IKernel kernel, [Named("OverwatchModel")] GameModel model)
- : base(main, model, kernel)
+ public OverwatchViewModel(MainManager mainManager, [Named(nameof(OverwatchModel))] ModuleModel moduleModel,
+ IKernel kernel) : base(mainManager, moduleModel, kernel)
{
DisplayName = "Overwatch";
}
+ public override bool UsesProfileEditor => true;
+
public void BrowseDirectory()
{
- var dialog = new FolderBrowserDialog {SelectedPath = ((OverwatchSettings) GameSettings).GameDirectory};
+ var dialog = new FolderBrowserDialog {SelectedPath = ((OverwatchSettings) Settings).GameDirectory};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
- ((OverwatchSettings) GameSettings).GameDirectory = dialog.SelectedPath;
- GameSettings.Save();
- ((OverwatchModel) GameModel).PlaceDll();
- NotifyOfPropertyChange(() => GameSettings);
+ ((OverwatchSettings) Settings).GameDirectory = dialog.SelectedPath;
+ ((OverwatchModel) ModuleModel).PlaceDll();
+ Settings.Save();
+ NotifyOfPropertyChange(() => Settings);
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsDataModel.cs b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsDataModel.cs
index 9271a0f1e..250f63e0e 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsDataModel.cs
@@ -1,11 +1,11 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Modules.Games.ProjectCars.Data;
using MoonSharp.Interpreter;
namespace Artemis.Modules.Games.ProjectCars
{
[MoonSharpUserData]
- public class ProjectCarsDataModel : IDataModel
+ public class ProjectCarsDataModel : ModuleDataModel
{
public ProjectCarsDataModel()
{
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsModel.cs b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsModel.cs
index c1bb99c98..787b5a12a 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsModel.cs
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsModel.cs
@@ -1,56 +1,31 @@
-using System.Collections.Generic;
-using Artemis.DAL;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Modules.Games.ProjectCars.Data;
-using Artemis.Profiles.Layers.Models;
-using Artemis.Services;
-
-namespace Artemis.Modules.Games.ProjectCars
-{
- public class ProjectCarsModel : GameModel
- {
- private readonly MetroDialogService _dialogService;
-
- public ProjectCarsModel(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService)
- : base(deviceManager, luaManager, SettingsProvider.Load(), new ProjectCarsDataModel())
- {
- _dialogService = dialogService;
- Name = "ProjectCars";
- ProcessName = "pCARS64";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
- }
-
- public int Scale { get; set; }
-
- public override void Dispose()
- {
- Initialized = false;
- base.Dispose();
- }
-
- public override void Enable()
- {
- base.Enable();
-
- Initialized = true;
- }
-
- public override void Update()
- {
- var dataModel = (ProjectCarsDataModel) DataModel;
- var returnTuple = pCarsAPI_GetData.ReadSharedMemoryData();
-
- // item1 is the true/false indicating a good read or not
- if (returnTuple.Item1)
- dataModel.GameData = dataModel.GameData.MapStructToClass(returnTuple.Item2, dataModel.GameData);
- }
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
- }
+using Artemis.DAL;
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Artemis.Modules.Games.ProjectCars.Data;
+
+namespace Artemis.Modules.Games.ProjectCars
+{
+ public class ProjectCarsModel : ModuleModel
+ {
+ public ProjectCarsModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
+ {
+ Settings = SettingsProvider.Load();
+ DataModel = new ProjectCarsDataModel();
+ ProcessName = "pCARS64";
+ }
+
+ public override string Name => "ProjectCars";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
+
+ public override void Update()
+ {
+ var dataModel = (ProjectCarsDataModel) DataModel;
+ var returnTuple = pCarsAPI_GetData.ReadSharedMemoryData();
+
+ // item1 is the true/false indicating a good read or not
+ if (returnTuple.Item1)
+ dataModel.GameData = dataModel.GameData.MapStructToClass(returnTuple.Item2, dataModel.GameData);
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsSettings.cs b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsSettings.cs
index 4c2cdaab5..6f0462e0c 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsSettings.cs
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsSettings.cs
@@ -1,9 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.ProjectCars
{
- public class ProjectCarsSettings : GameSettings
+ public class ProjectCarsSettings : ModuleSettings
{
- public string GameDirectory { get; set; }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsView.xaml b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsView.xaml
index e31d9c3be..cef09d6fc 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsView.xaml
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsView.xaml
@@ -46,11 +46,12 @@
project by MikeyTT
-
-
+
+
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsViewModel.cs b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsViewModel.cs
index 955b14efa..737558909 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/ProjectCarsViewModel.cs
@@ -1,16 +1,17 @@
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
+using Artemis.Modules.Abstract;
using Ninject;
namespace Artemis.Modules.Games.ProjectCars
{
- public sealed class ProjectCarsViewModel : GameViewModel
+ public sealed class ProjectCarsViewModel : ModuleViewModel
{
- public ProjectCarsViewModel(MainManager main, IKernel kernel,
- [Named("ProjectCarsModel")] GameModel model) : base(main, model, kernel)
+ public ProjectCarsViewModel(MainManager mainManager, [Named(nameof(ProjectCarsModel))] ModuleModel moduleModel,
+ IKernel kernel) : base(mainManager, moduleModel, kernel)
{
DisplayName = "Project CARS";
}
+
+ public override bool UsesProfileEditor => true;
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueDataModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueDataModel.cs
index 287f87fe2..80d746b31 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueDataModel.cs
@@ -1,10 +1,10 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
namespace Artemis.Modules.Games.RocketLeague
{
[MoonSharpUserData]
- public class RocketLeagueDataModel : IDataModel
+ public class RocketLeagueDataModel : ModuleDataModel
{
public int Boost { get; set; }
}
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
index abe3193c4..750c29643 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
@@ -1,29 +1,24 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Linq;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Memory;
-using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague
{
- public class RocketLeagueModel : GameModel
+ public class RocketLeagueModel : ModuleModel
{
private Memory _memory;
private GamePointersCollection _pointer;
- public RocketLeagueModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager, SettingsProvider.Load(), new RocketLeagueDataModel())
+
+ public RocketLeagueModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
{
- Name = "RocketLeague";
+ Settings = SettingsProvider.Load();
+ DataModel = new RocketLeagueDataModel();
ProcessName = "RocketLeague";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
// Generate a new offset when the game is updated
//var offset = new GamePointersCollection
@@ -43,20 +38,20 @@ namespace Artemis.Modules.Games.RocketLeague
//var res = JsonConvert.SerializeObject(offset, Formatting.Indented);
}
- public int Scale { get; set; }
+ public override string Name => "RocketLeague";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
public override void Dispose()
{
- Initialized = false;
- _memory = null;
base.Dispose();
+
+ _memory?.Dispose();
+ _memory = null;
}
public override void Enable()
{
- base.Enable();
-
- Initialized = false;
Updater.GetPointers();
_pointer = SettingsProvider.Load().RocketLeague;
@@ -66,17 +61,17 @@ namespace Artemis.Modules.Games.RocketLeague
_memory = new Memory(tempProcess);
- Initialized = true;
+ base.Enable();
}
public override void Update()
{
- if ((Profile == null) || (DataModel == null) || (_memory == null))
+ if (ProfileModel == null || DataModel == null || _memory == null)
return;
var offsets = _pointer.GameAddresses.First(ga => ga.Description == "Boost").ToString();
var boostAddress = _memory.GetAddress("\"RocketLeague.exe\"" + offsets);
- var boostInt = (int) (_memory.ReadFloat(boostAddress)*100);
+ var boostInt = (int) (_memory.ReadFloat(boostAddress) * 100);
if (boostInt > 100)
boostInt = 100;
if (boostInt < 0)
@@ -84,10 +79,5 @@ namespace Artemis.Modules.Games.RocketLeague
((RocketLeagueDataModel) DataModel).Boost = boostInt;
}
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueSettings.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueSettings.cs
index 38d0c3bfa..d9a3e8697 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueSettings.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueSettings.cs
@@ -1,8 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.RocketLeague
{
- public class RocketLeagueSettings : GameSettings
+ public class RocketLeagueSettings : ModuleSettings
{
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml
index 5bdbc3e76..bde64be05 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml
@@ -3,9 +3,7 @@
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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:cal="http://www.caliburnproject.org"
- xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772">
@@ -19,8 +17,6 @@
-
-
@@ -32,19 +28,25 @@
-
-
+
+ ToolTip="Note: You can't enable an module when Artemis is disabled"
+ IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
+ cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
+
+
-
+
true;
+
public string VersionText
{
get { return _versionText; }
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
index 8411289d1..0bd80f9eb 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs
@@ -1,10 +1,10 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
namespace Artemis.Modules.Games.TheDivision
{
[MoonSharpUserData]
- public class TheDivisionDataModel : IDataModel
+ public class TheDivisionDataModel : ModuleDataModel
{
public PlayerState PartyMember1 { get; set; }
public PlayerState PartyMember2 { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
index c80b08998..9892a08f1 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
@@ -3,35 +3,35 @@ using System.Threading;
using System.Threading.Tasks;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
using Artemis.Utilities;
using Artemis.Utilities.DataReaders;
namespace Artemis.Modules.Games.TheDivision
{
- public class TheDivisionModel : GameModel
+ public class TheDivisionModel : ModuleModel
{
private readonly PipeServer _pipeServer;
private StickyValue _stickyAmmo;
private StickyValue _stickyHp;
public TheDivisionModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer)
- : base(deviceManager, luaManager, SettingsProvider.Load(), new TheDivisionDataModel())
+ : base(deviceManager, luaManager)
{
_pipeServer = pipeServer;
- Name = "TheDivision";
+
+ Settings = SettingsProvider.Load();
+ DataModel = new TheDivisionDataModel();
ProcessName = "TheDivision";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
}
- public int Scale { get; set; }
+ public override string Name => "TheDivision";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
public override void Dispose()
{
- Initialized = false;
+ base.Dispose();
// Delay restoring the DLL to allow The Division to release it
Task.Factory.StartNew(() =>
@@ -42,28 +42,24 @@ namespace Artemis.Modules.Games.TheDivision
_stickyAmmo?.Dispose();
_stickyHp?.Dispose();
-
_pipeServer.PipeMessage -= PipeServerOnPipeMessage;
- base.Dispose();
}
public override void Enable()
{
- base.Enable();
-
- Initialized = false;
_stickyAmmo = new StickyValue(200);
_stickyHp = new StickyValue(200);
DllManager.PlaceLogitechDll();
_pipeServer.PipeMessage += PipeServerOnPipeMessage;
- Initialized = true;
+
+ base.Enable();
}
private void PipeServerOnPipeMessage(string reply)
{
- if (!Initialized)
+ if (!IsInitialized)
return;
// Convert the given string to a list of ints
@@ -86,7 +82,7 @@ namespace Artemis.Modules.Games.TheDivision
var bPer = parts[4];
// F1 to F4 indicate the player and his party. Blinks red on damage taken
- if ((keyCode >= 59) && (keyCode <= 62))
+ if (keyCode >= 59 && keyCode <= 62)
{
var playerId = keyCode - 58;
@@ -110,15 +106,15 @@ namespace Artemis.Modules.Games.TheDivision
// R blinks white when low on ammo
else if (keyCode == 19)
{
- _stickyAmmo.Value = (rPer == 100) && (gPer > 1) && (bPer > 1);
+ _stickyAmmo.Value = rPer == 100 && gPer > 1 && bPer > 1;
gameDataModel.LowAmmo = _stickyAmmo.Value;
}
// G turns white when holding a grenade, turns off when out of grenades
else if (keyCode == 34)
{
- if ((rPer == 100) && (gPer < 10) && (bPer < 10))
+ if (rPer == 100 && gPer < 10 && bPer < 10)
gameDataModel.GrenadeState = GrenadeState.HasGrenade;
- else if ((rPer == 100) && (gPer > 10) && (bPer > 10))
+ else if (rPer == 100 && gPer > 10 && bPer > 10)
gameDataModel.GrenadeState = GrenadeState.GrenadeEquipped;
else
gameDataModel.GrenadeState = GrenadeState.HasNoGrenade;
@@ -126,7 +122,7 @@ namespace Artemis.Modules.Games.TheDivision
// V blinks on low HP
else if (keyCode == 47)
{
- _stickyHp.Value = (rPer == 100) && (gPer > 1) && (bPer > 1);
+ _stickyHp.Value = rPer == 100 && gPer > 1 && bPer > 1;
gameDataModel.LowHp = _stickyHp.Value;
}
}
@@ -135,10 +131,5 @@ namespace Artemis.Modules.Games.TheDivision
{
// DataModel updating is done whenever a pipe message is received
}
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionSettings.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionSettings.cs
index c3f0c2ea1..2e0f96af0 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionSettings.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionSettings.cs
@@ -1,8 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.TheDivision
{
- public class TheDivisionSettings : GameSettings
+ public class TheDivisionSettings : ModuleSettings
{
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
index cd3c3aaf6..a73058315 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
@@ -29,11 +29,12 @@
-
-
+
+ ToolTip="Note: You can't enable an module when Artemis is disabled"
+ IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
+ cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
index 8105574be..1239cf98b 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionViewModel.cs
@@ -1,16 +1,17 @@
-using Ninject;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Ninject;
namespace Artemis.Modules.Games.TheDivision
{
- public sealed class TheDivisionViewModel : GameViewModel
+ public sealed class TheDivisionViewModel : ModuleViewModel
{
- public TheDivisionViewModel(MainManager main, IKernel kernel, [Named("TheDivisionModel")] GameModel model)
- : base(main, model, kernel)
+ public TheDivisionViewModel(MainManager mainManager, [Named(nameof(TheDivisionModel))] ModuleModel moduleModel,
+ IKernel kernel) : base(mainManager, moduleModel, kernel)
{
DisplayName = "The Division";
}
+
+ public override bool UsesProfileEditor => true;
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs
index d11a0f530..953bb7dcb 100644
--- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs
@@ -1,12 +1,12 @@
using System.ComponentModel;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.UnrealTournament
{
[MoonSharpUserData]
- public class UnrealTournamentDataModel : IDataModel
+ public class UnrealTournamentDataModel : ModuleDataModel
{
public State State { get; set; }
public Environment Environment { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs
index 142e852c4..09e9cf587 100644
--- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs
+++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs
@@ -1,16 +1,13 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Timers;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
using Artemis.Properties;
using Artemis.Services;
-using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.DataReaders;
using Newtonsoft.Json;
@@ -18,25 +15,22 @@ using Newtonsoft.Json.Linq;
namespace Artemis.Modules.Games.UnrealTournament
{
- public class UnrealTournamentModel : GameModel
+ public class UnrealTournamentModel : ModuleModel
{
- private readonly PipeServer _pipeServer;
private readonly MetroDialogService _dialogService;
- private Timer _killTimer;
+ private readonly PipeServer _pipeServer;
+ private readonly Timer _killTimer;
private int _lastScore;
public UnrealTournamentModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer,
- MetroDialogService dialogService)
- : base(deviceManager, luaManager, SettingsProvider.Load(),
- new UnrealTournamentDataModel())
+ MetroDialogService dialogService) : base(deviceManager, luaManager)
{
_pipeServer = pipeServer;
_dialogService = dialogService;
- Name = "UnrealTournament";
+
+ Settings = SettingsProvider.Load();
+ DataModel = new UnrealTournamentDataModel();
ProcessName = "UE4-Win64-Shipping";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
_killTimer = new Timer(3500);
_killTimer.Elapsed += KillTimerOnElapsed;
@@ -44,11 +38,15 @@ namespace Artemis.Modules.Games.UnrealTournament
FindGame();
}
+ public override string Name => "UnrealTournament";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
+
public void FindGame()
{
var gameSettings = (UnrealTournamentSettings) Settings;
// If already propertly set up, don't do anything
- if ((gameSettings.GameDirectory != null) &&
+ if (gameSettings.GameDirectory != null &&
File.Exists(gameSettings.GameDirectory + "UE4-Win64-Shipping.exe"))
return;
@@ -56,12 +54,10 @@ namespace Artemis.Modules.Games.UnrealTournament
if (!File.Exists(@"C:\ProgramData\Epic\UnrealEngineLauncher\LauncherInstalled.dat"))
return;
- var json =
- JsonConvert.DeserializeObject(
- File.ReadAllText(@"C:\ProgramData\Epic\UnrealEngineLauncher\LauncherInstalled.dat"));
- var utEntry =
- json["InstallationList"].Children()
- .FirstOrDefault(c => c["AppName"].Value() == "UnrealTournamentDev");
+ var json = JsonConvert.DeserializeObject(
+ File.ReadAllText(@"C:\ProgramData\Epic\UnrealEngineLauncher\LauncherInstalled.dat"));
+ var utEntry = json["InstallationList"].Children()
+ .FirstOrDefault(c => c["AppName"].Value() == "UnrealTournamentDev");
if (utEntry == null)
return;
@@ -113,25 +109,20 @@ namespace Artemis.Modules.Games.UnrealTournament
Logger?.Info("Installed Unreal Tournament plugin in '{0}'", path);
}
- public int Scale { get; set; }
-
public override void Dispose()
{
- Initialized = false;
+ base.Dispose();
_killTimer.Stop();
_pipeServer.PipeMessage -= PipeServerOnPipeMessage;
- base.Dispose();
}
public override void Enable()
{
- base.Enable();
-
_pipeServer.PipeMessage += PipeServerOnPipeMessage;
_killTimer.Start();
- Initialized = true;
+ base.Enable();
}
private void PipeServerOnPipeMessage(string message)
@@ -181,10 +172,5 @@ namespace Artemis.Modules.Games.UnrealTournament
if (dataModel.Player != null)
dataModel.Player.KillState = KillState.None;
}
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs
index 6de639c81..8c9ed9549 100644
--- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs
+++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs
@@ -1,8 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.UnrealTournament
{
- public class UnrealTournamentSettings : GameSettings
+ public class UnrealTournamentSettings : ModuleSettings
{
public string GameDirectory { get; set; }
}
diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml
index df2b3afc9..beaafe4a7 100644
--- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml
+++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml
@@ -29,11 +29,12 @@
-
-
+
+
@@ -45,7 +46,7 @@
true;
public void BrowseDirectory()
{
- var dialog = new FolderBrowserDialog
- {
- SelectedPath = ((UnrealTournamentSettings) GameSettings).GameDirectory
- };
+ var dialog = new FolderBrowserDialog {SelectedPath = ((UnrealTournamentSettings) Settings).GameDirectory};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
- ((UnrealTournamentSettings) GameSettings).GameDirectory = dialog.SelectedPath;
- GameSettings.Save();
- ((UnrealTournamentModel) GameModel).PlaceFiles();
- NotifyOfPropertyChange(() => GameSettings);
+ ((UnrealTournamentSettings) Settings).GameDirectory = dialog.SelectedPath;
+ ((UnrealTournamentModel) ModuleModel).PlaceFiles();
+ Settings.Save();
+ NotifyOfPropertyChange(() => Settings);
}
// Installing GIF on editor open to make sure the proper profiles are loaded
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3DataModel.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3DataModel.cs
index 35c1c9e8f..3fbe6bacc 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3DataModel.cs
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3DataModel.cs
@@ -1,10 +1,10 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
namespace Artemis.Modules.Games.Witcher3
{
[MoonSharpUserData]
- public class Witcher3DataModel : IDataModel
+ public class Witcher3DataModel : ModuleDataModel
{
public WitcherSign WitcherSign { get; set; }
public int MaxHealth { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs
index 109d80155..b1f74fc23 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs
@@ -1,51 +1,44 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.Witcher3
{
- public class Witcher3Model : GameModel
+ public class Witcher3Model : ModuleModel
{
private readonly Regex _configRegex;
private readonly Stopwatch _updateSw;
private string _witcherSettings;
- public Witcher3Model(DeviceManager deviceManager, LuaManager luaManager)
- : base(deviceManager, luaManager, SettingsProvider.Load(), new Witcher3DataModel())
+ public Witcher3Model(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
{
- Name = "Witcher3";
- ProcessName = "witcher3";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
-
_updateSw = new Stopwatch();
_configRegex = new Regex("\\[Artemis\\](.+?)\\[", RegexOptions.Singleline);
+
+ Settings = SettingsProvider.Load();
+ DataModel = new Witcher3DataModel();
+ ProcessName = "witcher3";
}
- public int Scale { get; set; }
+ public override string Name => "Witcher3";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
public override void Dispose()
{
- Initialized = false;
- _witcherSettings = null;
-
- _updateSw.Reset();
base.Dispose();
+
+ _witcherSettings = null;
+ _updateSw.Reset();
}
public override void Enable()
{
- base.Enable();
-
- Initialized = false;
// Ensure the config file is found
var witcherSettings = Environment.GetFolderPath(Environment.SpecialFolder.Personal) +
@"\The Witcher 3\user.settings";
@@ -54,7 +47,7 @@ namespace Artemis.Modules.Games.Witcher3
_updateSw.Start();
- Initialized = true;
+ base.Enable();
}
public override void Update()
@@ -139,10 +132,5 @@ namespace Artemis.Modules.Games.Witcher3
gameDataModel.Vitality = vitalityInt;
}
}
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Settings.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Settings.cs
index af2173169..bb239f5b8 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Settings.cs
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Settings.cs
@@ -1,8 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.Witcher3
{
- public class Witcher3Settings : GameSettings
+ public class Witcher3Settings : ModuleSettings
{
// TODO: Change this to work the same as UT
public string GameDirectory { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
index c8e7be806..a534a78b2 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
@@ -27,11 +27,12 @@
-
-
+
+
true;
+
public async void AutoInstall()
{
// Request The Witcher 3 folder
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs b/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
index 346317eda..3edf73ecc 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWDataModel.cs
@@ -1,9 +1,9 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Modules.Games.WoW.Data;
namespace Artemis.Modules.Games.WoW
{
- public class WoWDataModel : IDataModel
+ public class WoWDataModel : ModuleDataModel
{
public WoWUnit Player { get; set; }
public WoWUnit Target { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs b/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
index 400901f17..e1aa1688a 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWModel.cs
@@ -1,11 +1,9 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
+using Artemis.Modules.Abstract;
using Artemis.Modules.Games.WoW.Data;
-using Artemis.Profiles.Layers.Models;
using Artemis.Settings;
using Artemis.Utilities.Memory;
using Process.NET;
@@ -13,24 +11,22 @@ using Process.NET.Memory;
namespace Artemis.Modules.Games.WoW
{
- public class WoWModel : GameModel
+ public class WoWModel : ModuleModel
{
private readonly GamePointersCollection _pointer;
private ProcessSharp _process;
- public WoWModel(DeviceManager deviceManager, LuaManager luaManager)
- : base(deviceManager, luaManager, SettingsProvider.Load(), new WoWDataModel())
+
+ public WoWModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
{
- Name = "WoW";
+ Settings = SettingsProvider.Load();
+ DataModel = new WoWDataModel();
ProcessName = "Wow-64";
- Scale = 4;
// Currently WoW is locked behind a hidden trigger (obviously not that hidden since you're reading this)
// It is using memory reading and lets first try to contact Blizzard
var settings = SettingsProvider.Load();
- Enabled = (settings.GamestatePort == 62575) && Settings.Enabled;
-
- Initialized = false;
+ Settings.IsEnabled = settings.GamestatePort == 62575 && Settings.IsEnabled;
_pointer = SettingsProvider.Load().WorldOfWarcraft;
//_pointer = new GamePointersCollection
@@ -64,33 +60,32 @@ namespace Artemis.Modules.Games.WoW
//var res = JsonConvert.SerializeObject(_pointer, Formatting.Indented);
}
- public int Scale { get; set; }
+ public override string Name => "WoW";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => true;
public override void Dispose()
{
- Initialized = false;
+ base.Dispose();
_process?.Dispose();
_process = null;
- base.Dispose();
}
public override void Enable()
{
- base.Enable();
-
var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
if (tempProcess == null)
return;
_process = new ProcessSharp(tempProcess, MemoryType.Remote);
- Initialized = true;
+ base.Enable();
}
public override void Update()
{
- if ((Profile == null) || (DataModel == null) || (_process == null))
+ if (ProfileModel == null || DataModel == null || _process == null)
return;
var dataModel = (WoWDataModel) DataModel;
@@ -104,7 +99,7 @@ namespace Artemis.Modules.Games.WoW
_pointer.GameAddresses.First(a => a.Description == "TargetGuid").BasePointer, true);
dataModel.Player = player;
- if ((dataModel.Player != null) && (dataModel.Player.Guid != Guid.Empty))
+ if (dataModel.Player != null && dataModel.Player.Guid != Guid.Empty)
{
dataModel.Player.UpdateDetails(nameCache);
var target = player.GetTarget(objectManager);
@@ -119,10 +114,5 @@ namespace Artemis.Modules.Games.WoW
dataModel.Target = null;
}
}
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly);
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWSettings.cs b/Artemis/Artemis/Modules/Games/WoW/WoWSettings.cs
index a4d0f76c4..2b2797c93 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWSettings.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWSettings.cs
@@ -1,8 +1,8 @@
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
namespace Artemis.Modules.Games.WoW
{
- public class WoWSettings : GameSettings
+ public class WoWSettings : ModuleSettings
{
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWView.xaml b/Artemis/Artemis/Modules/Games/WoW/WoWView.xaml
index ed25c9f9c..411c1ddd3 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWView.xaml
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWView.xaml
@@ -32,11 +32,12 @@
-
-
+
+
diff --git a/Artemis/Artemis/Modules/Games/WoW/WoWViewModel.cs b/Artemis/Artemis/Modules/Games/WoW/WoWViewModel.cs
index 418ad5008..eed8a1228 100644
--- a/Artemis/Artemis/Modules/Games/WoW/WoWViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/WoW/WoWViewModel.cs
@@ -1,16 +1,17 @@
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
+using Artemis.Modules.Abstract;
using Ninject;
namespace Artemis.Modules.Games.WoW
{
- public sealed class WoWViewModel : GameViewModel
+ public sealed class WoWViewModel : ModuleViewModel
{
- public WoWViewModel(MainManager main, IKernel kernel, [Named("WoWModel")] GameModel model)
- : base(main, model, kernel)
+ public WoWViewModel(MainManager mainManager, [Named(nameof(WoWModel))] ModuleModel moduleModel, IKernel kernel)
+ : base(mainManager, moduleModel, kernel)
{
DisplayName = "WoW";
}
+
+ public override bool UsesProfileEditor => true;
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/Bubble.cs b/Artemis/Artemis/Modules/General/Bubbles/Bubble.cs
similarity index 97%
rename from Artemis/Artemis/Modules/Effects/Bubbles/Bubble.cs
rename to Artemis/Artemis/Modules/General/Bubbles/Bubble.cs
index 3e9755968..8f4976c92 100644
--- a/Artemis/Artemis/Modules/Effects/Bubbles/Bubble.cs
+++ b/Artemis/Artemis/Modules/General/Bubbles/Bubble.cs
@@ -2,7 +2,7 @@
using System.Windows;
using Point = System.Windows.Point;
-namespace Artemis.Modules.Effects.Bubbles
+namespace Artemis.Modules.General.Bubbles
{
public class Bubble
{
diff --git a/Artemis/Artemis/Modules/General/Bubbles/BubblesModel.cs b/Artemis/Artemis/Modules/General/Bubbles/BubblesModel.cs
new file mode 100644
index 000000000..03602bf9d
--- /dev/null
+++ b/Artemis/Artemis/Modules/General/Bubbles/BubblesModel.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows;
+using Artemis.DAL;
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Artemis.Utilities;
+using Point = System.Windows.Point;
+
+namespace Artemis.Modules.General.Bubbles
+{
+ public class BubblesModel : ModuleModel
+ {
+ #region Constructors
+
+ public BubblesModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
+ {
+ Settings = SettingsProvider.Load();
+ }
+
+ #endregion
+
+ #region Properties & Fields
+
+ public override string Name => "Bubbles";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => false;
+
+ private static readonly Random Random = new Random();
+ private readonly List _bubbles = new List();
+ private int _scale;
+
+ #endregion
+
+ #region Methods
+
+ public override void Enable()
+ {
+ var bubbleSettings = (BubblesSettings) Settings;
+ _scale = bubbleSettings.Smoothness;
+
+ var rect = DeviceManager.ActiveKeyboard.KeyboardRectangle(_scale);
+ var scaleFactor = bubbleSettings.Smoothness / 25.0;
+
+ for (var i = 0; i < bubbleSettings.BubbleCount; i++)
+ {
+ var color = bubbleSettings.IsRandomColors
+ ? ColorHelpers.GetRandomRainbowColor()
+ : ColorHelpers.ToDrawingColor(bubbleSettings.BubbleColor);
+ // -bubbleSettings.MoveSpeed because we want to spawn at least one move away from borders
+ var initialPositionX = (rect.Width - bubbleSettings.BubbleSize * scaleFactor * 2 -
+ bubbleSettings.MoveSpeed * scaleFactor) *
+ Random.NextDouble() + bubbleSettings.BubbleSize * scaleFactor;
+ var initialPositionY = (rect.Height - bubbleSettings.BubbleSize * scaleFactor * 2 -
+ bubbleSettings.MoveSpeed * scaleFactor) *
+ Random.NextDouble() + bubbleSettings.BubbleSize * scaleFactor;
+ var initialDirectionX = bubbleSettings.MoveSpeed * scaleFactor * Random.NextDouble() *
+ (Random.Next(1) == 0 ? -1 : 1);
+ var initialDirectionY = (bubbleSettings.MoveSpeed * scaleFactor - Math.Abs(initialDirectionX)) *
+ (Random.Next(1) == 0 ? -1 : 1);
+
+ _bubbles.Add(new Bubble(color, (int) Math.Round(bubbleSettings.BubbleSize * scaleFactor),
+ new Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
+ }
+
+ IsInitialized = true;
+ }
+
+ public override void Dispose()
+ {
+ _bubbles.Clear();
+ IsInitialized = false;
+ }
+
+ public override void Update()
+ {
+ var bubbleSettings = (BubblesSettings) Settings;
+ var keyboardRectangle = DeviceManager.ActiveKeyboard.KeyboardRectangle(_scale);
+ foreach (var bubble in _bubbles)
+ {
+ if (bubbleSettings.IsShiftColors)
+ bubble.Color = ColorHelpers.ShiftColor(bubble.Color,
+ bubbleSettings.IsRandomColors
+ ? (int) Math.Round(bubbleSettings.ShiftColorSpeed * Random.NextDouble())
+ : bubbleSettings.ShiftColorSpeed);
+
+ bubble.CheckCollision(keyboardRectangle);
+ bubble.Move();
+ }
+ }
+
+ public override void Render(RenderFrame frame, bool keyboardOnly)
+ {
+ using (var g = Graphics.FromImage(frame.KeyboardBitmap))
+ {
+ foreach (var bubble in _bubbles)
+ bubble.Draw(g);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesSettings.cs b/Artemis/Artemis/Modules/General/Bubbles/BubblesSettings.cs
similarity index 92%
rename from Artemis/Artemis/Modules/Effects/Bubbles/BubblesSettings.cs
rename to Artemis/Artemis/Modules/General/Bubbles/BubblesSettings.cs
index 17b4d9d37..9bb4763ca 100644
--- a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesSettings.cs
+++ b/Artemis/Artemis/Modules/General/Bubbles/BubblesSettings.cs
@@ -1,12 +1,12 @@
using System.ComponentModel;
using System.Windows.Media;
using Artemis.DAL;
-using Artemis.Settings;
+using Artemis.Modules.Abstract;
using Newtonsoft.Json;
-namespace Artemis.Modules.Effects.Bubbles
+namespace Artemis.Modules.General.Bubbles
{
- public class BubblesSettings : EffectSettings
+ public class BubblesSettings : ModuleSettings
{
[DefaultValue(true)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml b/Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml
similarity index 78%
rename from Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml
rename to Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml
index 3a478cee6..bbefe754e 100644
--- a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml
+++ b/Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml
@@ -1,10 +1,9 @@
-
-
-
+
-
-
-
-
-
+ ToolTip="Note: You can't enable an module when Artemis is disabled"
+ IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
+ cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
-
+
Bubble color
+ ShowNone="False" ShowLinear="False" ShowRadial="False" />
Use random colors
-
@@ -75,7 +67,7 @@
Height="16" Margin="0,8">
Shift through colors as the bubble moves
-
@@ -87,7 +79,7 @@
@@ -97,7 +89,7 @@
@@ -107,7 +99,7 @@
@@ -117,7 +109,7 @@
@@ -127,7 +119,7 @@
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml.cs b/Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml.cs
similarity index 81%
rename from Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml.cs
rename to Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml.cs
index 3a9bf3cca..01ae8f2a8 100644
--- a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesView.xaml.cs
+++ b/Artemis/Artemis/Modules/General/Bubbles/BubblesView.xaml.cs
@@ -1,6 +1,6 @@
using System.Windows.Controls;
-namespace Artemis.Modules.Effects.Bubbles
+namespace Artemis.Modules.General.Bubbles
{
public partial class BubblesView : UserControl
{
diff --git a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesViewModel.cs b/Artemis/Artemis/Modules/General/Bubbles/BubblesViewModel.cs
similarity index 53%
rename from Artemis/Artemis/Modules/Effects/Bubbles/BubblesViewModel.cs
rename to Artemis/Artemis/Modules/General/Bubbles/BubblesViewModel.cs
index 5d34270ea..7205f3b85 100644
--- a/Artemis/Artemis/Modules/Effects/Bubbles/BubblesViewModel.cs
+++ b/Artemis/Artemis/Modules/General/Bubbles/BubblesViewModel.cs
@@ -1,21 +1,19 @@
using System.Windows.Media;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
+using Artemis.Modules.Abstract;
using Ninject;
-namespace Artemis.Modules.Effects.Bubbles
+namespace Artemis.Modules.General.Bubbles
{
- public sealed class BubblesViewModel : EffectViewModel
+ public sealed class BubblesViewModel : ModuleViewModel
{
- private readonly BubblesModel _model;
private SolidColorBrush _bubbleColor;
- public BubblesViewModel(MainManager main, [Named("BubblesModel")] EffectModel model) : base(main, model)
+ public BubblesViewModel(MainManager mainManager, [Named(nameof(BubblesModel))] ModuleModel model, IKernel kernel)
+ : base(mainManager, model, kernel)
{
- _model = (BubblesModel) model;
DisplayName = "Bubbles";
- BubbleColor = new SolidColorBrush(_model.Settings.BubbleColor);
+ BubbleColor = new SolidColorBrush(((BubblesSettings) ModuleModel.Settings).BubbleColor);
}
///
@@ -29,9 +27,11 @@ namespace Artemis.Modules.Effects.Bubbles
if (Equals(value, _bubbleColor)) return;
_bubbleColor = (SolidColorBrush) value;
- _model.Settings.BubbleColor = _bubbleColor.Color;
+ ((BubblesSettings) ModuleModel.Settings).BubbleColor = _bubbleColor.Color;
NotifyOfPropertyChange(() => BubbleColor);
}
}
+
+ public override bool UsesProfileEditor => false;
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileDataModel.cs
similarity index 94%
rename from Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs
rename to Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileDataModel.cs
index 7efdf765f..7400ad81f 100644
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileDataModel.cs
@@ -1,12 +1,12 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
-namespace Artemis.Modules.Effects.WindowsProfile
+namespace Artemis.Modules.General.GeneralProfile
{
[MoonSharpUserData]
- public class WindowsProfileDataModel : IDataModel
+ public class GeneralProfileDataModel : ModuleDataModel
{
- public WindowsProfileDataModel()
+ public GeneralProfileDataModel()
{
Spotify = new Spotify();
GooglePlayMusic = new GooglePlayMusic();
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileModel.cs b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileModel.cs
similarity index 81%
rename from Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileModel.cs
rename to Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileModel.cs
index 6fd367001..73162b267 100644
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileModel.cs
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileModel.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -8,15 +8,14 @@ using System.Threading;
using System.Threading.Tasks;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
+using Artemis.Modules.Abstract;
using Artemis.Utilities;
using Newtonsoft.Json;
using SpotifyAPI.Local;
-namespace Artemis.Modules.Effects.WindowsProfile
+namespace Artemis.Modules.General.GeneralProfile
{
- public class WindowsProfileModel : EffectModel
+ public class GeneralProfileModel : ModuleModel
{
private List _cores;
private int _cpuFrames;
@@ -25,34 +24,29 @@ namespace Artemis.Modules.Effects.WindowsProfile
private SpotifyLocalAPI _spotify;
private bool _spotifySetupBusy;
- public WindowsProfileModel(DeviceManager deviceManager, LuaManager luaManager)
- : base(deviceManager, luaManager, SettingsProvider.Load(),
- new WindowsProfileDataModel())
+ public GeneralProfileModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
{
_lastMusicUpdate = DateTime.Now;
- Name = "WindowsProfile";
+ Settings = SettingsProvider.Load();
+ DataModel = new GeneralProfileDataModel();
}
- public override void Dispose()
- {
- Initialized = false;
- base.Dispose();
- }
+ public override string Name => "GeneralProfile";
+ public override bool IsOverlay => false;
+ public override bool IsBoundToProcess => false;
public override void Enable()
{
- base.Enable();
-
SetupCpu();
SetupSpotify();
- Initialized = true;
+ base.Enable();
}
public override void Update()
{
- var dataModel = (WindowsProfileDataModel) DataModel;
+ var dataModel = (GeneralProfileDataModel) DataModel;
UpdateCpu(dataModel);
UpdateMusicPlayers(dataModel);
UpdateDay(dataModel);
@@ -62,7 +56,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
#region Current Time
- private void UpdateDay(WindowsProfileDataModel dataModel)
+ private void UpdateDay(GeneralProfileDataModel dataModel)
{
var now = DateTime.Now;
dataModel.CurrentTime.Hours24 = int.Parse(now.ToString("HH"));
@@ -94,9 +88,9 @@ namespace Artemis.Modules.Effects.WindowsProfile
}
}
- private void UpdateCpu(WindowsProfileDataModel dataModel)
+ private void UpdateCpu(GeneralProfileDataModel dataModel)
{
- if ((_cores == null) || (_overallCpu == null))
+ if (_cores == null || _overallCpu == null)
return;
// CPU is only updated every 15 frames, the performance counter gives 0 if updated too often
@@ -135,11 +129,6 @@ namespace Artemis.Modules.Effects.WindowsProfile
dataModel.Performance.RAMUsage = (int) percentOccupied;
}
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return Profile.GetRenderLayers(DataModel, keyboardOnly, false);
- }
-
public static PerformanceCounter GetOverallPerformanceCounter()
{
var cpuCounter = new PerformanceCounter
@@ -181,8 +170,6 @@ namespace Artemis.Modules.Effects.WindowsProfile
{
var tryCount = 0;
while (tryCount <= 10)
- {
- // Causes WebException if not internet connection is available
try
{
tryCount++;
@@ -195,13 +182,11 @@ namespace Artemis.Modules.Effects.WindowsProfile
{
break;
}
-
- }
_spotifySetupBusy = false;
});
}
- public void UpdateMusicPlayers(WindowsProfileDataModel dataModel)
+ public void UpdateMusicPlayers(GeneralProfileDataModel dataModel)
{
// This is quite resource hungry so only update it once every two seconds
if (DateTime.Now - _lastMusicUpdate < TimeSpan.FromSeconds(2))
@@ -212,7 +197,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
UpdateGooglePlayMusic(dataModel);
}
- private void UpdateSpotify(WindowsProfileDataModel dataModel)
+ private void UpdateSpotify(GeneralProfileDataModel dataModel)
{
// Spotify
if (!dataModel.Spotify.Running && SpotifyLocalAPI.IsSpotifyRunning())
@@ -238,7 +223,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
(int) (status.PlayingPosition / dataModel.Spotify.SongLength * 100.0);
}
- private void UpdateGooglePlayMusic(WindowsProfileDataModel dataModel)
+ private void UpdateGooglePlayMusic(GeneralProfileDataModel dataModel)
{
// Google Play Music
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
@@ -257,14 +242,14 @@ namespace Artemis.Modules.Effects.WindowsProfile
CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
- private void UpdateKeyStates(WindowsProfileDataModel dataModel)
+ private void UpdateKeyStates(GeneralProfileDataModel dataModel)
{
dataModel.Keyboard.NumLock = ((ushort) GetKeyState(0x90) & 0xffff) != 0;
dataModel.Keyboard.CapsLock = ((ushort) GetKeyState(0x14) & 0xffff) != 0;
dataModel.Keyboard.ScrollLock = ((ushort) GetKeyState(0x91) & 0xffff) != 0;
}
- private void UpdateActiveWindow(WindowsProfileDataModel dataModel)
+ private void UpdateActiveWindow(GeneralProfileDataModel dataModel)
{
dataModel.ActiveWindow.ProcessName = ActiveWindowHelper.ActiveWindowProcessName;
dataModel.ActiveWindow.WindowTitle = ActiveWindowHelper.ActiveWindowWindowTitle;
diff --git a/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileSettings.cs b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileSettings.cs
new file mode 100644
index 000000000..084d94b0b
--- /dev/null
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileSettings.cs
@@ -0,0 +1,8 @@
+using Artemis.Modules.Abstract;
+
+namespace Artemis.Modules.General.GeneralProfile
+{
+ public class GeneralProfileSettings : ModuleSettings
+ {
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileView.xaml b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileView.xaml
similarity index 75%
rename from Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileView.xaml
rename to Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileView.xaml
index df8ec88a2..465b42322 100644
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileView.xaml
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileView.xaml
@@ -1,11 +1,9 @@
-
@@ -27,25 +25,25 @@
-
-
+
+ ToolTip="Note: You can't enable an module when Artemis is disabled"
+ IsChecked="{Binding Path=Settings.Enabled, Mode=OneWay}"
+ cal:Message.Attach="[Event Click] = [Action ToggleModule]" />
-
+
-
/// Interaction logic for RocketLeagueView.xaml
///
- public partial class WindowsProfileView : UserControl
+ public partial class GeneralProfileView : UserControl
{
- public WindowsProfileView()
+ public GeneralProfileView()
{
InitializeComponent();
}
diff --git a/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileViewModel.cs b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileViewModel.cs
new file mode 100644
index 000000000..33bfd7de0
--- /dev/null
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/GeneralProfileViewModel.cs
@@ -0,0 +1,17 @@
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Ninject;
+
+namespace Artemis.Modules.General.GeneralProfile
+{
+ public sealed class GeneralProfileViewModel : ModuleViewModel
+ {
+ public GeneralProfileViewModel(MainManager mainManager, [Named(nameof(GeneralProfileModel))] ModuleModel model,
+ IKernel kernel) : base(mainManager, model, kernel)
+ {
+ DisplayName = "General profile";
+ }
+
+ public override bool UsesProfileEditor => true;
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/PerformanceInfo.cs b/Artemis/Artemis/Modules/General/GeneralProfile/PerformanceInfo.cs
similarity index 97%
rename from Artemis/Artemis/Modules/Effects/WindowsProfile/PerformanceInfo.cs
rename to Artemis/Artemis/Modules/General/GeneralProfile/PerformanceInfo.cs
index e807c6582..ef88e7064 100644
--- a/Artemis/Artemis/Modules/Effects/WindowsProfile/PerformanceInfo.cs
+++ b/Artemis/Artemis/Modules/General/GeneralProfile/PerformanceInfo.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Artemis.Modules.Effects.WindowsProfile
+namespace Artemis.Modules.General.GeneralProfile
{
internal static class PerformanceInfo
{
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileDataModel.cs b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileDataModel.cs
new file mode 100644
index 000000000..4889d0a70
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileDataModel.cs
@@ -0,0 +1,13 @@
+using Artemis.Modules.Abstract;
+using Artemis.Modules.General.GeneralProfile;
+
+namespace Artemis.Modules.Overlays.OverlayProfile
+{
+ public class OverlayProfileDataModel : ModuleDataModel
+ {
+ public OverlayProfileDataModel()
+ {
+ ParentDataModel = new GeneralProfileDataModel();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileModel.cs b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileModel.cs
new file mode 100644
index 000000000..d8036d19f
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileModel.cs
@@ -0,0 +1,31 @@
+using Artemis.DAL;
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Artemis.Modules.General.GeneralProfile;
+using Ninject;
+
+namespace Artemis.Modules.Overlays.OverlayProfile
+{
+ public class OverlayProfileModel : ModuleModel
+ {
+ private readonly GeneralProfileModel _generalProfileModel;
+
+ public OverlayProfileModel(DeviceManager deviceManager, LuaManager luaManager,
+ [Named(nameof(GeneralProfileModel))] ModuleModel generalProfileModel) : base(deviceManager, luaManager)
+ {
+ _generalProfileModel = (GeneralProfileModel) generalProfileModel;
+ Settings = SettingsProvider.Load();
+ DataModel = new OverlayProfileDataModel();
+ }
+
+ public override string Name => "OverlayProfile";
+ public override bool IsOverlay => true;
+ public override bool IsBoundToProcess => false;
+
+ public override void Update()
+ {
+ // TODO: Find a clean way to update the parent profile model
+ DataModel.ParentDataModel = _generalProfileModel.DataModel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileSettings.cs b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileSettings.cs
new file mode 100644
index 000000000..a802554d9
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileSettings.cs
@@ -0,0 +1,8 @@
+using Artemis.Modules.Abstract;
+
+namespace Artemis.Modules.Overlays.OverlayProfile
+{
+ public class OverlayProfileSettings : ModuleSettings
+ {
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml
new file mode 100644
index 000000000..1d427a91c
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml.cs b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml.cs
new file mode 100644
index 000000000..47bb44f53
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileView.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace Artemis.Modules.Overlays.OverlayProfile
+{
+ ///
+ /// Interaction logic for RocketLeagueView.xaml
+ ///
+ public partial class OverlayProfileView : UserControl
+ {
+ public OverlayProfileView()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileViewModel.cs b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileViewModel.cs
new file mode 100644
index 000000000..248cd9cb5
--- /dev/null
+++ b/Artemis/Artemis/Modules/Overlays/OverlayProfile/OverlayProfileViewModel.cs
@@ -0,0 +1,17 @@
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Ninject;
+
+namespace Artemis.Modules.Overlays.OverlayProfile
+{
+ public sealed class OverlayProfileViewModel : ModuleViewModel
+ {
+ public OverlayProfileViewModel(MainManager mainManager, [Named(nameof(OverlayProfileModel))] ModuleModel model,
+ IKernel kernel) : base(mainManager, model, kernel)
+ {
+ DisplayName = "Overlay profile";
+ }
+
+ public override bool UsesProfileEditor => true;
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs
deleted file mode 100644
index cc98a9abc..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.Designer.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Artemis.Modules.Overlays.VolumeDisplay {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
- internal sealed partial class VolumeDisplay : global::System.Configuration.ApplicationSettingsBase {
-
- private static VolumeDisplay defaultInstance = ((VolumeDisplay)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new VolumeDisplay())));
-
- public static VolumeDisplay Default {
- get {
- return defaultInstance;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("True")]
- public bool Enabled {
- get {
- return ((bool)(this["Enabled"]));
- }
- set {
- this["Enabled"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")]
- public global::System.Windows.Media.Color MainColor {
- get {
- return ((global::System.Windows.Media.Color)(this["MainColor"]));
- }
- set {
- this["MainColor"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("#FF26F600")]
- public global::System.Windows.Media.Color SecondaryColor {
- get {
- return ((global::System.Windows.Media.Color)(this["SecondaryColor"]));
- }
- set {
- this["SecondaryColor"] = value;
- }
- }
- }
-}
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs
deleted file mode 100644
index 699ddd6f5..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using Artemis.Managers;
-using Artemis.Utilities;
-using Artemis.Utilities.Keyboard;
-
-namespace Artemis.Modules.Overlays.VolumeDisplay
-{
- public class VolumeBar
- {
- private readonly DeviceManager _deviceManager;
-
- public VolumeBar(DeviceManager deviceManager, VolumeDisplaySettings settings)
- {
- _deviceManager = deviceManager;
- Settings = settings;
- Transparancy = 255;
- Scale = 4;
- }
-
- public VolumeDisplaySettings Settings { get; set; }
-
- public int Scale { get; set; }
-
- public int Ttl { get; set; }
- public byte Transparancy { get; set; }
- public int Volume { get; set; }
-
-
- public void Draw(Graphics g)
- {
- var volumeRect = new KeyboardRectangle(_deviceManager.ActiveKeyboard, 0, 0, new List
- {
- ColorHelpers.ToDrawingColor(Settings.MainColor),
- ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
- },
- LinearGradientMode.Horizontal)
- {
- Width = (int) (_deviceManager.ActiveKeyboard.Width*Scale/100.00*Volume),
- ContainedBrush = false
- };
- volumeRect.Draw(g);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings
deleted file mode 100644
index 086ed27ae..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.settings
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
- True
-
-
- #FFFF2900
-
-
- #FF26F600
-
-
-
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs
deleted file mode 100644
index e43097b6c..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayModel.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System.Collections.Generic;
-using System.Drawing;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-using Artemis.DAL;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Profiles.Layers.Models;
-using Artemis.Utilities.Keyboard;
-using NAudio.CoreAudioApi;
-
-namespace Artemis.Modules.Overlays.VolumeDisplay
-{
- public class VolumeDisplayModel : OverlayModel
- {
- public VolumeDisplayModel(DeviceManager deviceManager, LuaManager luaManager)
- : base(deviceManager, luaManager, SettingsProvider.Load())
- {
- Name = "VolumeDisplay";
- Settings = (VolumeDisplaySettings) base.Settings;
- VolumeDisplay = new VolumeBar(DeviceManager, Settings);
- }
-
- public new VolumeDisplaySettings Settings { get; set; }
- public VolumeBar VolumeDisplay { get; set; }
-
- public override void Dispose()
- {
- KeyboardHook.KeyDownCallback -= KeyPressTask;
- }
-
- public override void Enable()
- {
- // Listener won't start unless the effect is active
- KeyboardHook.KeyDownCallback += KeyPressTask;
- }
-
- public override void Update()
- {
- // TODO: Get from settings
- var fps = 25;
-
- if (VolumeDisplay == null)
- return;
- if (VolumeDisplay.Ttl < 1)
- return;
-
- var decreaseAmount = 500 / fps;
- VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
- if (VolumeDisplay.Ttl < 128)
- VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
-
- try
- {
- var enumerator = new MMDeviceEnumerator();
- var volumeFloat =
- enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
- .AudioEndpointVolume.MasterVolumeLevelScalar;
- VolumeDisplay.Volume = (int) (volumeFloat * 100);
- }
- catch (COMException)
- {
- }
- }
-
- public override List GetRenderLayers(bool keyboardOnly)
- {
- return null;
- }
-
- private void KeyPressTask(KeyEventArgs e)
- {
- if ((e.KeyCode != Keys.VolumeUp) && (e.KeyCode != Keys.VolumeDown))
- return;
-
- VolumeDisplay.Ttl = 1000;
- VolumeDisplay.Transparancy = 255;
- }
-
- public override void RenderOverlay(RenderFrame frame, bool keyboardOnly)
- {
- if ((DeviceManager.ActiveKeyboard == null) || (VolumeDisplay == null) || (VolumeDisplay.Ttl < 1))
- return;
-
- using (var g = Graphics.FromImage(frame.KeyboardBitmap))
- {
- VolumeDisplay.Draw(g);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs
deleted file mode 100644
index 2a5de5b80..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplaySettings.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System.Windows.Media;
-using Artemis.DAL;
-using Artemis.Settings;
-using Newtonsoft.Json;
-
-namespace Artemis.Modules.Overlays.VolumeDisplay
-{
- public class VolumeDisplaySettings : OverlaySettings
- {
- public Color MainColor { get; set; }
- public Color SecondaryColor { get; set; }
-
- public new void Reset(bool save = false)
- {
- JsonConvert.PopulateObject("{}", this, new JsonSerializerSettings
- {
- ObjectCreationHandling = ObjectCreationHandling.Reuse
- });
-
- MainColor = Colors.Red;
- SecondaryColor = Colors.GreenYellow;
-
- if (save)
- SettingsProvider.Save(this);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml
deleted file mode 100644
index 3cdcdd1f9..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Main volume display color
-
-
-
-
-
- Secondary volume display color
-
-
-
-
- Note: This is an overlay. It will go over any other active effect, and is only shown at certain moments (in this case when changing volume). Please also note that it won't work if there aren't any active effects.
-
-
-
- Please also note that it won't work if there aren't any active effects.
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml.cs
deleted file mode 100644
index bbbda8c37..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayView.xaml.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace Artemis.Modules.Overlays.VolumeDisplay
-{
- ///
- /// Interaction logic for MediaKeysDisplayView.xaml
- ///
- public partial class VolumeDisplayView : UserControl
- {
- public VolumeDisplayView()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs
deleted file mode 100644
index 74ee3cef2..000000000
--- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplayViewModel.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.Windows.Media;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.ViewModels.Abstract;
-using Ninject;
-
-namespace Artemis.Modules.Overlays.VolumeDisplay
-{
- public sealed class VolumeDisplayViewModel : OverlayViewModel
- {
- private readonly VolumeDisplayModel _model;
- private SolidColorBrush _mainColor;
- private SolidColorBrush _secondaryColor;
-
- public VolumeDisplayViewModel(MainManager mainManager, [Named("VolumeDisplayModel")] OverlayModel model)
- : base(mainManager, model)
- {
- _model = (VolumeDisplayModel) model;
- DisplayName = "Volume Display";
-
- MainColor = new SolidColorBrush(_model.Settings.MainColor);
- SecondaryColor = new SolidColorBrush(_model.Settings.SecondaryColor);
- }
-
- public Brush MainColor
- {
- get { return _mainColor; }
- set
- {
- if (Equals(value, _mainColor)) return;
- _mainColor = (SolidColorBrush) value;
-
- _model.Settings.MainColor = _mainColor.Color;
- NotifyOfPropertyChange(() => MainColor);
- }
- }
-
- public Brush SecondaryColor
- {
- get { return _secondaryColor; }
- set
- {
- if (Equals(value, _secondaryColor)) return;
- _secondaryColor = (SolidColorBrush) value;
-
- _model.Settings.SecondaryColor = _secondaryColor.Color;
- NotifyOfPropertyChange(() => SecondaryColor);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/NLog.xsd b/Artemis/Artemis/NLog.xsd
index f61050fc6..2c7d1ff23 100644
--- a/Artemis/Artemis/NLog.xsd
+++ b/Artemis/Artemis/NLog.xsd
@@ -1,2673 +1,2723 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Watch config file for changes and reload automatically.
-
-
-
-
- Print internal NLog messages to the console. Default value is: false
-
-
-
-
- Print internal NLog messages to the console error output. Default value is: false
-
-
-
-
- Write internal NLog messages to the specified file.
-
-
-
-
- Log level threshold for internal log messages. Default value is: Info.
-
-
-
-
- Global log level threshold for application log messages. Messages below this level won't be logged..
-
-
-
-
- Pass NLog internal exceptions to the application. Default value is: false.
-
-
-
-
- Write internal NLog messages to the the System.Diagnostics.Trace. Default value is: false
-
-
-
-
-
-
-
-
-
-
-
-
-
- Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Prefix for targets/layout renderers/filters/conditions loaded from this assembly.
-
-
-
-
- Load NLog extensions from the specified file (*.dll)
-
-
-
-
- Load NLog extensions from the specified assembly. Assembly name should be fully qualified.
-
-
-
-
-
-
-
-
-
- Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name*
-
-
-
-
- Comma separated list of levels that this rule matches.
-
-
-
-
- Minimum level that this rule matches.
-
-
-
-
- Maximum level that this rule matches.
-
-
-
-
- Level that this rule matches.
-
-
-
-
- Comma separated list of target names.
-
-
-
-
- Ignore further rules if this one matches.
-
-
-
-
- Enable or disable logging rule. Disabled rules are ignored.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the file to be included. The name is relative to the name of the current config file.
-
-
-
-
- Ignore any errors in the include file.
-
-
-
-
-
-
- Variable name.
-
-
-
-
- Variable value.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
- Indicates whether to add <!-- --> comments around all written texts.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Number of log events that should be processed in a batch by the lazy writer thread.
-
-
-
-
- Action to be taken when the lazy writer thread request queue count exceeds the set limit.
-
-
-
-
- Limit on the number of requests in the lazy writer thread request queue.
-
-
-
-
- Time in milliseconds to sleep between batches.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Number of log events to be buffered.
-
-
-
-
- Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes.
-
-
-
-
- Indicates whether to use sliding timeout.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Encoding to be used.
-
-
-
-
- Instance of that is used to format log messages.
-
-
-
-
- End of line value if a newline is appended at the end of log message .
-
-
-
-
- Maximum message size in bytes.
-
-
-
-
- Indicates whether to append newline at the end of log message.
-
-
-
-
- Action that should be taken if the will be more connections than .
-
-
-
-
- Action that should be taken if the message is larger than maxMessageSize.
-
-
-
-
- Indicates whether to keep connection open whenever possible.
-
-
-
-
- Size of the connection cache (number of connections which are kept alive).
-
-
-
-
- Maximum current connections. 0 = no maximum.
-
-
-
-
- Network address.
-
-
-
-
- Maximum queue size.
-
-
-
-
- Indicates whether to include source info (file name and line number) in the information sent over the network.
-
-
-
-
- NDC item separator.
-
-
-
-
- Indicates whether to include stack contents.
-
-
-
-
- Indicates whether to include call site (class and method name) in the information sent over the network.
-
-
-
-
- AppInfo field. By default it's the friendly name of the current AppDomain.
-
-
-
-
- Indicates whether to include NLog-specific extensions to log4j schema.
-
-
-
-
- Indicates whether to include dictionary contents.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Layout that should be use to calcuate the value for the parameter.
-
-
-
-
- Viewer parameter name.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Text to be rendered.
-
-
-
-
- Header.
-
-
-
-
- Footer.
-
-
-
-
- Indicates whether to use default row highlighting rules.
-
-
-
-
- Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
-
-
-
-
- The encoding for writing messages to the .
-
-
-
-
- Indicates whether the error stream (stderr) should be used instead of the output stream (stdout).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Condition that must be met in order to set the specified foreground and background color.
-
-
-
-
- Background color.
-
-
-
-
- Foreground color.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Indicates whether to ignore case when comparing texts.
-
-
-
-
- Regular expression to be matched. You must specify either text or regex.
-
-
-
-
- Text to be matched. You must specify either text or regex.
-
-
-
-
- Indicates whether to match whole words only.
-
-
-
-
- Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used.
-
-
-
-
- Background color.
-
-
-
-
- Foreground color.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Text to be rendered.
-
-
-
-
- Header.
-
-
-
-
- Footer.
-
-
-
-
- Indicates whether to send the log messages to the standard error instead of the standard output.
-
-
-
-
- Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
-
-
-
-
- The encoding for writing messages to the .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase.
-
-
-
-
- Name of the connection string (as specified in <connectionStrings> configuration section.
-
-
-
-
- Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string.
-
-
-
-
- Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string.
-
-
-
-
- Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string.
-
-
-
-
- Name of the database provider.
-
-
-
-
- Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string.
-
-
-
-
- Indicates whether to keep the database connection open between the log events.
-
-
-
-
- Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this.
-
-
-
-
- Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used.
-
-
-
-
- Text of the SQL command to be run on each log level.
-
-
-
-
- Type of the SQL command to be run on each log level.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Type of the command.
-
-
-
-
- Connection string to run the command against. If not provided, connection string from the target is used.
-
-
-
-
- Indicates whether to ignore failures.
-
-
-
-
- Command text.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Layout that should be use to calcuate the value for the parameter.
-
-
-
-
- Database parameter name.
-
-
-
-
- Database parameter precision.
-
-
-
-
- Database parameter scale.
-
-
-
-
- Database parameter size.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Text to be rendered.
-
-
-
-
- Header.
-
-
-
-
- Footer.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
- Layout that renders event Category.
-
-
-
-
- Layout that renders event ID.
-
-
-
-
- Name of the Event Log to write to. This can be System, Application or any user-defined name.
-
-
-
-
- Name of the machine on which Event Log service is running.
-
-
-
-
- Value to be used as the event Source.
-
-
-
-
- Action to take if the message is larger than the option.
-
-
-
-
- Optional entrytype. When not set, or when not convertable to then determined by
-
-
-
-
- Message length limit to write to the Event Log.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Indicates whether to return to the first target after any successful write.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Text to be rendered.
-
-
-
-
- Header.
-
-
-
-
- Footer.
-
-
-
-
- File encoding.
-
-
-
-
- Line ending mode.
-
-
-
-
- Way file archives are numbered.
-
-
-
-
- Name of the file to be used for an archive.
-
-
-
-
- Indicates whether to automatically archive log files every time the specified time passes.
-
-
-
-
- Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose:
-
-
-
-
- Indicates whether to compress archive files into the zip archive format.
-
-
-
-
- Maximum number of archive files that should be kept.
-
-
-
-
- Is the an absolute or relative path?
-
-
-
-
- Is the an absolute or relative path?
-
-
-
-
- Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong.
-
-
-
-
- Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation.
-
-
-
-
- Indicates whether the footer should be written only when the file is archived.
-
-
-
-
- Name of the file to write to.
-
-
-
-
- Value specifying the date format to use when archiving files.
-
-
-
-
- Indicates whether to archive old log file on startup.
-
-
-
-
- Indicates whether to create directories if they do not exist.
-
-
-
-
- Indicates whether to enable log file(s) to be deleted.
-
-
-
-
- File attributes (Windows only).
-
-
-
-
- Indicates whether to delete old log file on startup.
-
-
-
-
- Indicates whether to replace file contents on each write instead of appending log message at the end.
-
-
-
-
- Indicates whether concurrent writes to the log file by multiple processes on the same host.
-
-
-
-
- Indicates whether to keep log file open instead of opening and closing it on each logging event.
-
-
-
-
- Maximum number of log filenames that should be stored as existing.
-
-
-
-
- Indicates whether concurrent writes to the log file by multiple processes on different network hosts.
-
-
-
-
- Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger).
-
-
-
-
- Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity.
-
-
-
-
- Log file buffer size in bytes.
-
-
-
-
- Indicates whether to automatically flush the file buffers after each log message.
-
-
-
-
- Delay in milliseconds to wait before attempting to write to the file again.
-
-
-
-
- Number of times the write is appended on the file before NLog discards the log message.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Condition expression. Log events who meet this condition will be forwarded to the wrapped target.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Windows domain name to change context to.
-
-
-
-
- Required impersonation level.
-
-
-
-
- Type of the logon provider.
-
-
-
-
- Logon Type.
-
-
-
-
- User account password.
-
-
-
-
- Indicates whether to revert to the credentials of the process instead of impersonating another user.
-
-
-
-
- Username to change context to.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Endpoint address.
-
-
-
-
- Name of the endpoint configuration in WCF configuration file.
-
-
-
-
- Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply)
-
-
-
-
- Client ID.
-
-
-
-
- Indicates whether to include per-event properties in the payload sent to the server.
-
-
-
-
- Indicates whether to use binary message encoding.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Layout that should be use to calculate the value for the parameter.
-
-
-
-
- Name of the parameter.
-
-
-
-
- Type of the parameter.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Text to be rendered.
-
-
-
-
- Header.
-
-
-
-
- Footer.
-
-
-
-
- Indicates whether to send message as HTML instead of plain text.
-
-
-
-
- Encoding to be used for sending e-mail.
-
-
-
-
- Indicates whether to add new lines between log entries.
-
-
-
-
- CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
-
-
-
-
- Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
-
-
-
-
- BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
-
-
-
-
- Mail message body (repeated for each log message send in one mail).
-
-
-
-
- Mail subject.
-
-
-
-
- Sender's email address (e.g. joe@domain.com).
-
-
-
-
- Indicates whether NewLine characters in the body should be replaced with tags.
-
-
-
-
- Priority used for sending mails.
-
-
-
-
- Indicates the SMTP client timeout.
-
-
-
-
- SMTP Server to be used for sending.
-
-
-
-
- SMTP Authentication mode.
-
-
-
-
- Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic").
-
-
-
-
- Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic").
-
-
-
-
- Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server.
-
-
-
-
- Port number that SMTP Server is listening on.
-
-
-
-
- Indicates whether the default Settings from System.Net.MailSettings should be used.
-
-
-
-
- Folder where applications save mail messages to be processed by the local SMTP server.
-
-
-
-
- Specifies how outgoing email messages will be handled.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
- Encoding to be used when writing text to the queue.
-
-
-
-
- Indicates whether to use the XML format when serializing message. This will also disable creating queues.
-
-
-
-
- Indicates whether to check if a queue exists before writing to it.
-
-
-
-
- Indicates whether to create the queue if it doesn't exists.
-
-
-
-
- Label to associate with each message.
-
-
-
-
- Name of the queue to write to.
-
-
-
-
- Indicates whether to use recoverable messages (with guaranteed delivery).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Class name.
-
-
-
-
- Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
- Encoding to be used.
-
-
-
-
- End of line value if a newline is appended at the end of log message .
-
-
-
-
- Maximum message size in bytes.
-
-
-
-
- Indicates whether to append newline at the end of log message.
-
-
-
-
- Action that should be taken if the will be more connections than .
-
-
-
-
- Action that should be taken if the message is larger than maxMessageSize.
-
-
-
-
- Network address.
-
-
-
-
- Size of the connection cache (number of connections which are kept alive).
-
-
-
-
- Indicates whether to keep connection open whenever possible.
-
-
-
-
- Maximum current connections. 0 = no maximum.
-
-
-
-
- Maximum queue size.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Encoding to be used.
-
-
-
-
- Instance of that is used to format log messages.
-
-
-
-
- End of line value if a newline is appended at the end of log message .
-
-
-
-
- Maximum message size in bytes.
-
-
-
-
- Indicates whether to append newline at the end of log message.
-
-
-
-
- Action that should be taken if the will be more connections than .
-
-
-
-
- Action that should be taken if the message is larger than maxMessageSize.
-
-
-
-
- Indicates whether to keep connection open whenever possible.
-
-
-
-
- Size of the connection cache (number of connections which are kept alive).
-
-
-
-
- Maximum current connections. 0 = no maximum.
-
-
-
-
- Network address.
-
-
-
-
- Maximum queue size.
-
-
-
-
- Indicates whether to include source info (file name and line number) in the information sent over the network.
-
-
-
-
- NDC item separator.
-
-
-
-
- Indicates whether to include stack contents.
-
-
-
-
- Indicates whether to include call site (class and method name) in the information sent over the network.
-
-
-
-
- AppInfo field. By default it's the friendly name of the current AppDomain.
-
-
-
-
- Indicates whether to include NLog-specific extensions to log4j schema.
-
-
-
-
- Indicates whether to include dictionary contents.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
- Indicates whether to perform layout calculation.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Indicates whether performance counter should be automatically created.
-
-
-
-
- Name of the performance counter category.
-
-
-
-
- Counter help text.
-
-
-
-
- Name of the performance counter.
-
-
-
-
- Performance counter type.
-
-
-
-
- The value by which to increment the counter.
-
-
-
-
- Performance counter instance name.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Default filter to be applied when no specific rule matches.
-
-
-
-
-
-
-
-
-
-
-
-
- Condition to be tested.
-
-
-
-
- Resulting filter to be applied when the condition matches.
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Number of times to repeat each log message.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Number of retries that should be attempted on the wrapped target in case of a failure.
-
-
-
-
- Time to wait between retries in milliseconds.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Layout used to format log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the target.
-
-
-
-
- Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8.
-
-
-
-
- Encoding.
-
-
-
-
- Web service method name. Only used with Soap.
-
-
-
-
- Web service namespace. Only used with Soap.
-
-
-
-
- Protocol to be used when calling web service.
-
-
-
-
- Web service URL.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Footer layout.
-
-
-
-
- Header layout.
-
-
-
-
- Body layout (can be repeated multiple times).
-
-
-
-
- Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom').
-
-
-
-
- Column delimiter.
-
-
-
-
- Quote Character.
-
-
-
-
- Quoting mode.
-
-
-
-
- Indicates whether CVS should include header.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Layout of the column.
-
-
-
-
- Name of the column.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Option to render the empty object value {}
-
-
-
-
- Option to suppress the extra spaces in the output json
-
-
-
-
-
-
-
-
-
-
-
-
-
- Determines wether or not this attribute will be Json encoded.
-
-
-
-
- Layout that will be rendered as the attribute's value.
-
-
-
-
- Name of the attribute.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Footer layout.
-
-
-
-
- Header layout.
-
-
-
-
- Body layout (can be repeated multiple times).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Layout text.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action to be taken when filter matches.
-
-
-
-
- Condition expression.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action to be taken when filter matches.
-
-
-
-
- Indicates whether to ignore case when comparing strings.
-
-
-
-
- Layout to be used to filter log messages.
-
-
-
-
- Substring to be matched.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action to be taken when filter matches.
-
-
-
-
- String to compare the layout to.
-
-
-
-
- Indicates whether to ignore case when comparing strings.
-
-
-
-
- Layout to be used to filter log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action to be taken when filter matches.
-
-
-
-
- Indicates whether to ignore case when comparing strings.
-
-
-
-
- Layout to be used to filter log messages.
-
-
-
-
- Substring to be matched.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action to be taken when filter matches.
-
-
-
-
- String to compare the layout to.
-
-
-
-
- Indicates whether to ignore case when comparing strings.
-
-
-
-
- Layout to be used to filter log messages.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Watch config file for changes and reload automatically.
+
+
+
+
+ Print internal NLog messages to the console. Default value is: false
+
+
+
+
+ Print internal NLog messages to the console error output. Default value is: false
+
+
+
+
+ Write internal NLog messages to the specified file.
+
+
+
+
+ Log level threshold for internal log messages. Default value is: Info.
+
+
+
+
+ Global log level threshold for application log messages. Messages below this level won't be logged..
+
+
+
+
+ Pass NLog internal exceptions to the application. Default value is: false.
+
+
+
+
+ Write internal NLog messages to the the System.Diagnostics.Trace. Default value is: false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Prefix for targets/layout renderers/filters/conditions loaded from this assembly.
+
+
+
+
+ Load NLog extensions from the specified file (*.dll)
+
+
+
+
+ Load NLog extensions from the specified assembly. Assembly name should be fully qualified.
+
+
+
+
+
+
+
+
+
+ Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name*
+
+
+
+
+ Comma separated list of levels that this rule matches.
+
+
+
+
+ Minimum level that this rule matches.
+
+
+
+
+ Maximum level that this rule matches.
+
+
+
+
+ Level that this rule matches.
+
+
+
+
+ Comma separated list of target names.
+
+
+
+
+ Ignore further rules if this one matches.
+
+
+
+
+ Enable or disable logging rule. Disabled rules are ignored.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the file to be included. The name is relative to the name of the current config file.
+
+
+
+
+ Ignore any errors in the include file.
+
+
+
+
+
+
+ Variable name.
+
+
+
+
+ Variable value.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of log events that should be processed in a batch by the lazy writer thread.
+
+
+
+
+ Action to be taken when the lazy writer thread request queue count exceeds the set limit.
+
+
+
+
+ Limit on the number of requests in the lazy writer thread request queue.
+
+
+
+
+ Time in milliseconds to sleep between batches.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Condition expression. Log events who meet this condition will cause a flush on the wrapped target.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of log events to be buffered.
+
+
+
+
+ Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes.
+
+
+
+
+ Indicates whether to use sliding timeout.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ Instance of that is used to format log messages.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Network address.
+
+
+
+
+ Maximum queue size.
+
+
+
+
+ Indicates whether to include source info (file name and line number) in the information sent over the network.
+
+
+
+
+ NDC item separator.
+
+
+
+
+ Indicates whether to include stack contents.
+
+
+
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
+
+
+
+
+ AppInfo field. By default it's the friendly name of the current AppDomain.
+
+
+
+
+ Indicates whether to include NLog-specific extensions to log4j schema.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that should be use to calcuate the value for the parameter.
+
+
+
+
+ Viewer parameter name.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether to use default row highlighting rules.
+
+
+
+
+ Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
+
+
+
+
+ The encoding for writing messages to the .
+
+
+
+
+ Indicates whether the error stream (stderr) should be used instead of the output stream (stdout).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Condition that must be met in order to set the specified foreground and background color.
+
+
+
+
+ Background color.
+
+
+
+
+ Foreground color.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Indicates whether to ignore case when comparing texts.
+
+
+
+
+ Regular expression to be matched. You must specify either text or regex.
+
+
+
+
+ Text to be matched. You must specify either text or regex.
+
+
+
+
+ Indicates whether to match whole words only.
+
+
+
+
+ Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used.
+
+
+
+
+ Background color.
+
+
+
+
+ Foreground color.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether to send the log messages to the standard error instead of the standard output.
+
+
+
+
+ Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
+
+
+
+
+ The encoding for writing messages to the .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase.
+
+
+
+
+ Name of the connection string (as specified in <connectionStrings> configuration section.
+
+
+
+
+ Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string.
+
+
+
+
+ Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string.
+
+
+
+
+ Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string.
+
+
+
+
+ Name of the database provider.
+
+
+
+
+ Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string.
+
+
+
+
+ Indicates whether to keep the database connection open between the log events.
+
+
+
+
+ Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this.
+
+
+
+
+ Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used.
+
+
+
+
+ Text of the SQL command to be run on each log level.
+
+
+
+
+ Type of the SQL command to be run on each log level.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Type of the command.
+
+
+
+
+ Connection string to run the command against. If not provided, connection string from the target is used.
+
+
+
+
+ Indicates whether to ignore failures.
+
+
+
+
+ Command text.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that should be use to calcuate the value for the parameter.
+
+
+
+
+ Database parameter name.
+
+
+
+
+ Database parameter precision.
+
+
+
+
+ Database parameter scale.
+
+
+
+
+ Database parameter size.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Layout that renders event Category.
+
+
+
+
+ Layout that renders event ID.
+
+
+
+
+ Name of the Event Log to write to. This can be System, Application or any user-defined name.
+
+
+
+
+ Name of the machine on which Event Log service is running.
+
+
+
+
+ Value to be used as the event Source.
+
+
+
+
+ Action to take if the message is larger than the option.
+
+
+
+
+ Optional entrytype. When not set, or when not convertable to then determined by
+
+
+
+
+ Message length limit to write to the Event Log.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Indicates whether to return to the first target after any successful write.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ File encoding.
+
+
+
+
+ Line ending mode.
+
+
+
+
+ Way file archives are numbered.
+
+
+
+
+ Name of the file to be used for an archive.
+
+
+
+
+ Indicates whether to automatically archive log files every time the specified time passes.
+
+
+
+
+ Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose:
+
+
+
+
+ Indicates whether to compress archive files into the zip archive format.
+
+
+
+
+ Maximum number of archive files that should be kept.
+
+
+
+
+ Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation.
+
+
+
+
+ Is the an absolute or relative path?
+
+
+
+
+ Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong.
+
+
+
+
+ Is the an absolute or relative path?
+
+
+
+
+ Value indicationg whether file creation calls should be synchronized by a system global mutex.
+
+
+
+
+ Indicates whether the footer should be written only when the file is archived.
+
+
+
+
+ Name of the file to write to.
+
+
+
+
+ Value specifying the date format to use when archiving files.
+
+
+
+
+ Indicates whether to archive old log file on startup.
+
+
+
+
+ Indicates whether to create directories if they do not exist.
+
+
+
+
+ Indicates whether to enable log file(s) to be deleted.
+
+
+
+
+ File attributes (Windows only).
+
+
+
+
+ Indicates whether to delete old log file on startup.
+
+
+
+
+ Indicates whether to replace file contents on each write instead of appending log message at the end.
+
+
+
+
+ Indicates whether concurrent writes to the log file by multiple processes on the same host.
+
+
+
+
+ Indicates whether to keep log file open instead of opening and closing it on each logging event.
+
+
+
+
+ Maximum number of log filenames that should be stored as existing.
+
+
+
+
+ Indicates whether concurrent writes to the log file by multiple processes on different network hosts.
+
+
+
+
+ Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger).
+
+
+
+
+ Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity.
+
+
+
+
+ Log file buffer size in bytes.
+
+
+
+
+ Indicates whether to automatically flush the file buffers after each log message.
+
+
+
+
+ Delay in milliseconds to wait before attempting to write to the file again.
+
+
+
+
+ Number of times the write is appended on the file before NLog discards the log message.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Condition expression. Log events who meet this condition will be forwarded to the wrapped target.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Windows domain name to change context to.
+
+
+
+
+ Required impersonation level.
+
+
+
+
+ Type of the logon provider.
+
+
+
+
+ Logon Type.
+
+
+
+
+ User account password.
+
+
+
+
+ Indicates whether to revert to the credentials of the process instead of impersonating another user.
+
+
+
+
+ Username to change context to.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Interval in which messages will be written up to the number of messages.
+
+
+
+
+ Maximum allowed number of messages written per .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Endpoint address.
+
+
+
+
+ Name of the endpoint configuration in WCF configuration file.
+
+
+
+
+ Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply)
+
+
+
+
+ Client ID.
+
+
+
+
+ Indicates whether to include per-event properties in the payload sent to the server.
+
+
+
+
+ Indicates whether to use binary message encoding.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that should be use to calculate the value for the parameter.
+
+
+
+
+ Name of the parameter.
+
+
+
+
+ Type of the parameter.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether to send message as HTML instead of plain text.
+
+
+
+
+ Encoding to be used for sending e-mail.
+
+
+
+
+ Indicates whether to add new lines between log entries.
+
+
+
+
+ CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ Mail message body (repeated for each log message send in one mail).
+
+
+
+
+ Mail subject.
+
+
+
+
+ Sender's email address (e.g. joe@domain.com).
+
+
+
+
+ Indicates whether NewLine characters in the body should be replaced with tags.
+
+
+
+
+ Priority used for sending mails.
+
+
+
+
+ Indicates the SMTP client timeout.
+
+
+
+
+ SMTP Server to be used for sending.
+
+
+
+
+ SMTP Authentication mode.
+
+
+
+
+ Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic").
+
+
+
+
+ Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic").
+
+
+
+
+ Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server.
+
+
+
+
+ Port number that SMTP Server is listening on.
+
+
+
+
+ Indicates whether the default Settings from System.Net.MailSettings should be used.
+
+
+
+
+ Folder where applications save mail messages to be processed by the local SMTP server.
+
+
+
+
+ Specifies how outgoing email messages will be handled.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Encoding to be used when writing text to the queue.
+
+
+
+
+ Indicates whether to use the XML format when serializing message. This will also disable creating queues.
+
+
+
+
+ Indicates whether to check if a queue exists before writing to it.
+
+
+
+
+ Indicates whether to create the queue if it doesn't exists.
+
+
+
+
+ Label to associate with each message.
+
+
+
+
+ Name of the queue to write to.
+
+
+
+
+ Indicates whether to use recoverable messages (with guaranteed delivery).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Class name.
+
+
+
+
+ Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Network address.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Maximum queue size.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ Instance of that is used to format log messages.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Network address.
+
+
+
+
+ Maximum queue size.
+
+
+
+
+ Indicates whether to include source info (file name and line number) in the information sent over the network.
+
+
+
+
+ NDC item separator.
+
+
+
+
+ Indicates whether to include stack contents.
+
+
+
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
+
+
+
+
+ AppInfo field. By default it's the friendly name of the current AppDomain.
+
+
+
+
+ Indicates whether to include NLog-specific extensions to log4j schema.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Indicates whether to perform layout calculation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Indicates whether performance counter should be automatically created.
+
+
+
+
+ Name of the performance counter category.
+
+
+
+
+ Counter help text.
+
+
+
+
+ Name of the performance counter.
+
+
+
+
+ Performance counter type.
+
+
+
+
+ The value by which to increment the counter.
+
+
+
+
+ Performance counter instance name.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Default filter to be applied when no specific rule matches.
+
+
+
+
+
+
+
+
+
+
+
+
+ Condition to be tested.
+
+
+
+
+ Resulting filter to be applied when the condition matches.
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of times to repeat each log message.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of retries that should be attempted on the wrapped target in case of a failure.
+
+
+
+
+ Time to wait between retries in milliseconds.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8.
+
+
+
+
+ Encoding.
+
+
+
+
+ Value whether escaping be done according to the old NLog style (Very non-standard)
+
+
+
+
+ Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs)
+
+
+
+
+ Web service method name. Only used with Soap.
+
+
+
+
+ Web service namespace. Only used with Soap.
+
+
+
+
+ Protocol to be used when calling web service.
+
+
+
+
+ Web service URL.
+
+
+
+
+ Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see and ).
+
+
+
+
+ (optional) root namespace of the XML document, if POST of XML document chosen. (see and ).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Footer layout.
+
+
+
+
+ Header layout.
+
+
+
+
+ Body layout (can be repeated multiple times).
+
+
+
+
+ Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom').
+
+
+
+
+ Column delimiter.
+
+
+
+
+ Quote Character.
+
+
+
+
+ Quoting mode.
+
+
+
+
+ Indicates whether CVS should include header.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout of the column.
+
+
+
+
+ Name of the column.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List of property names to exclude when is true
+
+
+
+
+ Option to include all properties from the log events
+
+
+
+
+ Option to render the empty object value {}
+
+
+
+
+ Option to suppress the extra spaces in the output json
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Determines wether or not this attribute will be Json encoded.
+
+
+
+
+ Layout that will be rendered as the attribute's value.
+
+
+
+
+ Name of the attribute.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Footer layout.
+
+
+
+
+ Header layout.
+
+
+
+
+ Body layout (can be repeated multiple times).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout text.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Condition expression.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+ Substring to be matched.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ String to compare the layout to.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+ Substring to be matched.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ String to compare the layout to.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Conditions/DataModelCondition.cs b/Artemis/Artemis/Profiles/Layers/Conditions/DataModelCondition.cs
index 620fb09e2..255b059b8 100644
--- a/Artemis/Artemis/Profiles/Layers/Conditions/DataModelCondition.cs
+++ b/Artemis/Artemis/Profiles/Layers/Conditions/DataModelCondition.cs
@@ -1,6 +1,6 @@
using System;
using System.Linq;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -8,7 +8,7 @@ namespace Artemis.Profiles.Layers.Conditions
{
public class DataModelCondition : ILayerCondition
{
- public bool ConditionsMet(LayerModel layerModel, IDataModel dataModel)
+ public bool ConditionsMet(LayerModel layerModel, ModuleDataModel dataModel)
{
lock (layerModel.Properties.Conditions)
{
diff --git a/Artemis/Artemis/Profiles/Layers/Conditions/EventCondition.cs b/Artemis/Artemis/Profiles/Layers/Conditions/EventCondition.cs
index 902331477..5db52f958 100644
--- a/Artemis/Artemis/Profiles/Layers/Conditions/EventCondition.cs
+++ b/Artemis/Artemis/Profiles/Layers/Conditions/EventCondition.cs
@@ -1,6 +1,6 @@
using System;
using System.Linq;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -8,7 +8,7 @@ namespace Artemis.Profiles.Layers.Conditions
{
public class EventCondition : ILayerCondition
{
- public bool ConditionsMet(LayerModel layerModel, IDataModel dataModel)
+ public bool ConditionsMet(LayerModel layerModel, ModuleDataModel dataModel)
{
lock (layerModel.Properties.Conditions)
{
diff --git a/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerCondition.cs b/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerCondition.cs
index 8fd7422ae..ee2ff364b 100644
--- a/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerCondition.cs
+++ b/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerCondition.cs
@@ -1,10 +1,10 @@
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Models;
namespace Artemis.Profiles.Layers.Interfaces
{
public interface ILayerCondition
{
- bool ConditionsMet(LayerModel layerModel, IDataModel dataModel);
+ bool ConditionsMet(LayerModel layerModel, ModuleDataModel dataModel);
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerType.cs b/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerType.cs
index 4b38d1a6d..83f8c9185 100644
--- a/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Interfaces/ILayerType.cs
@@ -1,5 +1,5 @@
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Models;
using Artemis.ViewModels.Profiles;
@@ -47,7 +47,7 @@ namespace Artemis.Profiles.Layers.Interfaces
/// The layerModel to apply to
/// The datamodel to base the layer on
/// Set to true if previewing this layer
- void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false);
+ void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false);
///
/// Sets up the layer's properties to accommodate this layerType
@@ -71,6 +71,7 @@ namespace Artemis.Profiles.Layers.Interfaces
Mouse,
Headset,
Generic,
- Mousemat
+ Mousemat,
+ Preview
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Models/DynamicPropertiesModel.cs b/Artemis/Artemis/Profiles/Layers/Models/DynamicPropertiesModel.cs
index 1063f71aa..b976a7d51 100644
--- a/Artemis/Artemis/Profiles/Layers/Models/DynamicPropertiesModel.cs
+++ b/Artemis/Artemis/Profiles/Layers/Models/DynamicPropertiesModel.cs
@@ -1,6 +1,6 @@
using System;
using System.ComponentModel;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Utilities;
namespace Artemis.Profiles.Layers.Models
@@ -37,7 +37,7 @@ namespace Artemis.Profiles.Layers.Models
///
public LayerPropertyOptions LayerPropertyOptions { get; set; }
- internal void ApplyProperty(IDataModel dataModel, LayerModel layerModel)
+ internal void ApplyProperty(ModuleDataModel dataModel, LayerModel layerModel)
{
if (LayerPropertyType == LayerPropertyType.PercentageOf)
ApplyPercentageOf(dataModel, layerModel, PercentageSource);
@@ -45,7 +45,7 @@ namespace Artemis.Profiles.Layers.Models
ApplyPercentageOfProperty(dataModel, layerModel);
}
- private void ApplyPercentageOf(IDataModel dataModel, LayerModel layerModel, float src)
+ private void ApplyPercentageOf(ModuleDataModel dataModel, LayerModel layerModel, float src)
{
if (GameProperty == null)
return;
@@ -105,7 +105,7 @@ namespace Artemis.Profiles.Layers.Models
layerModel.Brush = brush;
}
- private void ApplyPercentageOfProperty(IDataModel dataModel, LayerModel layerModel)
+ private void ApplyPercentageOfProperty(ModuleDataModel dataModel, LayerModel layerModel)
{
var value = dataModel.GetPropValue(PercentageProperty);
ApplyPercentageOf(dataModel, layerModel, value);
diff --git a/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs b/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs
index d48cb5097..e7a02c9d6 100644
--- a/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs
+++ b/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs
@@ -1,5 +1,5 @@
using System;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Utilities;
using DynamicExpresso;
@@ -19,7 +19,7 @@ namespace Artemis.Profiles.Layers.Models
public string Operator { get; set; }
public string Type { get; set; }
- public bool ConditionMet(IDataModel subject)
+ public bool ConditionMet(ModuleDataModel subject)
{
lock (subject)
{
diff --git a/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs b/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs
index 826d78250..e04354364 100644
--- a/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs
+++ b/Artemis/Artemis/Profiles/Layers/Models/LayerModel.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Conditions;
using Artemis.Profiles.Layers.Interfaces;
@@ -38,7 +38,7 @@ namespace Artemis.Profiles.Layers.Models
///
///
///
- public bool ConditionsMet(IDataModel dataModel)
+ public bool ConditionsMet(ModuleDataModel dataModel)
{
// Conditions are not even checked if the layer isn't enabled
return Enabled && LayerCondition.ConditionsMet(this, dataModel);
@@ -50,7 +50,7 @@ namespace Artemis.Profiles.Layers.Models
///
///
///
- public void Update(IDataModel dataModel, bool preview, bool updateAnimations)
+ public void Update(ModuleDataModel dataModel, bool preview, bool updateAnimations)
{
if (LayerType == null)
return;
@@ -58,7 +58,7 @@ namespace Artemis.Profiles.Layers.Models
LayerType.Update(this, dataModel, preview);
LayerAnimation?.Update(this, updateAnimations);
- if (!preview && updateAnimations)
+ if (!preview)
TweenModel.Update();
LastRender = DateTime.Now;
@@ -89,7 +89,7 @@ namespace Artemis.Profiles.Layers.Models
///
///
///
- public void Draw(IDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
+ public void Draw(ModuleDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
{
if (Brush == null)
return;
@@ -257,7 +257,7 @@ namespace Artemis.Profiles.Layers.Models
/// Whether or not to ignore anything but keyboards
///
/// A flat list containing all layers that must be rendered
- public List GetRenderLayers(IDataModel dataModel, bool keyboardOnly, bool ignoreConditions = false)
+ public List GetRenderLayers(ModuleDataModel dataModel, bool keyboardOnly, bool ignoreConditions = false)
{
var layers = new List();
foreach (var layerModel in Children.OrderByDescending(l => l.Order))
diff --git a/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/AmbientLightType.cs b/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/AmbientLightType.cs
index 5795bdbb0..d1170138b 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/AmbientLightType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/AmbientLight/AmbientLightType.cs
@@ -3,7 +3,7 @@ using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -52,7 +52,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
layerModel.Properties = new AmbientLightPropertiesModel(layerModel.Properties);
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
var properties = layerModel?.Properties as AmbientLightPropertiesModel;
if (properties == null) return;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/AudioCaptureManager.cs b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/AudioCaptureManager.cs
index 8d1df47a1..04ca51a5d 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/AudioCaptureManager.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/AudioCaptureManager.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Artemis.Modules.Effects.AudioVisualizer.Utilities;
using NAudio.CoreAudioApi;
using NAudio.Dsp;
using NAudio.Wave;
diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/FftEventArgs.cs b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/FftEventArgs.cs
similarity index 75%
rename from Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/FftEventArgs.cs
rename to Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/FftEventArgs.cs
index 01ce5163f..fb5466c7b 100644
--- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/FftEventArgs.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/FftEventArgs.cs
@@ -1,8 +1,8 @@
-using System;
+using System;
using System.Diagnostics;
using NAudio.Dsp;
-namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
+namespace Artemis.Profiles.Layers.Types.Audio.AudioCapturing
{
public class FftEventArgs : EventArgs
{
diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/SampleAggregator.cs b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/SampleAggregator.cs
similarity index 83%
rename from Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/SampleAggregator.cs
rename to Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/SampleAggregator.cs
index 14599c6be..ed286733a 100644
--- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/Utilities/SampleAggregator.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioCapturing/SampleAggregator.cs
@@ -1,9 +1,8 @@
using System;
using NAudio.Dsp;
-namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
-{ // The Complex and FFT are here!
-
+namespace Artemis.Profiles.Layers.Types.Audio.AudioCapturing
+{
public class SampleAggregator
{
private readonly FftEventArgs fftArgs;
@@ -17,9 +16,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
public SampleAggregator(int fftLength)
{
if (!IsPowerOfTwo(fftLength))
- {
throw new ArgumentException("FFT Length must be a power of two");
- }
m = (int) Math.Log(fftLength, 2.0);
this.fftLength = fftLength;
fftBuffer = new Complex[fftLength];
@@ -40,7 +37,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
if (PerformFFT && FftCalculated != null)
{
// Remember the window function! There are many others as well.
- fftBuffer[fftPos].X = (float) (value*FastFourierTransform.HammingWindow(fftPos, fftLength));
+ fftBuffer[fftPos].X = (float) (value * FastFourierTransform.HammingWindow(fftPos, fftLength));
fftBuffer[fftPos].Y = 0; // This is always zero with audio.
fftPos++;
if (fftPos >= fftLength)
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs
index 8aa99cefd..e2ee2999a 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -77,7 +77,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
}
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
layerModel.ApplyProperties(true);
if (isPreview)
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Folder/FolderType.cs b/Artemis/Artemis/Profiles/Layers/Types/Folder/FolderType.cs
index 2db638ead..52f5668c2 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Folder/FolderType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Folder/FolderType.cs
@@ -1,6 +1,6 @@
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -32,7 +32,7 @@ namespace Artemis.Profiles.Layers.Types.Folder
{
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
}
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Generic/GenericType.cs b/Artemis/Artemis/Profiles/Layers/Types/Generic/GenericType.cs
index 97fde86e3..04a01016e 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Generic/GenericType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Generic/GenericType.cs
@@ -1,7 +1,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -50,7 +50,7 @@ namespace Artemis.Profiles.Layers.Types.Generic
c.Pop();
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
// Generic layers are always drawn 10*10 (which is 40*40 when scaled up)
layerModel.Properties.Width = 10;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Headset/HeadsetType.cs b/Artemis/Artemis/Profiles/Layers/Types/Headset/HeadsetType.cs
index 76092cbea..1df4777bc 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Headset/HeadsetType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Headset/HeadsetType.cs
@@ -1,7 +1,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -50,7 +50,7 @@ namespace Artemis.Profiles.Layers.Types.Headset
c.Pop();
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
// Headset layers are always drawn 10*10 (which is 40*40 when scaled up)
layerModel.Properties.Width = 10;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
index 6c3628cd6..74f4d7cb0 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
@@ -5,7 +5,7 @@ using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
using Artemis.Managers;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -60,7 +60,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
}
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
// Key press is always as large as the entire keyboard it is drawn for
layerModel.Properties.Width = _deviceManager.ActiveKeyboard.Width;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Keyboard/KeyboardType.cs b/Artemis/Artemis/Profiles/Layers/Types/Keyboard/KeyboardType.cs
index d1ef34882..6e6627d43 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Keyboard/KeyboardType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Keyboard/KeyboardType.cs
@@ -1,6 +1,6 @@
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -59,7 +59,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
c.Pop();
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
layerModel.ApplyProperties(true);
if (isPreview || dataModel == null)
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyboardGif/KeyboardGifType.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyboardGif/KeyboardGifType.cs
index 4245d5350..bd0527a47 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/KeyboardGif/KeyboardGifType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyboardGif/KeyboardGifType.cs
@@ -2,7 +2,7 @@
using System.IO;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -56,10 +56,10 @@ namespace Artemis.Profiles.Layers.Types.KeyboardGif
}
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
layerModel.ApplyProperties(true);
- if (isPreview)
+ if (isPreview || dataModel == null)
return;
// If not previewing, apply dynamic properties according to datamodel
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Mouse/MouseType.cs b/Artemis/Artemis/Profiles/Layers/Types/Mouse/MouseType.cs
index 14b74f57b..df6d46592 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Mouse/MouseType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Mouse/MouseType.cs
@@ -1,7 +1,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -52,7 +52,7 @@ namespace Artemis.Profiles.Layers.Types.Mouse
c.Pop();
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
// Mouse layers are always drawn 10*10 (which is 40*40 when scaled up)
layerModel.Properties.Width = 10;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/Mousemat/MousematType.cs b/Artemis/Artemis/Profiles/Layers/Types/Mousemat/MousematType.cs
index d4986e7c0..58583e475 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/Mousemat/MousematType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/Mousemat/MousematType.cs
@@ -1,7 +1,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Media;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
@@ -50,7 +50,7 @@ namespace Artemis.Profiles.Layers.Types.Mousemat
c.Pop();
}
- public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
+ public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false)
{
// Mousemat layers are always drawn 10*10 (which is 40*40 when scaled up)
layerModel.Properties.Width = 10;
diff --git a/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceDrawingEventArgs.cs b/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceDrawingEventArgs.cs
index 3c5681a4d..3f46148e9 100644
--- a/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceDrawingEventArgs.cs
+++ b/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceDrawingEventArgs.cs
@@ -1,5 +1,5 @@
using System;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Lua.Wrappers;
using MoonSharp.Interpreter;
@@ -8,7 +8,7 @@ namespace Artemis.Profiles.Lua.Modules.Events
[MoonSharpUserData]
public class LuaDeviceDrawingEventArgs : EventArgs
{
- public LuaDeviceDrawingEventArgs(string deviceType, IDataModel dataModel, bool preview,
+ public LuaDeviceDrawingEventArgs(string deviceType, ModuleDataModel dataModel, bool preview,
LuaDrawWrapper luaDrawWrapper)
{
DeviceType = deviceType;
@@ -18,7 +18,7 @@ namespace Artemis.Profiles.Lua.Modules.Events
}
public string DeviceType { get; set; }
- public IDataModel DataModel { get; }
+ public ModuleDataModel DataModel { get; }
public bool Preview { get; }
public LuaDrawWrapper Drawing { get; set; }
}
diff --git a/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceUpdatingEventArgs.cs b/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceUpdatingEventArgs.cs
index 58945694f..83a500c41 100644
--- a/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceUpdatingEventArgs.cs
+++ b/Artemis/Artemis/Profiles/Lua/Modules/Events/LuaDeviceUpdatingEventArgs.cs
@@ -1,5 +1,5 @@
using System;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using MoonSharp.Interpreter;
namespace Artemis.Profiles.Lua.Modules.Events
@@ -7,7 +7,7 @@ namespace Artemis.Profiles.Lua.Modules.Events
[MoonSharpUserData]
public class LuaDeviceUpdatingEventArgs : EventArgs
{
- public LuaDeviceUpdatingEventArgs(string deviceType, IDataModel dataModel, bool preview)
+ public LuaDeviceUpdatingEventArgs(string deviceType, ModuleDataModel dataModel, bool preview)
{
DeviceType = deviceType;
DataModel = dataModel;
@@ -15,7 +15,7 @@ namespace Artemis.Profiles.Lua.Modules.Events
}
public string DeviceType { get; set; }
- public IDataModel DataModel { get; }
+ public ModuleDataModel DataModel { get; }
public bool Preview { get; }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Lua/Modules/LuaLayerModule.cs b/Artemis/Artemis/Profiles/Lua/Modules/LuaLayerModule.cs
index 77b99e7c8..f7e42ea1d 100644
--- a/Artemis/Artemis/Profiles/Lua/Modules/LuaLayerModule.cs
+++ b/Artemis/Artemis/Profiles/Lua/Modules/LuaLayerModule.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Windows.Media;
using Artemis.Managers;
-using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Profiles.Layers.Models;
using Artemis.Profiles.Lua.Modules.Brushes;
using Artemis.Profiles.Lua.Wrappers;
@@ -21,7 +20,7 @@ namespace Artemis.Profiles.Lua.Modules
SavedProperties = new Wrappers.LuaLayerProperties(_layerModel);
// Trigger an update to fill up the Properties
- _layerModel.Update(new ProfilePreviewDataModel(), true, false);
+ _layerModel.Update(null, true, false);
}
public override string ModuleName => "Layer";
diff --git a/Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs b/Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs
index 25a44a777..d107f57ff 100644
--- a/Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs
+++ b/Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
-using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Profiles.Layers.Models;
using Artemis.Profiles.Lua.Modules.Brushes;
using MoonSharp.Interpreter;
@@ -22,7 +21,7 @@ namespace Artemis.Profiles.Lua.Wrappers
SavedProperties = new LuaLayerProperties(layerModel);
// Triger an update to fill up the Properties
- _layerModel.Update(new ProfilePreviewDataModel(), true, false);
+ _layerModel.Update(null, true, false);
}
#region Child methods
diff --git a/Artemis/Artemis/Profiles/ProfileModel.cs b/Artemis/Artemis/Profiles/ProfileModel.cs
index da2f65901..b4ee3b625 100644
--- a/Artemis/Artemis/Profiles/ProfileModel.cs
+++ b/Artemis/Artemis/Profiles/ProfileModel.cs
@@ -8,7 +8,7 @@ using System.Windows.Media;
using Artemis.DeviceProviders;
using Artemis.Events;
using Artemis.Managers;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
using Artemis.Utilities;
@@ -71,12 +71,12 @@ namespace Artemis.Profiles
/// Generates a flat list containing all layers that must be rendered on the keyboard,
/// the first mouse layer to be rendered and the first headset layer to be rendered
///
- /// The game data model to base the conditions on
/// Instance of said game data model
/// Whether or not to ignore anything but keyboards
///
/// A flat list containing all layers that must be rendered
- public List GetRenderLayers(IDataModel dataModel, bool keyboardOnly, bool ignoreConditions = false)
+ public List GetRenderLayers(ModuleDataModel dataModel, bool keyboardOnly,
+ bool ignoreConditions = false)
{
var layers = new List();
foreach (var layerModel in Layers.OrderByDescending(l => l.Order))
@@ -85,10 +85,8 @@ namespace Artemis.Profiles
continue;
if (!ignoreConditions)
- {
if (!layerModel.ConditionsMet(dataModel))
continue;
- }
layers.Add(layerModel);
layers.AddRange(layerModel.GetRenderLayers(dataModel, keyboardOnly, ignoreConditions));
@@ -102,14 +100,15 @@ namespace Artemis.Profiles
///
/// The graphics to draw on
/// The layers to render
+ /// The type of device to draw for
/// The data model to base the layer's properties on
/// A rectangle matching the current keyboard's size on a scale of 4, used for clipping
/// Indicates wheter the layer is drawn as a preview, ignoring dynamic properties
/// Wheter or not to update the layer's animations
- /// The type of layers that are being updated, for reference in LUA
- internal void DrawLayers(Graphics g, IEnumerable renderLayers, IDataModel dataModel, Rect rect,
- bool preview, bool updateAnimations, string updateType)
+ internal void DrawLayers(Graphics g, List renderLayers, DrawType drawType, ModuleDataModel dataModel,
+ Rect rect, bool preview, bool updateAnimations)
{
+ renderLayers = renderLayers.Where(rl => rl.LayerType.DrawType == drawType).ToList();
var visual = new DrawingVisual();
var layerModels = renderLayers.ToList();
using (var c = visual.RenderOpen())
@@ -121,12 +120,12 @@ namespace Artemis.Profiles
// Update the layers
foreach (var layerModel in layerModels)
layerModel.Update(dataModel, preview, updateAnimations);
- RaiseDeviceUpdatedEvent(new ProfileDeviceEventsArg(updateType, dataModel, preview, null));
+ RaiseDeviceUpdatedEvent(new ProfileDeviceEventsArg(drawType, dataModel, preview, null));
// Draw the layers
foreach (var layerModel in layerModels)
layerModel.Draw(dataModel, c, preview, updateAnimations);
- RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(updateType, dataModel, preview, c));
+ RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(drawType, dataModel, preview, c));
// Remove the clip
c.Pop();
diff --git a/Artemis/Artemis/Settings/GameSettings.cs b/Artemis/Artemis/Settings/GameSettings.cs
deleted file mode 100644
index aa0c8015f..000000000
--- a/Artemis/Artemis/Settings/GameSettings.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.ComponentModel;
-using Newtonsoft.Json;
-
-namespace Artemis.Settings
-{
- public abstract class GameSettings : EffectSettings
- {
- [DefaultValue(true)]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public bool Enabled { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Settings/GeneralSettings.cs b/Artemis/Artemis/Settings/GeneralSettings.cs
index b8cf81ee0..e9e16ea9c 100644
--- a/Artemis/Artemis/Settings/GeneralSettings.cs
+++ b/Artemis/Artemis/Settings/GeneralSettings.cs
@@ -20,9 +20,9 @@ namespace Artemis.Settings
ApplyAutorun();
}
- [DefaultValue("WindowsProfile")]
+ [DefaultValue("GeneralProfile")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public string LastEffect { get; set; }
+ public string LastModule { get; set; }
[DefaultValue(null)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
diff --git a/Artemis/Artemis/Settings/OverlaySettings.cs b/Artemis/Artemis/Settings/OverlaySettings.cs
deleted file mode 100644
index efc7486c6..000000000
--- a/Artemis/Artemis/Settings/OverlaySettings.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.ComponentModel;
-using Newtonsoft.Json;
-
-namespace Artemis.Settings
-{
- public class OverlaySettings : EffectSettings
- {
- [DefaultValue(true)]
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
- public bool Enabled { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs b/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs
deleted file mode 100644
index ae443a4d6..000000000
--- a/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Artemis.DeviceProviders;
-
-namespace Artemis.Utilities.Keyboard
-{
- // TODO: Obsolete
- public class KeyboardRectangle
- {
- private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
- private readonly KeyboardProvider _keyboard;
- private int _blinkDelay;
- private double _rotationProgress;
-
- ///
- /// Represents a Rectangle on the keyboard which can be drawn to a Bitmap.
- /// By default, a rectangle is the entire keyboard's size.
- ///
- /// The keyboard this rectangle will be used for
- ///
- ///
- /// An array of colors the ColorBlend will use
- ///
- public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List colors,
- LinearGradientMode gradientMode)
- {
- _keyboard = keyboard;
- _rotationProgress = 0;
- _blinkWorker.DoWork += BlinkWorker_DoWork;
-
- Scale = 4;
- X = x;
- Y = y;
- Width = keyboard.Width*Scale;
- Height = keyboard.Height*Scale;
- Visible = true;
- Opacity = 255;
-
- ContainedBrush = true;
- GradientMode = gradientMode;
- Rotate = false;
- LoopSpeed = 1;
- Colors = colors;
- }
-
- public int X { get; set; }
- public int Y { get; set; }
- public int Width { get; set; }
- public int Height { get; set; }
- public bool Visible { get; set; }
- public byte Opacity { get; set; } // TODO: Remove
-
- ///
- /// Sets wether or not the colors should be contained within the rectangle, or span the entire keyboard.
- ///
- public bool ContainedBrush { get; set; }
-
- ///
- /// Used when ContainedBrush is set to false to make sure the colors span the entire keyboard on a higher scale.
- ///
- public int Scale { get; set; }
-
- ///
- /// Determines what grientmode to use in the LinearGradientBrush.
- ///
- public LinearGradientMode GradientMode { get; set; }
-
- ///
- /// Wether or not to rotate the colors over the brush.
- ///
- public bool Rotate { get; set; }
-
- ///
- /// What speed to ratate the colors on.
- ///
- public double LoopSpeed { get; set; }
-
- ///
- /// Colors used on the brush.
- ///
- public List Colors { get; set; }
-
- public void StartBlink(int delay)
- {
- _blinkDelay = delay;
-
- if (!_blinkWorker.IsBusy)
- _blinkWorker.RunWorkerAsync();
- }
-
- public void StartBlink(int delay, int time)
- {
- StartBlink(delay);
- Task.Factory.StartNew(() =>
- {
- Thread.Sleep(delay);
- StopBlink();
- });
- }
-
- public void StopBlink()
- {
- if (_blinkWorker.IsBusy)
- _blinkWorker.CancelAsync();
- }
-
- private void BlinkWorker_DoWork(object sender, DoWorkEventArgs e)
- {
- while (!_blinkWorker.CancellationPending)
- {
- Thread.Sleep(_blinkDelay);
- Visible = !Visible;
- }
- Visible = true;
- }
-
- public void Draw(Graphics g)
- {
- if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
- return;
-
- var brush = CreateBrush();
- var baseRect = new Rectangle(X, Y, Width, Height);
-
- g.FillRectangle(brush, baseRect);
- if (!Rotate)
- return;
-
- _rotationProgress = _rotationProgress + LoopSpeed;
- if (ContainedBrush && _rotationProgress > Width)
- _rotationProgress = LoopSpeed;
- else if (!ContainedBrush && _rotationProgress > _keyboard.Width*Scale)
- _rotationProgress = LoopSpeed;
- }
-
- private LinearGradientBrush CreateBrush()
- {
- var colorBlend = CreateColorBlend();
- RectangleF rect;
- if (Rotate)
- rect = ContainedBrush
- ? new Rectangle((int) _rotationProgress, Y, Width*2, Height*2)
- : new Rectangle((int) _rotationProgress, 0, _keyboard.Width*Scale*2, _keyboard.Height*Scale*2);
- else
- rect = ContainedBrush
- ? new Rectangle(X, Y, Width, Height)
- : new Rectangle(0, 0, _keyboard.Width*Scale, _keyboard.Height*Scale);
-
- return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, GradientMode)
- {
- InterpolationColors = colorBlend
- };
- }
-
- private ColorBlend CreateColorBlend()
- {
- if (Colors.Count == 1)
- return new ColorBlend {Colors = new[] {Colors[0], Colors[0]}, Positions = new[] {0F, 1F}};
- var colorBlend = Rotate
- ? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
- : new ColorBlend {Colors = Colors.ToArray()};
-
- // If needed, apply opacity to the colors in the blend
- if (Opacity < 255)
- for (var i = 0; i < colorBlend.Colors.Length; i++)
- colorBlend.Colors[i] = Color.FromArgb(Opacity, colorBlend.Colors[i]);
-
- // Devide the colors over the colorblend
- var devider = (float) colorBlend.Colors.Length - 1;
- var positions = new List();
- for (var i = 0; i < colorBlend.Colors.Length; i++)
- positions.Add(i/devider);
-
- // Apply the devided positions
- colorBlend.Positions = positions.ToArray();
- return colorBlend;
- }
-
- private List CreateTilebleColors(List sourceColors)
- {
- // Create a list using the original colors
- var tilebleColors = new List(sourceColors);
- // Add the original colors again
- tilebleColors.AddRange(sourceColors);
- // Add the first color, smoothing the transition
- tilebleColors.Add(sourceColors.FirstOrDefault());
- return tilebleColors;
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs
deleted file mode 100644
index 89e9ec09e..000000000
--- a/Artemis/Artemis/ViewModels/Abstract/EffectViewModel.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using Artemis.DAL;
-using Artemis.Events;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Services;
-using Artemis.Settings;
-using Caliburn.Micro;
-using Ninject;
-
-namespace Artemis.ViewModels.Abstract
-{
- public abstract class EffectViewModel : Screen
- {
- protected readonly EffectModel EffectModel;
- private EffectSettings _effectSettings;
- private bool _showDisabledPopup;
- protected MainManager MainManager;
-
- protected EffectViewModel(MainManager mainManager, EffectModel effectModel)
- {
- MainManager = mainManager;
- EffectModel = effectModel;
- EffectSettings = effectModel.Settings;
-
- MainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;
- MainManager.EffectManager.OnEffectChangedEvent += EffectManagerOnOnEffectChangedEvent;
- }
-
- private void MainManagerOnOnEnabledChangedEvent(object sender, EnabledChangedEventArgs e)
- {
- NotifyOfPropertyChange(() => EffectEnabled);
- }
-
- private void EffectManagerOnOnEffectChangedEvent(object sender, EffectChangedEventArgs e)
- {
- NotifyOfPropertyChange(() => EffectEnabled);
- }
-
- [Inject]
- public MetroDialogService DialogService { get; set; }
-
- public EffectSettings EffectSettings
- {
- get { return _effectSettings; }
- set
- {
- if (Equals(value, _effectSettings)) return;
- _effectSettings = value;
- NotifyOfPropertyChange(() => EffectSettings);
- }
- }
-
- public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel;
-
- public bool ShowDisabledPopup
- {
- get { return _showDisabledPopup; }
- set
- {
- if (value == _showDisabledPopup) return;
- _showDisabledPopup = value;
- NotifyOfPropertyChange(() => ShowDisabledPopup);
- }
- }
-
- public void ToggleEffect()
- {
- if (!MainManager.ProgramEnabled)
- {
- NotifyOfPropertyChange(() => EffectEnabled);
- ShowDisabledPopup = true;
- return;
- }
-
- if (EffectEnabled)
- MainManager.EffectManager.ClearEffect();
- else
- MainManager.EffectManager.ChangeEffect(EffectModel, MainManager.LoopManager);
- }
-
- public virtual void SaveSettings()
- {
- EffectSettings?.Save();
- if (!EffectEnabled)
- return;
-
- // Restart the effect if it's currently running to apply settings.
- MainManager.EffectManager.ChangeEffect(EffectModel);
- }
-
- public async void ResetSettings()
- {
- var resetConfirm = await
- 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;
-
- EffectSettings.Reset(true);
- NotifyOfPropertyChange(() => EffectSettings);
-
- SaveSettings();
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
deleted file mode 100644
index 6c8a9703d..000000000
--- a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System.ComponentModel;
-using System.Timers;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Modules.Effects.ProfilePreview;
-using Artemis.Services;
-using Artemis.Settings;
-using Artemis.ViewModels.Profiles;
-using Caliburn.Micro;
-using Ninject;
-using Ninject.Extensions.Logging;
-using Ninject.Parameters;
-
-namespace Artemis.ViewModels.Abstract
-{
- public abstract class GameViewModel : Screen
- {
- private GameSettings _gameSettings;
-
- protected GameViewModel(MainManager mainManager, GameModel gameModel, IKernel kernel)
- {
- MainManager = mainManager;
- GameModel = gameModel;
- GameSettings = gameModel.Settings;
-
- IParameter[] args =
- {
- new ConstructorArgument("mainManager", mainManager),
- new ConstructorArgument("effectModel", gameModel),
- new ConstructorArgument("lastProfile", GameSettings.LastProfile)
- };
- ProfileEditor = kernel.Get(args);
- ProfileEditor.PropertyChanged += ProfileUpdater;
-
- GameModel.Profile = ProfileEditor.SelectedProfile;
- }
-
- [Inject]
- public ILogger Logger { get; set; }
-
- [Inject]
- public ProfilePreviewModel ProfilePreviewModel { get; set; }
-
- [Inject]
- public MetroDialogService DialogService { get; set; }
-
- public ProfileEditorViewModel ProfileEditor { get; set; }
-
- public GameModel GameModel { get; set; }
- public MainManager MainManager { get; set; }
-
- public GameSettings GameSettings
- {
- get { return _gameSettings; }
- set
- {
- if (Equals(value, _gameSettings)) return;
- _gameSettings = value;
- NotifyOfPropertyChange(() => GameSettings);
- }
- }
-
- public bool GameEnabled => MainManager.EffectManager.ActiveEffect.Name == GameModel.Name;
-
- public void ToggleEffect()
- {
- GameModel.Enabled = GameSettings.Enabled;
- }
-
- public void SaveSettings()
- {
- GameSettings?.Save();
- ProfileEditor.SaveSelectedProfile();
-
- if (!GameEnabled)
- return;
-
- // Restart the game if it's currently running to apply settings.
- MainManager.EffectManager.ChangeEffect(GameModel, MainManager.LoopManager);
- }
-
- public async void ResetSettings()
- {
- var resetConfirm =
- await 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;
-
- GameSettings.Reset(true);
- NotifyOfPropertyChange(() => GameSettings);
-
- SaveSettings();
- }
-
- private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
- {
- if ((e.PropertyName != "SelectedProfile") && IsActive)
- return;
-
- GameModel.Profile = ProfileEditor.SelectedProfile;
- ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
-
- // Only update the last selected profile if it the editor was active and the new profile isn't null
- if ((e.PropertyName != "SelectedProfile") || !ProfileEditor.ProfileViewModel.Activated ||
- (ProfileEditor.ProfileViewModel.SelectedProfile == null))
- return;
-
- GameSettings.LastProfile = ProfileEditor.ProfileViewModel.SelectedProfile.Name;
- GameSettings.Save();
- }
-
- protected override void OnActivate()
- {
- base.OnActivate();
- ProfileEditor.Activate();
- }
-
- protected override void OnDeactivate(bool close)
- {
- base.OnDeactivate(close);
- ProfileEditor.Deactivate();
- }
- }
-
- public delegate void OnLayersUpdatedCallback(object sender);
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs
deleted file mode 100644
index 7d0a315cd..000000000
--- a/Artemis/Artemis/ViewModels/Abstract/OverlayViewModel.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Services;
-using Artemis.Settings;
-using Caliburn.Micro;
-using Ninject;
-
-namespace Artemis.ViewModels.Abstract
-{
- public abstract class OverlayViewModel : Screen
- {
- protected readonly MainManager MainManager;
- private OverlaySettings _overlaySettings;
-
- protected OverlayViewModel(MainManager mainManager, OverlayModel overlayModel)
- {
- MainManager = mainManager;
- OverlayModel = overlayModel;
- OverlaySettings = overlayModel.Settings;
- }
-
- [Inject]
- public MetroDialogService DialogService { get; set; }
-
- public OverlayModel OverlayModel { get; set; }
-
- public OverlaySettings OverlaySettings
- {
- get { return _overlaySettings; }
- set
- {
- if (Equals(value, _overlaySettings)) return;
- _overlaySettings = value;
- NotifyOfPropertyChange(() => OverlaySettings);
- }
- }
-
- public void ToggleOverlay()
- {
- OverlayModel.Enabled = OverlaySettings.Enabled;
- }
-
- public void SaveSettings()
- {
- OverlaySettings?.Save();
- }
-
- public async void ResetSettings()
- {
- var resetConfirm = await
- DialogService.ShowQuestionMessageBox("Reset overlay settings",
- "Are you sure you wish to reset this overlay's settings? \nAny changes you made will be lost.");
-
- if (!resetConfirm.Value)
- return;
-
- OverlaySettings.Reset(true);
- NotifyOfPropertyChange(() => OverlaySettings);
-
- OverlayModel.Enabled = OverlaySettings.Enabled;
- SaveSettings();
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/EffectsViewModel.cs b/Artemis/Artemis/ViewModels/EffectsViewModel.cs
deleted file mode 100644
index 5f41ea4a3..000000000
--- a/Artemis/Artemis/ViewModels/EffectsViewModel.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Linq;
-using Artemis.ViewModels.Abstract;
-
-namespace Artemis.ViewModels
-{
- public sealed class EffectsViewModel : BaseViewModel
- {
- private IOrderedEnumerable _vms;
-
- public EffectsViewModel(EffectViewModel[] effectViewModels)
- {
- DisplayName = "Effects";
-
- _vms = effectViewModels.OrderBy(o => o.DisplayName);
- }
-
- protected override void OnActivate()
- {
- base.OnActivate();
- Items.Clear();
- Items.AddRange(_vms);
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
index cda9415c9..1f9e8c4ad 100644
--- a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
@@ -40,8 +40,8 @@ namespace Artemis.ViewModels.Flyouts
LogLevels.AddRange(LogLevel.AllLoggingLevels.Select(l => l.Name));
PropertyChanged += KeyboardUpdater;
- mainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;
- mainManager.EffectManager.OnEffectChangedEvent += EffectManagerOnOnEffectChangedEvent;
+ mainManager.EnabledChanged += MainManagerEnabledChanged;
+ mainManager.ModuleManager.EffectChanged += EffectManagerEffectChanged;
}
public MainManager MainManager { get; set; }
@@ -162,14 +162,14 @@ namespace Artemis.ViewModels.Flyouts
}
}
- private void MainManagerOnOnEnabledChangedEvent(object sender, EnabledChangedEventArgs enabledChangedEventArgs)
+ private void MainManagerEnabledChanged(object sender, EnabledChangedEventArgs enabledChangedEventArgs)
{
NotifyOfPropertyChange(() => Enabled);
}
- private void EffectManagerOnOnEffectChangedEvent(object sender, EffectChangedEventArgs e)
+ private void EffectManagerEffectChanged(object sender, ModuleChangedEventArgs e)
{
- var effectDisplay = string.IsNullOrEmpty(e.Effect?.Name) ? "none" : e.Effect.Name;
+ var effectDisplay = string.IsNullOrEmpty(e.Module?.Name) ? "none" : e.Module.Name;
ActiveEffectName = $"Active effect: {effectDisplay}";
}
diff --git a/Artemis/Artemis/ViewModels/GamesViewModel.cs b/Artemis/Artemis/ViewModels/GamesViewModel.cs
index 6aac8e4e5..68a5d6041 100644
--- a/Artemis/Artemis/ViewModels/GamesViewModel.cs
+++ b/Artemis/Artemis/ViewModels/GamesViewModel.cs
@@ -1,7 +1,8 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
using Artemis.DAL;
using Artemis.Managers;
-using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.Modules.Abstract;
using Artemis.Settings;
using Artemis.ViewModels.Abstract;
@@ -9,21 +10,24 @@ namespace Artemis.ViewModels
{
public sealed class GamesViewModel : BaseViewModel
{
- private readonly IOrderedEnumerable _vms;
+ private readonly List _vms;
- public GamesViewModel(GameViewModel[] gameViewModels, ProfileManager profileManager,
- ProfilePreviewModel profilePreviewModel)
+ public GamesViewModel(IEnumerable moduleViewModels)
{
DisplayName = "Games";
// Currently WoW is locked behind a hidden trigger (obviously not that hidden since you're reading this)
// It is using memory reading and lets first try to contact Blizzard
- _vms = SettingsProvider.Load().GamestatePort == 62575
- ? gameViewModels.OrderBy(g => g.DisplayName)
- : gameViewModels.Where(g => g.DisplayName != "WoW").OrderBy(g => g.DisplayName);
-
- profileManager.ProfilePreviewModel = profilePreviewModel;
- profileManager.GameViewModels.AddRange(_vms);
+ if (SettingsProvider.Load().GamestatePort == 62575)
+ {
+ _vms = moduleViewModels.Where(m => m.ModuleModel.IsBoundToProcess)
+ .OrderBy(g => g.DisplayName).ToList();
+ }
+ else
+ {
+ _vms = moduleViewModels.Where(m => m.ModuleModel.IsBoundToProcess && m.DisplayName != "WoW")
+ .OrderBy(g => g.DisplayName).ToList();
+ }
}
protected override void OnActivate()
diff --git a/Artemis/Artemis/ViewModels/GeneralViewModel.cs b/Artemis/Artemis/ViewModels/GeneralViewModel.cs
new file mode 100644
index 000000000..f800712fe
--- /dev/null
+++ b/Artemis/Artemis/ViewModels/GeneralViewModel.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+using System.Linq;
+using Artemis.Managers;
+using Artemis.Modules.Abstract;
+using Artemis.ViewModels.Abstract;
+
+namespace Artemis.ViewModels
+{
+ public sealed class GeneralViewModel : BaseViewModel
+ {
+ private readonly List _vms;
+
+ public GeneralViewModel(List moduleViewModels, ProfileManager profileManager)
+ {
+ DisplayName = "General";
+ _vms = moduleViewModels.Where(m => !m.ModuleModel.IsOverlay && !m.ModuleModel.IsBoundToProcess)
+ .OrderBy(m => m.DisplayName).ToList();
+
+ profileManager.PreviewViewModules.Clear();
+ profileManager.PreviewViewModules.AddRange(moduleViewModels.Where(m => m.UsesProfileEditor));
+ }
+
+ protected override void OnActivate()
+ {
+ base.OnActivate();
+ Items.Clear();
+ Items.AddRange(_vms);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/OverlaysViewModel.cs b/Artemis/Artemis/ViewModels/OverlaysViewModel.cs
index cb7d93271..5844d44ff 100644
--- a/Artemis/Artemis/ViewModels/OverlaysViewModel.cs
+++ b/Artemis/Artemis/ViewModels/OverlaysViewModel.cs
@@ -1,16 +1,18 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
+using Artemis.Modules.Abstract;
using Artemis.ViewModels.Abstract;
namespace Artemis.ViewModels
{
public sealed class OverlaysViewModel : BaseViewModel
{
- private IOrderedEnumerable _vms;
+ private readonly List _vms;
- public OverlaysViewModel(OverlayViewModel[] overlayViewModels)
+ public OverlaysViewModel(IEnumerable moduleViewModels)
{
DisplayName = "Overlays";
- _vms = overlayViewModels.OrderBy(o => o.DisplayName);
+ _vms = moduleViewModels.Where(m => m.ModuleModel.IsOverlay).OrderBy(m => m.DisplayName).ToList();
}
protected override void OnActivate()
diff --git a/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
index edea36331..035fd42ad 100644
--- a/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
-using Artemis.Models.Interfaces;
+using Artemis.Modules.Abstract;
using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
@@ -26,7 +26,7 @@ namespace Artemis.ViewModels.Profiles
private LayerModel _proposedLayer;
private ILayerType _selectedLayerType;
- public LayerEditorViewModel(LayerModel layer, IDataModel dataModel, IEnumerable types,
+ public LayerEditorViewModel(LayerModel layer, ModuleDataModel dataModel, IEnumerable types,
IEnumerable layerAnimations)
{
Layer = layer;
diff --git a/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
index 1a6a8d678..82882ec80 100644
--- a/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
@@ -14,7 +14,7 @@ using Artemis.DAL;
using Artemis.DeviceProviders;
using Artemis.Events;
using Artemis.Managers;
-using Artemis.Models;
+using Artemis.Modules.Abstract;
using Artemis.Profiles;
using Artemis.Profiles.Layers.Models;
using Artemis.Profiles.Layers.Types.Folder;
@@ -23,10 +23,8 @@ using Artemis.Services;
using Artemis.Styles.DropTargetAdorners;
using Artemis.Utilities;
using Caliburn.Micro;
-using Castle.Core.Internal;
using GongSolutions.Wpf.DragDrop;
using MahApps.Metro.Controls.Dialogs;
-using Ninject;
using Ninject.Parameters;
using NuGet;
using DragDropEffects = System.Windows.DragDropEffects;
@@ -40,34 +38,33 @@ namespace Artemis.ViewModels.Profiles
public sealed class ProfileEditorViewModel : Screen, IDropTarget
{
private readonly DeviceManager _deviceManager;
- private readonly EffectModel _effectModel;
private readonly LuaManager _luaManager;
+ private readonly ModuleModel _moduleModel;
private readonly Timer _saveTimer;
+ private readonly MetroDialogService _dialogService;
+ private readonly WindowService _windowService;
private ImageSource _keyboardPreview;
private ObservableCollection _layers;
private ObservableCollection _profileNames;
private bool _saving;
- private ProfileModel _selectedProfile;
private FileSystemWatcher _watcher;
- public ProfileEditorViewModel(DeviceManager deviceManager, LuaManager luaManager, EffectModel effectModel,
- ProfileViewModel profileViewModel, MetroDialogService dialogService, WindowService windowService,
- string lastProfile)
+ public ProfileEditorViewModel(DeviceManager deviceManager, LuaManager luaManager, ModuleModel moduleModel,
+ ProfileViewModel profileViewModel, MetroDialogService dialogService, WindowService windowService)
{
_deviceManager = deviceManager;
_luaManager = luaManager;
- _effectModel = effectModel;
+ _moduleModel = moduleModel;
+ _dialogService = dialogService;
+ _windowService = windowService;
ProfileNames = new ObservableCollection();
Layers = new ObservableCollection();
ProfileViewModel = profileViewModel;
- DialogService = dialogService;
- WindowService = windowService;
- LastProfile = lastProfile;
PropertyChanged += EditorStateHandler;
ProfileViewModel.PropertyChanged += LayerSelectedHandler;
- _deviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;
+ _deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
_saveTimer = new Timer(5000);
_saveTimer.Elapsed += ProfileSaveHandler;
@@ -75,17 +72,14 @@ namespace Artemis.ViewModels.Profiles
LoadProfiles();
}
- [Inject]
- public MetroDialogService DialogService { get; set; }
-
- public WindowService WindowService { get; set; }
-
- public string LastProfile { get; set; }
-
public ProfileViewModel ProfileViewModel { get; set; }
public bool EditorEnabled
- => SelectedProfile != null && !SelectedProfile.IsDefault && _deviceManager.ActiveKeyboard != null;
+ =>
+ SelectedProfile != null && !SelectedProfile.IsDefault &&
+ _deviceManager.ActiveKeyboard != null;
+
+ public ProfileModel SelectedProfile => _moduleModel?.ProfileModel;
public ObservableCollection ProfileNames
{
@@ -117,36 +111,9 @@ namespace Artemis.ViewModels.Profiles
if (value == SelectedProfile?.Name)
return;
- SelectedProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _effectModel, value);
+ _moduleModel.ChangeProfile(ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _moduleModel, value));
NotifyOfPropertyChange(() => SelectedProfileName);
- }
- }
-
- public ProfileModel SelectedProfile
- {
- get { return _selectedProfile; }
- set
- {
- if (Equals(value, _selectedProfile))
- return;
-
- if (IsActive)
- {
- // Deactivate old profile
- _selectedProfile?.Deactivate(_luaManager);
- // Update the value
- _selectedProfile = value;
- // Activate new profile
- _selectedProfile?.Activate(_luaManager);
- }
- else
- {
- // Update the value
- _selectedProfile = value;
- }
-
NotifyOfPropertyChange(() => SelectedProfile);
- NotifyOfPropertyChange(() => SelectedProfileName);
}
}
@@ -237,7 +204,7 @@ namespace Artemis.ViewModels.Profiles
///
/// Handles chaning the active keyboard, updating the preview image and profiles collection
///
- private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs e)
+ private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
{
NotifyOfPropertyChange(() => PreviewSettings);
LoadProfiles();
@@ -245,7 +212,6 @@ namespace Artemis.ViewModels.Profiles
public void Activate()
{
- _selectedProfile?.Activate(_luaManager);
ProfileViewModel.Activate();
_saveTimer.Start();
}
@@ -265,22 +231,10 @@ namespace Artemis.ViewModels.Profiles
Execute.OnUIThread(() =>
{
ProfileNames.Clear();
- if (_effectModel == null || _deviceManager.ActiveKeyboard == null)
- return;
+ if (_moduleModel != null && _deviceManager.ActiveKeyboard != null)
+ ProfileNames.AddRange(ProfileProvider.GetProfileNames(_deviceManager.ActiveKeyboard, _moduleModel));
- ProfileNames.AddRange(ProfileProvider.GetProfileNames(_deviceManager.ActiveKeyboard, _effectModel));
-
- // If a profile name was provided, try to load it
- ProfileModel lastProfileModel = null;
- if (!string.IsNullOrEmpty(LastProfile))
- lastProfileModel = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _effectModel,
- LastProfile);
-
- if (lastProfileModel != null)
- SelectedProfile = lastProfileModel;
- else
- SelectedProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _effectModel,
- ProfileNames.FirstOrDefault());
+ NotifyOfPropertyChange(() => SelectedProfile);
});
}
@@ -313,10 +267,10 @@ namespace Artemis.ViewModels.Profiles
IParameter[] args =
{
- new ConstructorArgument("dataModel", _effectModel.DataModel),
+ new ConstructorArgument("dataModel", _moduleModel.DataModel),
new ConstructorArgument("layer", layer)
};
- WindowService.ShowDialog(args);
+ _windowService.ShowDialog(args);
// If the layer was a folder, but isn't anymore, assign it's children to it's parent.
if (!(layer.LayerType is FolderType) && layer.Children.Any())
@@ -410,7 +364,7 @@ namespace Artemis.ViewModels.Profiles
var newName =
await
- DialogService.ShowInputDialog("Rename layer", "Please enter a name for the layer",
+ _dialogService.ShowInputDialog("Rename layer", "Please enter a name for the layer",
new MetroDialogSettings {DefaultText = layer.Name});
// Null when the user cancelled
if (string.IsNullOrEmpty(newName))
@@ -498,12 +452,12 @@ namespace Artemis.ViewModels.Profiles
{
if (_deviceManager.ActiveKeyboard == null)
{
- DialogService.ShowMessageBox("Cannot add profile.",
+ _dialogService.ShowMessageBox("Cannot add profile.",
"To add a profile, please select a keyboard in the options menu first.");
return;
}
- var name = await DialogService.ShowInputDialog("Add new profile",
+ var name = await _dialogService.ShowInputDialog("Add new profile",
"Please provide a profile name unique to this game and keyboard.");
// Null when the user cancelled
@@ -512,7 +466,7 @@ namespace Artemis.ViewModels.Profiles
if (name.Length < 2)
{
- DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
+ _dialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
return;
}
@@ -522,12 +476,12 @@ namespace Artemis.ViewModels.Profiles
KeyboardSlug = _deviceManager.ActiveKeyboard.Slug,
Width = _deviceManager.ActiveKeyboard.Width,
Height = _deviceManager.ActiveKeyboard.Height,
- GameName = _effectModel.Name
+ GameName = _moduleModel.Name
};
if (!ProfileProvider.IsProfileUnique(profile))
{
- var overwrite = await DialogService.ShowQuestionMessageBox("Overwrite existing profile",
+ var overwrite = await _dialogService.ShowQuestionMessageBox("Overwrite existing profile",
"A profile with this name already exists for this game. Would you like to overwrite it?");
if (!overwrite.Value)
return;
@@ -535,7 +489,6 @@ namespace Artemis.ViewModels.Profiles
ProfileProvider.AddOrUpdate(profile);
- LastProfile = profile.Name;
LoadProfiles();
}
@@ -545,7 +498,7 @@ namespace Artemis.ViewModels.Profiles
return;
var oldName = SelectedProfile.Name;
- var name = await DialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
+ var name = await _dialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
// Null when the user cancelled
if (string.IsNullOrEmpty(name) || name.Length < 2)
@@ -556,7 +509,7 @@ namespace Artemis.ViewModels.Profiles
// Verify the name
while (!ProfileProvider.IsProfileUnique(SelectedProfile))
{
- name = await DialogService
+ name = await _dialogService
.ShowInputDialog("Name already in use", "Please enter a unique new profile name");
// Null when the user cancelled
@@ -571,8 +524,6 @@ namespace Artemis.ViewModels.Profiles
var profile = SelectedProfile;
ProfileProvider.RenameProfile(profile, name);
- SelectedProfile = null;
- LastProfile = name;
LoadProfiles();
}
@@ -582,7 +533,7 @@ namespace Artemis.ViewModels.Profiles
return;
var newProfile = GeneralHelpers.Clone(SelectedProfile);
- newProfile.Name = await DialogService
+ newProfile.Name = await _dialogService
.ShowInputDialog("Duplicate profile", "Please enter a unique profile name");
// Null when the user cancelled
@@ -592,7 +543,7 @@ namespace Artemis.ViewModels.Profiles
// Verify the name
while (!ProfileProvider.IsProfileUnique(newProfile))
{
- newProfile.Name = await DialogService
+ newProfile.Name = await _dialogService
.ShowInputDialog("Name already in use", "Please enter a unique profile name");
// Null when the user cancelled
@@ -602,7 +553,6 @@ namespace Artemis.ViewModels.Profiles
newProfile.IsDefault = false;
ProfileProvider.AddOrUpdate(newProfile);
- LastProfile = newProfile.Name;
LoadProfiles();
}
@@ -612,13 +562,18 @@ namespace Artemis.ViewModels.Profiles
return;
var confirm = await
- DialogService.ShowQuestionMessageBox("Delete profile",
+ _dialogService.ShowQuestionMessageBox("Delete profile",
$"Are you sure you want to delete the profile named: {SelectedProfile.Name}?\n\n" +
"This cannot be undone.");
if (!confirm.Value)
return;
- ProfileProvider.DeleteProfile(SelectedProfile);
+ var defaultProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _moduleModel, "Default");
+ var deleteProfile = SelectedProfile;
+
+ _moduleModel.ChangeProfile(defaultProfile);
+ ProfileProvider.DeleteProfile(deleteProfile);
+
LoadProfiles();
}
@@ -626,7 +581,7 @@ namespace Artemis.ViewModels.Profiles
{
if (_deviceManager.ActiveKeyboard == null)
{
- DialogService.ShowMessageBox("Cannot import profile.",
+ _dialogService.ShowMessageBox("Cannot import profile.",
"To import a profile, please select a keyboard in the options menu first.");
return;
}
@@ -638,16 +593,16 @@ namespace Artemis.ViewModels.Profiles
var profile = ProfileProvider.LoadProfileIfValid(dialog.FileName);
if (profile == null)
{
- DialogService.ShowErrorMessageBox("Oh noes, the profile you provided is invalid. " +
- "If this keeps happening, please make an issue on GitHub and provide the profile.");
+ _dialogService.ShowErrorMessageBox("Oh noes, the profile you provided is invalid. " +
+ "If this keeps happening, please make an issue on GitHub and provide the profile.");
return;
}
// Verify the game
- if (profile.GameName != _effectModel.Name)
+ if (profile.GameName != _moduleModel.Name)
{
- DialogService.ShowErrorMessageBox(
- $"Oh oops! This profile is ment for {profile.GameName}, not {_effectModel.Name} :c");
+ _dialogService.ShowErrorMessageBox(
+ $"Oh oops! This profile is ment for {profile.GameName}, not {_moduleModel.Name} :c");
return;
}
@@ -655,7 +610,8 @@ namespace Artemis.ViewModels.Profiles
var deviceManager = _deviceManager;
if (profile.KeyboardSlug != deviceManager.ActiveKeyboard.Slug)
{
- var adjustKeyboard = await DialogService.ShowQuestionMessageBox("Profile not inteded for this keyboard",
+ var adjustKeyboard = await _dialogService.ShowQuestionMessageBox(
+ "Profile not inteded for this keyboard",
$"Watch out, this profile wasn't ment for this keyboard, but for the {profile.KeyboardSlug}. " +
"You can still import it but you'll probably have to do some adjusting\n\n" +
"Continue?");
@@ -678,7 +634,7 @@ namespace Artemis.ViewModels.Profiles
// Verify the name
while (!ProfileProvider.IsProfileUnique(profile))
{
- profile.Name = await DialogService.ShowInputDialog("Rename imported profile",
+ profile.Name = await _dialogService.ShowInputDialog("Rename imported profile",
"A profile with this name already exists for this game. Please enter a new name");
// Null when the user cancelled
@@ -687,7 +643,6 @@ namespace Artemis.ViewModels.Profiles
}
ProfileProvider.AddOrUpdate(profile);
- LastProfile = profile.Name;
LoadProfiles();
}
@@ -714,7 +669,7 @@ namespace Artemis.ViewModels.Profiles
}
catch (Exception e)
{
- DialogService.ShowMessageBox("Couldn't open LUA file",
+ _dialogService.ShowMessageBox("Couldn't open LUA file",
"Please make sure you have a text editor associated with the .lua extension.\n\n" +
"Windows error message: \n" + e.Message);
}
@@ -727,8 +682,6 @@ namespace Artemis.ViewModels.Profiles
// Update editor enabled state
NotifyOfPropertyChange(() => EditorEnabled);
- // Update ProfileViewModel
- ProfileViewModel.SelectedProfile = SelectedProfile;
// Update interface
Layers.Clear();
@@ -768,66 +721,66 @@ namespace Artemis.ViewModels.Profiles
_saving = false;
}
- #region LUA Editor
-
- public void OpenEditor()
- {
- if (SelectedProfile == null)
- return;
-
- // Create a temp file
- var fileName = Guid.NewGuid() + ".lua";
- var file = File.Create(Path.GetTempPath() + fileName);
- file.Dispose();
-
- // Add instructions to LUA script if it's a new file
- if (SelectedProfile.LuaScript.IsNullOrEmpty())
- SelectedProfile.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
- File.WriteAllText(Path.GetTempPath() + fileName, SelectedProfile.LuaScript);
-
- // Watch the file for changes
- SetupWatcher(Path.GetTempPath(), fileName);
-
- // Open the temp file with the default editor
- System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
- }
-
- private void SetupWatcher(string path, string fileName)
- {
- if (_watcher == null)
- {
- _watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
- _watcher.Changed += LuaFileChanged;
- _watcher.EnableRaisingEvents = true;
- }
-
- _watcher.Path = path;
- _watcher.Filter = fileName;
- }
-
- private void LuaFileChanged(object sender, FileSystemEventArgs args)
- {
- if (args.ChangeType != WatcherChangeTypes.Changed)
- return;
-
- if (SelectedProfile == null)
- return;
-
- lock (SelectedProfile)
- {
- using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- using (var sr = new StreamReader(fs))
- {
- SelectedProfile.LuaScript = sr.ReadToEnd();
- }
- }
-
- ProfileProvider.AddOrUpdate(SelectedProfile);
- _luaManager.SetupLua(SelectedProfile);
- }
- }
-
+ #region LUA Editor
+
+ public void OpenEditor()
+ {
+ if (SelectedProfile == null)
+ return;
+
+ // Create a temp file
+ var fileName = Guid.NewGuid() + ".lua";
+ var file = File.Create(Path.GetTempPath() + fileName);
+ file.Dispose();
+
+ // Add instructions to LUA script if it's a new file
+ if (string.IsNullOrEmpty(SelectedProfile.LuaScript))
+ SelectedProfile.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
+ File.WriteAllText(Path.GetTempPath() + fileName, SelectedProfile.LuaScript);
+
+ // Watch the file for changes
+ SetupWatcher(Path.GetTempPath(), fileName);
+
+ // Open the temp file with the default editor
+ System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
+ }
+
+ private void SetupWatcher(string path, string fileName)
+ {
+ if (_watcher == null)
+ {
+ _watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
+ _watcher.Changed += LuaFileChanged;
+ _watcher.EnableRaisingEvents = true;
+ }
+
+ _watcher.Path = path;
+ _watcher.Filter = fileName;
+ }
+
+ private void LuaFileChanged(object sender, FileSystemEventArgs args)
+ {
+ if (args.ChangeType != WatcherChangeTypes.Changed)
+ return;
+
+ if (SelectedProfile == null)
+ return;
+
+ lock (SelectedProfile)
+ {
+ using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ {
+ using (var sr = new StreamReader(fs))
+ {
+ SelectedProfile.LuaScript = sr.ReadToEnd();
+ }
+ }
+
+ ProfileProvider.AddOrUpdate(SelectedProfile);
+ _luaManager.SetupLua(SelectedProfile);
+ }
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
index 219136b0e..f25ccf9da 100644
--- a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
@@ -7,8 +7,8 @@ using System.Windows.Input;
using System.Windows.Media;
using Artemis.Events;
using Artemis.Managers;
-using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Profiles;
+using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
using Artemis.Profiles.Layers.Types.Folder;
using Artemis.Properties;
@@ -40,7 +40,7 @@ namespace Artemis.ViewModels.Profiles
ShowAll = false;
loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
- deviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;
+ deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
}
public ProfileModel SelectedProfile { get; set; }
@@ -166,8 +166,8 @@ namespace Artemis.ViewModels.Profiles
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
}
- SelectedProfile.RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg("preview",
- new ProfilePreviewDataModel(), true, drawingContext));
+ SelectedProfile.RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(DrawType.Preview, null, true,
+ drawingContext));
// Remove the clip
drawingContext.Pop();
@@ -178,7 +178,7 @@ namespace Artemis.ViewModels.Profiles
KeyboardPreview = drawnPreview;
}
- private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs e)
+ private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
{
NotifyOfPropertyChange(() => KeyboardImage);
}
@@ -356,13 +356,13 @@ namespace Artemis.ViewModels.Profiles
// Get the layers that must be drawn
List drawLayers;
if (ShowAll)
- return SelectedProfile.GetRenderLayers(new ProfilePreviewDataModel(), false, true);
+ return SelectedProfile.GetRenderLayers(null, false, true);
if (SelectedLayer == null || !SelectedLayer.Enabled)
return new EditableList();
if (SelectedLayer.LayerType is FolderType)
- drawLayers = SelectedLayer.GetRenderLayers(new ProfilePreviewDataModel(), false, true);
+ drawLayers = SelectedLayer.GetRenderLayers(null, false, true);
else
drawLayers = new List {SelectedLayer};
diff --git a/Artemis/Artemis/ViewModels/ShellViewModel.cs b/Artemis/Artemis/ViewModels/ShellViewModel.cs
index 163fdb432..ffdf07735 100644
--- a/Artemis/Artemis/ViewModels/ShellViewModel.cs
+++ b/Artemis/Artemis/ViewModels/ShellViewModel.cs
@@ -42,7 +42,7 @@ namespace Artemis.ViewModels
flyoutSettings
};
- MainManager.OnEnabledChangedEvent += (sender, args) => Enabled = args.Enabled;
+ MainManager.EnabledChanged += (sender, args) => Enabled = args.Enabled;
// This gets updated automatically but during startup lets quickly preset it
Enabled = GeneralSettings.Suspended;
diff --git a/Artemis/Artemis/Views/EffectsView.xaml b/Artemis/Artemis/Views/GeneralView.xaml
similarity index 94%
rename from Artemis/Artemis/Views/EffectsView.xaml
rename to Artemis/Artemis/Views/GeneralView.xaml
index cf0b791bf..a2e24e6f8 100644
--- a/Artemis/Artemis/Views/EffectsView.xaml
+++ b/Artemis/Artemis/Views/GeneralView.xaml
@@ -1,4 +1,4 @@
-
/// Interaction logic for EffectsView.xaml
///
- public partial class EffectsView : UserControl
+ public partial class GeneralView : UserControl
{
- public EffectsView()
+ public GeneralView()
{
InitializeComponent();
}
diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config
index 6faac38d1..507184401 100644
--- a/Artemis/Artemis/packages.config
+++ b/Artemis/Artemis/packages.config
@@ -1,10 +1,10 @@
-
-
+
+
-
+
@@ -21,12 +21,12 @@
-
-
+
+
-
+