|
@@ -85,75 +85,6 @@ namespace PixiEditor
|
|
|
private void MainWindow_Initialized(object sender, EventArgs e)
|
|
|
{
|
|
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) => Helpers.CrashHelper.SaveCrashInfo((Exception)e.ExceptionObject);
|
|
|
-#if RELEASE
|
|
|
- CheckForDownloadedUpdates();
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- private void CheckForDownloadedUpdates()
|
|
|
- {
|
|
|
- string dir = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
- UpdateDownloader.CreateTempDirectory();
|
|
|
- bool updateZipExists = Directory.GetFiles(UpdateDownloader.DownloadLocation, "update-*.zip").Length > 0;
|
|
|
- string[] updateExeFiles = Directory.GetFiles(UpdateDownloader.DownloadLocation, "update-*.exe");
|
|
|
- bool updateExeExists = updateExeFiles.Length > 0;
|
|
|
-
|
|
|
- string updaterPath = Path.Join(dir, "PixiEditor.UpdateInstaller.exe");
|
|
|
-
|
|
|
- if (updateZipExists || updateExeExists)
|
|
|
- {
|
|
|
- ViewModelMain.Current.UpdateSubViewModel.UpdateReadyToInstall = true;
|
|
|
- var result = ConfirmationDialog.Show("Update is ready to install. Do you want to install it now?");
|
|
|
- if (result == Models.Enums.ConfirmationType.Yes)
|
|
|
- {
|
|
|
- if (updateZipExists && File.Exists(updaterPath))
|
|
|
- {
|
|
|
- InstallHeadless(updaterPath);
|
|
|
- }
|
|
|
- else if (updateExeExists)
|
|
|
- {
|
|
|
- OpenExeInstaller(updateExeFiles[0]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void InstallHeadless(string updaterPath)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- ProcessHelper.RunAsAdmin(updaterPath);
|
|
|
- Close();
|
|
|
- }
|
|
|
- catch (Win32Exception)
|
|
|
- {
|
|
|
- MessageBox.Show(
|
|
|
- "Couldn't update without administrator rights.",
|
|
|
- "Insufficient permissions",
|
|
|
- MessageBoxButton.OK,
|
|
|
- MessageBoxImage.Error);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void OpenExeInstaller(string updateExeFile)
|
|
|
- {
|
|
|
- bool alreadyUpdated = AssemblyHelper.GetCurrentAssemblyVersion() ==
|
|
|
- updateExeFile.Split('-')[1].Split(".exe")[0];
|
|
|
-
|
|
|
- if (!alreadyUpdated)
|
|
|
- {
|
|
|
- RestartToUpdate(updateExeFile);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- File.Delete(updateExeFile);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void RestartToUpdate(string updateExeFile)
|
|
|
- {
|
|
|
- Process.Start(updateExeFile);
|
|
|
- Close();
|
|
|
}
|
|
|
}
|
|
|
}
|