- Timestamp:
- 11/22/18 12:37:04 (6 years ago)
- Location:
- branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r16311 r16317 163 163 } 164 164 165 if (content.ProgressBarMode == ProgressBarMode.Continuous) { 166 progressBar.Style = ProgressBarStyle.Continuous; 167 progressBar.Value = (int)Math.Round(progressBar.Minimum + content.ProgressValue * (progressBar.Maximum - progressBar.Minimum)); 168 } else { 169 progressBar.Style = ProgressBarStyle.Marquee; 170 progressBar.Value = 0; 165 switch (content.ProgressMode) { 166 case ProgressMode.Determinate: 167 progressBar.Style = ProgressBarStyle.Continuous; 168 progressBar.Value = (int)Math.Round(progressBar.Minimum + content.ProgressValue * (progressBar.Maximum - progressBar.Minimum)); 169 break; 170 case ProgressMode.Indeterminate: 171 progressBar.Style = ProgressBarStyle.Marquee; 172 progressBar.Value = 0; 173 break; 174 default: 175 throw new NotImplementedException($"Invalid Progress Mode: {content.ProgressMode}"); 171 176 } 172 177 } -
branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r16314 r16317 381 381 /// Adds a <see cref="ProgressView"/> to the specified view. 382 382 /// </summary> 383 internal void AddProgressTo View(Control control, IProgress progress) {383 internal void AddProgressToControl(Control control, IProgress progress) { 384 384 if (InvokeRequired) { 385 Invoke((Action<Control, IProgress>)AddProgressTo View, control, progress);385 Invoke((Action<Control, IProgress>)AddProgressToControl, control, progress); 386 386 return; 387 387 } … … 426 426 /// Removes an existing <see cref="ProgressView"/> from the specified view. 427 427 /// </summary> 428 internal void RemoveProgressFrom View(Control control, bool finishProgress = true) {428 internal void RemoveProgressFromControl(Control control, bool finishProgress = true) { 429 429 if (InvokeRequired) { 430 Invoke((Action<Control, bool>)RemoveProgressFrom View, control, finishProgress);430 Invoke((Action<Control, bool>)RemoveProgressFromControl, control, finishProgress); 431 431 return; 432 432 } -
branches/2845_EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Progress.cs
r16314 r16317 48 48 } 49 49 50 private Progress BarMode progressBarMode;51 public Progress BarMode ProgressBarMode {52 get { return progress BarMode; }53 set { 54 if (progress BarMode != value) {55 progress BarMode = value;50 private ProgressMode progressMode; 51 public ProgressMode ProgressMode { 52 get { return progressMode; } 53 set { 54 if (progressMode != value) { 55 progressMode = value; 56 56 OnProgressBarModeChanged(); 57 57 } … … 63 63 get { return progressValue; } 64 64 set { 65 if (progress BarMode == ProgressBarMode.Marquee)66 throw new InvalidOperationException("Cannot set ProgressValue while ProgressBar is in Marquee-Mode");65 if (progressMode == ProgressMode.Indeterminate) 66 throw new InvalidOperationException("Cannot set ProgressValue while ProgressBar is in Indeterminate-Mode"); 67 67 if (progressValue != value) { 68 68 progressValue = Math.Max(Math.Min(value, 1.0), 0.0); … … 98 98 canBeStopped = false; 99 99 canBeCanceled = false; 100 progress BarMode = ProgressBarMode.Marquee;100 progressMode = ProgressMode.Indeterminate; 101 101 progressValue = 0.0; 102 102 } 103 103 104 public void Start(string message, double progressValue = 0) {104 public void Start(string message, ProgressMode mode = ProgressMode.Determinate) { 105 105 ProgressState = ProgressState.Started; 106 ProgressBarMode = ProgressBarMode.Continuous; 107 ProgressValue = progressValue; 106 ProgressMode = mode; 107 if (mode == ProgressMode.Determinate) 108 ProgressValue = 0.0; 108 109 Message = message; 109 110 } 110 public void StartMarquee(string message) {111 ProgressState = ProgressState.Started;112 ProgressBarMode = ProgressBarMode.Marquee;113 Message = message;114 }115 111 116 112 public void Finish() { 117 if (Progress BarMode == ProgressBarMode.Continuous&& ProgressValue != 1.0)113 if (ProgressMode == ProgressMode.Determinate && ProgressValue != 1.0) 118 114 ProgressValue = 1.0; 119 115 ProgressState = ProgressState.Finished; … … 135 131 #region Show/Hide Progress 136 132 /// <summary> 137 /// Shows a started Progress in Continuous-modeon all Views of the specified content.138 /// </summary> 139 public static IProgress Show(IContent content, string progressMessage, double initialProgressValue = 0, bool addToObjectGraphObjects = true) {133 /// Shows a started Progress on all Views of the specified content. 134 /// </summary> 135 public static IProgress Show(IContent content, string progressMessage, ProgressMode mode = ProgressMode.Determinate, bool addToObjectGraphObjects = true) { 140 136 var progress = new Progress(); 141 progress.Start(progressMessage, initialProgressValue);137 progress.Start(progressMessage, mode); 142 138 AddProgressToContent(content, progress, addToObjectGraphObjects); 143 139 return progress; 144 140 } 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) { 141 142 /// <summary> 143 /// Shows a started Progress on the specified view. 144 /// </summary> 145 public static IProgress Show(IView view, string progressMessage, ProgressMode mode = ProgressMode.Determinate) { 149 146 var progress = new Progress(); 150 progress.Start Marquee(progressMessage);151 AddProgressTo Content(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) {147 progress.Start(progressMessage, mode); 148 AddProgressToView(view, progress); 149 return progress; 150 } 151 /// <summary> 152 /// Shows a started Progress on the specified control. 153 /// </summary> 154 /// <remarks>Use Progress.Show(IView, ...) if possible.</remarks> 155 public static IProgress ShowOnControl(Control control, string progressMessage, ProgressMode mode = ProgressMode.Determinate) { 159 156 var progress = new Progress(); 160 progress.Start(progressMessage, initialProgressValue); 161 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 AddProgressToView(control, progress); 157 progress.Start(progressMessage, mode); 158 AddProgressToControl(control, progress); 171 159 return progress; 172 160 } … … 181 169 /// Hides the Progress from the specified view. 182 170 /// </summary> 183 public static void Hide(Control control) { 184 RemoveProgressFromView(control); 171 public static void Hide(IView view) { 172 RemoveProgressFromView(view); 173 } 174 /// <summary> 175 /// Hides the Progress from the specified control. 176 /// </summary> 177 /// <remarks>Use Progress.Hide(IView) if possible.</remarks> 178 public static void HideFromControl(Control control) { 179 RemoveProgressFromControl(control); 185 180 } 186 181 #endregion 187 182 188 #region Interface to fromMainForm183 #region Interface to MainForm 189 184 public static IProgress AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) { 190 185 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects); 191 186 return progress; 192 187 } 193 public static IProgress AddProgressToView(Control control, IProgress progress) { 194 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress); 188 public static IProgress AddProgressToView(IView view, IProgress progress) { 189 //return AddProgressToControl(MainFormManager.GetMainForm<WindowsForms.MainForm>().GetForm(view), progress); 190 return AddProgressToControl((Control)view, progress); 191 } 192 public static IProgress AddProgressToControl(Control control, IProgress progress) { 193 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToControl(control, progress); 195 194 return progress; 196 195 } … … 199 198 MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromContent(content, finishProgress); 200 199 } 201 public static void RemoveProgressFromView(Control control, bool finishProgress = true) { 202 MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromView(control, finishProgress); 200 public static void RemoveProgressFromView(IView view, bool finishProgress = true) { 201 //RemoveProgressFromControl(MainFormManager.GetMainForm<WindowsForms.MainForm>().GetForm(view), finishProgress); 202 RemoveProgressFromControl((Control)view, finishProgress); 203 } 204 public static void RemoveProgressFromControl(Control control, bool finishProgress = true) { 205 MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromControl(control, finishProgress); 203 206 } 204 207 #endregion
Note: See TracChangeset
for help on using the changeset viewer.