diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config
index 9734b6d7c..b9c62fe8d 100644
--- a/Artemis/Artemis/App.config
+++ b/Artemis/Artemis/App.config
@@ -264,6 +264,9 @@
True
+
+ Light
+
diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml
index 7acc3be4c..2221243e0 100644
--- a/Artemis/Artemis/App.xaml
+++ b/Artemis/Artemis/App.xaml
@@ -15,9 +15,9 @@
+
-
+
diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 0bd2cfdc5..bb57d99e2 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -670,10 +670,10 @@
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs
index e52bfc626..ea1c38f01 100644
--- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs
+++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System;
+using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Media;
@@ -33,7 +34,7 @@ namespace Artemis.DeviceProviders.Corsair
public override void Disable()
{
if (CueSDK.ProtocolDetails != null)
- CueSDK.Reinitialize(true);
+ CueSDK.Reinitialize();
}
public override void UpdateDevice(Brush brush)
@@ -65,36 +66,29 @@ namespace Artemis.DeviceProviders.Corsair
private static bool CanInitializeSdk()
{
- // Try for about 10 seconds, in case CUE isn't started yet
- var tries = 0;
- while (tries < 9)
+ // If already initialized, return result right away
+ if (CueSDK.ProtocolDetails != null)
+ return CueSDK.HeadsetSDK != null;
+
+ // Else try to enable the SDK
+ for (var tries = 0; tries < 9; tries++)
{
+ if (CueSDK.ProtocolDetails != null)
+ break;
+
try
{
- if (CueSDK.ProtocolDetails == null)
- CueSDK.Initialize(true);
- else
- return true;
+ CueSDK.Initialize();
}
- catch (CUEException e)
+ catch (Exception)
{
- if (e.Error != CorsairError.ServerNotFound)
- return true;
-
- tries++;
- Thread.Sleep(1000);
- continue;
+ Thread.Sleep(2000);
}
- catch (WrapperException)
- {
- CueSDK.Reinitialize(true);
- return true;
- }
-
- return true;
}
- return false;
+ if (CueSDK.ProtocolDetails == null)
+ return false;
+ return CueSDK.HeadsetSDK != null;
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs
index 3f272988e..f417b4615 100644
--- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs
+++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs
@@ -1,25 +1,25 @@
-using System.Linq;
+using System;
+using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Media;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Devices.Generic.Enums;
-using CUE.NET.Exceptions;
using Ninject.Extensions.Logging;
namespace Artemis.DeviceProviders.Corsair
{
internal class CorsairMice : DeviceProvider
{
- public ILogger Logger { get; set; }
-
public CorsairMice(ILogger logger)
{
Logger = logger;
Type = DeviceType.Mouse;
}
+ public ILogger Logger { get; set; }
+
public override bool TryEnable()
{
CanUse = CanInitializeSdk();
@@ -33,7 +33,7 @@ namespace Artemis.DeviceProviders.Corsair
public override void Disable()
{
if (CueSDK.ProtocolDetails != null)
- CueSDK.Reinitialize(true);
+ CueSDK.Reinitialize();
}
public override void UpdateDevice(Brush brush)
@@ -42,7 +42,7 @@ namespace Artemis.DeviceProviders.Corsair
return;
var leds = CueSDK.MouseSDK.Leds.Count();
- var rect = new Rect(new Size(leds*20, leds* 20));
+ var rect = new Rect(new Size(leds*20, leds*20));
var img = brush.Dispatcher.Invoke(() =>
{
var visual = new DrawingVisual();
@@ -57,7 +57,7 @@ namespace Artemis.DeviceProviders.Corsair
{
corsairLed.Color = ledIndex == 0
? img.GetPixel(0, 0)
- : img.GetPixel((ledIndex + 1) * 20 - 1, (ledIndex + 1) * 20 - 1);
+ : img.GetPixel((ledIndex + 1)*20 - 1, (ledIndex + 1)*20 - 1);
ledIndex++;
}
@@ -66,36 +66,29 @@ namespace Artemis.DeviceProviders.Corsair
private static bool CanInitializeSdk()
{
- // Try for about 10 seconds, in case CUE isn't started yet
- var tries = 0;
- while (tries < 9)
+ // If already initialized, return result right away
+ if (CueSDK.ProtocolDetails != null)
+ return CueSDK.MouseSDK != null;
+
+ // Else try to enable the SDK
+ for (var tries = 0; tries < 9; tries++)
{
+ if (CueSDK.ProtocolDetails != null)
+ break;
+
try
{
- if (CueSDK.ProtocolDetails == null)
- CueSDK.Initialize(true);
- else
- return true;
+ CueSDK.Initialize();
}
- catch (CUEException e)
+ catch (Exception)
{
- if (e.Error != CorsairError.ServerNotFound)
- return true;
-
- tries++;
- Thread.Sleep(1000);
- continue;
+ Thread.Sleep(2000);
}
- catch (WrapperException)
- {
- CueSDK.Reinitialize(true);
- return true;
- }
-
- return true;
}
- return false;
+ if (CueSDK.ProtocolDetails == null)
+ return false;
+ return CueSDK.MouseSDK != null;
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairRGB.cs
index 8c27d6a6e..a59430fb6 100644
--- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairRGB.cs
+++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairRGB.cs
@@ -1,13 +1,12 @@
-using System.Drawing;
+using System;
+using System.Drawing;
using System.Threading;
using System.Windows;
using Artemis.Properties;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
-using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
-using CUE.NET.Exceptions;
namespace Artemis.DeviceProviders.Corsair
{
@@ -26,34 +25,29 @@ namespace Artemis.DeviceProviders.Corsair
public override bool CanEnable()
{
- // Try for about 10 seconds, in case CUE isn't started yet
- var tries = 0;
- while (tries < 9)
+ // If already initialized, return result right away
+ if (CueSDK.ProtocolDetails != null)
+ return CueSDK.KeyboardSDK != null;
+
+ // Else try to enable the SDK
+ for (var tries = 0; tries < 9; tries++)
{
+ if (CueSDK.ProtocolDetails != null)
+ break;
+
try
{
- if (CueSDK.ProtocolDetails == null)
- CueSDK.Initialize(true);
+ CueSDK.Initialize();
}
- catch (CUEException e)
+ catch (Exception)
{
- if (e.Error == CorsairError.ServerNotFound)
- {
- tries++;
- Thread.Sleep(1000);
- continue;
- }
+ Thread.Sleep(2000);
}
- catch (WrapperException)
- {
- CueSDK.Reinitialize(true);
- return true;
- }
-
- return true;
}
- return false;
+ if (CueSDK.ProtocolDetails == null)
+ return false;
+ return CueSDK.KeyboardSDK != null;
}
///
@@ -62,7 +56,7 @@ namespace Artemis.DeviceProviders.Corsair
public override void Enable()
{
if (CueSDK.ProtocolDetails == null)
- CueSDK.Initialize(true);
+ CueSDK.Initialize();
_keyboard = CueSDK.KeyboardSDK;
switch (_keyboard.DeviceInfo.Model)
@@ -93,7 +87,7 @@ namespace Artemis.DeviceProviders.Corsair
public override void Disable()
{
if (CueSDK.ProtocolDetails != null)
- CueSDK.Reinitialize(true);
+ CueSDK.Reinitialize();
}
///
diff --git a/Artemis/Artemis/Models/Profiles/LayerModel.cs b/Artemis/Artemis/Models/Profiles/LayerModel.cs
index 524e62b94..1fb1d94d6 100644
--- a/Artemis/Artemis/Models/Profiles/LayerModel.cs
+++ b/Artemis/Artemis/Models/Profiles/LayerModel.cs
@@ -19,10 +19,10 @@ namespace Artemis.Models.Profiles
}
public string Name { get; set; }
+ public int Order { get; set; }
public LayerType LayerType { get; set; }
public bool Enabled { get; set; }
public bool Expanded { get; set; }
- public int Order { get; set; }
public LayerPropertiesModel Properties { get; set; }
public ChildItemCollection Children { get; }
diff --git a/Artemis/Artemis/Models/Profiles/ProfileModel.cs b/Artemis/Artemis/Models/Profiles/ProfileModel.cs
index 58c30b6dd..99bd715da 100644
--- a/Artemis/Artemis/Models/Profiles/ProfileModel.cs
+++ b/Artemis/Artemis/Models/Profiles/ProfileModel.cs
@@ -26,9 +26,9 @@ namespace Artemis.Models.Profiles
public ChildItemCollection Layers { get; }
public string Name { get; set; }
+ public bool IsDefault { get; set; }
public string KeyboardName { get; set; }
public string GameName { get; set; }
- public bool IsDefault { get; set; }
[XmlIgnore]
public DrawingVisual DrawingVisual { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
index ac9c61744..0f4f26545 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml
@@ -7,14 +7,14 @@
mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772">
-
+
-
+
@@ -39,8 +39,8 @@
-
+
+
-
+
diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
index 471ca6ddd..6adaf23ee 100644
--- a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
+++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml
@@ -7,14 +7,14 @@
mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772">
-
+
-
+
@@ -39,8 +39,7 @@
-
+
-
+
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
index 4e60f4d04..8dc3797be 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionView.xaml
@@ -7,15 +7,15 @@
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DesignHeight="416.495" d:DesignWidth="553.608">
-
-
+
+
-
+
@@ -37,15 +37,15 @@
-
- Note: For this game to work with Artemis, please open up your Division settings, navigate to 3rd Party
+ TextAlignment="Justify" Margin="5,0,0,0">
+ For this game to work with Artemis, please open up your Division settings, navigate to 3rd Party
and set LED keyboard support to Yes. (This only works if you have Artemis running before starting the game)
-
+
diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
index 6e4b10bba..276eec0be 100644
--- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
+++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml
@@ -6,8 +6,8 @@
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DesignHeight="386.842" d:DesignWidth="554.887">
-
-
+
+
@@ -34,11 +34,12 @@
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
-
+
Artemis requires the latest Witcher 3 version and mod to be installed in order to work. If you don't use any (conflicting) Witcher 3 mods, the mod can automatically be installed.
-
+
diff --git a/Artemis/Artemis/Settings/General.Designer.cs b/Artemis/Artemis/Settings/General.Designer.cs
index 57222230f..c2a4363c9 100644
--- a/Artemis/Artemis/Settings/General.Designer.cs
+++ b/Artemis/Artemis/Settings/General.Designer.cs
@@ -118,5 +118,17 @@ namespace Artemis.Settings {
this["CheckForUpdates"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Light")]
+ public string Theme {
+ get {
+ return ((string)(this["Theme"]));
+ }
+ set {
+ this["Theme"] = value;
+ }
+ }
}
}
diff --git a/Artemis/Artemis/Settings/General.settings b/Artemis/Artemis/Settings/General.settings
index 68066b8ec..86d585781 100644
--- a/Artemis/Artemis/Settings/General.settings
+++ b/Artemis/Artemis/Settings/General.settings
@@ -1,7 +1,5 @@
-
-
+
@@ -28,5 +26,8 @@
True
+
+ Light
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Settings/GeneralSettings.cs b/Artemis/Artemis/Settings/GeneralSettings.cs
index f120665a6..2314b2b1a 100644
--- a/Artemis/Artemis/Settings/GeneralSettings.cs
+++ b/Artemis/Artemis/Settings/GeneralSettings.cs
@@ -2,12 +2,20 @@
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
+using System.Windows;
using Artemis.Utilities;
+using MahApps.Metro;
namespace Artemis.Settings
{
public class GeneralSettings
{
+ private readonly Accent _artemisAccent = ThemeManager.GetAccent("Teal");
+ private readonly Accent _corsairAccent = new Accent("CorsairYellow",
+ new Uri("pack://application:,,,/Styles/Accents/CorsairYellow.xaml"));
+ private readonly AppTheme _darkTheme = ThemeManager.GetAppTheme("BaseDark");
+ private readonly AppTheme _lightTheme = ThemeManager.GetAppTheme("BaseLight");
+
public int GamestatePort
{
get { return General.Default.GamestatePort; }
@@ -58,6 +66,16 @@ namespace Artemis.Settings
}
}
+ public string Theme
+ {
+ get { return General.Default.Theme; }
+ set
+ {
+ if (General.Default.Theme == value) return;
+ General.Default.Theme = value;
+ }
+ }
+
private void ApplyGamestatePort()
{
// TODO: Restart Gamestate server with new port
@@ -83,9 +101,30 @@ namespace Artemis.Settings
General.Default.Save();
ApplyAutorun();
+ ApplyTheme();
ApplyGamestatePort();
}
+ // TODO: http://visionarycoder.com/2015/01/06/setting-themeaccent-with-mahapps-metro/
+ private void ApplyTheme()
+ {
+ switch (Theme)
+ {
+ case "Light":
+ ThemeManager.ChangeAppStyle(Application.Current, _artemisAccent, _lightTheme);
+ break;
+ case "Dark":
+ ThemeManager.ChangeAppStyle(Application.Current, _artemisAccent, _darkTheme);
+ break;
+ case "Corsair Light":
+ ThemeManager.ChangeAppStyle(Application.Current, _corsairAccent, _lightTheme);
+ break;
+ case "Corsair Dark":
+ ThemeManager.ChangeAppStyle(Application.Current, _corsairAccent, _darkTheme);
+ break;
+ }
+ }
+
public void ResetSettings()
{
GamestatePort = 51364;
@@ -93,6 +132,7 @@ namespace Artemis.Settings
Autorun = true;
CheckForUpdates = true;
ShowOnStartup = true;
+ Theme = "Light";
SaveSettings();
}
diff --git a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
index d965ff689..ee27a983f 100644
--- a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
@@ -7,9 +7,9 @@ using Artemis.Settings;
using Caliburn.Micro;
using MahApps.Metro.Controls;
using NLog;
-using NLog.Config;
using NLog.Targets;
using ILogger = Ninject.Extensions.Logging.ILogger;
+using LogManager = NLog.LogManager;
namespace Artemis.ViewModels.Flyouts
{
@@ -71,6 +71,20 @@ namespace Artemis.ViewModels.Flyouts
}
}
+ public BindableCollection Themes
+ => new BindableCollection {"Light", "Dark", "Corsair Light", "Corsair Dark"};
+
+ public string SelectedTheme
+ {
+ get { return GeneralSettings.Theme; }
+ set
+ {
+ if (value == GeneralSettings.Theme) return;
+ GeneralSettings.Theme = value;
+ NotifyOfPropertyChange(() => SelectedTheme);
+ }
+ }
+
public string SelectedKeyboardProvider
{
get { return _selectedKeyboardProvider; }
@@ -119,7 +133,7 @@ namespace Artemis.ViewModels.Flyouts
// TODO https://github.com/ninject/Ninject.Extensions.Logging/issues/35
private void ApplyLogging()
{
- var c = NLog.LogManager.Configuration;
+ var c = LogManager.Configuration;
var file = c.FindTargetByName("file") as FileTarget;
if (file == null)
return;
@@ -133,7 +147,7 @@ namespace Artemis.ViewModels.Flyouts
else
rule.DisableLoggingForLevel(LogLevel.Debug);
- NLog.LogManager.ReconfigExistingLoggers();
+ LogManager.ReconfigExistingLoggers();
_logger.Info("Set debug logging to: {0}", EnableDebug);
}
diff --git a/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
index 0b3dabf26..1cfb5d850 100644
--- a/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
@@ -59,6 +59,8 @@ namespace Artemis.ViewModels.Profiles
public ProfileViewModel ProfileViewModel { get; set; }
+ public bool EditorEnabled => SelectedProfile != null && !SelectedProfile.IsDefault;
+
public BindableCollection Profiles
{
get { return _profiles; }
@@ -204,6 +206,8 @@ namespace Artemis.ViewModels.Profiles
if (e.PropertyName != "SelectedProfile")
return;
+ // Update editor enabled state
+ NotifyOfPropertyChange(() => EditorEnabled);
// Update ProfileViewModel
ProfileViewModel.SelectedProfile = SelectedProfile;
// Update interface
@@ -524,6 +528,7 @@ namespace Artemis.ViewModels.Profiles
return;
}
+ newProfile.IsDefault = false;
ProfileProvider.AddOrUpdate(newProfile);
LoadProfiles();
SelectedProfile = Profiles.FirstOrDefault(p => p.Name == newProfile.Name);
diff --git a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
index e8cf9598b..48101a3b4 100644
--- a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs
@@ -117,8 +117,11 @@ namespace Artemis.ViewModels.Profiles
layer.Draw
@@ -50,45 +51,51 @@
IsChecked="{Binding Path=GeneralSettings.ShowOnStartup, Mode=TwoWay}"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/Artemis/Artemis/Views/Profiles/ProfileEditorView.xaml b/Artemis/Artemis/Views/Profiles/ProfileEditorView.xaml
index 4e915fa00..6409f06a1 100644
--- a/Artemis/Artemis/Views/Profiles/ProfileEditorView.xaml
+++ b/Artemis/Artemis/Views/Profiles/ProfileEditorView.xaml
@@ -7,7 +7,6 @@
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours"
xmlns:utilities="clr-namespace:Artemis.Utilities"
- xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
mc:Ignorable="d"
d:DesignHeight="510" Width="1055">
@@ -25,10 +24,10 @@
-
+
+ BorderThickness="3" Width="800" Height="400">
@@ -44,65 +43,73 @@
Stretch="Fill" Cursor="{Binding Path=ProfileViewModel.KeyboardPreviewCursor}"
cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
- [Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" />
+ [Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]"
+ IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}"/>
-
-
-
+
+
+
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
-
+
+