Changeset 9894
- Timestamp:
- 08/22/13 11:31:32 (11 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r9893 r9894 42 42 private ISet<TreeNode> filteredTreeNodes; 43 43 private ISet<TreeNode> nodeStore; 44 private Progress progress; 45 private ProgressView progressView; 46 44 47 45 private ISet<Resource> selectedResources; 48 46 public ISet<Resource> SelectedResources { … … 64 62 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge); 65 63 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge); 66 progress = new Progress(); 67 } 68 69 protected override void DeregisterContentEvents() { 70 if (progressView != null) { 71 progressView.Dispose(); 72 progressView = null; 73 } 74 base.DeregisterContentEvents(); 75 } 76 77 protected override void RegisterContentEvents() { 78 base.RegisterContentEvents(); 79 progressView = new ProgressView(this, progress); 80 } 81 64 } 65 82 66 public void StartProgressView() { 83 67 if (InvokeRequired) { 84 68 Invoke(new Action(StartProgressView)); 85 69 } else { 86 progress.Status= "Downloading resources. Please be patient.";87 progress.ProgressState = ProgressState.Started;70 var message = "Downloading resources. Please be patient."; 71 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 88 72 } 89 73 } … … 93 77 Invoke(new Action(FinishProgressView)); 94 78 } else { 95 progress.Finish();79 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 96 80 } 97 81 } -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r9893 r9894 34 34 [Content(typeof(ItemCollection<RefreshableJob>), false)] 35 35 public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> { 36 private Progress progress;37 private ProgressView progressView;38 39 36 public RefreshableHiveJobListView() { 40 37 InitializeComponent(); … … 49 46 50 47 this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending); 51 52 progress = new Progress();53 progressView = new ProgressView(this, progress);54 48 } 55 49 … … 115 109 116 110 task.ContinueWith((t) => { 117 progress.Finish();111 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 118 112 ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception); 119 113 }, TaskContinuationOptions.OnlyOnFaulted); … … 126 120 127 121 private void DeleteHiveJobsAsync(object items) { 128 progress.Start("Deleting job...");122 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Deleting job..."); 129 123 foreach (RefreshableJob item in (List<RefreshableJob>)items) { 130 124 Content.Remove(item); 131 125 } 132 progress.Finish();126 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 133 127 } 134 128 … … 222 216 if (disposing) { 223 217 if (components != null) components.Dispose(); 224 progressView.Dispose();225 progressView = null;226 218 } 227 219 base.Dispose(disposing); -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r9893 r9894 42 42 [Content(typeof(RefreshableJob), true)] 43 43 public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView { 44 private ProgressView progressView;45 44 private HiveResourceSelectorDialog hiveResourceSelectorDialog; 46 45 private bool SuppressEvents { get; set; } … … 72 71 Content.Loaded += new EventHandler(Content_Loaded); 73 72 Content.TaskReceived += new EventHandler(Content_TaskReceived); 74 progressView = new ProgressView(this, Content.Progress);73 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress); 75 74 } 76 75 … … 87 86 Content.Loaded -= new EventHandler(Content_Loaded); 88 87 Content.TaskReceived -= new EventHandler(Content_TaskReceived); 89 if (progressView != null) { 90 progressView.Dispose(); 91 progressView = null; 92 } 88 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false); 93 89 DeregisterHiveExperimentEvents(); 94 90 DeregisterHiveTasksEvents(); … … 251 247 SetEnabledStateOfControls(); 252 248 } 253 private void Content_Prepared(object sender, EventArgs e) { 254 if (InvokeRequired) 255 Invoke(new EventHandler(Content_Prepared), sender, e); 256 else { 257 nameTextBox.Enabled = true; 258 Locked = false; 259 SetEnabledStateOfControls(); 260 } 261 } 262 private void Content_Started(object sender, EventArgs e) { 263 if (InvokeRequired) 264 Invoke(new EventHandler(Content_Started), sender, e); 265 else { 266 nameTextBox.Enabled = false; 267 SetEnabledStateOfControls(); 268 } 269 } 270 private void Content_Paused(object sender, EventArgs e) { 271 if (InvokeRequired) 272 Invoke(new EventHandler(Content_Paused), sender, e); 273 else { 274 nameTextBox.Enabled = true; 275 SetEnabledStateOfControls(); 276 } 277 } 278 private void Content_Stopped(object sender, EventArgs e) { 279 if (InvokeRequired) 280 Invoke(new EventHandler(Content_Stopped), sender, e); 281 else { 282 nameTextBox.Enabled = true; 283 Locked = false; 284 SetEnabledStateOfControls(); 285 } 286 } 249 287 250 private void Content_ExecutionTimeChanged(object sender, EventArgs e) { 288 251 if (InvokeRequired) -
trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r9893 r9894 32 32 public partial class OptimizerHiveTaskView : HiveTaskView { 33 33 private Progress progress; 34 private ProgressView progressView; 35 34 36 35 public new OptimizerHiveTask Content { 37 36 get { return (OptimizerHiveTask)base.Content; } … … 61 60 base.RegisterContentEvents(); 62 61 Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged); 63 progressView = new ProgressView(this, progress);62 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, progress); 64 63 } 65 64 66 65 protected override void DeregisterContentEvents() { 67 66 Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged); 68 if (progressView != null) { 69 progressView.Dispose(); 70 progressView = null; 71 } 67 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false); 72 68 base.DeregisterContentEvents(); 73 69 } -
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r9893 r9894 54 54 Algorithm selectedAlgorithm = null; 55 55 Problem selectedProblem = null; 56 private ProgressView progressView;57 private Progress progress;58 56 59 57 public OKBExperimentUploadView() { 60 58 InitializeComponent(); 61 progress = new Progress();62 59 } 63 60 … … 93 90 RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing); 94 91 RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed); 95 progressView = new ProgressView(this, progress);96 92 } 97 93 … … 99 95 RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing); 100 96 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 101 if (progressView != null) { 102 progressView.Dispose(); 103 progressView = null; 104 } 97 105 98 base.DeregisterContentEvents(); 106 99 } … … 194 187 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 195 188 } else { 196 progress.Status= "Refreshing algorithms and problems...";197 progress.ProgressState = ProgressState.Started;189 var message = "Refreshing algorithms and problems..."; 190 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 198 191 } 199 192 } … … 203 196 Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e); 204 197 } else { 205 progress.Finish();198 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 206 199 SetEnabledStateOfControls(); 207 200 } … … 211 204 var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync); 212 205 task.ContinueWith((t) => { 213 progress.Finish();206 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 214 207 PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception); 215 208 }, TaskContinuationOptions.OnlyOnFaulted); … … 217 210 218 211 private void UploadAsync() { 219 progress.Status = "Uploading runs to OKB..."; 220 progress.ProgressValue = 0; 221 progress.ProgressState = ProgressState.Started; 212 var message = "Uploading runs to OKB..."; 213 IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 222 214 double count = dataGridView.Rows.Count; 223 215 int i = 0; … … 234 226 progress.ProgressValue = ((double)i) / count; 235 227 } 236 progress.Finish();228 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 237 229 ClearRuns(); 238 230 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r9893 r9894 24 24 25 25 namespace HeuristicLab.MainForm.WindowsForms { 26 publicsealed partial class ProgressView : UserControl {26 internal sealed partial class ProgressView : UserControl { 27 27 private readonly Control control; 28 28 public Control Control { … … 46 46 ShowProgress(); 47 47 RegisterContentEvents(); 48 } 49 50 /// <summary> 51 /// Clean up any resources being used. 52 /// </summary> 53 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 54 protected override void Dispose(bool disposing) { 55 DeregisterContentEvents(); 56 HideProgress(); 57 58 if (disposing && (components != null)) { 59 components.Dispose(); 60 } 61 base.Dispose(disposing); 48 62 } 49 63 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.designer.cs
r9893 r9894 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary> 30 /// Clean up any resources being used. 31 /// </summary> 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 protected override void Dispose(bool disposing) { 34 DeregisterContentEvents(); 35 if (disposing && (components != null)) { 36 components.Dispose(); 37 } 38 base.Dispose(disposing); 39 } 40 29 41 30 #region Component Designer generated code 42 31 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r9893 r9894 353 353 /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content. 354 354 /// </summary> 355 public voidAddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {355 public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) { 356 356 if (contentProgressLookup.ContainsKey(content)) 357 357 throw new ArgumentException("A progress is already registered for the specified content.", "content"); … … 373 373 374 374 contentProgressLookup[content] = progress; 375 return progress; 375 376 } 376 377 … … 378 379 /// Adds a <see cref="ProgressView"/> to the specified view. 379 380 /// </summary> 380 public void AddOperationProgressToView(IView view, string progressMessage) { 381 if (viewProgressLookup.ContainsKey(view)) 382 throw new ArgumentException("A progress is already registered for the specified view.", "view"); 381 public IProgress AddOperationProgressToView(IView view, string progressMessage) { 382 var progress = new Progress(progressMessage, ProgressState.Started); 383 AddOperationProgressToView(view, progress); 384 return progress; 385 } 386 387 public void AddOperationProgressToView(IView view, IProgress progress) { 388 if (view == null) throw new ArgumentNullException("view", "The view must not be null."); 389 if (progress == null) throw new ArgumentNullException("progress", "The progress must not be null."); 383 390 384 391 var control = view as Control; 385 392 if (control == null) throw new ArgumentException("The passed view must be a control.", "view"); 386 393 387 var progress = new Progress(progressMessage, ProgressState.Started); 394 IProgress oldProgress; 395 if (viewProgressLookup.TryGetValue(view, out oldProgress)) { 396 foreach (var progressView in progressViews.Where(v => v.Content == oldProgress).ToList()) { 397 progressView.Dispose(); 398 progressViews.Remove(progressView); 399 } 400 viewProgressLookup.Remove(view); 401 } 402 388 403 progressViews.Add(new ProgressView(control, progress)); 389 404 viewProgressLookup[view] = progress; … … 393 408 /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content. 394 409 /// </summary> 395 public void RemoveOperationProgressFromContent(IContent content ) {410 public void RemoveOperationProgressFromContent(IContent content, bool finishProgress = true) { 396 411 IProgress progress; 397 412 if (!contentProgressLookup.TryGetValue(content, out progress)) 398 413 throw new ArgumentException("No progress is registered for the specified content.", "content"); 399 414 400 progress.Finish();415 if (finishProgress) progress.Finish(); 401 416 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 402 417 progressView.Dispose(); … … 409 424 /// Removes an existing <see cref="ProgressView"/> from the specified view. 410 425 /// </summary> 411 public void RemoveOperationProgressFromView(IView view ) {426 public void RemoveOperationProgressFromView(IView view, bool finishProgress = true) { 412 427 IProgress progress; 413 428 if (!viewProgressLookup.TryGetValue(view, out progress)) 414 429 throw new ArgumentException("No progress is registered for the specified view.", "view"); 415 430 416 progress.Finish();431 if (finishProgress) progress.Finish(); 417 432 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 418 433 progressView.Dispose(); -
trunk/sources/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs
r9893 r9894 41 41 /// If it is reused it may be Started again. 42 42 /// </summary> 43 ProgressState ProgressState { get; set;}43 ProgressState ProgressState { get; } 44 44 /// <summary> 45 45 /// Returns whether the operation can be canceled or not. … … 54 54 /// </summary> 55 55 /// <exception cref="NotSupportedException">Thrown when cancellation is not supported.</exception> 56 /// <param name="timeoutMs">The operation is given a certain timeout to cancel. If the operation doesn't cancel in this time it will be forcibly closed.</param> 57 void Cancel(int timeoutMs = 0); 56 void Cancel(); 58 57 /// <summary> 59 58 /// Sets the ProgressValue to 1 and the ProgressState to Finished. … … 61 60 void Finish(); 62 61 62 /// <summary> 63 /// Starts or restarts a Progress. 64 /// </summary> 65 void Start(); 66 63 67 void Start(string status); 64 65 void Start();66 68 67 69 /// <summary> … … 82 84 event EventHandler CanBeCanceledChanged; 83 85 /// <summary> 84 /// A cancelation is requested with a certain timeout (in ms) in which it should occur gracefully. If the timeout is surpassed, it should be forcibly canceled.86 /// A cancelation is requested. 85 87 /// </summary> 86 event EventHandler <EventArgs<int>>CancelRequested;88 event EventHandler CancelRequested; 87 89 } 88 90 } -
trunk/sources/HeuristicLab.MainForm/3.3/Progress.cs
r9893 r9894 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 25 24 namespace HeuristicLab.MainForm { … … 50 49 public ProgressState ProgressState { 51 50 get { return progressState; } 52 set {51 private set { 53 52 if (progressState != value) { 54 53 progressState = value; … … 83 82 } 84 83 85 public void Cancel( int timeoutMs = 0) {84 public void Cancel() { 86 85 if (canBeCanceled) 87 OnCancelRequested( timeoutMs);86 OnCancelRequested(); 88 87 } 89 88 … … 126 125 var handler = CanBeCanceledChanged; 127 126 if (handler != null) handler(this, EventArgs.Empty); 128 129 127 } 130 128 131 public event EventHandler <EventArgs<int>>CancelRequested;132 private void OnCancelRequested( int timeoutMs) {129 public event EventHandler CancelRequested; 130 private void OnCancelRequested() { 133 131 var handler = CancelRequested; 134 132 if (handler != null) throw new NotSupportedException("Cancel request was ignored."); 135 else handler(this, new EventArgs<int>(timeoutMs));133 else handler(this, EventArgs.Empty); 136 134 } 137 135 #endregion
Note: See TracChangeset
for help on using the changeset viewer.