Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/16/17 10:30:21 (6 years ago)
Author:
pfleck
Message:

#2845

  • Added an explicit method for StartMarquee.
  • Renamed Add/RemoveOperationProgress methods.
  • Moved progress helpers from MainForm into static Progress methods named Show and Hide.
Location:
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj

    r11623 r15477  
    151151    </Compile>
    152152    <Compile Include="Plugin.cs" />
     153    <Compile Include="Progress.cs" />
    153154    <Compile Include="Views\AsynchronousContentView.cs">
    154155      <SubType>UserControl</SubType>
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r15446 r15477  
    350350    private readonly List<ProgressView> progressViews = new List<ProgressView>();
    351351
    352     public IProgress AddOperationProgressToContent(IContent content, string progressMessage, double? initialProgressValue = null, bool addToObjectGraphObjects = true) {
    353       var progress = new Progress();
    354       if (initialProgressValue.HasValue)
    355         progress.Start(progressMessage, initialProgressValue.Value);
    356       else
    357         progress.Start(progressMessage);
    358       AddOperationProgressToContent(content, progress, addToObjectGraphObjects);
    359       return progress;
    360     }
    361352    /// <summary>
    362353    /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content.
    363354    /// </summary>
    364     public void AddOperationProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
     355    public void AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {
    365356      if (InvokeRequired) {
    366         Invoke((Action<IContent, IProgress, bool>)AddOperationProgressToContent, content, progress, addToObjectGraphObjects);
     357        Invoke((Action<IContent, IProgress, bool>)AddProgressToContent, content, progress, addToObjectGraphObjects);
    367358        return;
    368359      }
     
    387378    }
    388379
    389     public IProgress AddOperationProgressToView(Control control, string progressMessage, double? initialProgressValue = null) {
    390       var progress = new Progress();
    391       if (initialProgressValue.HasValue)
    392         progress.Start(progressMessage, initialProgressValue.Value);
    393       else
    394         progress.Start(progressMessage);
    395       AddOperationProgressToView(control, progress);
    396       return progress;
    397     }
    398380    /// <summary>
    399381    /// Adds a <see cref="ProgressView"/> to the specified view.
    400382    /// </summary>
    401     public void AddOperationProgressToView(Control control, IProgress progress) {
     383    public void AddProgressToView(Control control, IProgress progress) {
    402384      if (InvokeRequired) {
    403         Invoke((Action<Control, IProgress>)AddOperationProgressToView, control, progress);
     385        Invoke((Action<Control, IProgress>)AddProgressToView, control, progress);
    404386        return;
    405387      }
     
    423405    /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content.
    424406    /// </summary>
    425     public void RemoveOperationProgressFromContent(IContent content, bool finishProgress = true) {
     407    public void RemoveProgressFromContent(IContent content, bool finishProgress = true) {
    426408      if (InvokeRequired) {
    427         Invoke((Action<IContent, bool>)RemoveOperationProgressFromContent, content, finishProgress);
     409        Invoke((Action<IContent, bool>)RemoveProgressFromContent, content, finishProgress);
    428410        return;
    429411      }
     
    439421      }
    440422      contentProgressLookup.Remove(content);
    441 
    442423    }
    443424
     
    445426    /// Removes an existing <see cref="ProgressView"/> from the specified view.
    446427    /// </summary>
    447     public void RemoveOperationProgressFromView(Control control, bool finishProgress = true) {
     428    public void RemoveProgressFromView(Control control, bool finishProgress = true) {
    448429      if (InvokeRequired) {
    449         Invoke((Action<Control, bool>)RemoveOperationProgressFromView, control, finishProgress);
     430        Invoke((Action<Control, bool>)RemoveProgressFromView, control, finishProgress);
    450431        return;
    451432      }
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Progress.cs

    r15466 r15477  
    2121
    2222using System;
     23using System.Windows.Forms;
     24using HeuristicLab.Common;
    2325
    2426namespace HeuristicLab.MainForm {
     
    100102    }
    101103
    102     /// <summary>
    103     /// Starts or restarts an "undefined" progress in marquee-mode
    104     /// </summary>
    105     public void Start(string message) {
    106       ProgressState = ProgressState.Started;
    107       ProgressBarMode = ProgressBarMode.Marquee;
    108       Message = message;
    109     }
    110     /// <summary>
    111     /// Starts or restarts a progress in continuous-mode
    112     /// </summary>
    113     public void Start(string message, double progressValue) {
     104    public void Start(string message, double progressValue = 0) {
    114105      ProgressState = ProgressState.Started;
    115106      ProgressBarMode = ProgressBarMode.Continuous;
    116107      ProgressValue = progressValue;
     108      Message = message;
     109    }
     110    public void StartMarquee(string message) {
     111      ProgressState = ProgressState.Started;
     112      ProgressBarMode = ProgressBarMode.Marquee;
    117113      Message = message;
    118114    }
     
    137133    }
    138134
     135    #region Show/Hide Progress
     136    /// <summary>
     137    /// Shows a started Progress in Continuous-mode on all Views of the specified content.
     138    /// </summary>
     139    public static IProgress Show(IContent content, string progressMessage, double initialProgressValue = 0, bool addToObjectGraphObjects = true) {
     140      var progress = new Progress();
     141      progress.Start(progressMessage, initialProgressValue);
     142      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects);
     143      return progress;
     144    }
     145    /// <summary>
     146    /// Shows a started Progress in Marquee-mode on all Views of the specified content.
     147    /// </summary>
     148    public static IProgress ShowMarquee(IContent content, string progressMessage, bool addToObjectGraphObjects = true) {
     149      var progress = new Progress();
     150      progress.StartMarquee(progressMessage);
     151      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects);
     152      return progress;
     153    }
     154
     155    /// <summary>
     156    /// Shows a started Progress in Continuous-mode on the specified view.
     157    /// </summary>
     158    public static IProgress Show(Control control, string progressMessage, double initialProgressValue = 0) {
     159      var progress = new Progress();
     160      progress.Start(progressMessage, initialProgressValue);
     161      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress);
     162      return progress;
     163    }
     164    /// <summary>
     165    /// Shows a started Progress in Marquee-mode on the specified view.
     166    /// </summary>
     167    public static IProgress ShowMarquee(Control control, string progressMessage) {
     168      var progress = new Progress();
     169      progress.StartMarquee(progressMessage);
     170      MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress);
     171      return progress;
     172    }
     173
     174    /// <summary>
     175    /// Hides the Progress fom all Views of the specified content.
     176    /// </summary>
     177    public static void Hide(IContent content) {
     178      MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromContent(content);
     179    }
     180    /// <summary>
     181    /// Hides the Progress fom the specified view.
     182    /// </summary>
     183    public static void Hide(Control control) {
     184      MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromView(control);
     185    }
     186    #endregion
     187
    139188    #region Event Handler
    140189    public event EventHandler ProgressStateChanged;
Note: See TracChangeset for help on using the changeset viewer.