/// <summary> /// Sets the progress bar of this form's taskbar button to the /// specified percentage. /// </summary> /// <param name="form">The form.</param> /// <param name="percent">The progress percentage.</param> public static void SetTaskbarProgress(this Form form, float percent) { Windows7Taskbar.SetProgressState( form.Handle, Windows7Taskbar.ThumbnailProgressState.Normal); Windows7Taskbar.SetProgressValue( form.Handle, (ulong)percent, 100); }
private void updateProgressBarUnsafe(int pe, bool total) { if (pe < 0) { pe = 0; } if (pe > 100) { pe = 100; } if (total) { if (pe == 0) { Windows7Taskbar.SetProgressState(Handle, ThumbnailProgressState.NoProgress); } else { Windows7Taskbar.SetProgressValue(Handle, pe, 100); } _totalProgress.Value = pe; //_totalProgress.Refresh(); } else { _fileProgressBar.Value = pe; //_fileProgressBar.Refresh(); } }
void ChangeStatus(string Status, int ProgressValue) { statusStrip1.Invoke(new Action(() => { toolStripProgressBar1.Value = ProgressValue; toolStripStatusLabel1.Text = Status; })); if (Utils.IsWindows7OrSuperior()) { this.Invoke(new Action(() => { if (ProgressValue > 0) { Windows7Taskbar.SetProgressState(Handle, Windows7Taskbar.ThumbnailProgressState.Normal); } else { Windows7Taskbar.SetProgressState(Handle, Windows7Taskbar.ThumbnailProgressState.NoProgress); } Windows7Taskbar.SetProgressValue(Handle, (ulong)ProgressValue, (ulong)PatchInfo.ProgressBarMaxValue); })); } }
internal void updateProgress(int current, int total, string caption) { caption += "..."; if (label1.Text != caption) { label1.Text = caption; return; } if (progressBar1.Maximum != total) { progressBar1.Maximum = total; } progressBar1.Value = current; if (progressBar1.Visible == false) { progressBar1.Visible = true; } if (taskHwnd == null) { taskHwnd = Windows7Taskbar.GetTaskBarForm(this); } if (taskHwnd.Value != IntPtr.Zero) { Windows7Taskbar.SetProgressValue(taskHwnd.Value, (uint)current, (uint)total); } }
/// <summary> /// Sets the progress bar in the containing form's taskbar button /// to this progress bar's progress. /// </summary> /// <param name="progressBar">The progress bar.</param> public static void SetTaskbarProgress(this ProgressBar progressBar) { Form form = (Form)progressBar.TopLevelControl; //Approximation: ulong maximum = (ulong)(progressBar.Maximum - progressBar.Minimum); ulong progress = (ulong)(progressBar.Value - progressBar.Minimum); Windows7Taskbar.SetProgressState( form.Handle, Windows7Taskbar.ThumbnailProgressState.Normal); Windows7Taskbar.SetProgressValue( form.Handle, progress, maximum); }
public void UpdateOverallProgressState(long progress, long maximum) { if (Utils.IsWin7OrLater) { if (progress == 0 || maximum == 0) { Windows7Taskbar.SetProgressState(Handle, Windows7Taskbar.ThumbnailProgressState.NoProgress); } else { Windows7Taskbar.SetProgressState(Handle, Windows7Taskbar.ThumbnailProgressState.Normal); Windows7Taskbar.SetProgressValue(Handle, (ulong)progress, (ulong)maximum); } } }
private void sendFileToolStripMenuItem_Click(object sender, EventArgs e) { sendFileTimer.Interval = 1000; sendFileTimer.Tick += delegate { _percentFileCompleted += 10; if (_percentFileCompleted == 100) { sendFileTimer.Stop(); MessageBox.Show("File operation failed!"); Windows7Taskbar.SetProgressState(Handle, Windows7Taskbar.ThumbnailProgressState.Error); _percentFileCompleted = 0; } else { Windows7Taskbar.SetProgressValue(Handle, (ulong)_percentFileCompleted, (ulong)100); } }; sendFileTimer.Start(); }
public void setValue(int v) { _totalProgress.Value = v; Windows7Taskbar.SetProgressValue(Handle, v, 100); }
public void setValue(int v) { StatusProgress.Value = v; Windows7Taskbar.SetProgressValue(Handle, v, StatusProgress.Maximum); }
internal void updateProgress(long current, long total, string caption, int subCurrent = -1, int subTotal = -1) { caption += "..."; if (label1.Text != caption) { label1.Text = caption; } if (current > total) { return; } int useTotal; int useCurrent; if (total > int.MaxValue) { useTotal = (int)(total / 0x10000); useCurrent = (int)(current / 0x10000); } else { useTotal = (int)total; useCurrent = (int)current; } if (progressBar1.Maximum != useTotal) { progressBar1.Maximum = useTotal; } if (progressBar1.Value != useCurrent) { progressBar1.Value = useCurrent; } if (progressBar1.Visible == false && progressBar1.Maximum > 0) { progressBar1.Visible = true; } if (subTotal > -1) { if (progressBar2.Maximum != subTotal) { progressBar2.Maximum = subTotal; } progressBar2.Value = subCurrent; if (progressBar2.Visible == false && progressBar2.Maximum > 0) { progressBar2.Visible = true; } } else { progressBar2.Visible = false; } if (taskHwnd == null) { taskHwnd = Windows7Taskbar.GetTaskBarForm(this); } if (taskHwnd.Value != IntPtr.Zero) { Windows7Taskbar.SetProgressValue(taskHwnd.Value, (uint)current, (uint)total); } }