void bp_DownloadProgress(object sender, Tools.BackgroundPatcher.DownloadProgressEventArgs e) { if (this.InvokeRequired) { try { this.Invoke(new MethodInvoker( delegate { bp_DownloadProgress(sender, e); })); } catch (Exception exc) { Util.Logging.Log(exc); } return; } bool update = false; if (e.downloadRate != this.downloadRate) { this.downloadRate = e.downloadRate; update = true; } this.contentBytesTotal = e.contentBytesTotal; this.contentBytesCore = e.contentBytesCore; if (e.bytesDownloaded != this.bytesDownloaded) { this.bytesDownloaded = e.bytesDownloaded; update = true; } if (update) { var t = Util.Text.FormatBytes(bytesDownloaded); if (downloadRate > 0) { labelDownloaded.Text = t + " @ " + Util.Text.FormatBytes(downloadRate) + "/s"; } else { labelDownloaded.Text = t; } } if (e.estimatedBytesRemaining != this.estimatedBytesRemaining) { this.estimatedBytesRemaining = e.estimatedBytesRemaining; labelSize.Text = Util.Text.FormatBytes(estimatedBytesRemaining); } int files = e.filesDownloaded + e.manifestsDownloaded; int total = e.filesTotal + e.manifestsTotal; if (files != this.filesDownloaded || total != this.filesTotal) { this.filesDownloaded = files; this.filesTotal = total; if (!manifestsComplete && e.manifestsDownloaded == e.manifestsTotal) { manifestsComplete = true; labelSizeEstimated.Visible = true; if (taskBar != null) { taskBar.SetState(this.Handle, Windows.Taskbar.TaskbarStates.Normal); } } if (manifestsComplete) { if (!errored) { labelFiles.Text = string.Format("{0:#,##0} of {1:#,##0}", files, total); } if (progressDownload.Maximum != e.filesTotal) { progressDownload.Maximum = e.filesTotal; } if (progressDownload.Value != e.filesDownloaded) { progressDownload.Value = e.filesDownloaded; } if (taskBar != null) { taskBar.SetValue(this.Handle, (ulong)e.filesDownloaded, (ulong)e.filesTotal); } } else if (!errored) { labelFiles.Text = string.Format("{0:#,##0} of ...", files); } } }
public static void Show(NotifyType t, int screen, Settings.ScreenAnchor anchor, Tools.BackgroundPatcher.DownloadProgressEventArgs pe) { Show(new formNotify(t, screen, anchor, new Tools.BackgroundPatcher.PatchEventArgs() { Build = pe.build, Files = pe.filesTotal + pe.manifestsTotal, Size = pe.estimatedBytesRemaining + pe.contentBytesTotal, Elapsed = DateTime.UtcNow.Subtract(pe.startTime) })); }
public formScreenPosition(NotificationType type, int screen, Settings.ScreenAnchor anchor) { InitializeComponents(); this.type = type; switch (type) { case NotificationType.Patch: pe = new Tools.BackgroundPatcher.DownloadProgressEventArgs() { build = 12345, filesTotal = 123, startTime = DateTime.UtcNow, contentBytesTotal = 12345 }; break; case NotificationType.Note: break; case NotificationType.Screenshot: break; } screens = Screen.AllScreens; currentScreen = screen; if (currentScreen >= screens.Length) { currentScreen = 0; } if (screens.Length > 1) { arrowLeft.Visible = true; arrowRight.Visible = true; } labelScreen.Text = (currentScreen + 1).ToString(); radioBL.Tag = Settings.ScreenAnchor.BottomLeft; radioBR.Tag = Settings.ScreenAnchor.BottomRight; radioTL.Tag = Settings.ScreenAnchor.TopLeft; radioTR.Tag = Settings.ScreenAnchor.TopRight; radioBR.Checked = true; currentAnchor = Settings.ScreenAnchor.BottomRight; foreach (Control c in this.Controls) { c.LostFocus += c_LostFocus; if (c is RadioButton) { var r = (RadioButton)c; if (r.Tag != null && (Settings.ScreenAnchor)r.Tag == anchor) { r.Checked = true; currentAnchor = anchor; } r.CheckedChanged += radio_CheckedChanged; } } }
void bp_DownloadProgress(object sender, Tools.BackgroundPatcher.DownloadProgressEventArgs e) { progress = e; }