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

Store install path in registry

Finalized auto-update code
This commit is contained in:
Robert Beekman 2017-11-28 13:08:33 +01:00
parent b394c03dbb
commit bc64ac33f8
14 changed files with 232 additions and 169 deletions

View File

@ -18,6 +18,7 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
<SuppressPdbOutput>False</SuppressPdbOutput>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>HarvestPath=..\Artemis\bin\Release</DefineConstants>
@ -59,6 +60,12 @@
<Target Name="BeforeBuild">
<HeatDirectory Directory="..\Artemis\bin\Release" PreprocessorVariable="var.HarvestPath" OutputFile="HeatGeneratedFileList.wxs" ComponentGroupName="HeatGenerated" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" ToolPath="$(WixToolPath)" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" />
</Target>
<PropertyGroup>
<PreBuildEvent />
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent />
</PropertyGroup>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.

View File

@ -38,9 +38,6 @@
<Component Id="cmpA643245E2404309B3DABA70BB912DCCB" Guid="*">
<File Id="filB4B2021C4282D7C64C5B4AD0AF512DCA" KeyPath="yes" Source="$(var.HarvestPath)\ColorBox.dll" />
</Component>
<Component Id="cmp4D0A4ED17FB1630F800FD706E2563C80" Guid="*">
<File Id="fil9AA96F00A2CBCD318E0F8757A28B4271" KeyPath="yes" Source="$(var.HarvestPath)\ColorBox.pdb" />
</Component>
<Component Id="cmpFBDA3E7CEA190733BF9F05003E25D5AF" Guid="*">
<File Id="filB20254A9D5C181C3E378CFFA814C5E33" KeyPath="yes" Source="$(var.HarvestPath)\Corale.Colore.dll" />
</Component>
@ -62,9 +59,6 @@
<Component Id="cmp51BF717902634148759143BD6AD539B0" Guid="*">
<File Id="fil13BFD35B4184B1F8F1AAB29A7C3686BC" KeyPath="yes" Source="$(var.HarvestPath)\DynamicExpresso.Core.dll" />
</Component>
<Component Id="cmp73C85F3EAF424BD70648B36B74C26770" Guid="*">
<File Id="filC2A40A556A913567A37A2740351EDC2D" KeyPath="yes" Source="$(var.HarvestPath)\DynamicExpresso.Core.pdb" />
</Component>
<Component Id="cmpF91C67D347AB218E39A848636AB895E3" Guid="*">
<File Id="fil92C151A1E3668BA2B0166FD3BDCDE7CB" KeyPath="yes" Source="$(var.HarvestPath)\DynamicExpresso.Core.xml" />
</Component>
@ -74,18 +68,12 @@
<Component Id="cmp781EEA928029B571EC5B4E7090BD7946" Guid="*">
<File Id="fil093D81EF2D0F558E4AF6DBB696C8B611" KeyPath="yes" Source="$(var.HarvestPath)\GongSolutions.Wpf.DragDrop.dll" />
</Component>
<Component Id="cmp247A5C6B2FC2255D2495669F4BBC5B13" Guid="*">
<File Id="fil5337173B3C652BB7E832CBB74A945243" KeyPath="yes" Source="$(var.HarvestPath)\GongSolutions.Wpf.DragDrop.pdb" />
</Component>
<Component Id="cmp349050BDBF99EA8BFA2BA8F9E31ED252" Guid="*">
<File Id="filAB2DEF8A4601402AB380F6101D5A66E0" KeyPath="yes" Source="$(var.HarvestPath)\GongSolutions.Wpf.DragDrop.xml" />
</Component>
<Component Id="cmpBE3C1D05C7C90455322C9F819A57A07A" Guid="*">
<File Id="filE7C602A91344AD969255F20A2CA7411A" KeyPath="yes" Source="$(var.HarvestPath)\Hardcodet.Wpf.TaskbarNotification.dll" />
</Component>
<Component Id="cmp92758FBE7BAD0A8C22E2DF7485108D82" Guid="*">
<File Id="fil37C16A438720B34E2BAED72C2359E6B8" KeyPath="yes" Source="$(var.HarvestPath)\Hardcodet.Wpf.TaskbarNotification.pdb" />
</Component>
<Component Id="cmp1AB3F692680AD43D977D2B4893C60651" Guid="*">
<File Id="fil8DCFE8E2064CED909E7B76E107F2D738" KeyPath="yes" Source="$(var.HarvestPath)\Hardcodet.Wpf.TaskbarNotification.xml" />
</Component>
@ -104,18 +92,12 @@
<Component Id="cmp223D4754378C01052DA8253A843FD297" Guid="*">
<File Id="filBC562C5B3D9848A2114F0AF7275FF1E6" KeyPath="yes" Source="$(var.HarvestPath)\MahApps.Metro.dll" />
</Component>
<Component Id="cmp31541C871E68AFBC70137561BF857C7B" Guid="*">
<File Id="fil109901354A5E9C0DB4A287ECF7B10D9E" KeyPath="yes" Source="$(var.HarvestPath)\MahApps.Metro.pdb" />
</Component>
<Component Id="cmp43D899344ED173B0DAFCD84946D02788" Guid="*">
<File Id="fil7FCB3B29476FFB610381CD77013296AD" KeyPath="yes" Source="$(var.HarvestPath)\MahApps.Metro.xml" />
</Component>
<Component Id="cmp2FCEBC7A99564B55654E85ED28E48600" Guid="*">
<File Id="fil4EAD90E131DF96A66C4D6F6426CE480B" KeyPath="yes" Source="$(var.HarvestPath)\MoonSharp.Interpreter.dll" />
</Component>
<Component Id="cmp10359C02FE64062C8403FF433E774083" Guid="*">
<File Id="fil7357720C30D1947ABE224E6EF4581E03" KeyPath="yes" Source="$(var.HarvestPath)\MoonSharp.Interpreter.pdb" />
</Component>
<Component Id="cmpF3259CFFC7B5247438581E9B04AB35D8" Guid="*">
<File Id="filD117DB2E80E33BDED00898D9DB2B086A" KeyPath="yes" Source="$(var.HarvestPath)\MoonSharp.Interpreter.xml" />
</Component>
@ -158,9 +140,6 @@
<Component Id="cmpC788DBAFBC9F98E69B6A163430726358" Guid="*">
<File Id="fil90249C4571D1C5C77FEF83E6CD7C0486" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Base.dll" />
</Component>
<Component Id="cmp0DEB91AD1FD75E285540D446C99E9C2C" Guid="*">
<File Id="fil4A9AC11AC6C5EC445B2D36E6CD933E91" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Base.pdb" />
</Component>
<Component Id="cmp34B431D779DBCB134781FB546E793672" Guid="*">
<File Id="filF22891E372F5EE5250A214F03B209159" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Base.xml" />
</Component>
@ -170,33 +149,21 @@
<Component Id="cmp880114322C539610888B6FE5E0430EFD" Guid="*">
<File Id="filA3DCFB0511C279CFF23D9027A6EF8034" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.Extensions.dll" />
</Component>
<Component Id="cmp52B77D4D77F60AD44714157DBA1F8386" Guid="*">
<File Id="filF397572DD5CBE63F669A23C685E278AB" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.Extensions.pdb" />
</Component>
<Component Id="cmp2BDA3BC9AACE855B92939FAC7E485D24" Guid="*">
<File Id="fil74465812CD5B22E5E5E2DAACA2F84A09" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.Extensions.xml" />
</Component>
<Component Id="cmp571CF516DB97F7011AAF8A137D2996FF" Guid="*">
<File Id="filFFAD6D65B4CFFFAC7982074225CA6DAB" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.pdb" />
</Component>
<Component Id="cmp0DE0CF5F9F4EBB61B3E2366D5E01ACDA" Guid="*">
<File Id="fil2B276F38ABE0890FD005BE1FD1450AC2" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.xml" />
</Component>
<Component Id="cmp5B06590B9AB52A536B50EE73700F03B7" Guid="*">
<File Id="filC3001B1F38283A14D605C01009EE5815" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Packets.dll" />
</Component>
<Component Id="cmpFC6F09A2810126E4E716AE2EA4AD7E6C" Guid="*">
<File Id="fil6E76B5334F262B8C788A6ADD9E6B577F" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Packets.pdb" />
</Component>
<Component Id="cmp4D8569518C357F8E84EFB1725283D60A" Guid="*">
<File Id="fil160F2677CE3E20572D82BFFADCA3E0D4" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Packets.xml" />
</Component>
<Component Id="cmp2DDF6D17BE1860B9D9659B9467BE29B2" Guid="*">
<File Id="fil7DCA2F46028FF87F6BF1D93C796F2940" KeyPath="yes" Source="$(var.HarvestPath)\Process.NET.dll" />
</Component>
<Component Id="cmpB7EBAD40DC64AFBEFD12B3567739DCEF" Guid="*">
<File Id="filCAD83C0189995547B3C00B767092E1B5" KeyPath="yes" Source="$(var.HarvestPath)\Process.NET.pdb" />
</Component>
<Component Id="cmpC4421A56E3C93C93233BC144EDDD52DE" Guid="*">
<File Id="fil094D2250A8E795A10D0384375675E336" KeyPath="yes" Source="$(var.HarvestPath)\Process.NET.xml" />
</Component>
@ -255,7 +222,6 @@
<ComponentRef Id="cmp3E3AA980BDCF05810907BC4EB3821194" />
<ComponentRef Id="cmp17D9A8147FAEAB525E5B8101916313BA" />
<ComponentRef Id="cmpA643245E2404309B3DABA70BB912DCCB" />
<ComponentRef Id="cmp4D0A4ED17FB1630F800FD706E2563C80" />
<ComponentRef Id="cmpFBDA3E7CEA190733BF9F05003E25D5AF" />
<ComponentRef Id="cmp0215030D177DFD73F427CC3D7CA19238" />
<ComponentRef Id="cmpA1F7266A1B0ADDC69DE569177E196895" />
@ -263,24 +229,19 @@
<ComponentRef Id="cmp8D9BC4E9081E35E49D1317948B71CF9E" />
<ComponentRef Id="cmp6527C67EBA0A64B342B4DFD472F51344" />
<ComponentRef Id="cmp51BF717902634148759143BD6AD539B0" />
<ComponentRef Id="cmp73C85F3EAF424BD70648B36B74C26770" />
<ComponentRef Id="cmpF91C67D347AB218E39A848636AB895E3" />
<ComponentRef Id="cmpFDA802159822E5F335299869D8F57A96" />
<ComponentRef Id="cmp781EEA928029B571EC5B4E7090BD7946" />
<ComponentRef Id="cmp247A5C6B2FC2255D2495669F4BBC5B13" />
<ComponentRef Id="cmp349050BDBF99EA8BFA2BA8F9E31ED252" />
<ComponentRef Id="cmpBE3C1D05C7C90455322C9F819A57A07A" />
<ComponentRef Id="cmp92758FBE7BAD0A8C22E2DF7485108D82" />
<ComponentRef Id="cmp1AB3F692680AD43D977D2B4893C60651" />
<ComponentRef Id="cmp13D58469BCB864EB53214ED46E622188" />
<ComponentRef Id="cmp742785C9A7B88BE6B2E81C2322E3D2EE" />
<ComponentRef Id="cmp57FCE16B127552B85167E1625E9421BE" />
<ComponentRef Id="cmpC92D9566450D2381C819C291B41E2EE8" />
<ComponentRef Id="cmp223D4754378C01052DA8253A843FD297" />
<ComponentRef Id="cmp31541C871E68AFBC70137561BF857C7B" />
<ComponentRef Id="cmp43D899344ED173B0DAFCD84946D02788" />
<ComponentRef Id="cmp2FCEBC7A99564B55654E85ED28E48600" />
<ComponentRef Id="cmp10359C02FE64062C8403FF433E774083" />
<ComponentRef Id="cmpF3259CFFC7B5247438581E9B04AB35D8" />
<ComponentRef Id="cmpBC4FC00A26E7D32479D42D3411317FC5" />
<ComponentRef Id="cmp125C379E185231EFADA4CB4301BD0A9E" />
@ -295,19 +256,14 @@
<ComponentRef Id="cmpB7F1EBE42DCB1051B92D42C1EF84E2F9" />
<ComponentRef Id="cmpAF162B14FA6391E4D0D34D9485A3CBEB" />
<ComponentRef Id="cmpC788DBAFBC9F98E69B6A163430726358" />
<ComponentRef Id="cmp0DEB91AD1FD75E285540D446C99E9C2C" />
<ComponentRef Id="cmp34B431D779DBCB134781FB546E793672" />
<ComponentRef Id="cmpC306A22C66D6CF8D48E8AA6050A52C97" />
<ComponentRef Id="cmp880114322C539610888B6FE5E0430EFD" />
<ComponentRef Id="cmp52B77D4D77F60AD44714157DBA1F8386" />
<ComponentRef Id="cmp2BDA3BC9AACE855B92939FAC7E485D24" />
<ComponentRef Id="cmp571CF516DB97F7011AAF8A137D2996FF" />
<ComponentRef Id="cmp0DE0CF5F9F4EBB61B3E2366D5E01ACDA" />
<ComponentRef Id="cmp5B06590B9AB52A536B50EE73700F03B7" />
<ComponentRef Id="cmpFC6F09A2810126E4E716AE2EA4AD7E6C" />
<ComponentRef Id="cmp4D8569518C357F8E84EFB1725283D60A" />
<ComponentRef Id="cmp2DDF6D17BE1860B9D9659B9467BE29B2" />
<ComponentRef Id="cmpB7EBAD40DC64AFBEFD12B3567739DCEF" />
<ComponentRef Id="cmpC4421A56E3C93C93233BC144EDDD52DE" />
<ComponentRef Id="cmp5628FD27631E522C3D67C498667BC8A5" />
<ComponentRef Id="cmp3145619F7A6A826AB72CAFCEF603B974" />

View File

@ -2,7 +2,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="Artemis" Language="1033" Version="1.12.0.0" Manufacturer="SpoinkyNL" UpgradeCode="ebc7bc50-0473-4729-8de8-32ddb99bb986">
<Product Id="*" Name="Artemis" Language="1033" Version="1.11.0.0" Manufacturer="SpoinkyNL" UpgradeCode="ebc7bc50-0473-4729-8de8-32ddb99bb986">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
@ -16,11 +16,17 @@
<Property Id="ARPHELPLINK" Value="https://github.com/SpoinkyNL/Artemis/wiki" />
<Property Id="ARPURLINFOABOUT" Value="https://github.com/SpoinkyNL/Artemis" />
<Property Id="ARPNOREPAIR" Value="1" />
<Property Id="INSTALLFOLDER">
<RegistrySearch Id="ArtemisRegistry" Type="raw" Root="HKLM" Key="Software\[Manufacturer]\[ProductName]" Name="InstallDir" />
</Property>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Feature Id="ProductFeature" Title="Artemis" Level="1">
<ComponentGroupRef Id="HeatGenerated" />
<ComponentRef Id="InstallDirRegistry"/>
<ComponentRef Id="ApplicationShortcuts" />
</Feature>
<UI Id='Mondo'>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Artemis" />
@ -42,18 +48,23 @@
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Artemis" />
<!-- Retrieve install dir from registry -->
<Component Id="InstallDirRegistry">
<RegistryValue Root="HKLM" Key="Software\[Manufacturer]\[ProductName]" Name="InstallDir" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuSubfolder" Name="Artemis">
<Component Id="ApplicationShortcuts" Guid="b7465bd9-c8d7-4999-9695-8bbfd9306986">
<Shortcut Id="ApplicationShortcut1" Name="Artemis" Description="Artemis" Target="[INSTALLFOLDER]Artemis.exe" WorkingDirectory="INSTALLFOLDER" />
<RegistryValue Root="HKCU" Key="Software\SpoinkyNL\Artemis" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
<RemoveFolder Id="ProgramMenuSubfolder" On="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
<!-- Optionally run Artemis after intallation -->
<Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]Artemis.exe" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

View File

@ -288,7 +288,7 @@
<Compile Include="DeviceProviders\Corsair\CorsairMouse.cs" />
<Compile Include="DeviceProviders\Corsair\CorsairHeadset.cs" />
<Compile Include="DeviceProviders\Corsair\CorsairMousemat.cs" />
<Compile Include="DeviceProviders\Corsair\Utilities\KeyMap.cs" />
<Compile Include="DeviceProviders\Corsair\Utilities\CorsairUtilities.cs" />
<Compile Include="DeviceProviders\DeviceProvider.cs" />
<Compile Include="DeviceProviders\Logitech\G810.cs" />
<Compile Include="DeviceProviders\Logitech\LogitechGeneric.cs" />
@ -1093,6 +1093,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\CUE.NET.1.2.0\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.2.0\build\net45\CUE.NET.targets'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
attrib +r Artemis.pdb
del *.pdb
attrib -r Artemis.pdb
echo Access denied is intended, see post build event
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Threading;
using Artemis.DeviceProviders.Corsair.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
@ -25,9 +26,13 @@ namespace Artemis.DeviceProviders.Corsair
{
try
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
lock (CorsairUtilities.SDKLock)
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
}
}
catch (Exception)
{

View File

@ -44,8 +44,11 @@ namespace Artemis.DeviceProviders.Corsair
/// </summary>
public override void Enable()
{
if (!CueSDK.IsInitialized)
CueSDK.Initialize(true);
lock (CorsairUtilities.SDKLock)
{
if (!CueSDK.IsInitialized)
CueSDK.Initialize(true);
}
CueSDK.UpdateMode = UpdateMode.Manual;
_keyboard = CueSDK.KeyboardSDK;
@ -127,7 +130,7 @@ namespace Artemis.DeviceProviders.Corsair
try
{
cueLed = _keyboard.Leds.FirstOrDefault(k => k.Id.ToString() == keyCode.ToString()) ??
_keyboard.Leds.FirstOrDefault(k => k.Id == KeyMap.FormsKeys[keyCode]);
_keyboard.Leds.FirstOrDefault(k => k.Id == CorsairUtilities.FormsKeys[keyCode]);
Logger.Trace("Keycode: {0} resolved to CUE LED: {1}", keyCode, cueLed);
}

View File

@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Threading;
using Artemis.DeviceProviders.Corsair.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
@ -25,9 +26,12 @@ namespace Artemis.DeviceProviders.Corsair
{
try
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
lock (CorsairUtilities.SDKLock)
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
}
}
catch (Exception)
{

View File

@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Threading;
using Artemis.DeviceProviders.Corsair.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
@ -25,9 +26,12 @@ namespace Artemis.DeviceProviders.Corsair
{
try
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
lock (CorsairUtilities.SDKLock)
{
CanUse = CanInitializeSdk();
if (CanUse && !CueSDK.IsInitialized)
CueSDK.Initialize(true);
}
}
catch (Exception)
{

View File

@ -1,71 +1,72 @@
using System.Collections.Generic;
using System.Windows.Forms;
using CUE.NET.Devices.Generic.Enums;
namespace Artemis.DeviceProviders.Corsair.Utilities
{
public static class KeyMap
{
static KeyMap()
{
FormsKeys = new Dictionary<Keys, CorsairLedId>
{
{Keys.Scroll, CorsairLedId.ScrollLock},
{Keys.Pause, CorsairLedId.PauseBreak},
{Keys.Back, CorsairLedId.Backspace},
{Keys.Oemtilde, CorsairLedId.GraveAccentAndTilde},
{Keys.OemMinus, CorsairLedId.MinusAndUnderscore},
{Keys.Oemplus, CorsairLedId.EqualsAndPlus},
{Keys.OemOpenBrackets, CorsairLedId.BracketLeft},
{Keys.Oem6, CorsairLedId.BracketRight},
{Keys.Return, CorsairLedId.Enter},
{Keys.Next, CorsairLedId.PageDown},
{Keys.Capital, CorsairLedId.CapsLock},
{Keys.Oem1, CorsairLedId.SemicolonAndColon},
{Keys.Oem7, CorsairLedId.ApostropheAndDoubleQuote},
{Keys.OemBackslash, CorsairLedId.NonUsBackslash},
{Keys.LShiftKey, CorsairLedId.LeftShift},
{Keys.Oem5, CorsairLedId.NonUsTilde},
{Keys.Oemcomma, CorsairLedId.CommaAndLessThan},
{Keys.OemPeriod, CorsairLedId.PeriodAndBiggerThan},
{Keys.OemQuestion, CorsairLedId.SlashAndQuestionMark},
{Keys.RShiftKey, CorsairLedId.RightShift},
{Keys.LControlKey, CorsairLedId.LeftCtrl},
{Keys.LWin, CorsairLedId.LeftGui},
{Keys.LMenu, CorsairLedId.LeftAlt},
{Keys.RMenu, CorsairLedId.RightAlt},
{Keys.RWin, CorsairLedId.RightGui},
{Keys.Apps, CorsairLedId.Application},
{Keys.RControlKey, CorsairLedId.RightCtrl},
{Keys.Left, CorsairLedId.LeftArrow},
{Keys.Down, CorsairLedId.DownArrow},
{Keys.Right, CorsairLedId.RightArrow},
{Keys.Up, CorsairLedId.UpArrow},
{Keys.NumPad0, CorsairLedId.Keypad0},
{Keys.NumPad1, CorsairLedId.Keypad1},
{Keys.NumPad2, CorsairLedId.Keypad2},
{Keys.NumPad3, CorsairLedId.Keypad3},
{Keys.NumPad4, CorsairLedId.Keypad4},
{Keys.NumPad5, CorsairLedId.Keypad5},
{Keys.NumPad6, CorsairLedId.Keypad6},
{Keys.NumPad7, CorsairLedId.Keypad7},
{Keys.NumPad8, CorsairLedId.Keypad8},
{Keys.NumPad9, CorsairLedId.Keypad9},
{Keys.Divide, CorsairLedId.KeypadSlash},
{Keys.Multiply, CorsairLedId.KeypadAsterisk},
{Keys.Subtract, CorsairLedId.KeypadMinus},
{Keys.Add, CorsairLedId.KeypadPlus},
{Keys.Decimal, CorsairLedId.KeypadPeriodAndDelete},
{Keys.MediaStop, CorsairLedId.Stop},
{Keys.MediaPreviousTrack, CorsairLedId.ScanPreviousTrack},
{Keys.MediaNextTrack, CorsairLedId.ScanNextTrack},
{Keys.MediaPlayPause, CorsairLedId.PlayPause},
{Keys.VolumeMute, CorsairLedId.Mute},
{Keys.VolumeUp, CorsairLedId.VolumeUp},
{Keys.VolumeDown, CorsairLedId.VolumeDown}
};
}
public static Dictionary<Keys, CorsairLedId> FormsKeys { get; set; }
}
using System.Collections.Generic;
using System.Windows.Forms;
using CUE.NET.Devices.Generic.Enums;
namespace Artemis.DeviceProviders.Corsair.Utilities
{
public static class CorsairUtilities
{
static CorsairUtilities()
{
FormsKeys = new Dictionary<Keys, CorsairLedId>
{
{Keys.Scroll, CorsairLedId.ScrollLock},
{Keys.Pause, CorsairLedId.PauseBreak},
{Keys.Back, CorsairLedId.Backspace},
{Keys.Oemtilde, CorsairLedId.GraveAccentAndTilde},
{Keys.OemMinus, CorsairLedId.MinusAndUnderscore},
{Keys.Oemplus, CorsairLedId.EqualsAndPlus},
{Keys.OemOpenBrackets, CorsairLedId.BracketLeft},
{Keys.Oem6, CorsairLedId.BracketRight},
{Keys.Return, CorsairLedId.Enter},
{Keys.Next, CorsairLedId.PageDown},
{Keys.Capital, CorsairLedId.CapsLock},
{Keys.Oem1, CorsairLedId.SemicolonAndColon},
{Keys.Oem7, CorsairLedId.ApostropheAndDoubleQuote},
{Keys.OemBackslash, CorsairLedId.NonUsBackslash},
{Keys.LShiftKey, CorsairLedId.LeftShift},
{Keys.Oem5, CorsairLedId.NonUsTilde},
{Keys.Oemcomma, CorsairLedId.CommaAndLessThan},
{Keys.OemPeriod, CorsairLedId.PeriodAndBiggerThan},
{Keys.OemQuestion, CorsairLedId.SlashAndQuestionMark},
{Keys.RShiftKey, CorsairLedId.RightShift},
{Keys.LControlKey, CorsairLedId.LeftCtrl},
{Keys.LWin, CorsairLedId.LeftGui},
{Keys.LMenu, CorsairLedId.LeftAlt},
{Keys.RMenu, CorsairLedId.RightAlt},
{Keys.RWin, CorsairLedId.RightGui},
{Keys.Apps, CorsairLedId.Application},
{Keys.RControlKey, CorsairLedId.RightCtrl},
{Keys.Left, CorsairLedId.LeftArrow},
{Keys.Down, CorsairLedId.DownArrow},
{Keys.Right, CorsairLedId.RightArrow},
{Keys.Up, CorsairLedId.UpArrow},
{Keys.NumPad0, CorsairLedId.Keypad0},
{Keys.NumPad1, CorsairLedId.Keypad1},
{Keys.NumPad2, CorsairLedId.Keypad2},
{Keys.NumPad3, CorsairLedId.Keypad3},
{Keys.NumPad4, CorsairLedId.Keypad4},
{Keys.NumPad5, CorsairLedId.Keypad5},
{Keys.NumPad6, CorsairLedId.Keypad6},
{Keys.NumPad7, CorsairLedId.Keypad7},
{Keys.NumPad8, CorsairLedId.Keypad8},
{Keys.NumPad9, CorsairLedId.Keypad9},
{Keys.Divide, CorsairLedId.KeypadSlash},
{Keys.Multiply, CorsairLedId.KeypadAsterisk},
{Keys.Subtract, CorsairLedId.KeypadMinus},
{Keys.Add, CorsairLedId.KeypadPlus},
{Keys.Decimal, CorsairLedId.KeypadPeriodAndDelete},
{Keys.MediaStop, CorsairLedId.Stop},
{Keys.MediaPreviousTrack, CorsairLedId.ScanPreviousTrack},
{Keys.MediaNextTrack, CorsairLedId.ScanNextTrack},
{Keys.MediaPlayPause, CorsairLedId.PlayPause},
{Keys.VolumeMute, CorsairLedId.Mute},
{Keys.VolumeUp, CorsairLedId.VolumeUp},
{Keys.VolumeDown, CorsairLedId.VolumeDown}
};
}
public static Dictionary<Keys, CorsairLedId> FormsKeys { get; set; }
public static object SDKLock { get; set; } = new object();
}
}

View File

@ -53,6 +53,6 @@ using System.Windows;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.12.0.0")]
[assembly: AssemblyFileVersion("1.12.0.0")]
[assembly: AssemblyVersion("1.11.0.0")]
[assembly: AssemblyFileVersion("1.11.0.0")]
[assembly: InternalsVisibleTo("Artemis.Explorables")]

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
@ -9,10 +10,12 @@ using Artemis.DAL;
using Artemis.Services;
using Artemis.Settings;
using Artemis.Utilities.Memory;
using Caliburn.Micro;
using MahApps.Metro.Controls.Dialogs;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using LogManager = NLog.LogManager;
namespace Artemis.Utilities
{
@ -25,12 +28,8 @@ namespace Artemis.Utilities
/// </summary>
/// <param name="dialogService">The dialog service to use for progress and result dialogs</param>
/// <returns></returns>
public static async void CheckForUpdate(MetroDialogService dialogService)
public static async Task<bool?> CheckForUpdate(MetroDialogService dialogService)
{
var settings = SettingsProvider.Load<GeneralSettings>();
if (!settings.AutoUpdate)
return;
// Check GitHub for a new version
var jsonClient = new WebClient();
@ -39,14 +38,28 @@ namespace Artemis.Utilities
// Random number to get around cache issues
var rand = new Random(DateTime.Now.Millisecond);
var json = await jsonClient.DownloadStringTaskAsync("https://api.github.com/repos/SpoinkyNL/Artemis/releases/latest?random=" + rand.Next());
string json;
try
{
json = await jsonClient.DownloadStringTaskAsync("https://api.github.com/repos/SpoinkyNL/Artemis/releases/latest?random=" + rand.Next());
}
catch (Exception e)
{
Logger.Warn(e, "Update check failed.");
return null;
}
var release = JObject.Parse(json);
var releaseVersion = Version.Parse(release["tag_name"].Value<string>());
var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
// if (releaseVersion > currentVersion)
await ShowChanges(dialogService, release);
if (releaseVersion > currentVersion)
{
await Execute.OnUIThreadAsync(async () => await ShowChanges(dialogService, release));
return true;
}
return false;
}
/// <summary>
@ -69,20 +82,31 @@ namespace Artemis.Utilities
// Show a process dialog
var dialog = await dialogService.ShowProgressDialog("Applying update", "The new update is being downloaded right now...");
dialog.SetIndeterminate();
// Download the release file, it's the one starting with "artemis-setup"
// var releaseFile = release["assets"].Children().FirstOrDefault(c => c["name"].Value<string>().StartsWith("artemis-setup"));
var releaseFile = release["assets"].Children().FirstOrDefault(c => c["name"].Value<string>().StartsWith("Artemis-1.9.0.1-delta"));
var releaseFile = release["assets"].Children().FirstOrDefault(c => c["name"].Value<string>().StartsWith("artemis-setup") &&
c["name"].Value<string>().EndsWith(".exe"));
// If there's no matching release it means whoever published the new version fucked up, can't do much about that
if (releaseFile == null)
{
await dialog.CloseAsync();
dialogService.ShowMessageBox("Applying update failed", "Couldn't find the update file. Please install the latest version manually, sorry!");
return;
}
var downloadClient = new WebClient();
downloadClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
var download = downloadClient.DownloadDataTaskAsync(releaseFile["browser_download_url"].Value<string>());
Task<byte[]> download;
try
{
download = downloadClient.DownloadDataTaskAsync(releaseFile["browser_download_url"].Value<string>());
}
catch (Exception e)
{
dialogService.ShowMessageBox("Applying update failed", "We ran into an issue downloaidng the update: \n\n" + e.Message);
Logger.Warn(e, "Update check failed.");
return;
}
downloadClient.DownloadProgressChanged += (sender, args) =>
{
dialog.SetMessage("The new update is being downloaded right now...\n\n" +
@ -92,21 +116,33 @@ namespace Artemis.Utilities
var setupBytes = await download;
dialog.SetMessage("Installing the new update...");
dialog.SetIndeterminate();
// Ensure the update folder exists
var artemisFolder = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.Length - 1);
var updateFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Artemis\\updates";
var updatePath = updateFolder + "\\" + releaseFile["name"].Value<string>();
if (!Directory.Exists(updateFolder))
Directory.CreateDirectory(updateFolder);
// Store the bytes
File.WriteAllBytes(updateFolder + "\\" + releaseFile["name"].Value<string>(), setupBytes);
File.WriteAllBytes(updatePath, setupBytes);
// Create a bat file that'll take care of the installation (Artemis gets shut down during install) the bat file will
// carry forth our legacy (read that in an heroic tone)
//ECHO OFF
//CLS
//"C:\Repos\Artemis\Artemis\Artemis.Installer\bin\Release\Artemis.msi" / passive
//cd "C:\Program Files\Artemis"
//start Artemis.exe
var updateScript = "ECHO OFF\r\n" +
"CLS\r\n" +
$"\"{updatePath}\" /passive\r\n" +
$"cd \"{artemisFolder}\"\r\n" +
"start Artemis.exe --show";
File.WriteAllText(updateFolder + "\\updateScript.bat", updateScript);
var psi = new ProcessStartInfo
{
FileName = updateFolder + "\\updateScript.bat",
Verb = "runas"
};
var process = new System.Diagnostics.Process {StartInfo = psi};
process.Start();
process.WaitForExit();
}
private static object ConvertBytesToMegabytes(long bytes)
@ -181,4 +217,4 @@ namespace Artemis.Utilities
offsetSettings.Save();
}
}
}
}

View File

@ -8,6 +8,7 @@ using Artemis.Events;
using Artemis.Managers;
using Artemis.Services;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.ActiveWindowDetection;
using Caliburn.Micro;
using MahApps.Metro.Controls;
@ -20,15 +21,17 @@ namespace Artemis.ViewModels.Flyouts
{
private readonly ILogger _logger;
private readonly WindowService _windowService;
private readonly MetroDialogService _metroDialogService;
private string _activeEffectName;
private bool _enableDebug;
private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider;
public FlyoutSettingsViewModel(MainManager mainManager, ILogger logger, WindowService windowService)
public FlyoutSettingsViewModel(MainManager mainManager, ILogger logger, WindowService windowService, MetroDialogService metroDialogService)
{
_logger = logger;
_windowService = windowService;
_metroDialogService = metroDialogService;
MainManager = mainManager;
Header = "Settings";
@ -244,6 +247,21 @@ namespace Artemis.ViewModels.Flyouts
GeneralSettings.Save();
}
public async void CheckForUpdate()
{
var update = await Updater.CheckForUpdate(_metroDialogService);
if (update == null)
{
_metroDialogService.ShowMessageBox("Update check failed",
"Couldn't perform the update check, please check your internet connection and try again." +
"You can also perform a manual update by downloading and installing the latest version from GitHub");
}
else if (!update.Value)
{
_metroDialogService.ShowMessageBox("No update available", "You're running the latest version of Artemis.");
}
}
public void NavigateTo(string url)
{
System.Diagnostics.Process.Start(new ProcessStartInfo(url));

View File

@ -20,15 +20,15 @@ namespace Artemis.ViewModels
{
private readonly IKernel _kernel;
private string _activeIcon;
private bool _checked;
private bool _checkedForDuplicate;
private bool _enabled;
private bool _exiting;
private string _toggleText;
public ShellViewModel(IKernel kernel, MainManager mainManager, MetroDialogService metroDialogService,
FlyoutSettingsViewModel flyoutSettings)
public ShellViewModel(IKernel kernel, MainManager mainManager, MetroDialogService metroDialogService, FlyoutSettingsViewModel flyoutSettings)
{
_kernel = kernel;
var checkedForUpdate = false;
MainManager = mainManager;
MetroDialogService = metroDialogService;
@ -41,7 +41,17 @@ namespace Artemis.ViewModels
flyoutSettings
};
MainManager.EnabledChanged += (sender, args) => Enabled = args.Enabled;
MainManager.EnabledChanged += (sender, args) =>
{
Enabled = args.Enabled;
// Check for updates once if auto update is enabled and the window is shown
if (GeneralSettings.AutoUpdate && !checkedForUpdate && CanHideWindow)
{
checkedForUpdate = true;
Updater.CheckForUpdate(MetroDialogService);
}
};
// This gets updated automatically but during startup lets quickly preset it
Enabled = GeneralSettings.Suspended;
@ -106,7 +116,7 @@ namespace Artemis.ViewModels
// TODO: This is probably an awful idea. I can't reliably hook into the view being ready to be hidden
Thread.Sleep(500);
if (GeneralSettings.ShowOnStartup)
if (GeneralSettings.ShowOnStartup || Environment.GetCommandLineArgs().Contains("--show"))
ShowWindow();
else
HideWindow();
@ -129,20 +139,17 @@ namespace Artemis.ViewModels
public void ShowWindow()
{
if (CanShowWindow)
{
Window?.Dispatcher.Invoke(() =>
{
Window.Show();
Window.Activate();
});
}
GeneralSettings.ApplyTheme();
// Show certain dialogs if needed
CheckKeyboardState();
CheckDuplicateInstances();
Updater.CheckForUpdate(MetroDialogService);
// Run this on the UI thread to avoid having to use dispatchers in VMs
Execute.OnUIThread(ActivateViews);
@ -237,12 +244,11 @@ namespace Artemis.ViewModels
private void CheckDuplicateInstances()
{
if (_checked)
if (_checkedForDuplicate)
return;
_checked = true;
_checkedForDuplicate = true;
bool aIsNewInstance;
Mutex = new Mutex(true, "ArtemisMutex", out aIsNewInstance);
Mutex = new Mutex(true, "ArtemisMutex", out var aIsNewInstance);
if (aIsNewInstance)
return;
@ -252,4 +258,4 @@ namespace Artemis.ViewModels
"If so, please make sure Artemis isn't already running");
}
}
}
}

View File

@ -26,6 +26,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@ -95,7 +96,7 @@
<controls:NumericUpDown Grid.Row="8" Grid.Column="1" Margin="10" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="140" Minimum="1" Maximum="60"
Value="{Binding Path=GeneralSettings.ScreenCaptureFPS, Mode=TwoWay}" />
<Label Grid.Row="9" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Active window detection" />
<ComboBox Grid.Row="9" Grid.Column="1" x:Name="ActiveWindowDetections" Margin="10" VerticalAlignment="Center"
@ -122,9 +123,12 @@
<Button Grid.Row="12" Grid.Column="1" Margin="11" x:Name="SaveSettings" Content="Save changes"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="100"
Style="{DynamicResource SquareButtonStyle}" />
<Button Grid.Row="13" Grid.Column="0" Margin="10" x:Name="CheckForUpdate" Content="Check for update"
VerticalAlignment="Center" HorizontalAlignment="Left" Width="100"
Style="{DynamicResource SquareButtonStyle}" />
<!-- Version -->
<Grid Grid.Row="13" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom">
<Grid Grid.Row="14" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />