- Timestamp:
- 08/05/13 16:16:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r9626 r9849 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; 32 34 private bool initialized; 33 35 private int appStartingCursors; … … 39 41 this.views = new Dictionary<IView, Form>(); 40 42 this.userInterfaceItems = new List<IUserInterfaceItem>(); 43 this.contentProgressLookup = new Dictionary<IContent, IProgress>(); 44 this.viewProgressLookup = new Dictionary<IView, IProgress>(); 41 45 this.initialized = false; 42 46 this.showContentInViewHost = false; … … 343 347 CloseView(view, closeReason); 344 348 } 349 350 /// <summary> 351 /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content. 352 /// </summary> 353 public void AddOperationProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) { 354 if (contentProgressLookup.ContainsKey(content)) 355 throw new ArgumentException("A progress is already registered for the specified content.", "content"); 356 357 var contentViews = Enumerable.Empty<IContentView>(); 358 if (addToObjectGraphObjects) { 359 var containedObjects = content.GetObjectGraphObjects(); 360 contentViews = views.Keys.OfType<IContentView>().Where(v => containedObjects.Contains(v.Content)); 361 } else 362 contentViews = views.Keys.OfType<IContentView>().Where(v => v.Content == content); 363 364 foreach (var contentView in contentViews) 365 ProgressView.Attach(contentView, progress, true); 366 367 contentProgressLookup[content] = progress; 368 } 369 370 /// <summary> 371 /// Adds a <see cref="ProgressView"/> to the specified view. 372 /// </summary> 373 public void AddOperationProgressToView(IView view, Progress progress) { 374 if (viewProgressLookup.ContainsKey(view)) 375 throw new ArgumentException("A progress is already registered for the specified view.", "view"); 376 377 ProgressView.Attach(view, progress, true); 378 viewProgressLookup[view] = progress; 379 } 380 381 /// <summary> 382 /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content. 383 /// </summary> 384 public void RemoveOperationProgressFromContent(IContent content) { 385 IProgress progress; 386 if (!contentProgressLookup.TryGetValue(content, out progress)) 387 throw new ArgumentException("No progress is registered for the specified content.", "content"); 388 389 progress.Finish(); 390 contentProgressLookup.Remove(content); 391 } 392 393 /// <summary> 394 /// Removes an existing <see cref="ProgressView"/> from the specified view. 395 /// </summary> 396 public void RemoveOperationProgressFromView(IView view) { 397 IProgress progress; 398 if (!viewProgressLookup.TryGetValue(view, out progress)) 399 throw new ArgumentException("No progress is registered for the specified view.", "view"); 400 401 progress.Finish(); 402 viewProgressLookup.Remove(view); 403 } 345 404 #endregion 346 405
Note: See TracChangeset
for help on using the changeset viewer.