Changeset 15 for Common/FormProgress.cs
- Timestamp:
- Jun 18, 2024, 12:15:33 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/FormProgress.cs
r14 r15 2 2 using System.Collections.Generic; 3 3 using System.ComponentModel; 4 using System.Drawing;5 4 using System.Linq; 6 5 using System.Windows.Forms; … … 8 7 namespace Common 9 8 { 10 public partial class FormProgress : Form 9 public partial class FormProgress : FormEx 11 10 { 12 11 public List<Progress> Tasks; 13 12 public DateTime StartTime; 14 13 public Progress CurrentTask; 14 private bool _canClose; 15 15 16 16 public FormProgress() … … 20 20 Tasks = new List<Progress>(); 21 21 CurrentTask = null; 22 _canClose = false; 22 23 } 23 24 24 25 private void timer1_Tick(object sender, EventArgs e) 25 26 { 26 int steps = 10000;27 const int steps = 10000; 27 28 int total = Tasks.Count * steps; 28 29 int current; … … 48 49 } 49 50 else labelTime.Text = ""; 51 52 // Update task bar progress 53 if (progressBar1.Value < progressBar1.Maximum) 54 { 55 TaskBarProgress.SetValue(Handle, progressBar1.Value, progressBar1.Maximum); 56 if (progressBar1.Value == 0) 57 { 58 TaskBarProgress.SetState(Handle, TaskBarProgress.TaskBarStates.Indeterminate); 59 } 60 } 61 else 62 { 63 TaskBarProgress.SetState(Handle, TaskBarProgress.TaskBarStates.NoProgress); 64 } 50 65 } 51 66 52 67 private void FormProgress_Load(object sender, EventArgs e) 53 68 { 54 Theme.UseTheme(this);55 DpiScaling.Apply(this);56 Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);57 58 69 timer1_Tick(this, null); 59 70 timer1.Enabled = true; … … 63 74 private void FormProgress_FormClosing(object sender, FormClosingEventArgs e) 64 75 { 76 e.Cancel = !_canClose; 65 77 CurrentTask.Terminated = true; 66 78 timer1.Enabled = false; … … 86 98 { 87 99 CurrentTask = Tasks[nextIndex]; 88 BackgroundWorker b g= new BackgroundWorker();89 b g.DoWork += bg_DoWork;90 b g.RunWorkerCompleted += bg_DoWorkerCompleted;91 b g.RunWorkerAsync();100 BackgroundWorker backgroundWorker = new BackgroundWorker(); 101 backgroundWorker.DoWork += bg_DoWork; 102 backgroundWorker.RunWorkerCompleted += bg_DoWorkerCompleted; 103 backgroundWorker.RunWorkerAsync(); 92 104 } 93 else Close(); 94 } 95 else Close(); 105 else 106 { 107 _canClose = true; 108 Close(); 109 } 110 } 111 else 112 { 113 _canClose = true; 114 Close(); 115 } 96 116 } 97 117 … … 122 142 StartTime = DateTime.Now; 123 143 CurrentTask = Tasks.First(); 124 BackgroundWorker b g= new BackgroundWorker();125 b g.DoWork += bg_DoWork;126 b g.RunWorkerCompleted += bg_DoWorkerCompleted;127 b g.RunWorkerAsync();144 BackgroundWorker backgroundWorker = new BackgroundWorker(); 145 backgroundWorker.DoWork += bg_DoWork; 146 backgroundWorker.RunWorkerCompleted += bg_DoWorkerCompleted; 147 backgroundWorker.RunWorkerAsync(); 128 148 ShowDialog(); 129 149 }
Note:
See TracChangeset
for help on using the changeset viewer.