- Timestamp:
- 10/11/17 10:00:34 (7 years ago)
- Location:
- branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r15415 r15417 48 48 this.content = content; 49 49 50 UpdateButtonsState();51 if (content.Visible)ShowProgress();50 if (content.ProgressState != ProgressState.Finished) 51 ShowProgress(); 52 52 RegisterContentEvents(); 53 53 } 54 54 55 /// <summary>56 /// Clean up any resources being used.57 /// </summary>58 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>59 55 protected override void Dispose(bool disposing) { 60 56 DeregisterContentEvents(); … … 72 68 content.ProgressBarModeChanged += new EventHandler(Content_ProgressBarModeChanged); 73 69 content.ProgressValueChanged += new EventHandler(Content_ProgressValueChanged); 74 content.VisibleChanged += new EventHandler(Content_VisibleChanged);75 70 content.CanBeStoppedChanged += new EventHandler(Content_CanBeStoppedChanged); 76 71 content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged); … … 81 76 content.ProgressBarModeChanged -= new EventHandler(Content_ProgressBarModeChanged); 82 77 content.ProgressValueChanged -= new EventHandler(Content_ProgressValueChanged); 83 content.VisibleChanged -= new EventHandler(Content_VisibleChanged);84 78 content.CanBeStoppedChanged -= new EventHandler(Content_CanBeStoppedChanged); 85 79 content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged); … … 102 96 } 103 97 104 private void Content_VisibleChanged(object sender, EventArgs e) { 105 if (content.Visible) 98 private void Content_CanBeStoppedChanged(object sender, EventArgs e) { 99 UpdateButtonsState(); 100 } 101 private void Content_CanBeCanceledChanged(object sender, EventArgs e) { 102 UpdateButtonsState(); 103 } 104 105 private void ShowProgress() { 106 if (control.InvokeRequired) { 107 control.Invoke((Action)ShowProgress); 108 return; 109 } 110 if (Parent != null) return; 111 112 int height = (content.CanBeStopped || content.CanBeCanceled) ? Height : collapsedControlHeight; 113 Left = (control.ClientRectangle.Width / 2) - (Width / 2); 114 Top = (control.ClientRectangle.Height / 2) - (height / 2); 115 Anchor = AnchorStyles.None; 116 117 UpdateProgressMessage(); 118 UpdateProgressValue(); 119 UpdateButtonsState(); 120 121 control.Enabled = false; 122 Parent = control.Parent; 123 BringToFront(); 124 Visible = true; 125 } 126 127 private void HideProgress() { 128 if (control.InvokeRequired) { 129 control.Invoke((Action)HideProgress); 130 return; 131 } 132 if (Parent == null) return; 133 134 Visible = false; 135 control.Enabled = true; 136 Parent = null; 137 } 138 139 private void UpdateProgressState() { 140 if (control.InvokeRequired) { 141 control.Invoke((Action)UpdateProgressState); 142 return; 143 } 144 145 if (content.ProgressState != ProgressState.Finished) 106 146 ShowProgress(); 107 147 else 108 148 HideProgress(); 109 }110 111 private void Content_CanBeStoppedChanged(object sender, EventArgs e) {112 UpdateButtonsState();113 }114 private void Content_CanBeCanceledChanged(object sender, EventArgs e) {115 UpdateButtonsState();116 }117 118 private void ShowProgress() {119 if (control.InvokeRequired) {120 control.Invoke((Action)ShowProgress);121 return;122 }123 124 int height = (content.CanBeStopped || content.CanBeCanceled) ? Height : collapsedControlHeight;125 126 Left = (control.ClientRectangle.Width / 2) - (Width / 2);127 Top = (control.ClientRectangle.Height / 2) - (height / 2);128 Anchor = AnchorStyles.None;129 130 control.Enabled = false;131 Parent = control.Parent;132 BringToFront();133 134 UpdateProgressValue();135 UpdateProgressMessage();136 UpdateButtonsState();137 Visible = true;138 }139 140 private void HideProgress() {141 if (control.InvokeRequired) {142 control.Invoke((Action)HideProgress);143 return;144 }145 146 control.Enabled = true;147 Parent = null;148 Visible = false;149 }150 151 private void UpdateProgressState() {152 if (control.InvokeRequired) {153 control.Invoke((Action)UpdateProgressState);154 return;155 }156 149 157 150 switch (content.ProgressState) { 158 151 case ProgressState.Started: 152 case ProgressState.Finished: 159 153 progressBar.SetState(ProgressBarState.Normal); 160 154 break; 161 case ProgressState.Finished: 162 HideProgress(); 163 progressBar.SetState(ProgressBarState.Normal); 164 break; 165 case ProgressState.Stopped: 155 case ProgressState.StopRequested: 166 156 progressBar.SetState(ProgressBarState.Warning); 167 157 break; 168 case ProgressState.Cancel ed:158 case ProgressState.CancelRequested: 169 159 progressBar.SetState(ProgressBarState.Error); 170 160 break; … … 211 201 212 202 stopButton.Visible = content.CanBeStopped; 213 stopButton.Enabled = content. ProgressState == ProgressState.Started && content.CanBeStopped;203 stopButton.Enabled = content.CanBeStopped && content.ProgressState == ProgressState.Started; 214 204 215 205 cancelButton.Visible = content.CanBeCanceled; 216 cancelButton.Enabled = content. ProgressState == ProgressState.Started && content.CanBeCanceled;206 cancelButton.Enabled = content.CanBeCanceled && content.ProgressState == ProgressState.Started; 217 207 218 208 if (content.CanBeStopped || content.CanBeCanceled) { -
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.designer.cs
r15415 r15417 103 103 // stopButton 104 104 // 105 this.stopButton.Dock = System.Windows.Forms.DockStyle.Left;106 105 this.stopButton.Location = new System.Drawing.Point(193, 3); 107 106 this.stopButton.Name = "stopButton";
Note: See TracChangeset
for help on using the changeset viewer.