9 Commits

12 changed files with 270 additions and 112 deletions

View File

@@ -90,13 +90,14 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MD5File.cs" />
<Compile Include="DownloadUtil.cs" />
<Compile Include="MD5Util.cs" />
<Compile Include="ProcessUtil.cs" />
<Compile Include="Shortcut.cs" />
<Compile Include="UpdateState.cs" />
<Compile Include="Util.cs" />
<Compile Include="Objects\MD5File.cs" />
<Compile Include="Utils\DownloadUtil.cs" />
<Compile Include="Utils\MD5Util.cs" />
<Compile Include="Utils\ProcessUtil.cs" />
<Compile Include="Utils\RegistryUtil.cs" />
<Compile Include="Utils\ReleaseStreamUtil.cs" />
<Compile Include="Objects\UpdateState.cs" />
<Compile Include="Utils\OsuUtil.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
@@ -136,8 +137,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="DK.WshRuntime">
<Version>4.1.3.201115164</Version>
<PackageReference Include="DK.Standard">
<Version>4.137.4070.201115155</Version>
</PackageReference>
<PackageReference Include="ModernWpfUI">
<Version>0.9.4</Version>
@@ -149,5 +150,16 @@
<ItemGroup>
<Content Include=".gitignore" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -5,17 +5,20 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EZPPClient_Installer"
mc:Ignorable="d"
Title="EZPPClient Installer" Height="232.051" Width="525.487"
Title="EZPPClient Installer" Height="293.333" Width="525"
xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True" ResizeMode="CanMinimize" Icon="circle_new.ico" Topmost="True" WindowStartupLocation="CenterScreen">
<ui:SimpleStackPanel Margin="12" Spacing="24">
<CheckBox x:Name="linkFoldersCheckbox" Content="Link Song and Skins Folder" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="150,62,150,-62" IsChecked="True" />
<TextBox x:Name="folderTextbox" HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="422" Margin="10,-34,0,0" IsReadOnly="true"/>
<Button x:Name="InstallButton" Content="Install" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Bottom" Margin="176,0,176,-58" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
<Button x:Name="BrowseButton" Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-82,10,0" Click="Browse_Click"/>
<Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,0,176,-47" Click="Uninstall_Button_Click" Background="#CCCB3737" Foreground="White" Visibility="Hidden"/>
<ProgressBar x:Name="Download_Progressbar" Height="1" VerticalAlignment="Top" Margin="15,-34,15,0" IsIndeterminate="True" Visibility="Hidden"/>
<Label x:Name="Download_Text" Content="Downloading: " Height="19" VerticalAlignment="Top" Margin="10,-82,10,0" Visibility="Hidden"/>
<TextBlock Margin="349,-47,0,24"><Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink></TextBlock>
<CheckBox x:Name="linkFoldersCheckbox" Content="Link Song and Skins Folder" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="150,125,150,-125" IsChecked="True" />
<TextBox x:Name="folderTextbox" HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="422" Margin="10,-27,0,-5" IsReadOnly="true"/>
<Button x:Name="InstallButton" Content="Install" HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Bottom" Margin="176,0,176,-114" Style="{StaticResource AccentButtonStyle}" Click="Install_Click"/>
<Button x:Name="BrowseButton" Content="..." HorizontalAlignment="Stretch" Height="32" VerticalAlignment="Top" Margin="437,-75,10,0" Click="Browse_Click"/>
<Button x:Name="Uninstall_Button" Content="Uninstall" HorizontalAlignment="Stretch" Height="31" VerticalAlignment="Bottom" Margin="176,0,176,-100" Click="Uninstall_Button_Click" Foreground="White" Visibility="Hidden" IsCancel="True"/>
<ProgressBar x:Name="Download_Progressbar" Height="1" VerticalAlignment="Top" Margin="15,22,15,-26" IsIndeterminate="True" Visibility="Hidden"/>
<Label x:Name="Download_Text" Content="Downloading: " Height="19" VerticalAlignment="Top" Margin="10,-26,10,0" Visibility="Hidden"/>
<TextBlock Margin="349,14,0,-37"><Hyperlink NavigateUri="https://ez-pp.farm" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Copyright @ EZPPFarm"/></Hyperlink></TextBlock>
<ComboBox x:Name="ReleaseStreamComboBox" HorizontalAlignment="Left" Height="31" VerticalAlignment="Top" Width="475" Margin="10,-137,0,0" ClipToBounds="True" SelectionChanged="ReleaseStreamComboBox_SelectionChanged"/>
<Label x:Name="ReleaseStreamLabel" Content="Release:" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="145" Margin="10,-181,0,0"/>
<Label Content="Path to osu! Folder:" HorizontalAlignment="Left" Height="19" VerticalAlignment="Top" Width="145" Margin="10,-263,0,0"/>
</ui:SimpleStackPanel>
</Window>

View File

@@ -13,8 +13,13 @@ using ModernWpf.Controls;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices.ComTypes;
using Shortcut;
using Path = System.Windows.Shapes.Path;
using File = System.IO.File;
using EZPPClient_Installer.Utils;
using Microsoft.Win32;
using System.Windows.Controls;
using System.Threading;
using IWshRuntimeLibrary;
#if DEBUG
using MessageBox = System.Windows.MessageBox;
@@ -35,6 +40,8 @@ namespace EZPPClient_Installer
private static double VERSION = 1.6;
public static string RELEASESTREAM;
public MainWindow()
{
Instance = this;
@@ -62,7 +69,9 @@ namespace EZPPClient_Installer
string versionString = "v" + VERSION;
InstallerWindow.Title = "EZPPClient Installer " + versionString.Replace(",", ".");
string osuPath = Util.osuInstallDir();
await FetchReleaseStreams();
string osuPath = OsuUtil.osuInstallDir();
if (osuPath.EndsWith(@"\EZPPClient"))
{
@@ -83,7 +92,7 @@ namespace EZPPClient_Installer
UpdateInstallButton(false);
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false);
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
if (!IsEmpty(outdatedFiles))
{
@@ -105,6 +114,22 @@ namespace EZPPClient_Installer
}
private async Task FetchReleaseStreams()
{
List<string> releases = await ReleaseStreamUtil.GetAvailableReleaseStreams();
foreach(string release in releases)
{
ReleaseStreamComboBox.Items.Add(release.UppercaseFirst().Trim());
}
string systemRelease = RegistryUtil.GetUsedReleaseStream("Stable");
bool containsRelease = releases.Contains(systemRelease);
ReleaseStreamComboBox.SelectedValue = systemRelease;
}
private async Task<UpdateState> CheckForInstallerUpdates()
{
#if !DEBUG
@@ -113,7 +138,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
{
@@ -188,6 +213,10 @@ namespace EZPPClient_Installer
return;
}
var type = InstallButton.Content;
RegistryUtil.SetUsedReleaseStream(RELEASESTREAM);
if (!Directory.Exists(osuFolder + "\\EZPPClient"))
{
Directory.CreateDirectory(osuFolder + "\\EZPPClient");
@@ -264,7 +293,6 @@ namespace EZPPClient_Installer
{
try
{
//File.Copy(string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName), string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName));
if (!CreateSymbolicLink(string.Format(@"{0}\osu!.{1}.cfg", EZPPFolder, userName), string.Format(@"{0}\osu!.{1}.cfg", osuFolder, userName), SymbolicLink.File))
{
ContentDialog dg = new ContentDialog()
@@ -291,7 +319,6 @@ namespace EZPPClient_Installer
{
try
{
//File.Copy(string.Format(@"{0}\scores.db", osuFolder), string.Format(@"{0}\scores.db", EZPPFolder));
if (!CreateSymbolicLink(string.Format(@"{0}\scores.db", EZPPFolder), string.Format(@"{0}\scores.db", osuFolder), SymbolicLink.File))
{
ContentDialog dg = new ContentDialog()
@@ -318,7 +345,6 @@ namespace EZPPClient_Installer
{
try
{
//File.Copy(string.Format(@"{0}\collection.db", osuFolder), string.Format(@"{0}\collection.db", EZPPFolder));
if (!CreateSymbolicLink(string.Format(@"{0}\collection.db", EZPPFolder), string.Format(@"{0}\collection.db", osuFolder), SymbolicLink.File))
{
ContentDialog dg = new ContentDialog()
@@ -345,7 +371,6 @@ namespace EZPPClient_Installer
{
try
{
//File.Copy(string.Format(@"{0}\osu.db", osuFolder), string.Format(@"{0}\osu.db", EZPPFolder));
if (!CreateSymbolicLink(string.Format(@"{0}\osu!.db", EZPPFolder), string.Format(@"{0}\osu!.db", osuFolder), SymbolicLink.File))
{
ContentDialog dg = new ContentDialog()
@@ -372,7 +397,7 @@ namespace EZPPClient_Installer
List<string> filesToDownload = DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall"));
List<string> filesToDownload = await DownloadUtil.FilesToDownload(EZPPFolder, InstallButton.Content.Equals("Reinstall"));
Visibility prevInstallBtnVis = InstallButton.Visibility;
Visibility prevUninstallBtnVis = Uninstall_Button.Visibility;
@@ -382,32 +407,46 @@ namespace EZPPClient_Installer
InstallButton.Visibility = Visibility.Hidden;
Uninstall_Button.Visibility = Visibility.Hidden;
linkFoldersCheckbox.Visibility = Visibility.Hidden;
ReleaseStreamComboBox.IsEnabled = false;
Download_Text.Visibility = Visibility.Visible;
Download_Progressbar.Visibility = Visibility.Visible;
await DownloadUtil.DownloadFiles(filesToDownload, EZPPFolder);
if (InstallButton.Content.Equals("Install"))
if (type.Equals("Install"))
{
IShellLink link = (IShellLink)new ShellLink();
// setup shortcut information
link.SetDescription("Starts the EZPPClient");
link.SetPath(EZPPFolder + @"\EZPPClient.exe");
// save it
IPersistFile file = (IPersistFile)link;
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string LinkFile = System.IO.Path.Combine(desktopPath, "Start EZPPClient.lnk");
Console.Out.WriteLine("Saving Shortcut to " + LinkFile);
file.Save(LinkFile, false);
string desktopLinkFile = System.IO.Path.Combine(desktopPath, "Start EZPPClient.lnk");
string startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string startMenuPathPrograms = System.IO.Path.Combine(startMenuPath, "Programs");
string startMenuLinkFile = System.IO.Path.Combine(startMenuPathPrograms, "Start EZPPClient.lnk");
if (!File.Exists(desktopLinkFile))
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(desktopLinkFile);
shortcut.Description = $"Starts the EZPPClient";
shortcut.TargetPath = System.IO.Path.Combine(EZPPFolder, "EZPPClient.exe");
shortcut.Save();
}
if (!File.Exists(startMenuLinkFile))
{
WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(startMenuLinkFile);
shortcut.Description = $"Starts the EZPPClient";
shortcut.TargetPath = System.IO.Path.Combine(EZPPFolder, "EZPPClient.exe");
shortcut.Save();
}
}
InstallButton.Visibility = prevInstallBtnVis;
Uninstall_Button.Visibility = prevUninstallBtnVis;
linkFoldersCheckbox.Visibility = prevLinkFCVis;
BrowseButton.IsEnabled = true;
ReleaseStreamComboBox.IsEnabled = true;
Download_Text.Visibility = Visibility.Hidden;
Download_Progressbar.Visibility = Visibility.Hidden;
@@ -415,7 +454,7 @@ namespace EZPPClient_Installer
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
List<string> outdatedFiles = DownloadUtil.FilesToDownload(EZPPFolder, false);
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(EZPPFolder, false);
if (!IsEmpty(outdatedFiles))
{
@@ -424,7 +463,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.";
@@ -447,7 +486,7 @@ namespace EZPPClient_Installer
{
string updateText = "The EZPPClient was successfully installed!";
switch (InstallButton.Content)
switch (type)
{
case "Update":
updateText = "The EZPPClient was successfully updated!";
@@ -509,7 +548,7 @@ namespace EZPPClient_Installer
UpdateInstallButton(false);
string osuEZPPPath = folderTextbox.Text + @"\EZPPClient";
List<string> outdatedFiles = DownloadUtil.FilesToDownload(osuEZPPPath, false);
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
if (!IsEmpty(outdatedFiles))
{
@@ -557,11 +596,18 @@ namespace EZPPClient_Installer
if (Directory.Exists(osuEZPPPath))
Directory.Delete(osuEZPPPath, true);
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string linkFile = System.IO.Path.Combine(desktopPath, "Start EZPPClient.lnk");
if (File.Exists(linkFile))
File.Delete(linkFile);
string startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string startMenuPathPrograms = System.IO.Path.Combine(startMenuPath, "Programs");
string startMenuLinkFile = System.IO.Path.Combine(startMenuPathPrograms, "Start EZPPClient.lnk");
if (File.Exists(startMenuLinkFile))
File.Delete(startMenuLinkFile);
_ = new ContentDialog()
{
Title = "Success!",
@@ -634,5 +680,63 @@ namespace EZPPClient_Installer
Instance.Download_Progressbar.Value = progress;
Instance.Download_Text.Content = "Downloading: " + file;
}
private async void ReleaseStreamComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
bool init = string.IsNullOrEmpty(RELEASESTREAM);
RELEASESTREAM = (string)ReleaseStreamComboBox.SelectedValue;
if (init)
return;
ReleaseStreamComboBox.IsEnabled = false;
BrowseButton.IsEnabled = false;
InstallButton.IsEnabled = false;
Uninstall_Button.IsEnabled = false;
string osuPath = folderTextbox.Text;
bool isValidFolder = await isValidOsuFolder(osuPath);
UpdateInstallButton(!string.IsNullOrEmpty(osuPath));
if (!string.IsNullOrEmpty(osuPath) && isValidFolder)
{
bool foundInstall = isEZPPClientInstallationFound(osuPath);
if (foundInstall)
{
string osuEZPPPath = osuPath + @"\EZPPClient";
Uninstall_Button.Visibility = Visibility.Visible;
UpdateInstallButton(false);
List<string> outdatedFiles = await DownloadUtil.FilesToDownload(osuEZPPPath, false);
if (!IsEmpty(outdatedFiles))
{
UpdateInstallButton(true);
InstallButton.Content = "Update";
linkFoldersCheckbox.IsEnabled = false;
}
}
folderTextbox.Text = osuPath;
}
_ = new ContentDialog()
{
Title = "Success!",
Content = "ReleaseStream changed to " + RELEASESTREAM,
PrimaryButtonText = "Okay"
}.ShowAsync();
ReleaseStreamComboBox.IsEnabled = true;
BrowseButton.IsEnabled = true;
InstallButton.IsEnabled = true;
Uninstall_Button.IsEnabled = true;
}
}
}

View File

@@ -10,24 +10,14 @@ namespace EZPPClient_Installer
class MD5File
{
private string md5;
private string name;
public string MD5 { get; set; }
public string Name { get; set; }
public MD5File(string name, string md5)
{
this.md5 = md5;
this.name = name;
this.MD5 = md5;
this.Name = name;
}
public string getName()
{
return name;
}
public string getMD5()
{
return md5;
}
}
}

View File

@@ -1,39 +0,0 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Shortcut
{
[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

@@ -12,7 +12,7 @@ namespace EZPPClient_Installer
public class DownloadUtil
{
public static List<string> FilesToDownload(string pathToEZPP, bool reinstall)
public static async Task<List<string>> FilesToDownload(string pathToEZPP, bool reinstall)
{
bool directoryExists = Directory.Exists(pathToEZPP);
@@ -21,15 +21,14 @@ namespace EZPPClient_Installer
try
{
using (WebClient wc = new WebClient())
{
wc.Headers.Add("user-agent", "EZPPClientInstaller");
var data = wc.DownloadString("https://new.ez-pp.farm/ezppclient?list");
var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?list&release=" + MainWindow.RELEASESTREAM.ToLower());
string[] dataList = data.Split('\n');
foreach (string datastring in dataList)
{
if (string.IsNullOrWhiteSpace(datastring))
if (string.IsNullOrWhiteSpace(datastring) || !datastring.Contains("#"))
continue;
string[] se = datastring.Split('#');
@@ -41,7 +40,7 @@ namespace EZPPClient_Installer
}
catch (WebException error)
{
new ContentDialog()
_ = new ContentDialog()
{
Title = "Oops...",
Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message,
@@ -55,28 +54,28 @@ namespace EZPPClient_Installer
MessageBox.Show("Folder does not exist: " + pathToEZPP);
#endif
foreach (MD5File md5File in md5Files)
downloadList.Add(md5File.getName());
downloadList.Add(md5File.Name);
}
else
{
foreach (MD5File md5file in md5Files)
{
string file = pathToEZPP + @"\" + md5file.getName();
string file = pathToEZPP + @"\" + md5file.Name;
bool doesExistOnPC = File.Exists(file);
if (!doesExistOnPC)
{
downloadList.Add(md5file.getName());
downloadList.Add(md5file.Name);
}
else
{
string onlineHash = md5file.getMD5();
string onlineHash = md5file.MD5;
string pcHash = MD5Util.CalculateMD5(file);
#if DEBUG
MessageBox.Show("Filename: " + md5file.getName() + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
MessageBox.Show("Filename: " + md5file.Name + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
#endif
if (!string.Equals(onlineHash, pcHash))
{
downloadList.Add(md5file.getName());
downloadList.Add(md5file.Name);
}
}
}
@@ -151,7 +150,7 @@ namespace EZPPClient_Installer
MainWindow.updateProgress(filename + " - " + value.ProgressPercentage + "% - " + Math.Round((averageTransferRate / 1024000D) * 1.8, 2) + "MBit/s", value.ProgressPercentage);
};
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename, path + @"\" + filename);
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename + "&release=" + MainWindow.RELEASESTREAM.ToLower(), path + @"\" + filename); ;
}
}
catch (WebException)

View File

@@ -9,7 +9,7 @@ using Microsoft.Win32;
namespace EZPPClient_Installer
{
class Util
class OsuUtil
{
public static string osuInstallDir()
{

View File

@@ -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");
}
}
}

View File

@@ -0,0 +1,48 @@
using ModernWpf.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace EZPPClient_Installer
{
class ReleaseStreamUtil
{
public static async Task<List<string>> GetAvailableReleaseStreams()
{
List<string> releaseStreamList = new List<string>();
try
{
using (WebClient wc = new WebClient())
{
wc.Headers.Add("user-agent", "EZPPClientInstaller");
var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?releases");
string[] dataList = data.Split('\n');
foreach (string datastring in dataList)
{
if (string.IsNullOrWhiteSpace(datastring))
continue;
releaseStreamList.Add(datastring);
}
}
}
catch (WebException error)
{
_ = new ContentDialog()
{
Title = "Oops...",
Content = "A error occurred while trying to fetch the ReleaseStreams.\n" + error.Message,
PrimaryButtonText = "Okay"
}.ShowAsync();
}
return releaseStreamList;
}
}
}