- Timestamp:
- 06/28/12 12:00:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Views/ProgressView.cs
r8135 r8145 35 35 progress = value; 36 36 RegisterProgressEvents(); 37 ShowProgress(); 37 38 OnProgressChanged(); 38 39 } … … 48 49 } 49 50 50 /// <param name="parentView">This is the view which will be locked while progress is made.</param> 51 public ProgressView(ContentView parentView, IProgress progress) { 51 private void ShowProgress() { 52 this.Left = (parentView.ClientRectangle.Width / 2) - (this.Width / 2); 53 this.Top = (parentView.ClientRectangle.Height / 2) - (this.Height / 2); 54 this.Anchor = AnchorStyles.Left | AnchorStyles.Top; 55 56 LockBackground(); 57 58 if (!parentView.Controls.Contains(this)) { 59 parentView.Controls.Add(this); 60 } 61 62 BringToFront(); 63 Visible = true; 64 } 65 66 public ProgressView(ContentView parentView) { 52 67 InitializeComponent(); 53 Progress = progress;54 68 CancelEnabled = false; 55 69 56 70 if (parentView != null) { 57 71 this.parentView = parentView; 58 this.Left = (parentView.ClientRectangle.Width / 2) - (this.Width / 2); 59 this.Top = (parentView.ClientRectangle.Height / 2) - (this.Height / 2); 60 this.Anchor = AnchorStyles.Left | AnchorStyles.Top; 61 62 LockBackground(); 63 64 parentView.Controls.Add(this); 65 BringToFront(); 72 } else { 73 throw new ArgumentNullException("The parent view is null."); 66 74 } 67 75 } … … 72 80 progress.StatusChanged += new EventHandler(progress_StatusChanged); 73 81 progress.ProgressValueChanged += new EventHandler(progress_ProgressValueChanged); 82 progress.Canceled += new EventHandler(progress_Canceled); 74 83 } 75 84 … … 79 88 progress.StatusChanged -= new EventHandler(progress_StatusChanged); 80 89 progress.ProgressValueChanged -= new EventHandler(progress_ProgressValueChanged); 90 progress.Canceled -= new EventHandler(progress_Canceled); 81 91 } 82 92 … … 91 101 private void progress_ProgressValueChanged(object sender, EventArgs e) { 92 102 UpdateProgressValue(); 103 } 104 105 void progress_Canceled(object sender, EventArgs e) { 106 Finish(); 93 107 } 94 108 … … 128 142 } 129 143 130 p ublicvoid Finish() {144 private void Finish() { 131 145 if (InvokeRequired) { 132 146 Invoke(new Action(Finish)); … … 139 153 c.Enabled = true; 140 154 DeregisterProgressEvents(); 141 Dispose(); 155 progress = null; 156 this.Visible = false; 142 157 } 143 158 } 144 159 145 160 private void cancelButton_Click(object sender, EventArgs e) { 146 OnCanceled(); 147 Finish(); 161 if (progress != null) { 162 progress.CancelRequested = true; 163 cancelButton.Enabled = false; 164 } 148 165 } 149 166 … … 160 177 UpdateProgressValue(); 161 178 } 162 163 public event EventHandler Canceled;164 protected virtual void OnCanceled() {165 var handler = Canceled;166 if (handler != null) Canceled(this, EventArgs.Empty);167 }168 179 } 169 180 }
Note: See TracChangeset
for help on using the changeset viewer.