Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/13 23:08:47 (11 years ago)
Author:
ascheibe
Message:

#1042

  • applied mkommends progress view patch
  • adapted Hive views accordingly
  • made some minor improvements (more to come...)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r9865 r9893  
    3030namespace HeuristicLab.MainForm.WindowsForms {
    3131  public partial class MainForm : Form, IMainForm {
    32     private readonly Dictionary<IContent, IProgress> contentProgressLookup;
    33     private readonly Dictionary<IView, IProgress> viewProgressLookup;
    3432    private bool initialized;
    3533    private int appStartingCursors;
     
    4139      this.views = new Dictionary<IView, Form>();
    4240      this.userInterfaceItems = new List<IUserInterfaceItem>();
    43       this.contentProgressLookup = new Dictionary<IContent, IProgress>();
    44       this.viewProgressLookup = new Dictionary<IView, IProgress>();
    4541      this.initialized = false;
    4642      this.showContentInViewHost = false;
     
    347343        CloseView(view, closeReason);
    348344    }
     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>();
    349351
    350352    /// <summary>
     
    355357        throw new ArgumentException("A progress is already registered for the specified content.", "content");
    356358
    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
    358363      if (addToObjectGraphObjects) {
    359364        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));
    361366      } 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      }
    367373
    368374      contentProgressLookup[content] = progress;
     
    376382        throw new ArgumentException("A progress is already registered for the specified view.", "view");
    377383
    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));
    380389      viewProgressLookup[view] = progress;
    381390    }
     
    390399
    391400      progress.Finish();
     401      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
     402        progressView.Dispose();
     403        progressViews.Remove(progressView);
     404      }
    392405      contentProgressLookup.Remove(content);
    393406    }
     
    402415
    403416      progress.Finish();
     417      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
     418        progressView.Dispose();
     419        progressViews.Remove(progressView);
     420      }
    404421      viewProgressLookup.Remove(view);
    405422    }
Note: See TracChangeset for help on using the changeset viewer.