private void AutoCheckUpdate() { if (Program.Config.AutoCheckUpdate) { Thread updateThread = new Thread(() => { UpdateChecker updateChecker = AboutForm.CheckUpdate(); if (updateChecker != null && updateChecker.Status == ShareX.HelpersLib.UpdateStatus.UpdateAvailable && MessageBox.Show(Resources.MainWindow_CheckUpdate_, string.Format("{0} {1} is available", Application.ProductName, updateChecker.LatestVersion), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { using (DownloaderForm updaterForm = new DownloaderForm(updateChecker)) { updaterForm.ShowDialog(); if (updaterForm.Status == DownloaderFormStatus.InstallStarted) { Application.Exit(); } } } }); updateThread.IsBackground = true; updateThread.Start(); } }
private void CheckUpdate() { if (UpdaterAck != System.Windows.Forms.DialogResult.None) { UpdateChecker updateChecker = new UpdateChecker(ZLinks.URL_UPDATE, Application.ProductName, new Version(Adapter.AssemblyVersion), Engine.ConfigUI.ReleaseChannel, Uploader.ProxySettings.GetWebProxy); updateChecker.CheckUpdate(); UpdaterAck = System.Windows.Forms.DialogResult.None; if (updateChecker.UpdateInfo != null && updateChecker.UpdateInfo.Status == UpdateStatus.UpdateRequired && !string.IsNullOrEmpty(updateChecker.UpdateInfo.URL)) { UpdaterAck = MessageBox.Show("Update found. Do you want to download it?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (UpdaterAck == DialogResult.Yes) { DownloaderForm downloader = new DownloaderForm(updateChecker.UpdateInfo.URL, updateChecker.Proxy, updateChecker.UpdateInfo.Summary); downloader.ShowDialog(); if (downloader.Status == DownloaderFormStatus.InstallStarted) { Application.Exit(); } } } } }
/// <summary> /// Open the download window and download the Tycho catalog /// </summary> /// <param name="sender">object sender</param> /// <param name="e">event arguments</param> /// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks> private void ButtonDownloadTychoCatalog_Click(object sender, EventArgs e) { settings.Reload(); using (DownloaderForm downloaderForm = new DownloaderForm()) { downloaderForm.SetHost(host: settings.UserHostName); downloaderForm.SetHostUrls(files: filesTychoCatalog); downloaderForm.SetCatalogDirectory(directory: settings.UserTychoCatalogDirectory); downloaderForm.ShowDialog(); } }
private void llblUpdateAvailable_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (updateChecker != null && updateChecker.UpdateInfo != null && !string.IsNullOrEmpty(updateChecker.UpdateInfo.URL)) { DownloaderForm downloader = new DownloaderForm(updateChecker.UpdateInfo.URL, updateChecker.Proxy, updateChecker.UpdateInfo.Summary); downloader.ShowDialog(); if (downloader.Status == DownloaderFormStatus.InstallStarted) { Application.Exit(); } } }
void a_FormClosed(object sender, FormClosedEventArgs e) { var a = (DownloaderForm)sender; a.RequestAvailable = false; a.dorg.Stop(); removeForm(a.dorg.DownloadRequestMessage.FileName, a.dorg.DownloadRequestMessage.Url); a = new DownloaderForm(a.dorg, false) { NewUrlRequested = a.NewUrlRequested }; a.FormClosed += a_FormClosed; formlist.Add(a); }
public static DialogResult DownloadFFmpeg(bool async, DownloaderForm.DownloaderInstallEventHandler installRequested) { FFmpegUpdateChecker updateChecker = new FFmpegUpdateChecker("ShareX", "FFmpeg"); string url = updateChecker.GetLatestDownloadURL(true); using (DownloaderForm form = new DownloaderForm(url, "ffmpeg.zip")) { form.Proxy = HelpersOptions.CurrentProxy.GetWebProxy(); form.InstallType = InstallType.Event; form.RunInstallerInBackground = async; form.InstallRequested += installRequested; return(form.ShowDialog()); } }
void showForm(DownloaderForm f, DownloadMessage req, bool directStart) { if (f != null && f.Visible) { return; } else { removeForm(req.FileName, req.Url); var a = new DownloaderForm(f.dorg, directStart); a.FormClosed += a_FormClosed; formlist.Add(a); a.Shown += a_Shown; a.Show(); } }
private void CheckUpdate() { UpdateChecker updateChecker = TaskHelpers.CheckUpdate(); if (updateChecker.UpdateInfo != null && updateChecker.UpdateInfo.Status == UpdateStatus.UpdateAvailable && MessageBox.Show("A newer version of ShareX is available.\r\nWould you like to download and install it?", string.Format("{0} v{1} is available", Application.ProductName, updateChecker.UpdateInfo.LatestVersion.ToString()), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { using (DownloaderForm updaterForm = new DownloaderForm(updateChecker)) { updaterForm.ShowDialog(); if (updaterForm.Status == DownloaderFormStatus.InstallStarted) { Application.Exit(); } } } }
void readSettings() { try { var json = Properties.Settings.Default.DownloadList; var list = JsonConvert.DeserializeObject <List <HttpMultiThreadDownloader> >(json); if (list != null && list.Any()) { foreach (var item in list) { var a = new DownloaderForm(item, false); a.FormClosed += a_FormClosed; formlist.Add(a); } } } catch { } }
private void CheckUpdate() { UpdateChecker updateChecker = new UpdateChecker(ZLinks.URL_UPDATE, Application.ProductName, new Version(Program.AssemblyVersion), ReleaseChannelType.Stable, Uploader.ProxySettings.GetWebProxy); updateChecker.CheckUpdate(); if (updateChecker.UpdateInfo != null && updateChecker.UpdateInfo.Status == UpdateStatus.UpdateRequired && !string.IsNullOrEmpty(updateChecker.UpdateInfo.URL)) { if (MessageBox.Show("Update found. Do you want to download it?", "Update check", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { DownloaderForm downloader = new DownloaderForm(updateChecker.UpdateInfo.URL, updateChecker.Proxy, updateChecker.UpdateInfo.Summary); downloader.ShowDialog(); if (downloader.Status == DownloaderFormStatus.InstallStarted) { Application.Exit(); } } } }
public static DialogResult DownloadFFmpeg(bool async, DownloaderForm.DownloaderInstallEventHandler installRequested) { string url; if (NativeMethods.Is64Bit()) { url = "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.7z"; } else { url = "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.7z"; } using (DownloaderForm form = new DownloaderForm(url, "ffmpeg.7z")) { form.Proxy = ProxyInfo.Current.GetWebProxy(); form.InstallType = InstallType.Event; form.RunInstallerInBackground = async; form.InstallRequested += installRequested; return(form.ShowDialog()); } }
public void OnMessageReceived(MessageEventArgs e) { this.Invoke((MethodInvoker) delegate { var msg = e.Message.ToString(); var downloadRequest = JsonConvert.DeserializeObject <DownloadMessage>(msg); var f = findDownloader(downloadRequest.FileName, downloadRequest.Url); if (f != null) { f.TopMost = true; } var completed = checkDownloadCompleted(f); if (f == null) { this.Invoke((MethodInvoker) delegate { var mtdo = createMTDO(downloadRequest); var downloader = new DownloaderForm(mtdo, true); showForm(downloader, downloadRequest, true); }); } else if (f.NewUrlRequested) { if (f.Visible && f.RequestAvailable) { f.RefreshUrl(downloadRequest); } } else if (completed) { this.Activate(); f.dorg.Url = downloadRequest.Url; f.dorg.Info.Url = downloadRequest.Url; f.dorg.DownloadRequestMessage = downloadRequest; if (!f.Visible) { f.Show(); } var result = MessageBox.Show("Download already completed! Do you want to download again?", downloadRequest.FileName, MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { f.HandleAlreadyCompleted(); } else { f.Close(); } } else if (!f.dorg.IsActive) { Directory.CreateDirectory(f.dorg.RangeDir); foreach (var item in f.dorg.Ranges) { if (!File.Exists(item.FilePath)) { item.TotalBytesReceived = 0; } } if (!f.Visible) { f.Show(); } f.Resume(); } else if (f.dorg.IsActive) { this.Activate(); if (!f.Visible) { f.Show(); } } }); }
bool checkDownloadCompleted(DownloaderForm f) { return(f != null && f.dorg != null && f.dorg.Status == HttpDownloaderStatus.Completed); }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { var selected = lvLastestUpdates.SelectedObjects[0] as SearchItem; DownloaderForm form = new DownloaderForm(selected.StoryUrl); form.MdiParent = this.MdiParent; form.WindowState = FormWindowState.Minimized; form.Show(); form.WindowState = FormWindowState.Maximized; }