diff --git a/EZPPClient Installer/EZPPClient Installer.csproj b/EZPPClient Installer/EZPPClient Installer.csproj index 7146ed0..0042c6f 100644 --- a/EZPPClient Installer/EZPPClient Installer.csproj +++ b/EZPPClient Installer/EZPPClient Installer.csproj @@ -94,6 +94,7 @@ + diff --git a/EZPPClient Installer/MainWindow.xaml.cs b/EZPPClient Installer/MainWindow.xaml.cs index ebbfc6c..15fdec6 100644 --- a/EZPPClient Installer/MainWindow.xaml.cs +++ b/EZPPClient Installer/MainWindow.xaml.cs @@ -15,6 +15,10 @@ using System.Media; using System.Runtime.InteropServices.ComTypes; using Shortcut; using Path = System.Windows.Shapes.Path; +using EZPPClient_Installer.Utils; +using Microsoft.Win32; +using System.Windows.Controls; +using System.Threading; #if DEBUG using MessageBox = System.Windows.MessageBox; @@ -114,9 +118,15 @@ namespace EZPPClient_Installer List releases = await ReleaseStreamUtil.GetAvailableReleaseStreams(); foreach(string release in releases) { - ReleaseStreamComboBox.Items.Add(release.UppercaseFirst()); + ReleaseStreamComboBox.Items.Add(release.UppercaseFirst().Trim()); } - ReleaseStreamComboBox.SelectedIndex = 0; + + string systemRelease = RegistryUtil.GetUsedReleaseStream("Stable"); + + bool containsRelease = releases.Contains(systemRelease); + + ReleaseStreamComboBox.SelectedValue = systemRelease; + } private async Task CheckForInstallerUpdates() @@ -127,7 +137,7 @@ namespace EZPPClient_Installer using (WebClient client = new WebClient()) { client.Headers.Add("user-agent", "EZPPClientInstaller"); - string newVersionString = client.DownloadString("https://new.ez-pp.farm/ezppclient?version"); + string newVersionString = await client.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?version"); double ver = 0; try { @@ -202,6 +212,10 @@ namespace EZPPClient_Installer return; } + var type = InstallButton.Content; + + RegistryUtil.SetUsedReleaseStream(RELEASESTREAM); + if (!Directory.Exists(osuFolder + "\\EZPPClient")) { Directory.CreateDirectory(osuFolder + "\\EZPPClient"); @@ -403,7 +417,7 @@ namespace EZPPClient_Installer await DownloadUtil.DownloadFiles(filesToDownload, EZPPFolder); - if (InstallButton.Content.Equals("Install")) + if (type.Equals("Install")) { IShellLink link = (IShellLink)new ShellLink(); @@ -440,7 +454,7 @@ namespace EZPPClient_Installer linkFoldersCheckbox.IsEnabled = false; string updateText = "It seems like the installation was faulty, please hit Update to repair the EZPPClient."; - switch (InstallButton.Content) + switch (type) { case "Update": updateText = "It seems like the update was faulty, please hit Update to repair the EZPPClient."; @@ -463,7 +477,7 @@ namespace EZPPClient_Installer { string updateText = "The EZPPClient was successfully installed!"; - switch (InstallButton.Content) + switch (type) { case "Update": updateText = "The EZPPClient was successfully updated!"; diff --git a/EZPPClient Installer/Utils/RegistryUtil.cs b/EZPPClient Installer/Utils/RegistryUtil.cs new file mode 100644 index 0000000..9605c13 --- /dev/null +++ b/EZPPClient Installer/Utils/RegistryUtil.cs @@ -0,0 +1,41 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EZPPClient_Installer.Utils +{ + class RegistryUtil + { + + public static void SetUsedReleaseStream(string release) + { + RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\EZPPClientInstaller"); + key.SetValue("ReleaseStream", release); + key.Close(); + } + + public static String GetUsedReleaseStream(string defaultRelease) + { + string release = defaultRelease; + RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\EZPPClientInstaller"); + + //if it does exist, retrieve the stored values + if (key != null) + { + release = (string) key.GetValue("ReleaseStream"); + key.Close(); + } + + return release; + } + + public static void DeleteUsedReleaseStream() + { + Registry.CurrentUser.DeleteSubKey(@"SOFTWARE\EZPPClientInstaller"); + } + + } +}