private void MainForm_Load(object sender, EventArgs e) { this.TopMost = TopMost; // Ensures that TopMost works properly. applyCurrentTheme(); if (Settings.Capturing) { timer.Start(); } restoreUI(); setNewHotKey(Settings.ShortcutKey); updateChecker.CheckForUpdates(UpdateNotifyMode.Auto); Settings.Changed += settings_Changed; }
public MainApplicationContext() : base(Resources.PinWinIconWhite) { ContextMenu.Opening += ContextMenu_Opening; if (!String.IsNullOrWhiteSpace(Settings.Default.HotKey)) { var keyConv = new KeysConverter(); Keys keys = (Keys)keyConv.ConvertFromInvariantString(Settings.Default.HotKey); SetHotKey((KeyCombination)keys); } Application.ApplicationExit += Application_ApplicationExit; updateChecker = new WinFormsUpdateChecker(Program.UPDATE_URL, identifier: Program.UPDATE_IDENTIFIER); if (Settings.Default.AlwaysCheckForUpdates) { updateChecker.CheckForUpdates(); } }
public async Task MainAsync() { if (CheckConnection() == false) { Console.WriteLine("Could not check for updates. Please check your internet connection."); } else { Console.WriteLine("Checking for updates..."); IUpdateInfo updateInfo = await _updateChecker.CheckForUpdates(); if (CompareVersions(updateInfo, Info.version) == false) { Console.WriteLine("No new updates found."); } else { Console.WriteLine("New update is available."); Console.WriteLine("Update version: " + updateInfo.Version); Console.WriteLine("Current version: " + Info.version); Console.WriteLine("Do you wish to download update now? (y/n)"); if (UserResponse()) { Console.WriteLine(); await _downloader.DownloadUpdate(updateInfo); Console.WriteLine("Extracting files..."); _downloader.ExtractZip(); string updateDirPath = "Maia-DiscordBot"; if (Directory.Exists(updateDirPath)) { await Update(updateDirPath); } else { Console.WriteLine("Could not find update directory!"); } } } } Console.WriteLine(); Console.WriteLine("--------------------------------------------------"); Console.WriteLine("Current version: " + Info.version); }
public async Task <bool> Run(CancellationToken token) { #if !DEBUG || FAKERELEASE // Wait a minute after the application starts to check for updates. if (token.WaitHandle.WaitOne((int)TimeSpan.FromSeconds(30).TotalMilliseconds)) { _log.Information("We were instructed to stop (1)."); return(true); } #endif // Should we even check for updates? if (!_settings.Get <bool>(Constants.Settings.General.CheckForUpdates)) { _log.Information("We were instructed to stop since we should not check for updates."); return(true); } while (true) { _log.Information("Checking for updates..."); var result = await _checker.CheckForUpdates(); if (result != null && result.FutureVersion > result.CurrentVersion) { _log.Information($"New version available: {result.FutureVersion}"); _eventAggregator.PublishOnUIThread(new UpdateAvailableMessage(result)); // Don't run this check again. // At least not until we restart. _log.Information("Shutting down since update message have been sent."); return(true); } // Sleep for 30 minutes before checking for updates again. _log.Information("No new version available."); if (token.WaitHandle.WaitOne((int)TimeSpan.FromMinutes(30).TotalMilliseconds)) { _log.Information("We were instructed to stop (2)."); return(true); } } }
public void UpdateVividl() => updateChecker.CheckForUpdates(UpdateNotifyMode.Always);