Changeset 9894 for trunk/sources/HeuristicLab.MainForm.WindowsForms
- Timestamp:
- 08/22/13 11:31:32 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.