1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
This commit is contained in:
Logan Saso 2016-02-20 15:59:57 -08:00
commit 7c8d87d90d
15 changed files with 522 additions and 278 deletions

View File

@ -204,6 +204,9 @@
<setting name="GamestatePort" serializeAs="String"> <setting name="GamestatePort" serializeAs="String">
<value>51364</value> <value>51364</value>
</setting> </setting>
<setting name="Autorun" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Settings.General> </Artemis.Settings.General>
</userSettings> </userSettings>
<runtime> <runtime>

View File

@ -151,13 +151,10 @@
<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.17, 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-ALPHA017\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="MemorySharp">
<HintPath>E:\Downloads\Chome Downloads\MemorySharp-master\MemorySharp-master\MemorySharp\bin\Release\MemorySharp.dll</HintPath>
</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">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
</Reference> </Reference>
@ -175,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" />
@ -227,6 +227,7 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="ArtemisBootstrapper.cs" /> <Compile Include="ArtemisBootstrapper.cs" />
<Compile Include="Events\ToggleEnabled.cs" />
<Compile Include="Events\ChangeActiveEffect.cs" /> <Compile Include="Events\ChangeActiveEffect.cs" />
<Compile Include="Events\ChangeBitmap.cs" /> <Compile Include="Events\ChangeBitmap.cs" />
<Compile Include="KeyboardProviders\Corsair\K70.cs" /> <Compile Include="KeyboardProviders\Corsair\K70.cs" />
@ -303,6 +304,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>General.settings</DependentUpon> <DependentUpon>General.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Settings\GeneralSettings.cs" />
<Compile Include="Settings\Offsets.Designer.cs"> <Compile Include="Settings\Offsets.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
@ -320,6 +322,7 @@
<Compile Include="Utilities\Memory\Win32.cs" /> <Compile Include="Utilities\Memory\Win32.cs" />
<Compile Include="Utilities\Keyboard\Key.cs" /> <Compile Include="Utilities\Keyboard\Key.cs" />
<Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" /> <Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" />
<Compile Include="Utilities\ShellLink.cs" />
<Compile Include="ViewModels\EffectsViewModel.cs" /> <Compile Include="ViewModels\EffectsViewModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" /> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" /> <Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
@ -417,14 +420,16 @@
<None Include="packages.config" /> <None Include="packages.config" />
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
<Resource Include="Resources\bow.png" /> <Resource Include="Resources\bow.png" />
<Resource Include="Resources\WindowsIcons-license.txt" />
<Resource Include="Resources\Entypo-license.txt" />
<Content Include="Resources\Witcher3\playerWitcher.txt" /> <Content Include="Resources\Witcher3\playerWitcher.txt" />
<Content Include="Resources\Witcher3\artemis.txt" /> <Content Include="Resources\Witcher3\artemis.txt" />
<Resource Include="logo-disabled.ico" /> <Resource Include="logo-disabled.ico" />
<Resource Include="Resources\Entypo.ttf" />
<None Include="Settings\Offsets.settings"> <None Include="Settings\Offsets.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Offsets.Designer.cs</LastGenOutput> <LastGenOutput>Offsets.Designer.cs</LastGenOutput>
</None> </None>
<Resource Include="Resources\Entypo.ttf" />
<None Include="Settings\General.settings"> <None Include="Settings\General.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>General.Designer.cs</LastGenOutput> <LastGenOutput>General.Designer.cs</LastGenOutput>
@ -499,7 +504,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup />
<ItemGroup> <ItemGroup>
<Content Include="LogitechLedEnginesWrapper.dll"> <Content Include="LogitechLedEnginesWrapper.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@ -511,8 +515,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource> </Resource>
<Content Include="Resources\CounterStrike\gamestateConfiguration.txt" /> <Content Include="Resources\CounterStrike\gamestateConfiguration.txt" />
<Resource Include="Resources\Entypo-license.txt" />
<Resource Include="Resources\WindowsIcons-license.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2"> <BootstrapperPackage Include=".NETFramework,Version=v4.5.2">

View File

@ -0,0 +1,12 @@
namespace Artemis.Events
{
public class ToggleEnabled
{
public bool Enabled { get; set; }
public ToggleEnabled(bool enabled)
{
Enabled = enabled;
}
}
}

View File

@ -24,7 +24,12 @@ namespace Artemis.KeyboardProviders.Logitech
// Initialize the SDK // Initialize the SDK
LogitechGSDK.LogiLedInit(); LogitechGSDK.LogiLedInit();
Thread.Sleep(200); Thread.Sleep(200);
LogitechGSDK.LogiLedSaveCurrentLighting(); LogitechGSDK.LogiLedSaveCurrentLighting();
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
// Disable keys we can't color
LogitechGSDK.LogiLedSetLighting(0, 0, 0);
} }
public override void Disable() public override void Disable()

View File

@ -52,6 +52,14 @@ namespace Artemis.Models
public void StartEffects() public void StartEffects()
{ {
if (Enabled)
return;
if (_updateWorker.IsBusy || _processWorker.IsBusy)
{
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
return;
}
LoadLastKeyboard(); LoadLastKeyboard();
// If no keyboard was loaded, don't enable effects. // If no keyboard was loaded, don't enable effects.
if (ActiveKeyboard == null) if (ActiveKeyboard == null)
@ -66,10 +74,16 @@ namespace Artemis.Models
// Start the Background Workers // Start the Background Workers
_updateWorker.RunWorkerAsync(); _updateWorker.RunWorkerAsync();
_processWorker.RunWorkerAsync(); _processWorker.RunWorkerAsync();
Enabled = true;
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
} }
public void ShutdownEffects() public void ShutdownEffects()
{ {
if (!Enabled)
return;
// Stop the Background Worker // Stop the Background Worker
_updateWorker.CancelAsync(); _updateWorker.CancelAsync();
_processWorker.CancelAsync(); _processWorker.CancelAsync();
@ -80,6 +94,9 @@ namespace Artemis.Models
ActiveKeyboard?.Disable(); ActiveKeyboard?.Disable();
ActiveKeyboard = null; ActiveKeyboard = null;
Enabled = false;
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
} }
private void LoadLastKeyboard() private void LoadLastKeyboard()
@ -176,6 +193,12 @@ namespace Artemis.Models
var sw = new Stopwatch(); var sw = new Stopwatch();
while (!_updateWorker.CancellationPending) while (!_updateWorker.CancellationPending)
{ {
if (ActiveKeyboard == null)
{
Thread.Sleep(1000 / Fps);
continue;
}
sw.Start(); sw.Start();
// Update the current effect // Update the current effect
@ -186,7 +209,8 @@ namespace Artemis.Models
// Draw enabled overlays on top // Draw enabled overlays on top
foreach ( foreach (
var overlayModel in EffectModels.OfType<OverlayModel>().Where(overlayModel => overlayModel.Enabled)) var overlayModel in
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();
@ -197,7 +221,7 @@ namespace Artemis.Models
{ {
ActiveKeyboard.DrawBitmap(bitmap); ActiveKeyboard.DrawBitmap(bitmap);
// debugging // debugging TODO: Disable when window isn't shown
Events.PublishOnUIThread(new ChangeBitmap(bitmap)); Events.PublishOnUIThread(new ChangeBitmap(bitmap));
} }

View File

@ -74,9 +74,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
return bitmap; return bitmap;
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{
VolumeDisplay.Draw(g); VolumeDisplay.Draw(g);
}
return bitmap; return bitmap;
} }

View File

@ -70,5 +70,17 @@ namespace Artemis.Settings {
this["GamestatePort"] = value; this["GamestatePort"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool Autorun {
get {
return ((bool)(this["Autorun"]));
}
set {
this["Autorun"] = value;
}
}
} }
} }

View File

@ -1,7 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="LastEffect" Type="System.String" Scope="User"> <Setting Name="LastEffect" Type="System.String" Scope="User">
@ -16,5 +14,8 @@
<Setting Name="GamestatePort" Type="System.Int32" Scope="User"> <Setting Name="GamestatePort" Type="System.Int32" Scope="User">
<Value Profile="(Default)">51364</Value> <Value Profile="(Default)">51364</Value>
</Setting> </Setting>
<Setting Name="Autorun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -0,0 +1,66 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using Artemis.Utilities;
namespace Artemis.Settings
{
public class GeneralSettings
{
public int GamestatePort
{
get { return General.Default.GamestatePort; }
set
{
if (General.Default.GamestatePort == value) return;
General.Default.GamestatePort = value;
ApplyGamestatePort();
General.Default.Save();
}
}
public bool EnablePointersUpdate
{
get { return General.Default.EnablePointersUpdate; }
set
{
if (General.Default.EnablePointersUpdate == value) return;
General.Default.EnablePointersUpdate = value;
General.Default.Save();
}
}
public bool Autorun
{
get { return General.Default.Autorun; }
set
{
if (General.Default.Autorun == value) return;
General.Default.Autorun = value;
ApplyAutorun();
General.Default.Save();
}
}
private void ApplyGamestatePort()
{
// TODO: Restart Gamestate server
}
private void ApplyAutorun()
{
var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (Autorun)
{
var link = (IShellLink) new ShellLink();
link.SetPath(Assembly.GetExecutingAssembly().Location);
var file = (IPersistFile) link;
file.Save(startupFolder + @"\Artemis.lnk", false);
}
else if (File.Exists(startupFolder + @"\Artemis.lnk"))
File.Delete(startupFolder + @"\Artemis.lnk");
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Artemis.Utilities
{
/// <summary>
/// Creates a shortcut (.lnk) file.
/// Source: http://stackoverflow.com/a/14632782/5015269
/// </summary>
[ComImport]
[Guid("00021401-0000-0000-C000-000000000046")]
internal class ShellLink
{
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214F9-0000-0000-C000-000000000046")]
internal interface IShellLink
{
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd,
int fFlags);
void GetIDList(out IntPtr ppidl);
void SetIDList(IntPtr pidl);
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
void GetHotkey(out short pwHotkey);
void SetHotkey(short wHotkey);
void GetShowCmd(out int piShowCmd);
void SetShowCmd(int iShowCmd);
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath,
out int piIcon);
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
void Resolve(IntPtr hwnd, int fFlags);
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
}

View File

@ -1,24 +1,42 @@
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Windows.Forms; using Artemis.Events;
using Artemis.Models; using Artemis.Models;
using Artemis.Settings;
using Caliburn.Micro; using Caliburn.Micro;
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
namespace Artemis.ViewModels.Flyouts namespace Artemis.ViewModels.Flyouts
{ {
public class FlyoutSettingsViewModel : FlyoutBaseViewModel public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>
{ {
private bool _enabled;
private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider; private string _selectedKeyboardProvider;
public MainModel MainModel { get; set; }
public FlyoutSettingsViewModel(MainModel mainModel) public FlyoutSettingsViewModel(MainModel mainModel)
{ {
MainModel = mainModel; MainModel = mainModel;
Header = "settings"; Header = "settings";
Position = Position.Right; Position = Position.Right;
GeneralSettings = new GeneralSettings();
MainModel.Events.Subscribe(this);
} }
public GeneralSettings GeneralSettings
{
get { return _generalSettings; }
set
{
if (Equals(value, _generalSettings)) return;
_generalSettings = value;
NotifyOfPropertyChange(() => GeneralSettings);
}
}
public MainModel MainModel { get; set; }
public BindableCollection<string> KeyboardProviders public BindableCollection<string> KeyboardProviders
=> new BindableCollection<string>(MainModel.KeyboardProviders.Select(k => k.Name)); => new BindableCollection<string>(MainModel.KeyboardProviders.Select(k => k.Name));
@ -30,11 +48,38 @@ namespace Artemis.ViewModels.Flyouts
if (value == _selectedKeyboardProvider) return; if (value == _selectedKeyboardProvider) return;
_selectedKeyboardProvider = value; _selectedKeyboardProvider = value;
NotifyOfPropertyChange(() => SelectedKeyboardProvider); NotifyOfPropertyChange(() => SelectedKeyboardProvider);
if (value == null)
return;
MainModel.ChangeKeyboard(MainModel.KeyboardProviders.First(k => k.Name == _selectedKeyboardProvider)); MainModel.ChangeKeyboard(MainModel.KeyboardProviders.First(k => k.Name == _selectedKeyboardProvider));
} }
} }
public bool Enabled
{
get { return _enabled; }
set
{
if (value == _enabled) return;
_enabled = value;
NotifyOfPropertyChange(() => Enabled);
}
}
public void Handle(ToggleEnabled message)
{
Enabled = message.Enabled;
}
public void ToggleEnabled()
{
if (Enabled)
MainModel.ShutdownEffects();
else
MainModel.StartEffects();
}
public void NavigateTo(string url) public void NavigateTo(string url)
{ {
Process.Start(new ProcessStartInfo(url)); Process.Start(new ProcessStartInfo(url));

View File

@ -24,24 +24,11 @@ namespace Artemis.ViewModels
_overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"}; _overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel(MainModel)); Flyouts.Add(new FlyoutSettingsViewModel(MainModel));
// By now Effects are added to the MainModel so we can savely start one
ToggleEffects();
} }
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } = public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>(); new BindableCollection<FlyoutBaseViewModel>();
public bool EffectsEnabled
{
get { return MainModel.Enabled; }
private set
{
MainModel.Enabled = value;
NotifyOfPropertyChange(() => EffectsEnabled);
}
}
public MainModel MainModel { get; set; } public MainModel MainModel { get; set; }
protected override void OnActivate() protected override void OnActivate()
@ -53,16 +40,6 @@ namespace Artemis.ViewModels
ActivateItem(_overlaysVm); ActivateItem(_overlaysVm);
} }
public void ToggleEffects()
{
if (EffectsEnabled)
MainModel.ShutdownEffects();
else
MainModel.StartEffects();
EffectsEnabled = !EffectsEnabled;
}
public void OnClose(EventArgs e) public void OnClose(EventArgs e)
{ {
MainModel.ShutdownEffects(); MainModel.ShutdownEffects();

View File

@ -1,13 +1,16 @@
using System.Windows; using System.Windows;
using Artemis.Events;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
{ {
public class SystemTrayViewModel : Screen public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled>
{ {
private readonly ShellViewModel _shellViewModel; private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager; private readonly IWindowManager _windowManager;
private bool _enabled;
private string _toggleText;
/* /*
* NOTE: In this sample the system tray view-model doesn't receive any notification * NOTE: In this sample the system tray view-model doesn't receive any notification
* when the other window gets closed by pressing the top right 'x'. * when the other window gets closed by pressing the top right 'x'.
@ -21,6 +24,14 @@ namespace Artemis.ViewModels
{ {
_windowManager = windowManager; _windowManager = windowManager;
_shellViewModel = shellViewModel; _shellViewModel = shellViewModel;
_shellViewModel.MainModel.Events.Subscribe(this);
/*
* By now Effects are added to the MainModel so we can savely start
* This is done from here to make sure all UI elements listening to
* events will receive the first ToggleEnabled event
* */
_shellViewModel.MainModel.StartEffects();
// TODO: Check if show on startup is enabled, if so, show window. // TODO: Check if show on startup is enabled, if so, show window.
} }
@ -29,6 +40,43 @@ namespace Artemis.ViewModels
public bool CanHideWindow => _shellViewModel.IsActive; public bool CanHideWindow => _shellViewModel.IsActive;
public bool Enabled
{
get { return _enabled; }
set
{
if (value == _enabled) return;
_enabled = value;
ToggleText = _enabled ? "Disable Artemis" : "Enable Artemis";
NotifyOfPropertyChange(() => Enabled);
}
}
public string ToggleText
{
get { return _toggleText; }
set
{
if (value == _toggleText) return;
_toggleText = value;
NotifyOfPropertyChange(() => ToggleText);
}
}
public void Handle(ToggleEnabled message)
{
Enabled = message.Enabled;
}
public void ToggleEnabled()
{
if (Enabled)
_shellViewModel.MainModel.ShutdownEffects();
else
_shellViewModel.MainModel.StartEffects();
}
protected override void OnActivate() protected override void OnActivate()
{ {
base.OnActivate(); base.OnActivate();

View File

@ -31,12 +31,15 @@
<Label Grid.Row="0" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="0" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Enable Artemis:" /> Content="Enable Artemis:" />
<controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No" <controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" /> VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=Enabled, Mode=OneWay}"
cal:Message.Attach="[Event Unchecked] = [Action ToggleEnabled]; [Event Checked] = [Action ToggleEnabled]"/>
<!-- Startup with Windows --> <!-- Startup with Windows -->
<Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Startup with Windows:" /> Content="Startup with Windows:" />
<controls:ToggleSwitch Grid.Row="1" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No" <controls:ToggleSwitch Grid.Row="1" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
IsChecked="{Binding Path=GeneralSettings.Autorun, Mode=TwoWay}"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" /> VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
<!-- Keyboard selection --> <!-- Keyboard selection -->
@ -50,13 +53,15 @@
<Label Grid.Row="3" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="3" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Gamestate server port:" /> Content="Gamestate server port:" />
<controls:NumericUpDown Grid.Row="3" Grid.Column="1" Margin="10" VerticalAlignment="Center" <controls:NumericUpDown Grid.Row="3" Grid.Column="1" Margin="10" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="120" /> HorizontalAlignment="Right" Width="120"
Value="{Binding Path=GeneralSettings.GamestatePort, Mode=TwoWay}"/>
<!-- Update pointers --> <!-- Update pointers -->
<Label Grid.Row="4" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="4" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Download pointers:" /> Content="Download pointers:" />
<controls:ToggleSwitch Grid.Row="4" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No" <controls:ToggleSwitch Grid.Row="4" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" /> VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}"/>
<!-- Buttons --> <!-- Buttons -->
<Button Grid.Row="5" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings" <Button Grid.Row="5" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings"

View File

@ -17,7 +17,7 @@
<MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" /> <MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" />
<MenuItem Header="Hide Artemis" cal:Message.Attach="HideWindow" /> <MenuItem Header="Hide Artemis" cal:Message.Attach="HideWindow" />
<Separator /> <Separator />
<MenuItem Header="Disable all effects" cal:Message.Attach="DisableEffects" /> <MenuItem Header="{Binding Path=ToggleText, Mode=OneWay}" cal:Message.Attach="ToggleEnabled" />
<MenuItem Header="Exit" cal:Message.Attach="ExitApplication" /> <MenuItem Header="Exit" cal:Message.Attach="ExitApplication" />
</ContextMenu> </ContextMenu>