- Timestamp:
- 08/21/13 23:08:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r9865 r9893 30 30 namespace HeuristicLab.MainForm.WindowsForms { 31 31 public partial class MainForm : Form, IMainForm { 32 private readonly Dictionary<IContent, IProgress> contentProgressLookup;33 private readonly Dictionary<IView, IProgress> viewProgressLookup;34 32 private bool initialized; 35 33 private int appStartingCursors; … … 41 39 this.views = new Dictionary<IView, Form>(); 42 40 this.userInterfaceItems = new List<IUserInterfaceItem>(); 43 this.contentProgressLookup = new Dictionary<IContent, IProgress>();44 this.viewProgressLookup = new Dictionary<IView, IProgress>();45 41 this.initialized = false; 46 42 this.showContentInViewHost = false; … … 347 343 CloseView(view, closeReason); 348 344 } 345 #endregion 346 347 #region progress views 348 private readonly Dictionary<IContent, IProgress> contentProgressLookup = new Dictionary<IContent, IProgress>(); 349 private readonly Dictionary<IView, IProgress> viewProgressLookup = new Dictionary<IView, IProgress>(); 350 private readonly List<ProgressView> progressViews = new List<ProgressView>(); 349 351 350 352 /// <summary> … … 355 357 throw new ArgumentException("A progress is already registered for the specified content.", "content"); 356 358 357 var contentViews = Enumerable.Empty<IContentView>(); 359 var contentViews = views.Keys.OfType<ContentView>(); 360 if (!contentViews.Any(v => v.Content == content)) 361 throw new ArgumentException("The content is not displayed in a top-level view", "content"); 362 358 363 if (addToObjectGraphObjects) { 359 364 var containedObjects = content.GetObjectGraphObjects(); 360 contentViews = views.Keys.OfType<IContentView>().Where(v => containedObjects.Contains(v.Content));365 contentViews = contentViews.Where(v => containedObjects.Contains(v.Content)); 361 366 } else 362 contentViews = views.Keys.OfType<IContentView>().Where(v => v.Content == content); 363 364 var progress = new Progress(progressMessage); 365 foreach (var contentView in contentViews) 366 ProgressView.Attach(contentView, progress, true); 367 contentViews = contentViews.Where(v => v.Content == content); 368 369 var progress = new Progress(progressMessage, ProgressState.Started); 370 foreach (var contentView in contentViews) { 371 progressViews.Add(new ProgressView((Control)contentView, progress)); 372 } 367 373 368 374 contentProgressLookup[content] = progress; … … 376 382 throw new ArgumentException("A progress is already registered for the specified view.", "view"); 377 383 378 var progress = new Progress(progressMessage); 379 ProgressView.Attach(view, progress, true); 384 var control = view as Control; 385 if (control == null) throw new ArgumentException("The passed view must be a control.", "view"); 386 387 var progress = new Progress(progressMessage, ProgressState.Started); 388 progressViews.Add(new ProgressView(control, progress)); 380 389 viewProgressLookup[view] = progress; 381 390 } … … 390 399 391 400 progress.Finish(); 401 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 402 progressView.Dispose(); 403 progressViews.Remove(progressView); 404 } 392 405 contentProgressLookup.Remove(content); 393 406 } … … 402 415 403 416 progress.Finish(); 417 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 418 progressView.Dispose(); 419 progressViews.Remove(progressView); 420 } 404 421 viewProgressLookup.Remove(view); 405 422 }
Note: See TracChangeset
for help on using the changeset viewer.