public async void DownloadUpdateClick() { await Task.Run(() => { CLog.Here().Information($"AppUpdaterService - DownloadUpdate : [ Download for Update... ]"); AvailableUpdate?.ClosePopUp(); // this is async so that it can grab the download file name from the server SparkleInst.DownloadStarted -= CBStartedDownloading; SparkleInst.DownloadStarted += CBStartedDownloading; SparkleInst.DownloadFinished -= CBFinishedDownloading; SparkleInst.DownloadFinished += CBFinishedDownloading; SparkleInst.DownloadHadError -= CBDownloadError; SparkleInst.DownloadHadError += CBDownloadError; SparkleInst.DownloadMadeProgress -= CBDownloadMadeProgress; SparkleInst.DownloadMadeProgress += CBDownloadMadeProgress; SparkleInst.DownloadCanceled -= CBDownloadCanceled; SparkleInst.DownloadCanceled += CBDownloadCanceled; }); await SparkleInst.InitAndBeginDownload(UpdateInfo.Updates.First()); // ok, the file is downloading now }
public static bool IsNewVersionAvailable(AvailableUpdate availableUpdate) { if (Version.TryParse(availableUpdate.Version, out Version availableVersion)) { return(availableVersion.CompareTo(App.GetAppVersion()) > 0); } return(false); }
public UpdateWindow(IconSource source, AvailableUpdate update) { InitializeComponent(); AvailableUpdate = update; this.Icon = source.GetImage(IconType.NbtStudio).Icon; CurrentVersionValue.Text = Updater.GetCurrentVersion().ToString(false); AvailableVersionValue.Text = update.Version.ToString(false); ChangelogBox.Text = update.Changelog; ButtonOk.Select(); }
static Sys() { string appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); _7HFolder = appPath; SysFolder = Path.Combine(appPath, "7thWorkshop"); Directory.CreateDirectory(SysFolder); string sfile = Path.Combine(SysFolder, "settings.xml"); if (File.Exists(sfile)) { try { Settings = Util.Deserialize <Settings>(sfile); } catch (Exception e) { Sys.Message(new WMessage(StringKey.ErrorLoadingSettingsPleaseConfigure7H, WMessageLogLevel.Error, e)); } } if (Settings == null) { Settings = Settings.UseDefaultSettings(); Settings.IsFirstStart = true; } string lfile = Path.Combine(SysFolder, "library.xml"); if (File.Exists(lfile)) { try { Library = Util.Deserialize <Library>(lfile); } catch (Exception e) { Sys.Message(new WMessage(StringKey.ErrorLoadingLibraryFile, WMessageLogLevel.Error, e)); } } if (Library == null) { Library = new Library(); } if (Settings.HasOption(GeneralOptions.AutoUpdateMods)) { Library.DefaultUpdate = UpdateType.Install; } _statuses = Library.Items.ToDictionary(i => i.ModID, _ => ModStatus.Installed); ImageCache = new ImageCache(Path.Combine(SysFolder, "cache")); AppVersion = new Version(); string pathToVersions = Path.Combine(SysFolder, "version.xml"); if (File.Exists(pathToVersions)) { try { LastCheckedVersion = Util.Deserialize <AvailableUpdate>(pathToVersions); } catch (Exception e) { Sys.Message(new WMessage("Failed to open/deserialize version.xml", WMessageLogLevel.LogOnly, e)); } } if (LastCheckedVersion == null) { LastCheckedVersion = new AvailableUpdate(); } }