mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-25 10:46:51 +01:00
Extract updater check routine to its own method
This commit is contained in:
parent
977e37595a
commit
339846f701
@ -185,26 +185,7 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
|
|||||||
if (result == MessageBoxResult.Yes)
|
if (result == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
bool launch = true;
|
bool launch = true;
|
||||||
if (!File.Exists(Global.exedirpath + "\\DS4Updater.exe") ||
|
launch = RunUpdaterCheck(launch);
|
||||||
(File.Exists(Global.exedirpath + "\\DS4Updater.exe")
|
|
||||||
&& (FileVersionInfo.GetVersionInfo(Global.exedirpath + "\\DS4Updater.exe").FileVersion.CompareTo(MainWindowsViewModel.UPDATER_VERSION) != 0)))
|
|
||||||
{
|
|
||||||
Uri url2 = new Uri($"https://github.com/Ryochan7/DS4Updater/releases/download/v{MainWindowsViewModel.UPDATER_VERSION}/{mainWinVM.updaterExe}");
|
|
||||||
string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DS4Updater.exe");
|
|
||||||
using (var downloadStream = new FileStream(filename, FileMode.Create))
|
|
||||||
{
|
|
||||||
Task<System.Net.Http.HttpResponseMessage> temp =
|
|
||||||
App.requestClient.GetAsync(url2.ToString(), downloadStream);
|
|
||||||
temp.Wait();
|
|
||||||
if (!temp.Result.IsSuccessStatusCode) launch = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (launch)
|
|
||||||
{
|
|
||||||
int copyStatus = Util.ElevatedCopyUpdater(filename);
|
|
||||||
if (copyStatus != 0) launch = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (launch)
|
if (launch)
|
||||||
{
|
{
|
||||||
@ -259,6 +240,33 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool RunUpdaterCheck(bool launch)
|
||||||
|
{
|
||||||
|
if (!File.Exists(Global.exedirpath + "\\DS4Updater.exe") ||
|
||||||
|
(File.Exists(Global.exedirpath + "\\DS4Updater.exe")
|
||||||
|
&& (FileVersionInfo.GetVersionInfo(Global.exedirpath + "\\DS4Updater.exe").FileVersion.CompareTo(MainWindowsViewModel.UPDATER_VERSION) != 0)))
|
||||||
|
{
|
||||||
|
launch = false;
|
||||||
|
Uri url2 = new Uri($"https://github.com/Ryochan7/DS4Updater/releases/download/v{MainWindowsViewModel.UPDATER_VERSION}/{mainWinVM.updaterExe}");
|
||||||
|
string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DS4Updater.exe");
|
||||||
|
using (var downloadStream = new FileStream(filename, FileMode.Create))
|
||||||
|
{
|
||||||
|
Task<System.Net.Http.HttpResponseMessage> temp =
|
||||||
|
App.requestClient.GetAsync(url2.ToString(), downloadStream);
|
||||||
|
temp.Wait();
|
||||||
|
if (temp.Result.IsSuccessStatusCode) launch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (launch)
|
||||||
|
{
|
||||||
|
int copyStatus = Util.ElevatedCopyUpdater(filename);
|
||||||
|
if (copyStatus != 0) launch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return launch;
|
||||||
|
}
|
||||||
|
|
||||||
private void TrayIconVM_RequestMinimize(object sender, EventArgs e)
|
private void TrayIconVM_RequestMinimize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.WindowState = WindowState.Minimized;
|
this.WindowState = WindowState.Minimized;
|
||||||
|
Loading…
Reference in New Issue
Block a user