diff --git a/Project-Aurora/Project-Aurora/Project-Aurora.csproj b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
index 4347bdd01..378f87c50 100644
--- a/Project-Aurora/Project-Aurora/Project-Aurora.csproj
+++ b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
@@ -1492,6 +1492,7 @@
+
diff --git a/Project-Aurora/Project-Aurora/RazerSdkWrapper.dll b/Project-Aurora/Project-Aurora/RazerSdkWrapper.dll
index dab19dde7..705447307 100644
Binary files a/Project-Aurora/Project-Aurora/RazerSdkWrapper.dll and b/Project-Aurora/Project-Aurora/RazerSdkWrapper.dll differ
diff --git a/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml b/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml
index 57d801e47..7efdcd715 100755
--- a/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml
+++ b/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml
@@ -276,13 +276,14 @@
-
+
-
-
-
+
+
+
+
diff --git a/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml.cs
index c42c1f5e7..bbbd81a42 100755
--- a/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml.cs
@@ -18,6 +18,7 @@
using System.Net;
using RazerSdkWrapper.Data;
using System.Windows.Threading;
+using Aurora.Utils;
namespace Aurora.Settings
{
@@ -136,7 +137,8 @@ public Control_Settings()
var rzSdkEnabled = RzHelper.IsSdkEnabled();
this.razer_wrapper_installed_version_label.Content = rzVersion.ToString();
- if (!RzHelper.IsSdkVersionSupported(rzVersion))
+ this.razer_wrapper_supported_versions_label.Content = $"{RzHelper.MinimumSupportedVersion}-{RzHelper.MaximumSupportedVersion}";
+ if (rzVersion < RzHelper.MaximumSupportedVersion)
{
this.razer_wrapper_installed_version_label.Foreground = new SolidColorBrush(Colors.PaleVioletRed);
this.razer_wrapper_install_button.Visibility = Visibility.Visible;
@@ -147,6 +149,9 @@ public Control_Settings()
this.razer_wrapper_install_button.Visibility = Visibility.Hidden;
}
+ if (rzVersion == new RzSdkVersion())
+ this.razer_wrapper_uninstall_button.Visibility = Visibility.Hidden;
+
this.razer_wrapper_enabled_label.Content = rzSdkEnabled ? "Enabled" : "Disabled";
this.razer_wrapper_enabled_label.Foreground = rzSdkEnabled ? new SolidColorBrush(Colors.LightGreen) : new SolidColorBrush(Colors.PaleVioletRed);
@@ -158,7 +163,7 @@ public Control_Settings()
{
var appList = Global.razerManager.GetDataProvider();
appList.Update();
- this.razer_wrapper_current_application_label.Content = $"{appList.CurrentAppExecutable} [{appList.CurrentAppPid}]";
+ this.razer_wrapper_current_application_label.Content = $"{appList.CurrentAppExecutable ?? "None"} [{appList.CurrentAppPid}]";
}
Global.razerManager.DataUpdated += (s, _) =>
@@ -746,150 +751,122 @@ private void start_silently_enabled_Checked(object sender, RoutedEventArgs e)
private void razer_wrapper_install_button_Click(object sender, RoutedEventArgs e)
{
- razer_wrapper_install_button.IsEnabled = false;
-
- #region Razer SDK Installer/Uninstaller helpers
- Task UninstallAsync()
+ void HandleExceptions(AggregateException ae)
{
- return System.Threading.Tasks.Task.Run(() =>
- {
- if (RzHelper.IsSdkVersionSupported(RzHelper.GetSdkVersion()))
- return 0;
+ ShowMessageBox(ae.ToString(), "Exception!", MessageBoxImage.Error);
+ ae.Handle(ex => {
+ Global.logger.Error(ex.ToString());
+ return true;
+ });
+ }
- using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
- {
- var key = hklm.OpenSubKey(@"Software\Razer Chroma SDK");
- var path = (string)key?.GetValue("UninstallPath", null);
- var filename = (string)key?.GetValue("UninstallFilename", null);
+ void SetButtonContent(string s)
+ => Application.Current.Dispatcher.Invoke(() => razer_wrapper_install_button.Content = s);
- if (path == null || filename == null)
- return 0;
+ void ShowMessageBox(string message, string title, MessageBoxImage image = MessageBoxImage.Exclamation)
+ => Application.Current.Dispatcher.Invoke(() => System.Windows.MessageBox.Show(message, title, MessageBoxButton.OK, image));
- try
- {
- var processInfo = new ProcessStartInfo
- {
- FileName = filename,
- WorkingDirectory = path,
- Arguments = $"/S _?={path}",
- ErrorDialog = true
- };
-
- var process = Process.Start(processInfo);
- process.WaitForExit(120000);
- return process.ExitCode;
- }
- catch (Exception ex)
- {
- throw new OperationCanceledException("Razer SDK Uninstallation failed!", ex);
- }
- }
- });
- }
+ razer_wrapper_install_button.IsEnabled = false;
+ razer_wrapper_uninstall_button.IsEnabled = false;
- Task DownloadAsync()
+ System.Threading.Tasks.Task.Run(async () =>
{
- return System.Threading.Tasks.Task.Run(() =>
+ SetButtonContent("Uninstalling");
+ var uninstallSuccess = await RazerChromaUtils.UninstallAsync()
+ .ContinueWith(t =>
{
- var url = "http://cdn.razersynapse.com/156092369797u1UA8NRazerChromaBroadcasterSetup_v3.4.0630.061913.exe";
-
- try
+ if (t.Exception != null)
{
- using (var client = new WebClient())
- {
- var path = Path.ChangeExtension(Path.GetTempFileName(), ".exe");
- client.DownloadFile(url, path);
- return path;
- }
+ HandleExceptions(t.Exception);
+ return false;
}
- catch (Exception ex)
+ else if (t.Result == (int)RazerChromaInstallerExitCode.RestartRequired)
{
- throw new OperationCanceledException("Razer SDK Downloading failed!", ex);
+ ShowMessageBox("The uninstaller requested system restart!\nPlease reboot your pc and re-run the installation.", "Restart required!");
+ return false;
}
- });
- }
- Task InstallAsync(string installerPath)
- {
- return System.Threading.Tasks.Task.Run(() =>
+ return true;
+ })
+ .ConfigureAwait(false);
+
+ if (!uninstallSuccess)
+ return;
+
+ SetButtonContent("Downloading");
+ var downloadPath = await RazerChromaUtils.DownloadAsync()
+ .ContinueWith(t =>
{
- try
- {
- var processInfo = new ProcessStartInfo
- {
- FileName = Path.GetFileName(installerPath),
- WorkingDirectory = Path.GetDirectoryName(installerPath),
- Arguments = "/S",
- ErrorDialog = true
- };
-
- var process = Process.Start(processInfo);
- process.WaitForExit(120000);
- return process.ExitCode;
- }
- catch (Exception ex)
+ if (t.Exception != null)
{
- throw new OperationCanceledException("Razer SDK Installation failed!", ex);
+ HandleExceptions(t.Exception);
+ return null;
}
- });
- }
- #endregion
- bool HandleErrorLevel(int errorlevel)
- {
- switch (errorlevel)
- {
- case 3010:
- {
- Application.Current.Dispatcher.Invoke(() => Xceed.Wpf.Toolkit.MessageBox.Show("Razer SDK requested system restart!\nPlease reboot your pc and re-run the installation.",
- "Restart required!", MessageBoxButton.OK, MessageBoxImage.Exclamation));
- return false;
- }
- }
+ return t.Result;
+ })
+ .ConfigureAwait(false);
- return true;
- }
+ if (downloadPath == null)
+ return;
- void SetState(string name)
- => Application.Current.Dispatcher.Invoke(() => razer_wrapper_install_button.Content = name);
+ SetButtonContent("Installing");
+ await RazerChromaUtils.InstallAsync(downloadPath)
+ .ContinueWith(t =>
+ {
+ if (t.Exception != null)
+ HandleExceptions(t.Exception);
+ else if (t.Result == (int)RazerChromaInstallerExitCode.RestartRequired)
+ ShowMessageBox("The installer requested system restart!\nPlease reboot your pc.", "Restart required!");
+ else
+ {
+ SetButtonContent("Done!");
+ ShowMessageBox("Installation successful!\nPlease restart aurora for changes to take effect.", "Restart required!");
+ }
+ })
+ .ConfigureAwait(false);
+ });
+ }
- System.Threading.Tasks.Task.Run(async () =>
+ private void razer_wrapper_uninstall_button_Click(object sender, RoutedEventArgs e)
+ {
+ void HandleExceptions(AggregateException ae)
{
- try
- {
- SetState("Uninstalling");
- var errorlevel = await UninstallAsync();
- if (!HandleErrorLevel(errorlevel))
- return false;
+ ShowMessageBox(ae.ToString(), "Exception!", MessageBoxImage.Error);
+ ae.Handle(ex => {
+ Global.logger.Error(ex.ToString());
+ return true;
+ });
+ }
- SetState("Downloading");
- var path = await DownloadAsync();
+ void SetButtonContent(string s)
+ => Application.Current.Dispatcher.Invoke(() => razer_wrapper_uninstall_button.Content = s);
+
+ void ShowMessageBox(string message, string title, MessageBoxImage image = MessageBoxImage.Exclamation)
+ => Application.Current.Dispatcher.Invoke(() => System.Windows.MessageBox.Show(message, title, MessageBoxButton.OK, image));
- SetState("Installing");
- errorlevel = await InstallAsync(path);
- if (!HandleErrorLevel(errorlevel))
- return false;
- }
- catch (OperationCanceledException ex)
- {
- Application.Current.Dispatcher.Invoke(() => Xceed.Wpf.Toolkit.MessageBox.Show($"{ex.Message}:\n{ex.InnerException.ToString()}",
- "Exception!", MessageBoxButton.OK, MessageBoxImage.Error));
- return false;
- }
+ razer_wrapper_install_button.IsEnabled = false;
+ razer_wrapper_uninstall_button.IsEnabled = false;
- return true;
- }).ContinueWith(t =>
+ System.Threading.Tasks.Task.Run(async () =>
{
- if (t.Result)
- {
- SetState("Success!");
- Application.Current.Dispatcher.Invoke(() => Xceed.Wpf.Toolkit.MessageBox.Show("Installation successful!\nPlease restart Aurora for changes to take effect.",
- "Success!", MessageBoxButton.OK, MessageBoxImage.Information));
- }
- else
+ SetButtonContent("Uninstalling");
+ await RazerChromaUtils.UninstallAsync()
+ .ContinueWith(t =>
{
- SetState("Failure!");
- }
+ if (t.Exception != null)
+ HandleExceptions(t.Exception);
+ else if (t.Result == (int)RazerChromaInstallerExitCode.RestartRequired)
+ ShowMessageBox("The uninstaller requested system restart!\nPlease reboot your pc.", "Restart required!");
+ else if (t.Result == (int)RazerChromaInstallerExitCode.InvalidState)
+ ShowMessageBox("There is nothing to install!", "Invalid State!");
+ else
+ {
+ SetButtonContent("Done!");
+ ShowMessageBox("Uninstallation successful!\nPlease restart aurora for changes to take effect.", "Restart required!");
+ }
+ })
+ .ConfigureAwait(false);
});
}
diff --git a/Project-Aurora/Project-Aurora/Utils/RazerChromaUtils.cs b/Project-Aurora/Project-Aurora/Utils/RazerChromaUtils.cs
new file mode 100644
index 000000000..e6b75eaca
--- /dev/null
+++ b/Project-Aurora/Project-Aurora/Utils/RazerChromaUtils.cs
@@ -0,0 +1,107 @@
+using Microsoft.Win32;
+using RazerSdkWrapper.Utils;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aurora.Utils
+{
+ public enum RazerChromaInstallerExitCode
+ {
+ Success = 0,
+ InvalidState = 1,
+ RestartRequired = 3010
+ }
+
+ public static class RazerChromaUtils
+ {
+ public static Task UninstallAsync() => Task.Run(() =>
+ {
+ if (RzHelper.GetSdkVersion() == new RzSdkVersion())
+ return (int)RazerChromaInstallerExitCode.InvalidState;
+
+ int DoUninstall(string filepath)
+ {
+ var filename = Path.GetFileName(filepath);
+ var path = Path.GetDirectoryName(filepath);
+ var processInfo = new ProcessStartInfo
+ {
+ FileName = filename,
+ WorkingDirectory = path,
+ Arguments = $"/S _?={path}",
+ ErrorDialog = true
+ };
+
+ var process = Process.Start(processInfo);
+ process.WaitForExit(120000);
+ return process.ExitCode;
+ }
+
+ using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
+ {
+ var key = hklm.OpenSubKey(@"Software\Razer\Synapse3\PID0302MW");
+ if (key != null)
+ {
+ var filepath = (string)key.GetValue("UninstallPath", null);
+
+ var exitcode = DoUninstall(filepath);
+ if (exitcode == (int)RazerChromaInstallerExitCode.RestartRequired)
+ return exitcode;
+ }
+
+ key = hklm.OpenSubKey(@"Software\Razer\Synapse3\RazerChromaBroadcaster");
+ if (key != null)
+ {
+ var filepath = (string)key.GetValue("UninstallerPath", null);
+
+ var exitcode = DoUninstall(filepath);
+ if (exitcode == (int)RazerChromaInstallerExitCode.RestartRequired)
+ return exitcode;
+ }
+
+ key = hklm.OpenSubKey(@"Software\Razer Chroma SDK");
+ if (key != null)
+ {
+ var path = (string)key.GetValue("UninstallPath", null);
+ var filename = (string)key.GetValue("UninstallFilename", null);
+
+ var exitcode = DoUninstall($@"{path}\{filename}");
+ if (exitcode == (int)RazerChromaInstallerExitCode.RestartRequired)
+ return exitcode;
+ }
+
+ return (int)RazerChromaInstallerExitCode.Success;
+ }
+ });
+
+ public static Task DownloadAsync() => Task.Run(() =>
+ {
+ using (var client = new WebClient())
+ {
+ var path = Path.ChangeExtension(Path.GetTempFileName(), ".exe");
+ client.DownloadFile(RzHelper.LatestSupportedVersionUrl, path);
+ return path;
+ }
+ });
+
+ public static Task InstallAsync(string installerPath) => Task.Run(() =>
+ {
+ var processInfo = new ProcessStartInfo
+ {
+ FileName = Path.GetFileName(installerPath),
+ WorkingDirectory = Path.GetDirectoryName(installerPath),
+ Arguments = "/S",
+ ErrorDialog = true
+ };
+
+ var process = Process.Start(processInfo);
+ process.WaitForExit(120000);
+ return process.ExitCode;
+ });
+ }
+}