public static Color Update(Panel panel, int value, int maxValue = 100) { if (panel == null) { return(Color.OrangeRed); } var hWnd = panel.GetAncestor()?.Handle ?? IntPtr.Zero; if (hWnd != IntPtr.Zero) { if (value == 0) { TaskBarProgress.SetState(hWnd, TaskBarProgressState.Indeterminate); } else { TaskBarProgress.SetValue(hWnd, value, maxValue); } } var color = ForeColor; if (ForeColor == default) { color = Color.FromArgb(byte.MaxValue - (byte)(value * (byte.MaxValue / (float)maxValue)), byte.MaxValue, value); } using (var g = panel.CreateGraphics()) { var width = value > 0 && value < maxValue ? (int)Math.Round(panel.Width / (double)maxValue * value, MidpointRounding.AwayFromZero) : panel.Width; using (Brush b = new SolidBrush(value > 0 ? color : panel.BackColor)) g.FillRectangle(b, 0, 0, width, panel.Height); } return(color); }
internal void ReportFMExtractProgress(int percent) { ProgressBar.SetValueInstant(percent.Clamp(0, 100)); ProgressMessageLabel.Text = LText.ProgressBox.InstallingFM; ProgressPercentLabel.Text = percent + @"%"; if (Owner?.IsHandleCreated == true) { TaskBarProgress.SetValue(Owner.Handle, percent, 100); } }
private void UpdateTaskBarProgress() { if (this.VisibleInTaskBar) { TaskBarProgress.SetValue(this.Value, this.Maximum); } else { TaskBarProgress.State = TaskBarProgress.TaskBarState.NoProgress; } }
internal void ReportScanProgress(int fmNumber, int fmsTotal, int percent, string fmName) { ProgressBar.SetValueInstant(percent.Clamp(0, 100)); string first = LText.ProgressBox.ReportScanningFirst; string between = LText.ProgressBox.ReportScanningBetweenNumAndTotal; string last = LText.ProgressBox.ReportScanningLast; ProgressMessageLabel.Text = first + fmNumber + between + fmsTotal + last; CurrentThingLabel.Text = fmName; ProgressPercentLabel.Text = percent + @"%"; if (Owner?.IsHandleCreated == true) { TaskBarProgress.SetValue(Owner.Handle, percent, 100); } }
internal void ReportCachingProgress(int percent) { ProgressBar.SetValueInstant(percent.Clamp(0, 100)); ProgressPercentLabel.Text = percent + @"%"; if (Visible) { if (Owner?.IsHandleCreated == true) { TaskBarProgress.SetValue(Owner.Handle, percent, 100); } } else { if (Owner?.IsHandleCreated == true) { TaskBarProgress.SetState(Owner.Handle, TaskbarStates.NoProgress); } } }