mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Implemented suspension mechanism ('lets go' of the SDK when not using any effects)
This commit is contained in:
parent
b81120aa6a
commit
7526e4b239
@ -196,7 +196,7 @@
|
||||
<value>TypeWave</value>
|
||||
</setting>
|
||||
<setting name="LastKeyboard" serializeAs="String">
|
||||
<value>Corsair Gaming K95 RGB</value>
|
||||
<value>Logitech G910 RGB</value>
|
||||
</setting>
|
||||
<setting name="EnablePointersUpdate" serializeAs="String">
|
||||
<value>True</value>
|
||||
@ -207,6 +207,9 @@
|
||||
<setting name="Autorun" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="Suspended" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</Artemis.Settings.General>
|
||||
</userSettings>
|
||||
<runtime>
|
||||
|
||||
@ -10,12 +10,13 @@
|
||||
<ResourceDictionary>
|
||||
<local:ArtemisBootstrapper x:Key="ArtemisBootstrapper" />
|
||||
</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/Fonts.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/BaseLight.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
||||
<ResourceDictionary Source="/Resources/Icons.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@ -151,8 +151,8 @@
|
||||
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MahApps.Metro, Version=1.3.0.37, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.3.0-ALPHA037\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Reference Include="MahApps.Metro, Version=1.2.4.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<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.Web" />
|
||||
<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="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
@ -15,7 +13,10 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
|
||||
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()
|
||||
@ -37,7 +38,6 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,13 +76,13 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
using (
|
||||
var resized = ImageUtilities.ResizeImage(bitmap,
|
||||
(int)_keyboard.KeyboardRectangle.Width,
|
||||
(int)_keyboard.KeyboardRectangle.Height)
|
||||
(int) _keyboard.KeyboardRectangle.Width,
|
||||
(int) _keyboard.KeyboardRectangle.Height)
|
||||
)
|
||||
{
|
||||
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))
|
||||
ledColor = Color.Black;
|
||||
item.Led.Color = ledColor;
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
@ -15,7 +13,10 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
|
||||
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()
|
||||
@ -37,7 +38,6 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -7,6 +7,7 @@ namespace Artemis.KeyboardProviders
|
||||
public string Name { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public string CantEnableText { get; set; }
|
||||
|
||||
public abstract bool CanEnable();
|
||||
public abstract void Enable();
|
||||
|
||||
@ -8,7 +8,10 @@ namespace Artemis.KeyboardProviders.Logitech
|
||||
{
|
||||
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;
|
||||
Width = 21;
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Drawing;
|
||||
using Artemis.KeyboardProviders.Razer.Utilities;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer.Keyboard;
|
||||
using Color = Corale.Colore.Core.Color;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Razer
|
||||
{
|
||||
@ -12,6 +11,9 @@ namespace Artemis.KeyboardProviders.Razer
|
||||
public BlackWidow()
|
||||
{
|
||||
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()
|
||||
@ -38,8 +40,8 @@ namespace Artemis.KeyboardProviders.Razer
|
||||
public override void Enable()
|
||||
{
|
||||
Chroma.Instance.Initialize();
|
||||
Height = (int) Constants.MaxRows;
|
||||
Width = (int) Constants.MaxColumns;
|
||||
Height = Constants.MaxRows;
|
||||
Width = Constants.MaxColumns;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
|
||||
@ -17,19 +17,24 @@ namespace Artemis.Models
|
||||
{
|
||||
public class MainModel
|
||||
{
|
||||
private readonly int _fps;
|
||||
private readonly BackgroundWorker _processWorker;
|
||||
private readonly BackgroundWorker _updateWorker;
|
||||
|
||||
private EffectModel _activeEffect;
|
||||
private bool _wasSuspendedBeforeGame;
|
||||
|
||||
public MainModel(IEventAggregator events)
|
||||
{
|
||||
EffectModels = new List<EffectModel>();
|
||||
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
|
||||
GameStateWebServer = new GameStateWebServer();
|
||||
KeyboardHook = new KeyboardHook();
|
||||
Suspended = false;
|
||||
|
||||
Events = events;
|
||||
Fps = 25;
|
||||
|
||||
_fps = 25;
|
||||
_updateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||
_processWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||
_updateWorker.DoWork += UpdateWorker_DoWork;
|
||||
@ -37,16 +42,13 @@ namespace Artemis.Models
|
||||
}
|
||||
|
||||
public KeyboardHook KeyboardHook { get; set; }
|
||||
|
||||
public EffectModel ActiveEffect { get; set; }
|
||||
public KeyboardProvider ActiveKeyboard { get; set; }
|
||||
public List<EffectModel> EffectModels { get; set; }
|
||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||
|
||||
public GameStateWebServer GameStateWebServer { get; set; }
|
||||
public IEventAggregator Events { get; set; }
|
||||
public int Fps { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool Enabled { get; private set; }
|
||||
public bool Suspended { get; private set; }
|
||||
|
||||
#region Effect methods
|
||||
|
||||
@ -77,75 +79,31 @@ namespace Artemis.Models
|
||||
|
||||
Enabled = true;
|
||||
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
|
||||
|
||||
if (General.Default.Suspended && !Suspended)
|
||||
ToggleSuspension();
|
||||
}
|
||||
|
||||
public void ShutdownEffects()
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
|
||||
// Stop the Background Worker
|
||||
_updateWorker.CancelAsync();
|
||||
_processWorker.CancelAsync();
|
||||
|
||||
// Dispose the current active effect
|
||||
ActiveEffect?.Dispose();
|
||||
ActiveEffect = null;
|
||||
_activeEffect?.Dispose();
|
||||
_activeEffect = null;
|
||||
|
||||
ActiveKeyboard?.Disable();
|
||||
ActiveKeyboard = null;
|
||||
|
||||
|
||||
Enabled = false;
|
||||
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()
|
||||
{
|
||||
var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect);
|
||||
@ -163,21 +121,30 @@ namespace Artemis.Models
|
||||
if (!gameModel.Enabled)
|
||||
return;
|
||||
|
||||
if (ActiveEffect != null && effectModel.Name == ActiveEffect.Name)
|
||||
if (_activeEffect != null && effectModel.Name == _activeEffect.Name)
|
||||
return;
|
||||
|
||||
ActiveEffect?.Dispose();
|
||||
ActiveEffect = effectModel;
|
||||
ActiveEffect.Enable();
|
||||
_activeEffect?.Dispose();
|
||||
|
||||
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.
|
||||
General.Default.LastEffect = ActiveEffect.Name;
|
||||
General.Default.LastEffect = _activeEffect.Name;
|
||||
General.Default.Save();
|
||||
|
||||
// Let the ViewModels know
|
||||
Events.PublishOnUIThread(new ChangeActiveEffect(ActiveEffect.Name));
|
||||
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect.Name));
|
||||
}
|
||||
|
||||
public void EnableEffect(EffectModel effectModel)
|
||||
@ -188,15 +155,71 @@ namespace Artemis.Models
|
||||
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)
|
||||
{
|
||||
if (Suspended)
|
||||
return false;
|
||||
if (effectModel is GameModel)
|
||||
return false;
|
||||
|
||||
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
|
||||
|
||||
@ -205,24 +228,23 @@ namespace Artemis.Models
|
||||
var sw = new Stopwatch();
|
||||
while (!_updateWorker.CancellationPending)
|
||||
{
|
||||
if (ActiveKeyboard == null)
|
||||
if (ActiveKeyboard == null || Suspended)
|
||||
{
|
||||
Thread.Sleep(1000 / Fps);
|
||||
Thread.Sleep(1000/_fps);
|
||||
continue;
|
||||
}
|
||||
|
||||
sw.Start();
|
||||
|
||||
// Update the current effect
|
||||
ActiveEffect.Update();
|
||||
_activeEffect.Update();
|
||||
|
||||
// Get ActiveEffect's bitmap
|
||||
var bitmap = ActiveEffect.GenerateBitmap();
|
||||
var bitmap = _activeEffect.GenerateBitmap();
|
||||
|
||||
// Draw enabled overlays on top
|
||||
foreach (
|
||||
var overlayModel in
|
||||
EffectModels.OfType<OverlayModel>().Where(overlayModel => overlayModel.Enabled))
|
||||
foreach (var overlayModel in EffectModels.OfType<OverlayModel>()
|
||||
.Where(overlayModel => overlayModel.Enabled))
|
||||
{
|
||||
overlayModel.Update();
|
||||
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
|
||||
@ -238,7 +260,7 @@ namespace Artemis.Models
|
||||
}
|
||||
|
||||
// Sleep according to time left this frame
|
||||
var sleep = (int)(1000 / Fps - sw.ElapsedMilliseconds);
|
||||
var sleep = (int) (1000/_fps - sw.ElapsedMilliseconds);
|
||||
if (sleep > 0)
|
||||
Thread.Sleep(sleep);
|
||||
sw.Reset();
|
||||
@ -261,7 +283,7 @@ namespace Artemis.Models
|
||||
continue;
|
||||
|
||||
// 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)
|
||||
LoadLastEffect();
|
||||
else
|
||||
@ -272,9 +294,16 @@ namespace Artemis.Models
|
||||
}
|
||||
|
||||
// If no game process is found, but the active effect still belongs to a game,
|
||||
// set it to a normal effect
|
||||
if (!foundProcess && ActiveEffect is GameModel)
|
||||
// set it to a normal effect, and if needed, suspend again.
|
||||
if (!foundProcess && _activeEffect is GameModel)
|
||||
{
|
||||
LoadLastEffect();
|
||||
if (_wasSuspendedBeforeGame)
|
||||
{
|
||||
ToggleSuspension();
|
||||
_wasSuspendedBeforeGame = false;
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
@ -46,8 +46,15 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
||||
|
||||
public void ToggleEffect()
|
||||
{
|
||||
MainModel.EnableEffect(AudioVisualizerModel);
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
if (EffectEnabled && !MainModel.Suspended)
|
||||
MainModel.ToggleSuspension();
|
||||
else if (!EffectEnabled && !MainModel.Suspended)
|
||||
MainModel.EnableEffect(AudioVisualizerModel);
|
||||
else
|
||||
{
|
||||
MainModel.ToggleSuspension();
|
||||
MainModel.EnableEffect(AudioVisualizerModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
|
||||
@ -100,7 +100,15 @@ namespace Artemis.Modules.Effects.Debug
|
||||
|
||||
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()
|
||||
|
||||
@ -30,7 +30,15 @@ namespace Artemis.Modules.Effects.TypeHole
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,8 +46,15 @@ namespace Artemis.Modules.Effects.TypeWave
|
||||
|
||||
public void ToggleEffect()
|
||||
{
|
||||
MainModel.EnableEffect(TypeWaveModel);
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
if (EffectEnabled && !MainModel.Suspended)
|
||||
MainModel.ToggleSuspension();
|
||||
else if (!EffectEnabled && !MainModel.Suspended)
|
||||
MainModel.EnableEffect(TypeWaveModel);
|
||||
else
|
||||
{
|
||||
MainModel.ToggleSuspension();
|
||||
MainModel.EnableEffect(TypeWaveModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
@ -59,7 +60,13 @@
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
|
||||
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
|
||||
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>
|
||||
|
||||
<!-- Buttons -->
|
||||
|
||||
14
Artemis/Artemis/Settings/General.Designer.cs
generated
14
Artemis/Artemis/Settings/General.Designer.cs
generated
@ -37,7 +37,7 @@ namespace Artemis.Settings {
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Corsair Gaming K95 RGB")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Logitech G910 RGB")]
|
||||
public string LastKeyboard {
|
||||
get {
|
||||
return ((string)(this["LastKeyboard"]));
|
||||
@ -82,5 +82,17 @@ namespace Artemis.Settings {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<Value Profile="(Default)">TypeWave</Value>
|
||||
</Setting>
|
||||
<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 Name="EnablePointersUpdate" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
@ -17,5 +17,8 @@
|
||||
<Setting Name="Autorun" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="Suspended" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -15,8 +15,6 @@ namespace Artemis.Settings
|
||||
{
|
||||
if (General.Default.GamestatePort == value) return;
|
||||
General.Default.GamestatePort = value;
|
||||
ApplyGamestatePort();
|
||||
General.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +25,6 @@ namespace Artemis.Settings
|
||||
{
|
||||
if (General.Default.EnablePointersUpdate == value) return;
|
||||
General.Default.EnablePointersUpdate = value;
|
||||
General.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,8 +35,6 @@ namespace Artemis.Settings
|
||||
{
|
||||
if (General.Default.Autorun == value) return;
|
||||
General.Default.Autorun = value;
|
||||
ApplyAutorun();
|
||||
General.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,5 +57,22 @@ namespace Artemis.Settings
|
||||
else if (File.Exists(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,6 +80,17 @@ namespace Artemis.ViewModels.Flyouts
|
||||
MainModel.StartEffects();
|
||||
}
|
||||
|
||||
public void ResetSettings()
|
||||
{
|
||||
GeneralSettings.ResetSettings();
|
||||
NotifyOfPropertyChange(() => GeneralSettings);
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
{
|
||||
GeneralSettings.SaveSettings();
|
||||
}
|
||||
|
||||
public void NavigateTo(string url)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(url));
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.Windows;
|
||||
using Artemis.Events;
|
||||
using Artemis.Settings;
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Keyboard:" />
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" x:Name="KeyboardProviders" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Width="120" />
|
||||
Width="140" />
|
||||
<!-- TODO: Ugly -->
|
||||
|
||||
<!-- Gamestate port -->
|
||||
|
||||
@ -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: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:tb="http://www.hardcodet.net/taskbar"
|
||||
Title="SystemTrayView"
|
||||
@ -11,7 +12,7 @@
|
||||
Background="Transparent"
|
||||
Visibility="Hidden">
|
||||
|
||||
<Window.Resources>
|
||||
<Controls:MetroWindow.Resources>
|
||||
|
||||
<ContextMenu x:Shared="false" x:Key="MainSysTrayMenu">
|
||||
<MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" />
|
||||
@ -28,9 +29,9 @@
|
||||
cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]"
|
||||
ContextMenu="{StaticResource MainSysTrayMenu}" />
|
||||
|
||||
</Window.Resources>
|
||||
</Controls:MetroWindow.Resources>
|
||||
|
||||
<Grid>
|
||||
<ContentControl Content="{StaticResource SystemTrayIcon}" />
|
||||
</Grid>
|
||||
</Window>
|
||||
</Controls:MetroWindow>
|
||||
@ -1,11 +1,12 @@
|
||||
using System.Windows;
|
||||
using MahApps.Metro.Controls;
|
||||
|
||||
namespace Artemis.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SystemTrayView.xaml
|
||||
/// </summary>
|
||||
public partial class SystemTrayView : Window
|
||||
public partial class SystemTrayView : MetroWindow
|
||||
{
|
||||
public SystemTrayView()
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
|
||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.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="MouseKeyHook" version="5.4.0" targetFramework="net452" />
|
||||
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user