Ignore:
Timestamp:
09/03/13 15:55:36 (6 years ago)
Author:
ascheibe
Message:

#1042 merged r9849, r9851, r9865, r9867, r9868, r9893, r9894, r9895, r9896, r9900, r9901, r9905, r9907 into stable branch

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs

    r9456 r9933  
    2828  public interface IProgress : IContent {
    2929    /// <summary>
    30     /// Gets the currently associated status text with the progress.
     30    /// Gets or sets the currently associated status text with the progress.
    3131    /// </summary>
    32     string Status { get; }
     32    string Status { get; set; }
    3333    /// <summary>
    34     /// Gets the currently associated progress value in the range (0;1].
     34    /// Gets or sets the currently associated progress value in the range (0;1].
    3535    ///  Values outside this range are permitted and need to be handled in some feasible manner.
    3636    /// </summary>
    37     double ProgressValue { get; }
     37    double ProgressValue { get; set; }
    3838    /// <summary>
    39     /// Gets the current state of the progress. Every progress starts in state
     39    /// Gets or sets the current state of the progress. Every progress starts in state
    4040    /// Started and then becomes either Canceled or Finished.
    4141    /// If it is reused it may be Started again.
     
    5454    /// </summary>
    5555    /// <exception cref="NotSupportedException">Thrown when cancellation is not supported.</exception>
    56     /// <param name="timeoutMs">The operation is given a certain timeout to cancel. If the operation doesn't cancel in this time it will be forcibly closed.</param>
    57     void Cancel(int timeoutMs);
     56    void Cancel();
     57    /// <summary>
     58    /// Sets the ProgressValue to 1 and the ProgressState to Finished.
     59    /// </summary>
     60    void Finish();
     61
     62    /// <summary>
     63    /// Starts or restarts a Progress.
     64    /// </summary>
     65    void Start();
     66
     67    void Start(string status);
    5868
    5969    /// <summary>
     
    7484    event EventHandler CanBeCanceledChanged;
    7585    /// <summary>
    76     /// A cancelation is requested with a certain timeout (in ms) in which it should occur gracefully. If the timeout is surpassed, it should be forcibly canceled.
     86    /// A cancelation is requested.
    7787    /// </summary>
    78     event EventHandler<EventArgs<int>> CancelRequested;
     88    event EventHandler CancelRequested;
    7989  }
    8090}
  • stable/HeuristicLab.MainForm/3.3/Progress.cs

    r9456 r9933  
    2121
    2222using System;
    23 using HeuristicLab.Common;
    2423
    2524namespace HeuristicLab.MainForm {
     
    5049    public ProgressState ProgressState {
    5150      get { return progressState; }
    52       set {
     51      private set {
    5352        if (progressState != value) {
    5453          progressState = value;
     
    7069
    7170    public Progress() {
    72       progressState = ProgressState.Started;
     71      progressState = ProgressState.Finished;
     72      canBeCanceled = false;
    7373    }
    7474    public Progress(string status)
     
    7676      this.status = status;
    7777    }
    78     public Progress(string status, double progressValue)
    79       : this(status) {
    80       this.progressValue = progressValue;
     78    public Progress(string status, ProgressState state)
     79      : this() {
     80      this.status = status;
     81      this.progressState = state;
    8182    }
    8283
    83     public void Cancel(int timeoutMs) {
     84    public void Cancel() {
    8485      if (canBeCanceled)
    85         OnCancelRequested(timeoutMs);
     86        OnCancelRequested();
    8687    }
    8788
    88     /// <summary>
    89     /// Sets the ProgressValue to 1 and the ProgressState to Finished.
    90     /// </summary>
    9189    public void Finish() {
    9290      if (ProgressValue != 1.0) ProgressValue = 1.0;
    9391      ProgressState = ProgressState.Finished;
     92    }
     93
     94    public void Start() {
     95      ProgressValue = 0.0;
     96      ProgressState = ProgressState.Started;
     97    }
     98
     99    public void Start(string status) {
     100      Start();
     101      Status = status;
    94102    }
    95103
     
    98106    private void OnStatusChanged() {
    99107      var handler = StatusChanged;
    100       try {
    101         if (handler != null) handler(this, EventArgs.Empty);
    102       } catch { }
     108      if (handler != null) handler(this, EventArgs.Empty);
    103109    }
    104110
     
    106112    private void OnProgressChanged() {
    107113      var handler = ProgressValueChanged;
    108       try {
    109         if (handler != null) handler(this, EventArgs.Empty);
    110       } catch { }
     114      if (handler != null) handler(this, EventArgs.Empty);
    111115    }
    112116
     
    114118    private void OnProgressStateChanged() {
    115119      var handler = ProgressStateChanged;
    116       try {
    117         if (handler != null) handler(this, EventArgs.Empty);
    118       } catch { }
     120      if (handler != null) handler(this, EventArgs.Empty);
    119121    }
    120122
     
    122124    private void OnCanBeCanceledChanged() {
    123125      var handler = CanBeCanceledChanged;
    124       try {
    125         if (handler != null) handler(this, EventArgs.Empty);
    126       } catch { }
     126      if (handler != null) handler(this, EventArgs.Empty);
    127127    }
    128128
    129     public event EventHandler<EventArgs<int>> CancelRequested;
    130     private void OnCancelRequested(int timeoutMs) {
     129    public event EventHandler CancelRequested;
     130    private void OnCancelRequested() {
    131131      var handler = CancelRequested;
    132       try {
    133         if (handler == null) throw new NotSupportedException("Cancel request was ignored.");
    134         else handler(this, new EventArgs<int>(timeoutMs));
    135       } catch { }
     132      if (handler != null) throw new NotSupportedException("Cancel request was ignored.");
     133      else handler(this, EventArgs.Empty);
    136134    }
    137135    #endregion
Note: See TracChangeset for help on using the changeset viewer.