Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/22/13 11:31:32 (11 years ago)
Author:
ascheibe
Message:

#1042

  • changed Hive views to use MainForm for progress handling
  • removed Cancel timeout
  • setter for ProgressState is now private
  • added Start methods to Progress
  • removed unused methods from RefreshableHiveJobView
File:
1 edited

Legend:

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

    r9893 r9894  
    353353    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
    354354    /// </summary>
    355     public void AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     355    public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
    356356      if (contentProgressLookup.ContainsKey(content))
    357357        throw new ArgumentException("A progress is already registered for the specified content.", "content");
     
    373373
    374374      contentProgressLookup[content] = progress;
     375      return progress;
    375376    }
    376377
     
    378379    /// Adds a <see cref="ProgressView"/> to the specified view.
    379380    /// </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.");
    383390
    384391      var control = view as Control;
    385392      if (control == null) throw new ArgumentException("The passed view must be a control.", "view");
    386393
    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
    388403      progressViews.Add(new ProgressView(control, progress));
    389404      viewProgressLookup[view] = progress;
     
    393408    /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content.
    394409    /// </summary>
    395     public void RemoveOperationProgressFromContent(IContent content) {
     410    public void RemoveOperationProgressFromContent(IContent content, bool finishProgress = true) {
    396411      IProgress progress;
    397412      if (!contentProgressLookup.TryGetValue(content, out progress))
    398413        throw new ArgumentException("No progress is registered for the specified content.", "content");
    399414
    400       progress.Finish();
     415      if (finishProgress) progress.Finish();
    401416      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
    402417        progressView.Dispose();
     
    409424    /// Removes an existing <see cref="ProgressView"/> from the specified view.
    410425    /// </summary>
    411     public void RemoveOperationProgressFromView(IView view) {
     426    public void RemoveOperationProgressFromView(IView view, bool finishProgress = true) {
    412427      IProgress progress;
    413428      if (!viewProgressLookup.TryGetValue(view, out progress))
    414429        throw new ArgumentException("No progress is registered for the specified view.", "view");
    415430
    416       progress.Finish();
     431      if (finishProgress) progress.Finish();
    417432      foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) {
    418433        progressView.Dispose();
Note: See TracChangeset for help on using the changeset viewer.