Changeset 8145
- Timestamp:
- 06/28/12 12:00:51 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs
r8143 r8145 35 35 36 36 private ProgressView progressView; 37 IProgress progress; 37 38 38 39 public ClientView() { 39 40 InitializeComponent(); 41 progressView = new ProgressView(this); 40 42 } 41 43 … … 82 84 Invoke(new Action(StartProgressView)); 83 85 } else { 84 if (progressView == null) { 85 IProgress prog = new Progress(); 86 prog.Status = "Downloading client information. Please be patient."; 87 progressView = new ProgressView(this, prog); 88 } 86 progress = new Progress(); 87 progress.Status = "Downloading client information. Please be patient."; 88 progressView.Progress = progress; 89 89 } 90 90 } … … 94 94 Invoke(new Action(FinishProgressView)); 95 95 } else { 96 if (progressView != null) { 97 progressView.Finish(); 98 progressView = null; 99 SetEnabledStateOfControls(); 100 } 96 progress.Finish(); 97 SetEnabledStateOfControls(); 101 98 } 102 99 } -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r7928 r8145 42 42 private ISet<TreeNode> filteredTreeNodes; 43 43 private ISet<TreeNode> nodeStore; 44 private IProgress currentProgress; 44 45 45 46 private ISet<Resource> selectedResources; … … 68 69 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge); 69 70 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge); 71 progressView = new ProgressView(this); 70 72 } 71 73 … … 74 76 Invoke(new Action(StartProgressView)); 75 77 } else { 76 if (progressView == null) { 77 IProgress prog = new Progress(); 78 prog.Status = "Downloading resources. Please be patient."; 79 progressView = new ProgressView(this, prog); 80 } 78 currentProgress = new Progress(); 79 currentProgress.Status = "Downloading resources. Please be patient."; 80 progressView.Progress = currentProgress; 81 81 } 82 82 } … … 86 86 Invoke(new Action(FinishProgressView)); 87 87 } else { 88 if (progressView != null) { 89 progressView.Finish(); 90 progressView = null; 91 SetEnabledStateOfControls(); 92 } 88 currentProgress.Finish(); 89 SetEnabledStateOfControls(); 93 90 } 94 91 } -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r8109 r8145 55 55 public RefreshableHiveJobView() { 56 56 InitializeComponent(); 57 progressView = new ProgressView(this); 57 58 } 58 59 … … 475 476 Invoke(new Action(SetProgressView)); 476 477 } else { 477 if (progressView == null) { 478 progressView = new ProgressView(this, Content.Progress); 479 } else { 480 progressView.Progress = Content.Progress; 481 } 478 progressView.Progress = Content.Progress; 482 479 } 483 480 } … … 487 484 Invoke(new Action<IProgress>(SetProgressView), progress); 488 485 } else { 489 if (progressView == null) { 490 progressView = new ProgressView(this, progress); 491 } else { 492 progressView.Progress = progress; 493 } 486 progressView.Progress = progress; 494 487 } 495 488 } … … 499 492 Invoke(new Action(FinishProgressView)); 500 493 } else { 501 if (progressView != null) { 502 progressView.Finish(); 503 progressView = null; 504 SetEnabledStateOfControls(); 505 } 494 if (Content.Progress != null) 495 Content.Progress.Finish(); 496 SetEnabledStateOfControls(); 506 497 } 507 498 } -
trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r7582 r8145 32 32 public partial class OptimizerHiveTaskView : HiveTaskView { 33 33 private ProgressView progressView; 34 private IProgress progress; 34 35 35 36 public new OptimizerHiveTask Content { … … 44 45 public OptimizerHiveTaskView() { 45 46 InitializeComponent(); 47 progressView = new ProgressView(this); 46 48 } 47 49 … … 97 99 98 100 private void PauseTaskAsync() { 99 IProgress prog= new Progress();100 prog .Status = "Pausing task. Please be patient for the command to take effect.";101 SetProgressView(prog );101 progress = new Progress(); 102 progress.Status = "Pausing task. Please be patient for the command to take effect."; 103 SetProgressView(progress); 102 104 Content.Pause(); 103 105 FinishProgressView(); … … 105 107 106 108 private void StopTaskAsync() { 107 IProgress prog= new Progress();108 prog .Status = "Stopping task. Please be patient for the command to take effect.";109 SetProgressView(prog );109 progress = new Progress(); 110 progress.Status = "Stopping task. Please be patient for the command to take effect."; 111 SetProgressView(progress); 110 112 Content.Stop(); 111 113 FinishProgressView(); … … 113 115 114 116 private void ResumeTaskAsync() { 115 IProgress prog= new Progress();116 prog .Status = "Resuming task. Please be patient for the command to take effect.";117 SetProgressView(prog );117 progress = new Progress(); 118 progress.Status = "Resuming task. Please be patient for the command to take effect."; 119 SetProgressView(progress); 118 120 Content.Restart(); 119 121 FinishProgressView(); … … 124 126 Invoke(new Action<IProgress>(SetProgressView), progress); 125 127 } else { 126 if (progressView == null) { 127 progressView = new ProgressView(this, progress); 128 } else { 129 progressView.Progress = progress; 130 } 128 progressView.Progress = progress; 131 129 } 132 130 } … … 136 134 Invoke(new Action(FinishProgressView)); 137 135 } else { 138 if (progressView != null) { 139 progressView.Finish(); 140 progressView = null; 141 SetEnabledStateOfControls(); 142 } 136 progress.Finish(); 137 SetEnabledStateOfControls(); 143 138 } 144 139 } -
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r8117 r8145 57 57 Problem selectedProblem = null; 58 58 private ProgressView progressView; 59 private IProgress progress; 59 60 60 61 public OKBExperimentUploadView() { 61 62 InitializeComponent(); 63 progressView = new ProgressView(this); 62 64 } 63 65 … … 176 178 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 177 179 } else { 178 IProgress prog= new Progress();179 prog .Status = "Refreshing algorithms and problems...";180 SetProgressView(prog );180 progress = new Progress(); 181 progress.Status = "Refreshing algorithms and problems..."; 182 SetProgressView(progress); 181 183 } 182 184 } … … 200 202 201 203 private void UploadAsync() { 202 IProgress prog= new Progress();203 prog .Status = "Uploading runs to OKB...";204 prog .ProgressValue = 0;204 progress = new Progress(); 205 progress.Status = "Uploading runs to OKB..."; 206 progress.ProgressValue = 0; 205 207 double count = dataGridView.Rows.Count; 206 208 int i = 0; 207 209 208 SetProgressView(prog );210 SetProgressView(progress); 209 211 foreach (DataGridViewRow row in dataGridView.Rows) { 210 212 selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault(); … … 217 219 run.Store(); 218 220 i++; 219 prog .ProgressValue = ((double)i) / count;221 progress.ProgressValue = ((double)i) / count; 220 222 } 221 223 FinishProgressView(); … … 226 228 Invoke(new Action<IProgress>(SetProgressView), progress); 227 229 } else { 228 if (progressView == null) { 229 progressView = new ProgressView(this, progress); 230 } else { 231 progressView.Progress = progress; 232 } 230 progressView.Progress = progress; 233 231 } 234 232 } … … 238 236 Invoke(new Action(FinishProgressView)); 239 237 } else { 240 if (progressView != null) { 241 progressView.Finish(); 242 progressView = null; 243 SetEnabledStateOfControls(); 244 ClearRuns(); 245 } 238 progress.Finish(); 239 SetEnabledStateOfControls(); 240 ClearRuns(); 246 241 } 247 242 } -
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 } -
trunk/sources/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs
r7582 r8145 28 28 29 29 void Finish(); 30 void SignalSuccessfulCancelation(); 30 31 31 32 event EventHandler Finished; 32 33 event EventHandler StatusChanged; 33 34 event EventHandler ProgressValueChanged; 35 36 bool CancelRequested { get; set; } 37 event EventHandler Canceled; 38 39 34 40 } 35 41 } -
trunk/sources/HeuristicLab.MainForm/3.3/Progress.cs
r7582 r8145 37 37 } 38 38 39 public bool CancelRequested { get; set; } 40 39 41 private double progressValue; 40 42 public double ProgressValue { … … 60 62 } 61 63 64 public void SignalSuccessfulCancelation() { 65 OnCanceled(); 66 } 67 62 68 #region Event Handler 69 public event EventHandler Canceled; 70 private void OnCanceled() { 71 var handler = Canceled; 72 try { 73 if (handler != null) handler(this, EventArgs.Empty); 74 } 75 catch (Exception) { } 76 } 77 63 78 public event EventHandler Finished; 64 79 private void OnFinished() {
Note: See TracChangeset
for help on using the changeset viewer.