Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15320


Ignore:
Timestamp:
08/10/17 13:53:08 (7 years ago)
Author:
pfleck
Message:

#1666 Adapted ProgressView so that 0 is a valid ProgressValue. Small refactorings.

Location:
branches/SimplifierViewsProgress
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/SimplifierViewsProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r14297 r15320  
    146146        try {
    147147          Invoke((Action)UpdateProgressValue);
    148         }
    149         catch (InvalidOperationException) {
     148        } catch (InvalidOperationException) {
    150149          // swallow ObjectDisposedException
    151150          // which might occur if the invoke call is executed after or while the control is disposing
     
    154153        if (content != null) {
    155154          double progressValue = content.ProgressValue;
    156           if (progressValue <= 0.0 || progressValue > 1.0) {
     155          if (progressValue < 0.0 || progressValue > 1.0) {
    157156            progressBar.Style = ProgressBarStyle.Marquee;
    158157          } else {
  • branches/SimplifierViewsProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r14185 r15320  
    230230    }
    231231
    232     public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent {
     232    public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, IContent {
    233233      if (content == null) throw new ArgumentNullException("Content cannot be null.");
    234234      if (!reuseExistingView) return ShowContent(content);
     
    353353    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
    354354    /// </summary>
    355     public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     355    public IProgress AddOperationProgressToContent(IContent content, string progressMessage, double progressValue = -1, bool addToObjectGraphObjects = true) {
    356356      if (InvokeRequired) {
    357         IProgress result = (IProgress)Invoke((Func<IContent, string, bool, IProgress>)AddOperationProgressToContent, content, progressMessage, addToObjectGraphObjects);
     357        IProgress result = (IProgress)Invoke((Func<IContent, string, double, bool, IProgress>)AddOperationProgressToContent, content, progressMessage, progressValue, addToObjectGraphObjects);
    358358        return result;
    359359      }
     
    371371        contentViews = contentViews.Where(v => v.Content == content);
    372372
    373       var progress = new Progress(progressMessage, ProgressState.Started);
     373      var progress = new Progress(progressMessage, ProgressState.Started, progressValue);
    374374      foreach (var contentView in contentViews) {
    375375        progressViews.Add(new ProgressView(contentView, progress));
     
    560560      try {
    561561        ((IActionUserInterfaceItem)item.Tag).Execute();
    562       }
    563       catch (Exception ex) {
     562      } catch (Exception ex) {
    564563        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    565564      }
  • branches/SimplifierViewsProgress/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs

    r14185 r15320  
    6363    /// Starts or restarts a Progress.
    6464    /// </summary>
    65     void Start();
    66 
    67     void Start(string status);
     65    void Start(string status = null, double progressValue = -1.0);
    6866
    6967    /// <summary>
  • branches/SimplifierViewsProgress/HeuristicLab.MainForm/3.3/Progress.cs

    r14185 r15320  
    6868    }
    6969
    70     public Progress() {
    71       progressState = ProgressState.Finished;
    72       canBeCanceled = false;
    73     }
    74     public Progress(string status)
    75       : this() {
    76       this.status = status;
    77     }
    78     public Progress(string status, ProgressState state)
    79       : this() {
     70    public Progress(string status = null, ProgressState state = ProgressState.Finished, double progressValue = -1)
     71      : base() {
    8072      this.status = status;
    8173      this.progressState = state;
     74      this.progressValue = progressValue;
    8275    }
    8376
     
    9285    }
    9386
    94     public void Start() {
    95       ProgressValue = 0.0;
     87    public void Start(string status = null, double progressValue = -1.0) {
    9688      ProgressState = ProgressState.Started;
    97     }
    98 
    99     public void Start(string status) {
    100       Start();
    10189      Status = status;
     90      ProgressValue = progressValue;
    10291    }
    10392
Note: See TracChangeset for help on using the changeset viewer.