public UpdaterForm(IAppCast item) { InitializeComponent(); this.item = item; localizationService = ServiceLocator.GetInstance<ILocalizationService>(); Localize(); Browser.AllowWebBrowserDrop = false; Browser.AllowNavigation = false; if (!string.IsNullOrEmpty(item.ReleaseNotesLink)) { Browser.Navigate(item.ReleaseNotesLink); } }
public DownloadForm(IUpdater updater, IAppCast appcast) { InitializeComponent(); this.updater = updater; this.appcast = appcast; downloader = ServiceLocator.GetInstance<IDownloader>(); installer = ServiceLocator.GetInstance<IInstaller>(); localizationService = ServiceLocator.GetInstance<ILocalizationService>(); ToogleControls(); Localize(); SetTempFileName(); StartDownload(); }
public void DownloadUpdate(IAppCast appcast, string fileName, Form form) { var downloadForm = (DownloadForm)form; using (WebClient client = new WebClient()) { // Check if we need a proxy var settings = settingsService.LoadSettings(); if (settings.Proxy.IsValid) { client.Proxy = new WebProxy(settings.Proxy.Url) { Credentials = new NetworkCredential(settings.Proxy.Username, settings.Proxy.Password) }; } client.DownloadProgressChanged += downloadForm.ClientDownloadProgressChanged; client.DownloadFileCompleted += downloadForm.ClientDownloadFileCompleted; Uri url = new Uri(appcast.DownloadLink); client.DownloadFileAsync(url, fileName); } }
private void ShowUpdateForm(IAppCast currentItem) { UpdaterForm updaterForm = new UpdaterForm(currentItem) { TopMost = true }; DialogResult dialogResult = updaterForm.ShowDialog(); if (dialogResult.Equals(DialogResult.Yes)) { InitDownloadAndInstallProcess(currentItem); } }
private bool IsUpdateRequired(out IAppCast latestVersion) { ReportDiagnosticMessage(localizationService.GetString(LocalizationResourceNames.UpdaterCheckingAppCastDiagMessage)); try { latestVersion = downloader.DownloadAppCast(AppCastUrl, Configuration); } catch (Exception exception) { ReportDiagnosticMessage(string.Format(localizationService.GetString(LocalizationResourceNames.UpdaterErrorDownloadingAppCastDiagMessage), exception.Message)); latestVersion = null; } if (latestVersion == null) { ReportDiagnosticMessage(localizationService.GetString(LocalizationResourceNames.UpdaterNoVersionInfoInAppCastDiagMessage)); return false; } ReportDiagnosticMessage(string.Format(localizationService.GetString(LocalizationResourceNames.UpdaterLatestVersionDiagMessage), latestVersion.Version)); // Compare the installed version with the one available on the server. Version installedVersion = new Version(Configuration.InstalledVersion); Version serverVersion = new Version(latestVersion.Version); if (serverVersion <= installedVersion) { ReportDiagnosticMessage(string.Format(localizationService.GetString(LocalizationResourceNames.UpdaterInstalledVersionIsValidDiagMessage), Configuration.InstalledVersion)); return false; } return true; }
private void InitDownloadAndInstallProcess(IAppCast item) { DownloadForm downloadForm = new DownloadForm(this, item); downloadForm.ShowDialog(); }
private void GetUpdate(IAppCast appCastItem) { ShowDiagnosticWindowIfNeeded(); ReportDiagnosticMessage(localizationService.GetString(LocalizationResourceNames.UpdaterUpdateStartDiagMessage)); ReportDiagnosticMessage(localizationService.GetString(LocalizationResourceNames.UpdaterReadingConfigDiagMessage)); ReportDiagnosticMessage(string.Format(localizationService.GetString(LocalizationResourceNames.UpdaterUpdateNeededDiagMessage), Configuration.InstalledVersion, appCastItem.Version)); ShowUpdateForm(appCastItem); }