- Timestamp:
- 07/03/12 16:46:35 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:mergeinfo changed
/trunk/sources merged: 8084,8088-8090,8092-8100,8102-8113,8115,8117-8132,8134-8146,8148-8156,8158-8160,8163-8170,8173-8176,8178-8190,8192-8205
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.MainForm/3.3/Progress.cs
r7582 r8206 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 24 25 namespace HeuristicLab.MainForm { … … 26 27 private string status; 27 28 public string Status { 28 get { 29 return this.status; 30 } 29 get { return status; } 31 30 set { 32 if ( this.status != value) {33 this.status = value;31 if (status != value) { 32 status = value; 34 33 OnStatusChanged(); 35 34 } … … 39 38 private double progressValue; 40 39 public double ProgressValue { 41 get { 42 return this.progressValue; 43 } 40 get { return progressValue; } 44 41 set { 45 if ( this.progressValue != value) {46 this.progressValue = value;42 if (progressValue != value) { 43 progressValue = value; 47 44 OnProgressChanged(); 48 45 } … … 50 47 } 51 48 52 public Progress() { } 53 54 public Progress(string status) { 55 this.Status = status; 49 private ProgressState progressState; 50 public ProgressState ProgressState { 51 get { return progressState; } 52 set { 53 if (progressState != value) { 54 progressState = value; 55 OnProgressStateChanged(); 56 } 57 } 56 58 } 57 59 60 private bool canBeCanceled; 61 public bool CanBeCanceled { 62 get { return canBeCanceled; } 63 set { 64 if (canBeCanceled != value) { 65 canBeCanceled = value; 66 OnCanBeCanceledChanged(); 67 } 68 } 69 } 70 71 public Progress() { 72 progressState = ProgressState.Started; 73 } 74 public Progress(string status) 75 : this() { 76 this.status = status; 77 } 78 public Progress(string status, double progressValue) 79 : this(status) { 80 this.progressValue = progressValue; 81 } 82 83 public void Cancel(int timeoutMs) { 84 if (canBeCanceled) 85 OnCancelRequested(timeoutMs); 86 } 87 88 /// <summary> 89 /// Sets the ProgressValue to 1 and the ProgressState to Finished. 90 /// </summary> 58 91 public void Finish() { 59 OnFinished(); 92 if (ProgressValue != 1.0) ProgressValue = 1.0; 93 ProgressState = ProgressState.Finished; 60 94 } 61 95 62 96 #region Event Handler 63 public event EventHandler Finished;64 private void OnFinished() {65 var handler = Finished;66 try {67 if (handler != null) handler(this, EventArgs.Empty);68 }69 catch (Exception) { }70 }71 72 97 public event EventHandler StatusChanged; 73 98 private void OnStatusChanged() { … … 75 100 try { 76 101 if (handler != null) handler(this, EventArgs.Empty); 77 } 78 catch (Exception) { } 102 } catch { } 79 103 } 80 104 … … 84 108 try { 85 109 if (handler != null) handler(this, EventArgs.Empty); 86 } 87 catch (Exception) { } 110 } catch { } 111 } 112 113 public event EventHandler ProgressStateChanged; 114 private void OnProgressStateChanged() { 115 var handler = ProgressStateChanged; 116 try { 117 if (handler != null) handler(this, EventArgs.Empty); 118 } catch { } 119 } 120 121 public event EventHandler CanBeCanceledChanged; 122 private void OnCanBeCanceledChanged() { 123 var handler = CanBeCanceledChanged; 124 try { 125 if (handler != null) handler(this, EventArgs.Empty); 126 } catch { } 127 } 128 129 public event EventHandler<EventArgs<int>> CancelRequested; 130 private void OnCancelRequested(int timeoutMs) { 131 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 { } 88 136 } 89 137 #endregion
Note: See TracChangeset
for help on using the changeset viewer.