-
-
Save CADbloke/8c57628908548ea2a33c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all the libraries that we are using | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Navigation; | |
using System.Windows.Shapes; | |
// separating so I know the difference | |
using wyDay.Controls; // have to add this later anyways | |
namespace testWPF // we can change this to InsiteVR once I figure shit out | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow /*we can change this to UpdateWindow*/: Window | |
{ | |
AutomaticUpdaterBackend updater; //this is what we are adding | |
// We are getting | |
public MainWindow() // remember to chnage this to UpdateWindow if above changed | |
{ | |
System.Threading.Thread.Sleep(3000); //We are telling program to pause here | |
InitializeComponent(); // now lets start | |
updater = new AutomaticUpdaterBackend() | |
{ | |
GUID = "APP_GUID", | |
UpdateType = UpdateType.CheckAndDownload, | |
}; | |
// we define the updater things | |
updater.CheckingFailed += OnCheckingFailed; | |
updater.UpdateAvailable += OnUpdateAvailable; | |
updater.DownloadingFailed += OnDownloadingFailed; | |
updater.ExtractingFailed += OnExtractingFailed; | |
//alot of things fail | |
updater.ReadyToBeInstalled += OnReadyToBeInstalled; | |
updater.UpdateSuccessful += OnUpdateSuccessful; | |
updater.UpdateFailed += OnFailed; | |
updater.UpToDate += OnUpToDate; | |
// telling the updater we are good to go | |
updater.Initialize(); | |
updater.AppLoaded(); | |
updater.ForceCheckForUpdate(); | |
// Console.WriteLine("legggo b0$$") | |
} | |
void OnCheckingFailed(object sender, FailArgs e) | |
{ | |
Console.WriteLine("check fail"); | |
UpdateErrorBox(); | |
} | |
void OnUpdateAvailable(object sender, EventArgs e) | |
{ | |
Console.WriteLine("update available"); | |
} | |
void OnDownloadingFailed(object sender, FailArgs e) | |
{ | |
Console.WriteLine("download fail"); | |
UpdateErrorBox(); | |
} | |
void OnExtractingFailed(object sender, FailArgs e) | |
{ | |
Console.WriteLine("extract fail"); | |
UpdateErrorBox(); | |
} | |
void OnReadyToBeInstalled(object sender, EventArgs e) | |
{ | |
Console.WriteLine("ready install"); | |
} | |
void OnUpToDate(object sender, EventArgs e) | |
{ | |
Console.WriteLine("update successful"); | |
} | |
void OnUpdateSuccessful(object sender, SuccessArgs e) | |
{ | |
Console.WriteLine("success"); | |
} | |
void OnFailed(object sender, FailArgs e) //OnUpdateFailed | |
{ | |
Console.WriteLine("fail"); | |
UpdateErrorBox(); | |
} | |
void UpdateErrorBox() | |
{ | |
MessageBoxResult result = MessageBox.Show("ERROR: Update failed."); | |
Application.Current.Shutdown(); | |
} | |
void LoadMainWindow() | |
{ | |
Application.Current.Dispatcher.Invoke((Action)delegate | |
{ | |
MainWindow main = new MainWindow(); | |
App.Current.MainWindow = main; | |
main.Show(); | |
this.Close(); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment