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

Implemented suspension mechanism ('lets go' of the SDK when not using any effects)

This commit is contained in:
SpoinkyNL 2016-02-21 21:47:04 +01:00
parent b81120aa6a
commit 7526e4b239
23 changed files with 240 additions and 120 deletions

View File

@ -196,7 +196,7 @@
<value>TypeWave</value> <value>TypeWave</value>
</setting> </setting>
<setting name="LastKeyboard" serializeAs="String"> <setting name="LastKeyboard" serializeAs="String">
<value>Corsair Gaming K95 RGB</value> <value>Logitech G910 RGB</value>
</setting> </setting>
<setting name="EnablePointersUpdate" serializeAs="String"> <setting name="EnablePointersUpdate" serializeAs="String">
<value>True</value> <value>True</value>
@ -207,6 +207,9 @@
<setting name="Autorun" serializeAs="String"> <setting name="Autorun" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="Suspended" serializeAs="String">
<value>False</value>
</setting>
</Artemis.Settings.General> </Artemis.Settings.General>
</userSettings> </userSettings>
<runtime> <runtime>

View File

@ -10,12 +10,13 @@
<ResourceDictionary> <ResourceDictionary>
<local:ArtemisBootstrapper x:Key="ArtemisBootstrapper" /> <local:ArtemisBootstrapper x:Key="ArtemisBootstrapper" />
</ResourceDictionary> </ResourceDictionary>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
<ResourceDictionary <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="/Resources/Icons.xaml" /> <ResourceDictionary Source="/Resources/Icons.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@ -151,8 +151,8 @@
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="MahApps.Metro, Version=1.3.0.37, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MahApps.Metro, Version=1.2.4.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0-ALPHA037\lib\net45\MahApps.Metro.dll</HintPath> <HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -172,7 +172,10 @@
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View File

@ -1,6 +1,4 @@
using System; using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
using Artemis.Utilities; using Artemis.Utilities;
using CUE.NET; using CUE.NET;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
@ -15,7 +13,10 @@ namespace Artemis.KeyboardProviders.Corsair
public K70() public K70()
{ {
Name = "Corsair Gaming K70 RGB"; Name = "Corsair K70 RGB";
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
} }
public override bool CanEnable() public override bool CanEnable()
@ -37,7 +38,6 @@ namespace Artemis.KeyboardProviders.Corsair
} }
return true; return true;
} }
/// <summary> /// <summary>
@ -76,13 +76,13 @@ namespace Artemis.KeyboardProviders.Corsair
{ {
using ( using (
var resized = ImageUtilities.ResizeImage(bitmap, var resized = ImageUtilities.ResizeImage(bitmap,
(int)_keyboard.KeyboardRectangle.Width, (int) _keyboard.KeyboardRectangle.Width,
(int)_keyboard.KeyboardRectangle.Height) (int) _keyboard.KeyboardRectangle.Height)
) )
{ {
foreach (var item in _keyboard.Keys) foreach (var item in _keyboard.Keys)
{ {
var ledColor = resized.GetPixel((int)item.KeyRectangle.X, (int)item.KeyRectangle.Y); var ledColor = resized.GetPixel((int) item.KeyRectangle.X, (int) item.KeyRectangle.Y);
if (ledColor == Color.FromArgb(0, 0, 0, 0)) if (ledColor == Color.FromArgb(0, 0, 0, 0))
ledColor = Color.Black; ledColor = Color.Black;
item.Led.Color = ledColor; item.Led.Color = ledColor;

View File

@ -1,6 +1,4 @@
using System; using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
using Artemis.Utilities; using Artemis.Utilities;
using CUE.NET; using CUE.NET;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
@ -15,7 +13,10 @@ namespace Artemis.KeyboardProviders.Corsair
public K95() public K95()
{ {
Name = "Corsair Gaming K95 RGB"; Name = "Corsair K95 RGB";
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
} }
public override bool CanEnable() public override bool CanEnable()
@ -37,7 +38,6 @@ namespace Artemis.KeyboardProviders.Corsair
} }
return true; return true;
} }
/// <summary> /// <summary>

View File

@ -7,6 +7,7 @@ namespace Artemis.KeyboardProviders
public string Name { get; set; } public string Name { get; set; }
public int Height { get; set; } public int Height { get; set; }
public int Width { get; set; } public int Width { get; set; }
public string CantEnableText { get; set; }
public abstract bool CanEnable(); public abstract bool CanEnable();
public abstract void Enable(); public abstract void Enable();

View File

@ -8,7 +8,10 @@ namespace Artemis.KeyboardProviders.Logitech
{ {
public Orion() public Orion()
{ {
Name = "Logitech G910 Orion Spark RGB"; Name = "Logitech G910 RGB";
CantEnableText = "Couldn't connect to your Logitech G910.\n " +
"Please check your cables and updating the Logitech Gaming Software.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
Height = 6; Height = 6;
Width = 21; Width = 21;
} }

View File

@ -3,7 +3,6 @@ using System.Drawing;
using Artemis.KeyboardProviders.Razer.Utilities; using Artemis.KeyboardProviders.Razer.Utilities;
using Corale.Colore.Core; using Corale.Colore.Core;
using Corale.Colore.Razer.Keyboard; using Corale.Colore.Razer.Keyboard;
using Color = Corale.Colore.Core.Color;
namespace Artemis.KeyboardProviders.Razer namespace Artemis.KeyboardProviders.Razer
{ {
@ -12,6 +11,9 @@ namespace Artemis.KeyboardProviders.Razer
public BlackWidow() public BlackWidow()
{ {
Name = "Razer BlackWidow Chroma"; Name = "Razer BlackWidow Chroma";
CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n " +
"Please check your cables and try updating Razer Synapse.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
} }
public override bool CanEnable() public override bool CanEnable()
@ -38,8 +40,8 @@ namespace Artemis.KeyboardProviders.Razer
public override void Enable() public override void Enable()
{ {
Chroma.Instance.Initialize(); Chroma.Instance.Initialize();
Height = (int) Constants.MaxRows; Height = Constants.MaxRows;
Width = (int) Constants.MaxColumns; Width = Constants.MaxColumns;
} }
public override void Disable() public override void Disable()

View File

@ -17,19 +17,24 @@ namespace Artemis.Models
{ {
public class MainModel public class MainModel
{ {
private readonly int _fps;
private readonly BackgroundWorker _processWorker; private readonly BackgroundWorker _processWorker;
private readonly BackgroundWorker _updateWorker; private readonly BackgroundWorker _updateWorker;
private EffectModel _activeEffect;
private bool _wasSuspendedBeforeGame;
public MainModel(IEventAggregator events) public MainModel(IEventAggregator events)
{ {
EffectModels = new List<EffectModel>(); EffectModels = new List<EffectModel>();
KeyboardProviders = ProviderHelper.GetKeyboardProviders(); KeyboardProviders = ProviderHelper.GetKeyboardProviders();
GameStateWebServer = new GameStateWebServer(); GameStateWebServer = new GameStateWebServer();
KeyboardHook = new KeyboardHook(); KeyboardHook = new KeyboardHook();
Suspended = false;
Events = events; Events = events;
Fps = 25;
_fps = 25;
_updateWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; _updateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_processWorker = new BackgroundWorker {WorkerSupportsCancellation = true}; _processWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_updateWorker.DoWork += UpdateWorker_DoWork; _updateWorker.DoWork += UpdateWorker_DoWork;
@ -37,16 +42,13 @@ namespace Artemis.Models
} }
public KeyboardHook KeyboardHook { get; set; } public KeyboardHook KeyboardHook { get; set; }
public EffectModel ActiveEffect { get; set; }
public KeyboardProvider ActiveKeyboard { get; set; } public KeyboardProvider ActiveKeyboard { get; set; }
public List<EffectModel> EffectModels { get; set; } public List<EffectModel> EffectModels { get; set; }
public List<KeyboardProvider> KeyboardProviders { get; set; } public List<KeyboardProvider> KeyboardProviders { get; set; }
public GameStateWebServer GameStateWebServer { get; set; } public GameStateWebServer GameStateWebServer { get; set; }
public IEventAggregator Events { get; set; } public IEventAggregator Events { get; set; }
public int Fps { get; set; } public bool Enabled { get; private set; }
public bool Enabled { get; set; } public bool Suspended { get; private set; }
#region Effect methods #region Effect methods
@ -77,75 +79,31 @@ namespace Artemis.Models
Enabled = true; Enabled = true;
Events.PublishOnUIThread(new ToggleEnabled(Enabled)); Events.PublishOnUIThread(new ToggleEnabled(Enabled));
if (General.Default.Suspended && !Suspended)
ToggleSuspension();
} }
public void ShutdownEffects() public void ShutdownEffects()
{ {
if (!Enabled) if (!Enabled)
return; return;
// Stop the Background Worker // Stop the Background Worker
_updateWorker.CancelAsync(); _updateWorker.CancelAsync();
_processWorker.CancelAsync(); _processWorker.CancelAsync();
// Dispose the current active effect // Dispose the current active effect
ActiveEffect?.Dispose(); _activeEffect?.Dispose();
ActiveEffect = null; _activeEffect = null;
ActiveKeyboard?.Disable(); ActiveKeyboard?.Disable();
ActiveKeyboard = null; ActiveKeyboard = null;
Enabled = false; Enabled = false;
Events.PublishOnUIThread(new ToggleEnabled(Enabled)); Events.PublishOnUIThread(new ToggleEnabled(Enabled));
} }
private void LoadLastKeyboard()
{
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
ChangeKeyboard(keyboard ?? KeyboardProviders.First(k => k.Name == "Logitech G910 Orion Spark RGB"));
}
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
{
if (ActiveKeyboard != null && keyboardProvider.Name == ActiveKeyboard.Name)
return;
ActiveKeyboard?.Disable();
// Disable everything if there's no active keyboard found
if (!keyboardProvider.CanEnable())
{
string message;
if (keyboardProvider.Name.ToLower().Contains("Corsair"))
{
message = "Couldn't connect to the " + keyboardProvider.Name + ".\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
}
else
{
message = "Couldn't connect to the " + keyboardProvider.Name + ".\n " +
"Please check your cables and/or drivers (could be outdated).\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
}
ActiveKeyboard = null;
MessageBox.Show(
message,
"Artemis (╯°□°)╯︵ ┻━┻",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
ShutdownEffects();
return;
}
ActiveKeyboard = keyboardProvider;
ActiveKeyboard.Enable();
General.Default.LastKeyboard = ActiveKeyboard.Name;
General.Default.Save();
}
private void LoadLastEffect() private void LoadLastEffect()
{ {
var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect); var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect);
@ -163,21 +121,30 @@ namespace Artemis.Models
if (!gameModel.Enabled) if (!gameModel.Enabled)
return; return;
if (ActiveEffect != null && effectModel.Name == ActiveEffect.Name) if (_activeEffect != null && effectModel.Name == _activeEffect.Name)
return; return;
ActiveEffect?.Dispose(); _activeEffect?.Dispose();
ActiveEffect = effectModel;
ActiveEffect.Enable();
if (ActiveEffect is GameModel) return; // If needed, unsuspend when loading a new effect
if (Suspended)
{
_wasSuspendedBeforeGame = true;
ToggleSuspension();
}
_activeEffect = effectModel;
_activeEffect.Enable();
if (_activeEffect is GameModel)
return;
// Non-game effects are stored as the new LastEffect. // Non-game effects are stored as the new LastEffect.
General.Default.LastEffect = ActiveEffect.Name; General.Default.LastEffect = _activeEffect.Name;
General.Default.Save(); General.Default.Save();
// Let the ViewModels know // Let the ViewModels know
Events.PublishOnUIThread(new ChangeActiveEffect(ActiveEffect.Name)); Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect.Name));
} }
public void EnableEffect(EffectModel effectModel) public void EnableEffect(EffectModel effectModel)
@ -188,15 +155,71 @@ namespace Artemis.Models
ChangeEffect(effectModel); ChangeEffect(effectModel);
} }
public void ToggleSuspension()
{
if (Suspended)
{
LoadLastKeyboard();
Suspended = false;
General.Default.Suspended = false;
General.Default.Save();
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name));
return;
}
Suspended = true;
General.Default.Suspended = true;
General.Default.Save();
ActiveKeyboard?.Disable();
ActiveKeyboard = null;
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name));
}
public bool IsEnabled(EffectModel effectModel) public bool IsEnabled(EffectModel effectModel)
{ {
if (Suspended)
return false;
if (effectModel is GameModel) if (effectModel is GameModel)
return false; return false;
return General.Default.LastEffect == effectModel.Name; return General.Default.LastEffect == effectModel.Name;
} }
#endregion Effect methods #endregion
#region Keyboard methods
private void LoadLastKeyboard()
{
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
ChangeKeyboard(keyboard ?? KeyboardProviders.First());
}
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
{
if (ActiveKeyboard != null && keyboardProvider.Name == ActiveKeyboard.Name)
return;
ActiveKeyboard?.Disable();
// Disable everything if there's no active keyboard found
if (!keyboardProvider.CanEnable())
{
ActiveKeyboard = null;
MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
ShutdownEffects();
return;
}
ActiveKeyboard = keyboardProvider;
ActiveKeyboard.Enable();
General.Default.LastKeyboard = ActiveKeyboard.Name;
General.Default.Save();
}
#endregion
#region Workers #region Workers
@ -205,24 +228,23 @@ namespace Artemis.Models
var sw = new Stopwatch(); var sw = new Stopwatch();
while (!_updateWorker.CancellationPending) while (!_updateWorker.CancellationPending)
{ {
if (ActiveKeyboard == null) if (ActiveKeyboard == null || Suspended)
{ {
Thread.Sleep(1000 / Fps); Thread.Sleep(1000/_fps);
continue; continue;
} }
sw.Start(); sw.Start();
// Update the current effect // Update the current effect
ActiveEffect.Update(); _activeEffect.Update();
// Get ActiveEffect's bitmap // Get ActiveEffect's bitmap
var bitmap = ActiveEffect.GenerateBitmap(); var bitmap = _activeEffect.GenerateBitmap();
// Draw enabled overlays on top // Draw enabled overlays on top
foreach ( foreach (var overlayModel in EffectModels.OfType<OverlayModel>()
var overlayModel in .Where(overlayModel => overlayModel.Enabled))
EffectModels.OfType<OverlayModel>().Where(overlayModel => overlayModel.Enabled))
{ {
overlayModel.Update(); overlayModel.Update();
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap(); bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
@ -238,7 +260,7 @@ namespace Artemis.Models
} }
// Sleep according to time left this frame // Sleep according to time left this frame
var sleep = (int)(1000 / Fps - sw.ElapsedMilliseconds); var sleep = (int) (1000/_fps - sw.ElapsedMilliseconds);
if (sleep > 0) if (sleep > 0)
Thread.Sleep(sleep); Thread.Sleep(sleep);
sw.Reset(); sw.Reset();
@ -261,7 +283,7 @@ namespace Artemis.Models
continue; continue;
// If the active effect is a disabled game model, disable it // If the active effect is a disabled game model, disable it
var model = ActiveEffect as GameModel; var model = _activeEffect as GameModel;
if (model != null && !model.Enabled) if (model != null && !model.Enabled)
LoadLastEffect(); LoadLastEffect();
else else
@ -272,9 +294,16 @@ namespace Artemis.Models
} }
// If no game process is found, but the active effect still belongs to a game, // If no game process is found, but the active effect still belongs to a game,
// set it to a normal effect // set it to a normal effect, and if needed, suspend again.
if (!foundProcess && ActiveEffect is GameModel) if (!foundProcess && _activeEffect is GameModel)
{
LoadLastEffect(); LoadLastEffect();
if (_wasSuspendedBeforeGame)
{
ToggleSuspension();
_wasSuspendedBeforeGame = false;
}
}
Thread.Sleep(1000); Thread.Sleep(1000);
} }

View File

@ -46,8 +46,15 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public void ToggleEffect() public void ToggleEffect()
{ {
MainModel.EnableEffect(AudioVisualizerModel); if (EffectEnabled && !MainModel.Suspended)
NotifyOfPropertyChange(() => EffectEnabled); MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(AudioVisualizerModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(AudioVisualizerModel);
}
} }
public void SaveSettings() public void SaveSettings()

View File

@ -100,7 +100,15 @@ namespace Artemis.Modules.Effects.Debug
public void ToggleEffect() public void ToggleEffect()
{ {
MainModel.EnableEffect(DebugEffectModel); if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(DebugEffectModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(DebugEffectModel);
}
} }
public void ResetSettings() public void ResetSettings()

View File

@ -30,7 +30,15 @@ namespace Artemis.Modules.Effects.TypeHole
public void ToggleEffect() public void ToggleEffect()
{ {
MainModel.EnableEffect(TypeHoleModel); if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(TypeHoleModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(TypeHoleModel);
}
} }
} }
} }

View File

@ -46,8 +46,15 @@ namespace Artemis.Modules.Effects.TypeWave
public void ToggleEffect() public void ToggleEffect()
{ {
MainModel.EnableEffect(TypeWaveModel); if (EffectEnabled && !MainModel.Suspended)
NotifyOfPropertyChange(() => EffectEnabled); MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(TypeWaveModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(TypeWaveModel);
}
} }
public void SaveSettings() public void SaveSettings()

View File

@ -18,6 +18,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -59,7 +60,13 @@
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="520" TextAlignment="Justify"> Foreground="#535353" MaxWidth="520" TextAlignment="Justify">
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). 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.
</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#B50000" MaxWidth="520" TextAlignment="Justify">
Please also note that it won't work if there aren't any active effects.
</TextBlock> </TextBlock>
<!-- Buttons --> <!-- Buttons -->

View File

@ -37,7 +37,7 @@ namespace Artemis.Settings {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Corsair Gaming K95 RGB")] [global::System.Configuration.DefaultSettingValueAttribute("Logitech G910 RGB")]
public string LastKeyboard { public string LastKeyboard {
get { get {
return ((string)(this["LastKeyboard"])); return ((string)(this["LastKeyboard"]));
@ -82,5 +82,17 @@ namespace Artemis.Settings {
this["Autorun"] = value; this["Autorun"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Suspended {
get {
return ((bool)(this["Suspended"]));
}
set {
this["Suspended"] = value;
}
}
} }
} }

View File

@ -6,7 +6,7 @@
<Value Profile="(Default)">TypeWave</Value> <Value Profile="(Default)">TypeWave</Value>
</Setting> </Setting>
<Setting Name="LastKeyboard" Type="System.String" Scope="User"> <Setting Name="LastKeyboard" Type="System.String" Scope="User">
<Value Profile="(Default)">Corsair Gaming K95 RGB</Value> <Value Profile="(Default)">Logitech G910 RGB</Value>
</Setting> </Setting>
<Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User"> <Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
@ -17,5 +17,8 @@
<Setting Name="Autorun" Type="System.Boolean" Scope="User"> <Setting Name="Autorun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="Suspended" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -15,8 +15,6 @@ namespace Artemis.Settings
{ {
if (General.Default.GamestatePort == value) return; if (General.Default.GamestatePort == value) return;
General.Default.GamestatePort = value; General.Default.GamestatePort = value;
ApplyGamestatePort();
General.Default.Save();
} }
} }
@ -27,7 +25,6 @@ namespace Artemis.Settings
{ {
if (General.Default.EnablePointersUpdate == value) return; if (General.Default.EnablePointersUpdate == value) return;
General.Default.EnablePointersUpdate = value; General.Default.EnablePointersUpdate = value;
General.Default.Save();
} }
} }
@ -38,8 +35,6 @@ namespace Artemis.Settings
{ {
if (General.Default.Autorun == value) return; if (General.Default.Autorun == value) return;
General.Default.Autorun = value; General.Default.Autorun = value;
ApplyAutorun();
General.Default.Save();
} }
} }
@ -62,5 +57,22 @@ namespace Artemis.Settings
else if (File.Exists(startupFolder + @"\Artemis.lnk")) else if (File.Exists(startupFolder + @"\Artemis.lnk"))
File.Delete(startupFolder + @"\Artemis.lnk"); File.Delete(startupFolder + @"\Artemis.lnk");
} }
public void SaveSettings()
{
General.Default.Save();
ApplyAutorun();
ApplyGamestatePort();
}
public void ResetSettings()
{
GamestatePort = 51364;
EnablePointersUpdate = true;
Autorun = true;
SaveSettings();
}
} }
} }

View File

@ -80,6 +80,17 @@ namespace Artemis.ViewModels.Flyouts
MainModel.StartEffects(); MainModel.StartEffects();
} }
public void ResetSettings()
{
GeneralSettings.ResetSettings();
NotifyOfPropertyChange(() => GeneralSettings);
}
public void SaveSettings()
{
GeneralSettings.SaveSettings();
}
public void NavigateTo(string url) public void NavigateTo(string url)
{ {
Process.Start(new ProcessStartInfo(url)); Process.Start(new ProcessStartInfo(url));

View File

@ -1,5 +1,6 @@
using System.Windows; using System.Windows;
using Artemis.Events; using Artemis.Events;
using Artemis.Settings;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels

View File

@ -46,7 +46,7 @@
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Keyboard:" /> Content="Keyboard:" />
<ComboBox Grid.Row="2" Grid.Column="1" x:Name="KeyboardProviders" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Right" <ComboBox Grid.Row="2" Grid.Column="1" x:Name="KeyboardProviders" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Right"
Width="120" /> Width="140" />
<!-- TODO: Ugly --> <!-- TODO: Ugly -->
<!-- Gamestate port --> <!-- Gamestate port -->

View File

@ -1,6 +1,7 @@
<Window x:Class="Artemis.Views.SystemTrayView" <Controls:MetroWindow x:Class="Artemis.Views.SystemTrayView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:tb="http://www.hardcodet.net/taskbar"
Title="SystemTrayView" Title="SystemTrayView"
@ -11,7 +12,7 @@
Background="Transparent" Background="Transparent"
Visibility="Hidden"> Visibility="Hidden">
<Window.Resources> <Controls:MetroWindow.Resources>
<ContextMenu x:Shared="false" x:Key="MainSysTrayMenu"> <ContextMenu x:Shared="false" x:Key="MainSysTrayMenu">
<MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" /> <MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" />
@ -28,9 +29,9 @@
cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]" cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]"
ContextMenu="{StaticResource MainSysTrayMenu}" /> ContextMenu="{StaticResource MainSysTrayMenu}" />
</Window.Resources> </Controls:MetroWindow.Resources>
<Grid> <Grid>
<ContentControl Content="{StaticResource SystemTrayIcon}" /> <ContentControl Content="{StaticResource SystemTrayIcon}" />
</Grid> </Grid>
</Window> </Controls:MetroWindow>

View File

@ -1,11 +1,12 @@
using System.Windows; using System.Windows;
using MahApps.Metro.Controls;
namespace Artemis.Views namespace Artemis.Views
{ {
/// <summary> /// <summary>
/// Interaction logic for SystemTrayView.xaml /// Interaction logic for SystemTrayView.xaml
/// </summary> /// </summary>
public partial class SystemTrayView : Window public partial class SystemTrayView : MetroWindow
{ {
public SystemTrayView() public SystemTrayView()
{ {

View File

@ -9,7 +9,7 @@
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" /> <package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" /> <package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="MahApps.Metro" version="1.3.0-ALPHA037" targetFramework="net452" /> <package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" /> <package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
<package id="MouseKeyHook" version="5.4.0" targetFramework="net452" /> <package id="MouseKeyHook" version="5.4.0" targetFramework="net452" />
<package id="NAudio" version="1.7.3" targetFramework="net452" /> <package id="NAudio" version="1.7.3" targetFramework="net452" />