Skip to content

Commit

Permalink
Add auto download MahApps.Metro.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Jan 30, 2020
1 parent 50b5611 commit a525430
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
14 changes: 13 additions & 1 deletion WindowsGSM/Functions/Github.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ public static async Task<bool> DownloadGameServerConfig(string filePath, string

using (WebClient webClient = new WebClient())
{
await webClient.DownloadFileTaskAsync("https://" + $"github.com/WindowsGSM/Game-Server-Configs/raw/master/{gameFullName.Replace(":", "")}/{fileName}", filePath);
await webClient.DownloadFileTaskAsync($"https://github.com/WindowsGSM/Game-Server-Configs/raw/master/{gameFullName.Replace(":", "")}/{fileName}", filePath);
}

return File.Exists(filePath);
}

public static async Task<bool> DownloadMahAppsMetroDll()
{
string filePath = MainWindow.WGSM_PATH + @"\MahApps.Metro.dll";

using (WebClient webClient = new WebClient())
{
await webClient.DownloadFileTaskAsync("https://github.com/WindowsGSM/WindowsGSM/raw/master/packages/MahApps.Metro.1.6.5/lib/net47/MahApps.Metro.dll", filePath);
}

return File.Exists(filePath);
Expand Down
14 changes: 14 additions & 0 deletions WindowsGSM/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public MainWindow()

Title = "WindowsGSM " + WGSM_VERSION;

//Check DLL
if(!IsMahAppsMetroDllExist())
{
#pragma warning disable 4014
Functions.Github.DownloadMahAppsMetroDll();
#pragma warning restore
}

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\WindowsGSM");
if (key == null)
{
Expand Down Expand Up @@ -171,6 +179,12 @@ public MainWindow()
AutoStartServer();
}

private bool IsMahAppsMetroDllExist()
{
string mahappsPath = Path.Combine(WGSM_PATH, "MahApps.Metro.dll");
return File.Exists(mahappsPath);
}

private void RefreshServerList_Click(object sender, RoutedEventArgs e)
{
LoadServerTable();
Expand Down

0 comments on commit a525430

Please sign in to comment.