Changeset 9933
- Timestamp:
- 09/03/13 15:55:36 (11 years ago)
- Location:
- stable
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 9849,9851,9865,9867-9868,9893-9896,9900-9901,9905,9907
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs
r9456 r9933 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Core.Views; 24 23 using HeuristicLab.MainForm; … … 34 33 } 35 34 36 private ProgressView progressView;37 private Progress progress;38 39 35 public ClientView() { 40 36 InitializeComponent(); 41 progress = new Progress() {42 CanBeCanceled = false,43 ProgressState = ProgressState.Finished44 };45 }46 47 protected override void DeregisterContentEvents() {48 if (progressView != null) {49 progressView.Content = null;50 progressView.Dispose();51 progressView = null;52 }53 base.DeregisterContentEvents();54 }55 56 protected override void RegisterContentEvents() {57 base.RegisterContentEvents();58 progressView = new ProgressView(this, progress);59 37 } 60 38 … … 98 76 99 77 public void StartProgressView() { 100 if (InvokeRequired) { 101 Invoke(new Action(StartProgressView)); 102 } else { 103 progress.Status = "Downloading client information. Please be patient."; 104 progress.ProgressState = ProgressState.Started; 105 } 78 var message = "Downloading client information. Please be patient."; 79 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 106 80 } 107 81 108 82 public void FinishProgressView() { 109 if (InvokeRequired) { 110 Invoke(new Action(FinishProgressView)); 111 } else { 112 progress.Finish(); 113 } 83 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 114 84 } 115 85 } -
stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r9456 r9933 42 42 private ISet<TreeNode> filteredTreeNodes; 43 43 private ISet<TreeNode> nodeStore; 44 private Progress progress; 45 private ProgressView progressView; 46 44 47 45 private ISet<Resource> selectedResources; 48 46 public ISet<Resource> SelectedResources { … … 64 62 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge); 65 63 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge); 66 progress = new Progress() { 67 CanBeCanceled = false, 68 ProgressState = ProgressState.Finished 69 }; 70 } 71 72 protected override void DeregisterContentEvents() { 73 if (progressView != null) { 74 progressView.Content = null; 75 progressView.Dispose(); 76 progressView = null; 77 } 78 base.DeregisterContentEvents(); 79 } 80 81 protected override void RegisterContentEvents() { 82 base.RegisterContentEvents(); 83 progressView = new ProgressView(this, progress); 84 } 85 64 } 65 86 66 public void StartProgressView() { 87 67 if (InvokeRequired) { 88 68 Invoke(new Action(StartProgressView)); 89 69 } else { 90 progress.Status= "Downloading resources. Please be patient.";91 progress.ProgressState = ProgressState.Started;70 var message = "Downloading resources. Please be patient."; 71 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 92 72 } 93 73 } … … 97 77 Invoke(new Action(FinishProgressView)); 98 78 } else { 99 progress.Finish();79 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 100 80 } 101 81 } -
stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r9559 r9933 34 34 [Content(typeof(ItemCollection<RefreshableJob>), false)] 35 35 public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> { 36 private Progress progress;37 private ProgressView progressView;38 39 36 public RefreshableHiveJobListView() { 40 37 InitializeComponent(); … … 49 46 50 47 this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending); 51 52 progress = new Progress() {53 CanBeCanceled = false,54 ProgressState = ProgressState.Finished55 };56 progressView = new ProgressView(this, progress);57 48 } 58 49 … … 118 109 119 110 task.ContinueWith((t) => { 120 progress.Finish();111 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 121 112 ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception); 122 113 }, TaskContinuationOptions.OnlyOnFaulted); … … 129 120 130 121 private void DeleteHiveJobsAsync(object items) { 131 progress.Status = "Deleting job..."; 132 progress.ProgressState = ProgressState.Started; 133 progress.ProgressValue = 0.0; 122 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Deleting job..."); 134 123 foreach (RefreshableJob item in (List<RefreshableJob>)items) { 135 124 Content.Remove(item); 136 125 } 137 progress.Finish();126 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 138 127 } 139 128 … … 227 216 if (disposing) { 228 217 if (components != null) components.Dispose(); 229 progressView.Content = null;230 progressView.Dispose();231 218 } 232 219 base.Dispose(disposing); -
stable/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r9722 r9933 42 42 [Content(typeof(RefreshableJob), true)] 43 43 public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView { 44 private Progress progress;45 private ProgressView progressView;46 44 private HiveResourceSelectorDialog hiveResourceSelectorDialog; 47 45 private bool SuppressEvents { get; set; } … … 58 56 public RefreshableHiveJobView() { 59 57 InitializeComponent(); 60 progress = new Progress() {61 CanBeCanceled = false,62 ProgressState = ProgressState.Finished63 };64 58 } 65 59 … … 72 66 Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 73 67 Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged); 74 Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);75 68 Content.HiveTasksChanged += new EventHandler(Content_HiveTasksChanged); 76 69 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); … … 78 71 Content.Loaded += new EventHandler(Content_Loaded); 79 72 Content.TaskReceived += new EventHandler(Content_TaskReceived); 80 progressView = new ProgressView(this, progress);73 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress); 81 74 } 82 75 … … 88 81 Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured); 89 82 Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged); 90 Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);91 83 Content.HiveTasksChanged -= new EventHandler(Content_HiveTasksChanged); 92 84 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 94 86 Content.Loaded -= new EventHandler(Content_Loaded); 95 87 Content.TaskReceived -= new EventHandler(Content_TaskReceived); 96 if (progressView != null) { 97 progressView.Content = null; 98 progressView.Dispose(); 99 progressView = null; 100 } 88 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false); 101 89 DeregisterHiveExperimentEvents(); 102 90 DeregisterHiveTasksEvents(); … … 159 147 Content_HiveExperimentChanged(this, EventArgs.Empty); 160 148 Content_HiveTasksChanged(this, EventArgs.Empty); 161 Content_IsProgressingChanged(this, EventArgs.Empty);162 149 Content_StateLogListChanged(this, EventArgs.Empty); 163 150 HiveExperiment_PropertyChanged(this, new PropertyChangedEventArgs("Id")); … … 260 247 SetEnabledStateOfControls(); 261 248 } 262 private void Content_Prepared(object sender, EventArgs e) { 263 if (InvokeRequired) 264 Invoke(new EventHandler(Content_Prepared), sender, e); 265 else { 266 nameTextBox.Enabled = true; 267 Locked = false; 268 SetEnabledStateOfControls(); 269 } 270 } 271 private void Content_Started(object sender, EventArgs e) { 272 if (InvokeRequired) 273 Invoke(new EventHandler(Content_Started), sender, e); 274 else { 275 nameTextBox.Enabled = false; 276 SetEnabledStateOfControls(); 277 } 278 } 279 private void Content_Paused(object sender, EventArgs e) { 280 if (InvokeRequired) 281 Invoke(new EventHandler(Content_Paused), sender, e); 282 else { 283 nameTextBox.Enabled = true; 284 SetEnabledStateOfControls(); 285 } 286 } 287 private void Content_Stopped(object sender, EventArgs e) { 288 if (InvokeRequired) 289 Invoke(new EventHandler(Content_Stopped), sender, e); 290 else { 291 nameTextBox.Enabled = true; 292 Locked = false; 293 SetEnabledStateOfControls(); 294 } 295 } 249 296 250 private void Content_ExecutionTimeChanged(object sender, EventArgs e) { 297 251 if (InvokeRequired) … … 336 290 if (Content != null && Content.Job != null) { 337 291 RegisterHiveExperimentEvents(); 338 Content_IsProgressingChanged(sender, e);339 292 } 340 293 } … … 410 363 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); 411 364 task.ContinueWith((t) => { 412 progress.Finish();365 Content.Progress.Finish(); 413 366 MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 414 367 Content.Log.LogException(t.Exception); … … 422 375 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content); 423 376 task.ContinueWith((t) => { 424 progress.Finish();377 Content.Progress.Finish(); 425 378 MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 426 379 Content.Log.LogException(t.Exception); … … 431 384 var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content); 432 385 task.ContinueWith((t) => { 433 progress.Finish();386 Content.Progress.Finish(); 434 387 MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 435 388 Content.Log.LogException(t.Exception); … … 439 392 440 393 private void PauseJobAsync(object job) { 441 progress.Status = "Pausing job..."; 442 progress.ProgressState = ProgressState.Started; 394 Content.Progress.Start("Pausing job..."); 443 395 HiveClient.PauseJob((RefreshableJob)job); 444 progress.Finish();396 Content.Progress.Finish(); 445 397 } 446 398 447 399 private void StopJobAsync(object job) { 448 progress.Status = "Stopping job..."; 449 progress.ProgressState = ProgressState.Started; 400 Content.Progress.Start("Stopping job..."); 450 401 HiveClient.StopJob((RefreshableJob)job); 451 progress.Finish();402 Content.Progress.Finish(); 452 403 } 453 404 454 405 private void ResumeJobAsync(object job) { 455 progress.Status = "Resuming job..."; 456 progress.ProgressState = ProgressState.Started; 406 Content.Progress.Start("Resuming job..."); 457 407 HiveClient.ResumeJob((RefreshableJob)job); 458 progress.Finish();408 Content.Progress.Finish(); 459 409 } 460 410 … … 507 457 stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 508 458 resetButton.Enabled = false; 509 }510 }511 #endregion512 513 #region Progress reporting514 private void Content_IsProgressingChanged(object sender, EventArgs e) {515 if (this.InvokeRequired) {516 Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);517 } else {518 if (Content != null && Content.Progress != null && Content.IsProgressing) {519 progressView.Content = Content.Progress;520 } else if (Content != null) {521 progressView.Content = progress;522 }523 459 } 524 460 } -
stable/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r9456 r9933 31 31 [Content(typeof(OptimizerHiveTask), true)] 32 32 public partial class OptimizerHiveTaskView : HiveTaskView { 33 private Progress progress;34 private ProgressView progressView;35 36 33 public new OptimizerHiveTask Content { 37 34 get { return (OptimizerHiveTask)base.Content; } … … 45 42 public OptimizerHiveTaskView() { 46 43 InitializeComponent(); 47 progress = new Progress() {48 CanBeCanceled = false,49 ProgressState = ProgressState.Finished50 };51 44 } 52 45 … … 60 53 } 61 54 } 55 62 56 #region Content Events 63 57 protected override void RegisterContentEvents() { 64 58 base.RegisterContentEvents(); 65 59 Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged); 66 progressView = new ProgressView(this, progress);60 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, Content.Progress); 67 61 } 68 62 69 63 protected override void DeregisterContentEvents() { 70 64 Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged); 71 if (progressView != null) { 72 progressView.Content = null; 73 progressView.Dispose(); 74 progressView = null; 75 } 65 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false); 76 66 base.DeregisterContentEvents(); 77 67 } … … 80 70 SetEnabledStateOfControls(); 81 71 } 82 83 72 #endregion 84 73 … … 87 76 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync); 88 77 task.ContinueWith((t) => { 89 progress.Finish();78 Content.Progress.Finish(); 90 79 ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception); 91 80 }, TaskContinuationOptions.OnlyOnFaulted); … … 95 84 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync); 96 85 task.ContinueWith((t) => { 97 progress.Finish();86 Content.Progress.Finish(); 98 87 ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception); 99 88 }, TaskContinuationOptions.OnlyOnFaulted); … … 103 92 var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync); 104 93 task.ContinueWith((t) => { 105 progress.Finish();94 Content.Progress.Finish(); 106 95 ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception); 107 96 }, TaskContinuationOptions.OnlyOnFaulted); … … 110 99 111 100 private void PauseTaskAsync() { 112 progress.Status = "Pausing task. Please be patient for the command to take effect."; 113 progress.ProgressState = ProgressState.Started; 101 Content.Progress.Start("Pausing task. Please be patient for the command to take effect."); 114 102 Content.Pause(); 115 progress.Finish();103 Content.Progress.Finish(); 116 104 } 117 105 118 106 private void StopTaskAsync() { 119 progress.Status = "Stopping task. Please be patient for the command to take effect."; 120 progress.ProgressState = ProgressState.Started; 107 Content.Progress.Start("Stopping task. Please be patient for the command to take effect."); 121 108 Content.Stop(); 122 progress.Finish();109 Content.Progress.Finish(); 123 110 } 124 111 125 112 private void ResumeTaskAsync() { 126 progress.Status = "Resuming task. Please be patient for the command to take effect."; 127 progress.ProgressState = ProgressState.Started; 113 Content.Progress.Start("Resuming task. Please be patient for the command to take effect."); 128 114 Content.Restart(); 129 progress.Finish();115 Content.Progress.Finish(); 130 116 } 131 117 -
stable/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r9456 r9933 265 265 try { 266 266 refreshableJob.IsProgressing = true; 267 refreshableJob.Progress = new Progress("Connecting to server...");267 refreshableJob.Progress.Start("Connecting to server..."); 268 268 IEnumerable<string> resourceNames = ToResourceNameList(refreshableJob.Job.ResourceNames); 269 269 var resourceIds = new List<Guid>(); … … 424 424 var hiveExperiment = refreshableJob.Job; 425 425 refreshableJob.IsProgressing = true; 426 refreshableJob.Progress = new Progress();427 426 TaskDownloader downloader = null; 428 427 … … 431 430 IEnumerable<LightweightTask> allTasks; 432 431 433 refreshableJob.Progress.Status = "Connecting to Server...";434 432 // fetch all task objects to create the full tree of tree of HiveTask objects 435 refreshableJob.Progress.Sta tus = "Downloading list of tasks...";433 refreshableJob.Progress.Start("Downloading list of tasks..."); 436 434 allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(hiveExperiment.Id)); 437 435 totalJobCount = allTasks.Count(); -
stable/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs
r9456 r9933 26 26 using HeuristicLab.Collections; 27 27 using HeuristicLab.Common; 28 using HeuristicLab.MainForm; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.PluginInfrastructure; … … 31 32 namespace HeuristicLab.Clients.Hive { 32 33 public class OptimizerHiveTask : HiveTask<OptimizerTask> { 34 public Progress Progress { get; private set; } 35 33 36 #region Constructors and Cloning 34 public OptimizerHiveTask() { } 37 public OptimizerHiveTask() { 38 Progress = new Progress(); 39 } 35 40 public OptimizerHiveTask(IOptimizer optimizer) 36 41 : this() { … … 43 48 protected OptimizerHiveTask(OptimizerHiveTask original, Cloner cloner) 44 49 : base(original, cloner) { 50 Progress = new Progress(); 45 51 } 46 52 public override IDeepCloneable Clone(Cloner cloner) { -
stable/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs
r9456 r9933 178 178 #region Constructors and Cloning 179 179 public RefreshableJob() { 180 this.progress = new Progress(); 180 181 this.refreshAutomatically = false; 181 182 this.Job = new Job(); … … 186 187 } 187 188 public RefreshableJob(Job hiveJob) { 189 this.progress = new Progress(); 188 190 this.refreshAutomatically = true; 189 191 this.Job = hiveJob; -
stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r9456 r9933 54 54 Algorithm selectedAlgorithm = null; 55 55 Problem selectedProblem = null; 56 private ProgressView progressView;57 private Progress progress;58 56 59 57 public OKBExperimentUploadView() { 60 58 InitializeComponent(); 61 progress = new Progress() {62 CanBeCanceled = false,63 ProgressState = ProgressState.Finished64 };65 59 } 66 60 … … 96 90 RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing); 97 91 RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed); 98 progressView = new ProgressView(this, progress);99 92 } 100 93 … … 102 95 RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing); 103 96 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 104 if (progressView != null) { 105 progressView.Content = null; 106 progressView.Dispose(); 107 progressView = null; 108 } 97 109 98 base.DeregisterContentEvents(); 110 99 } … … 198 187 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 199 188 } else { 200 progress.Status= "Refreshing algorithms and problems...";201 progress.ProgressState = ProgressState.Started;189 var message = "Refreshing algorithms and problems..."; 190 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 202 191 } 203 192 } … … 207 196 Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e); 208 197 } else { 209 progress.Finish();198 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 210 199 SetEnabledStateOfControls(); 211 200 } … … 215 204 var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync); 216 205 task.ContinueWith((t) => { 217 progress.Finish();206 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 218 207 PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception); 219 208 }, TaskContinuationOptions.OnlyOnFaulted); … … 221 210 222 211 private void UploadAsync() { 223 progress.Status = "Uploading runs to OKB..."; 224 progress.ProgressValue = 0; 225 progress.ProgressState = ProgressState.Started; 212 var message = "Uploading runs to OKB..."; 213 IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 226 214 double count = dataGridView.Rows.Count; 227 215 int i = 0; … … 238 226 progress.ProgressValue = ((double)i) / count; 239 227 } 240 progress.Finish();228 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 241 229 ClearRuns(); 242 230 } -
stable/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r9456 r9933 21 21 22 22 using System; 23 using System.ComponentModel;24 23 using System.Windows.Forms; 25 24 26 25 namespace HeuristicLab.MainForm.WindowsForms { 27 [View("ProgressView")] 28 [Content(typeof(IProgress), true)] 29 public partial class ProgressView : AsynchronousContentView { 30 private const int DefaultCancelTimeoutMs = 3000; 31 private ContentView parentView; 26 internal sealed partial class ProgressView : UserControl { 27 private const int defaultControlHeight = 88; 28 private const int collapsedControlHeight = 55; 32 29 33 [Category("Custom"), Description("The time that the process is allowed to exit.")] 34 [DefaultValue(DefaultCancelTimeoutMs)] 35 public int CancelTimeoutMs { get; set; } 36 private bool ShouldSerializeCancelTimeoutMs() { return CancelTimeoutMs != DefaultCancelTimeoutMs; } 37 38 public new IProgress Content { 39 get { return (IProgress)base.Content; } 40 set { base.Content = value; } 30 private readonly Control control; 31 public Control Control { 32 get { return control; } 41 33 } 42 34 43 public ProgressView() { 44 InitializeComponent(); 45 } 46 public ProgressView(IProgress progress) 47 : this() { 48 Content = progress; 49 } 50 public ProgressView(ContentView parentView) 51 : this() { 52 if (parentView == null) throw new ArgumentNullException("parentView", "The parent view is null."); 53 this.parentView = parentView; 54 } 55 public ProgressView(ContentView parentView, IProgress progress) 56 : this(parentView) { 57 Content = progress; 35 private readonly IProgress content; 36 public IProgress Content { 37 get { return content; } 58 38 } 59 39 60 protected override void RegisterContentEvents() { 61 Content.StatusChanged += new EventHandler(progress_StatusChanged); 62 Content.ProgressValueChanged += new EventHandler(progress_ProgressValueChanged); 63 Content.ProgressStateChanged += new EventHandler(Content_ProgressStateChanged); 64 Content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged); 65 base.RegisterContentEvents(); 40 public ProgressView(Control control, IProgress content) 41 : base() { 42 if (control == null) throw new ArgumentNullException("control", "The control is null."); 43 if (content == null) throw new ArgumentNullException("content", "The passed progress is null."); 44 InitializeComponent(); 45 46 this.control = control; 47 this.content = content; 48 if (content.ProgressState == ProgressState.Started) 49 ShowProgress(); 50 RegisterContentEvents(); 66 51 } 67 52 68 protected override void DeregisterContentEvents() { 69 base.DeregisterContentEvents(); 70 Content.StatusChanged -= new EventHandler(progress_StatusChanged); 71 Content.ProgressValueChanged -= new EventHandler(progress_ProgressValueChanged); 72 Content.ProgressStateChanged -= new EventHandler(Content_ProgressStateChanged); 73 Content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged); 53 /// <summary> 54 /// Clean up any resources being used. 55 /// </summary> 56 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 57 protected override void Dispose(bool disposing) { 58 DeregisterContentEvents(); 59 HideProgress(); 60 61 if (disposing && (components != null)) { 62 components.Dispose(); 63 } 64 base.Dispose(disposing); 74 65 } 75 66 76 protected override void OnContentChanged() { 77 base.OnContentChanged(); 78 if (Content == null) { 79 HideProgress(); 80 } else { 81 if (Content.ProgressState == ProgressState.Started) 82 ShowProgress(); 83 } 67 private void RegisterContentEvents() { 68 content.StatusChanged += new EventHandler(progress_StatusChanged); 69 content.ProgressValueChanged += new EventHandler(progress_ProgressValueChanged); 70 content.ProgressStateChanged += new EventHandler(Content_ProgressStateChanged); 71 content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged); 84 72 } 85 86 protected override void SetEnabledStateOfControls() {87 base.SetEnabledStateOfControls();88 c ancelButton.Visible = Content != null && Content.CanBeCanceled;89 c ancelButton.Enabled = Content != null && Content.CanBeCanceled && !ReadOnly;73 private void DeregisterContentEvents() { 74 content.StatusChanged -= new EventHandler(progress_StatusChanged); 75 content.ProgressValueChanged -= new EventHandler(progress_ProgressValueChanged); 76 content.ProgressStateChanged -= new EventHandler(Content_ProgressStateChanged); 77 content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged); 90 78 } 91 79 92 80 private void ShowProgress() { 93 if (InvokeRequired) Invoke((Action)ShowProgress); 94 else { 95 if (parentView != null) { 96 this.Left = (parentView.ClientRectangle.Width / 2) - (this.Width / 2); 97 this.Top = (parentView.ClientRectangle.Height / 2) - (this.Height / 2); 98 this.Anchor = AnchorStyles.None; 81 if (Control.InvokeRequired) { 82 Control.Invoke((Action)ShowProgress); 83 return; 84 } 85 int height = Content.CanBeCanceled ? Height : collapsedControlHeight; 99 86 100 LockBackground(); 87 Left = (Control.ClientRectangle.Width / 2) - (Width / 2); 88 Top = (Control.ClientRectangle.Height / 2) - (height / 2); 89 Anchor = AnchorStyles.None; 101 90 102 if (!parentView.Controls.Contains(this)) 103 parentView.Controls.Add(this); 91 control.Enabled = false; 92 Parent = Control.Parent; 93 BringToFront(); 104 94 105 BringToFront(); 106 } 107 UpdateProgressValue(); 108 UpdateProgressStatus(); 109 Visible = true; 110 } 95 UpdateProgressValue(); 96 UpdateProgressStatus(); 97 UpdateCancelButton(); 98 Visible = true; 111 99 } 112 100 … … 114 102 if (InvokeRequired) Invoke((Action)HideProgress); 115 103 else { 116 if (parentView != null) { 117 if (parentView.Controls.Contains(this)) 118 parentView.Controls.Remove(this); 119 120 UnlockBackground(); 121 } 104 control.Enabled = true; 105 Parent = null; 122 106 Visible = false; 123 107 } … … 133 117 134 118 private void Content_ProgressStateChanged(object sender, EventArgs e) { 135 if (Content.ProgressState == ProgressState.Finished 136 || Content.ProgressState == ProgressState.Canceled) 137 HideProgress(); 138 if (Content.ProgressState == ProgressState.Started) 139 ShowProgress(); 119 switch (content.ProgressState) { 120 case ProgressState.Finished: HideProgress(); break; 121 case ProgressState.Canceled: HideProgress(); break; 122 case ProgressState.Started: ShowProgress(); break; 123 default: throw new NotSupportedException("The progress state " + content.ProgressState + " is not supported by the ProgressView."); 124 } 140 125 } 141 126 142 127 private void Content_CanBeCanceledChanged(object sender, EventArgs e) { 143 SetEnabledStateOfControls();128 UpdateCancelButton(); 144 129 } 145 130 146 private void LockBackground() { 147 if (InvokeRequired) { 148 Invoke((Action)LockBackground); 149 } else { 150 parentView.Locked = true; 151 parentView.ReadOnly = true; 152 Locked = false; 153 ReadOnly = false; 154 } 155 } 131 private void UpdateCancelButton() { 132 cancelButton.Visible = content != null && content.CanBeCanceled; 133 cancelButton.Enabled = content != null && content.CanBeCanceled; 156 134 157 private void UnlockBackground() { 158 if (InvokeRequired) Invoke((Action)UnlockBackground); 159 else { 160 parentView.Locked = false; 161 parentView.ReadOnly = false; 162 Locked = true; 163 ReadOnly = true; 135 if (content != null && content.CanBeCanceled) { 136 Height = defaultControlHeight; 137 } else if (content != null && !content.CanBeCanceled) { 138 Height = collapsedControlHeight; 164 139 } 165 140 } … … 168 143 if (InvokeRequired) Invoke((Action)UpdateProgressValue); 169 144 else { 170 if ( Content != null) {171 double progressValue = Content.ProgressValue;145 if (content != null) { 146 double progressValue = content.ProgressValue; 172 147 if (progressValue <= 0.0 || progressValue > 1.0) { 173 if (progressBar.Style != ProgressBarStyle.Marquee) 174 progressBar.Style = ProgressBarStyle.Marquee; 148 progressBar.Style = ProgressBarStyle.Marquee; 175 149 } else { 176 if (progressBar.Style != ProgressBarStyle.Blocks) 177 progressBar.Style = ProgressBarStyle.Blocks; 150 progressBar.Style = ProgressBarStyle.Blocks; 178 151 progressBar.Value = (int)Math.Round(progressBar.Minimum + progressValue * (progressBar.Maximum - progressBar.Minimum)); 179 152 } … … 184 157 private void UpdateProgressStatus() { 185 158 if (InvokeRequired) Invoke((Action)UpdateProgressStatus); 186 else if ( Content != null)187 statusLabel.Text = Content.Status;159 else if (content != null) 160 statusLabel.Text = content.Status; 188 161 } 189 162 190 163 private void cancelButton_Click(object sender, EventArgs e) { 191 if (Content != null) { 192 try { 193 Content.Cancel(CancelTimeoutMs); 194 ReadOnly = true; 195 cancelButtonTimer.Interval = CancelTimeoutMs; 196 cancelButtonTimer.Start(); 197 } catch (NotSupportedException nse) { 198 PluginInfrastructure.ErrorHandling.ShowErrorDialog(nse); 199 } 200 } 201 } 202 203 private void cancelButtonTimer_Tick(object sender, EventArgs e) { 204 cancelButtonTimer.Stop(); 205 if (Visible) ReadOnly = false; 164 content.Cancel(); 206 165 } 207 166 } -
stable/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.designer.cs
r9456 r9933 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary> 30 /// Clean up any resources being used. 31 /// </summary> 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 protected override void Dispose(bool disposing) { 34 if (disposing && (components != null)) { 35 components.Dispose(); 36 } 37 base.Dispose(disposing); 38 } 39 29 40 30 #region Component Designer generated code 41 31 … … 45 35 /// </summary> 46 36 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container();48 37 this.progressBar = new System.Windows.Forms.ProgressBar(); 49 38 this.statusLabel = new System.Windows.Forms.Label(); 50 39 this.cancelButton = new System.Windows.Forms.Button(); 51 40 this.panel = new System.Windows.Forms.Panel(); 52 this.cancelButtonTimer = new System.Windows.Forms.Timer(this.components);53 41 this.panel.SuspendLayout(); 54 42 this.SuspendLayout(); … … 56 44 // progressBar 57 45 // 58 this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 59 46 this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 47 | System.Windows.Forms.AnchorStyles.Right))); 60 48 this.progressBar.Location = new System.Drawing.Point(3, 3); 61 49 this.progressBar.Name = "progressBar"; … … 66 54 // statusLabel 67 55 // 68 this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 69 56 this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 57 | System.Windows.Forms.AnchorStyles.Right))); 70 58 this.statusLabel.Location = new System.Drawing.Point(3, 33); 71 59 this.statusLabel.Name = "statusLabel"; … … 86 74 // panel 87 75 // 88 this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 89 | System.Windows.Forms.AnchorStyles.Right))); 76 this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 77 | System.Windows.Forms.AnchorStyles.Left) 78 | System.Windows.Forms.AnchorStyles.Right))); 90 79 this.panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 91 80 this.panel.Controls.Add(this.progressBar); … … 96 85 this.panel.Size = new System.Drawing.Size(360, 88); 97 86 this.panel.TabIndex = 3; 98 //99 // cancelButtonTimer100 //101 this.cancelButtonTimer.Tick += new System.EventHandler(this.cancelButtonTimer_Tick);102 87 // 103 88 // ProgressView … … 118 103 private System.Windows.Forms.Button cancelButton; 119 104 private System.Windows.Forms.Panel panel; 120 private System.Windows.Forms.Timer cancelButtonTimer;121 105 } 122 106 } -
stable/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r9931 r9933 345 345 #endregion 346 346 347 #region progress views 348 private readonly Dictionary<IContent, IProgress> contentProgressLookup = new Dictionary<IContent, IProgress>(); 349 private readonly Dictionary<Control, IProgress> viewProgressLookup = new Dictionary<Control, IProgress>(); 350 private readonly List<ProgressView> progressViews = new List<ProgressView>(); 351 352 /// <summary> 353 /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content. 354 /// </summary> 355 public IProgress AddOperationProgressToContent(IContent content, string progressMessage, bool addToObjectGraphObjects = true) { 356 if (InvokeRequired) { 357 IProgress result = (IProgress)Invoke((Func<IContent, string, bool, IProgress>)AddOperationProgressToContent, content, progressMessage, addToObjectGraphObjects); 358 return result; 359 } 360 if (contentProgressLookup.ContainsKey(content)) 361 throw new ArgumentException("A progress is already registered for the specified content.", "content"); 362 363 var contentViews = views.Keys.OfType<ContentView>(); 364 if (!contentViews.Any(v => v.Content == content)) 365 throw new ArgumentException("The content is not displayed in a top-level view", "content"); 366 367 if (addToObjectGraphObjects) { 368 var containedObjects = content.GetObjectGraphObjects(); 369 contentViews = contentViews.Where(v => containedObjects.Contains(v.Content)); 370 } else 371 contentViews = contentViews.Where(v => v.Content == content); 372 373 var progress = new Progress(progressMessage, ProgressState.Started); 374 foreach (var contentView in contentViews) { 375 progressViews.Add(new ProgressView(contentView, progress)); 376 } 377 378 contentProgressLookup[content] = progress; 379 return progress; 380 } 381 382 /// <summary> 383 /// Adds a <see cref="ProgressView"/> to the specified view. 384 /// </summary> 385 public IProgress AddOperationProgressToView(Control control, string progressMessage) { 386 var progress = new Progress(progressMessage, ProgressState.Started); 387 AddOperationProgressToView(control, progress); 388 return progress; 389 } 390 391 public void AddOperationProgressToView(Control control, IProgress progress) { 392 if (InvokeRequired) { 393 Invoke((Action<Control, IProgress>)AddOperationProgressToView, control, progress); 394 return; 395 } 396 if (control == null) throw new ArgumentNullException("control", "The view must not be null."); 397 if (progress == null) throw new ArgumentNullException("progress", "The progress must not be null."); 398 399 IProgress oldProgress; 400 if (viewProgressLookup.TryGetValue(control, out oldProgress)) { 401 foreach (var progressView in progressViews.Where(v => v.Content == oldProgress).ToList()) { 402 progressView.Dispose(); 403 progressViews.Remove(progressView); 404 } 405 viewProgressLookup.Remove(control); 406 } 407 408 progressViews.Add(new ProgressView(control, progress)); 409 viewProgressLookup[control] = progress; 410 } 411 412 /// <summary> 413 /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content. 414 /// </summary> 415 public void RemoveOperationProgressFromContent(IContent content, bool finishProgress = true) { 416 if (InvokeRequired) { 417 Invoke((Action<IContent, bool>)RemoveOperationProgressFromContent, content, finishProgress); 418 return; 419 } 420 421 IProgress progress; 422 if (!contentProgressLookup.TryGetValue(content, out progress)) 423 throw new ArgumentException("No progress is registered for the specified content.", "content"); 424 425 if (finishProgress) progress.Finish(); 426 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 427 progressView.Dispose(); 428 progressViews.Remove(progressView); 429 } 430 contentProgressLookup.Remove(content); 431 432 } 433 434 /// <summary> 435 /// Removes an existing <see cref="ProgressView"/> from the specified view. 436 /// </summary> 437 public void RemoveOperationProgressFromView(Control control, bool finishProgress = true) { 438 IProgress progress; 439 if (!viewProgressLookup.TryGetValue(control, out progress)) 440 throw new ArgumentException("No progress is registered for the specified control.", "control"); 441 442 if (finishProgress) progress.Finish(); 443 foreach (var progressView in progressViews.Where(v => v.Content == progress).ToList()) { 444 progressView.Dispose(); 445 progressViews.Remove(progressView); 446 } 447 viewProgressLookup.Remove(control); 448 } 449 #endregion 450 347 451 #region create menu and toolbar 348 452 private void CreateGUI() { -
stable/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs
r9456 r9933 28 28 public interface IProgress : IContent { 29 29 /// <summary> 30 /// Gets the currently associated status text with the progress.30 /// Gets or sets the currently associated status text with the progress. 31 31 /// </summary> 32 string Status { get; }32 string Status { get; set; } 33 33 /// <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]. 35 35 /// Values outside this range are permitted and need to be handled in some feasible manner. 36 36 /// </summary> 37 double ProgressValue { get; }37 double ProgressValue { get; set; } 38 38 /// <summary> 39 /// Gets the current state of the progress. Every progress starts in state39 /// Gets or sets the current state of the progress. Every progress starts in state 40 40 /// Started and then becomes either Canceled or Finished. 41 41 /// If it is reused it may be Started again. … … 54 54 /// </summary> 55 55 /// <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); 58 68 59 69 /// <summary> … … 74 84 event EventHandler CanBeCanceledChanged; 75 85 /// <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. 77 87 /// </summary> 78 event EventHandler <EventArgs<int>>CancelRequested;88 event EventHandler CancelRequested; 79 89 } 80 90 } -
stable/HeuristicLab.MainForm/3.3/Progress.cs
r9456 r9933 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 25 24 namespace HeuristicLab.MainForm { … … 50 49 public ProgressState ProgressState { 51 50 get { return progressState; } 52 set {51 private set { 53 52 if (progressState != value) { 54 53 progressState = value; … … 70 69 71 70 public Progress() { 72 progressState = ProgressState.Started; 71 progressState = ProgressState.Finished; 72 canBeCanceled = false; 73 73 } 74 74 public Progress(string status) … … 76 76 this.status = status; 77 77 } 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; 81 82 } 82 83 83 public void Cancel( int timeoutMs) {84 public void Cancel() { 84 85 if (canBeCanceled) 85 OnCancelRequested( timeoutMs);86 OnCancelRequested(); 86 87 } 87 88 88 /// <summary>89 /// Sets the ProgressValue to 1 and the ProgressState to Finished.90 /// </summary>91 89 public void Finish() { 92 90 if (ProgressValue != 1.0) ProgressValue = 1.0; 93 91 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; 94 102 } 95 103 … … 98 106 private void OnStatusChanged() { 99 107 var handler = StatusChanged; 100 try { 101 if (handler != null) handler(this, EventArgs.Empty); 102 } catch { } 108 if (handler != null) handler(this, EventArgs.Empty); 103 109 } 104 110 … … 106 112 private void OnProgressChanged() { 107 113 var handler = ProgressValueChanged; 108 try { 109 if (handler != null) handler(this, EventArgs.Empty); 110 } catch { } 114 if (handler != null) handler(this, EventArgs.Empty); 111 115 } 112 116 … … 114 118 private void OnProgressStateChanged() { 115 119 var handler = ProgressStateChanged; 116 try { 117 if (handler != null) handler(this, EventArgs.Empty); 118 } catch { } 120 if (handler != null) handler(this, EventArgs.Empty); 119 121 } 120 122 … … 122 124 private void OnCanBeCanceledChanged() { 123 125 var handler = CanBeCanceledChanged; 124 try { 125 if (handler != null) handler(this, EventArgs.Empty); 126 } catch { } 126 if (handler != null) handler(this, EventArgs.Empty); 127 127 } 128 128 129 public event EventHandler <EventArgs<int>>CancelRequested;130 private void OnCancelRequested( int timeoutMs) {129 public event EventHandler CancelRequested; 130 private void OnCancelRequested() { 131 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 { } 132 if (handler != null) throw new NotSupportedException("Cancel request was ignored."); 133 else handler(this, EventArgs.Empty); 136 134 } 137 135 #endregion -
stable/HeuristicLab.Optimizer/3.3/FileManager.cs
r9456 r9933 22 22 using System; 23 23 using System.Collections.Generic; 24 using System. Linq;24 using System.IO; 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Common; … … 98 98 SaveAs(view); 99 99 else { 100 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();101 Set EnabledStateOfContentViews(content, false);100 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 101 SetSaveOperationProgressInContentViews(content, true); 102 102 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 103 103 } … … 123 123 124 124 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 125 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();126 Set EnabledStateOfContentViews(content, false);125 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 126 SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName); 127 127 if (saveFileDialog.FilterIndex == 1) { 128 128 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); … … 135 135 private static void SavingCompleted(IStorableContent content, Exception error) { 136 136 try { 137 SetEnabledStateOfContentViews(content, true);138 137 if (error != null) throw error; 139 138 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); … … 143 142 } 144 143 finally { 145 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor(); 144 SetSaveOperationProgressInContentViews(content, false); 145 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor(); 146 146 } 147 147 } 148 148 149 private static void Set EnabledStateOfContentViews(IStorableContent content, bool enabled) {149 private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) { 150 150 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>(); 151 151 #region Mono Compatibility 152 152 // removed the InvokeRequired check because of Mono 153 153 mainForm.Invoke((Action)delegate { 154 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 155 views.ForEach(v => v.Enabled = enabled); 154 if (showProgress) { 155 mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename))); 156 } else 157 mainForm.RemoveOperationProgressFromContent(content); 156 158 }); 157 159 #endregion -
stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs
r9456 r9933 50 50 this.titleLabel = new System.Windows.Forms.Label(); 51 51 this.samplesGroupBox = new System.Windows.Forms.GroupBox(); 52 this.loadingPanel = new System.Windows.Forms.Panel();53 this.loadingProgressBar = new System.Windows.Forms.ProgressBar();54 this.loadingLabel = new System.Windows.Forms.Label();55 52 this.samplesListView = new System.Windows.Forms.ListView(); 56 this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();57 this.descriptionColumnHeader = new System.Windows.Forms.ColumnHeader();53 this.nameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 54 this.descriptionColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 58 55 this.imageList = new System.Windows.Forms.ImageList(this.components); 59 56 this.splitContainer = new System.Windows.Forms.SplitContainer(); 60 57 this.samplesGroupBox.SuspendLayout(); 61 this.loadingPanel.SuspendLayout();58 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 62 59 this.splitContainer.Panel1.SuspendLayout(); 63 60 this.splitContainer.Panel2.SuspendLayout(); … … 80 77 // firstStepsRichTextBox 81 78 // 82 this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 83 | System.Windows.Forms.AnchorStyles.Left)84 79 this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 80 | System.Windows.Forms.AnchorStyles.Left) 81 | System.Windows.Forms.AnchorStyles.Right))); 85 82 this.firstStepsRichTextBox.BackColor = System.Drawing.SystemColors.Control; 86 83 this.firstStepsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; … … 96 93 // titleLabel 97 94 // 98 this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 99 95 this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 96 | System.Windows.Forms.AnchorStyles.Right))); 100 97 this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 101 98 this.titleLabel.Location = new System.Drawing.Point(-1, 0); … … 108 105 // samplesGroupBox 109 106 // 110 this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 111 | System.Windows.Forms.AnchorStyles.Left) 112 | System.Windows.Forms.AnchorStyles.Right))); 113 this.samplesGroupBox.Controls.Add(this.loadingPanel); 107 this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 108 | System.Windows.Forms.AnchorStyles.Left) 109 | System.Windows.Forms.AnchorStyles.Right))); 114 110 this.samplesGroupBox.Controls.Add(this.samplesListView); 115 111 this.samplesGroupBox.Location = new System.Drawing.Point(0, 3); … … 119 115 this.samplesGroupBox.TabStop = false; 120 116 this.samplesGroupBox.Text = "Samples"; 121 //122 // loadingPanel123 //124 this.loadingPanel.Anchor = System.Windows.Forms.AnchorStyles.None;125 this.loadingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;126 this.loadingPanel.Controls.Add(this.loadingProgressBar);127 this.loadingPanel.Controls.Add(this.loadingLabel);128 this.loadingPanel.Enabled = false;129 this.loadingPanel.Location = new System.Drawing.Point(189, 89);130 this.loadingPanel.Name = "loadingPanel";131 this.loadingPanel.Size = new System.Drawing.Size(350, 62);132 this.loadingPanel.TabIndex = 1;133 //134 // loadingProgressBar135 //136 this.loadingProgressBar.Anchor = System.Windows.Forms.AnchorStyles.None;137 this.loadingProgressBar.Location = new System.Drawing.Point(101, 19);138 this.loadingProgressBar.Name = "loadingProgressBar";139 this.loadingProgressBar.Size = new System.Drawing.Size(229, 23);140 this.loadingProgressBar.Step = 1;141 this.loadingProgressBar.TabIndex = 1;142 //143 // loadingLabel144 //145 this.loadingLabel.Anchor = System.Windows.Forms.AnchorStyles.None;146 this.loadingLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));147 this.loadingLabel.Location = new System.Drawing.Point(12, 19);148 this.loadingLabel.Name = "loadingLabel";149 this.loadingLabel.Size = new System.Drawing.Size(83, 23);150 this.loadingLabel.TabIndex = 0;151 this.loadingLabel.Text = "Loading ...";152 117 // 153 118 // samplesListView … … 168 133 this.samplesListView.UseCompatibleStateImageBehavior = false; 169 134 this.samplesListView.View = System.Windows.Forms.View.Details; 135 this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag); 170 136 this.samplesListView.DoubleClick += new System.EventHandler(this.samplesListView_DoubleClick); 171 this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag);172 137 // 173 138 // nameColumnHeader … … 189 154 // splitContainer 190 155 // 191 this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 192 | System.Windows.Forms.AnchorStyles.Left)193 156 this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 157 | System.Windows.Forms.AnchorStyles.Left) 158 | System.Windows.Forms.AnchorStyles.Right))); 194 159 this.splitContainer.Location = new System.Drawing.Point(0, 0); 195 160 this.splitContainer.Name = "splitContainer"; … … 210 175 // StartPage 211 176 // 212 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);213 177 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 214 178 this.Controls.Add(this.splitContainer); … … 217 181 this.Size = new System.Drawing.Size(728, 640); 218 182 this.samplesGroupBox.ResumeLayout(false); 219 this.loadingPanel.ResumeLayout(false);220 183 this.splitContainer.Panel1.ResumeLayout(false); 221 184 this.splitContainer.Panel2.ResumeLayout(false); 185 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 222 186 this.splitContainer.ResumeLayout(false); 223 187 this.ResumeLayout(false); … … 236 200 private System.Windows.Forms.ImageList imageList; 237 201 private System.Windows.Forms.ColumnHeader descriptionColumnHeader; 238 private System.Windows.Forms.Panel loadingPanel;239 private System.Windows.Forms.ProgressBar loadingProgressBar;240 private System.Windows.Forms.Label loadingLabel;241 202 private System.Windows.Forms.SplitContainer splitContainer; 242 203 } -
stable/HeuristicLab.Optimizer/3.3/StartPage.cs
r9456 r9933 34 34 [View("Start Page")] 35 35 public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View { 36 private IProgress progress; 37 36 38 public StartPage() { 37 39 InitializeComponent(); … … 67 69 68 70 private void LoadSamples(object state) { 71 progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading..."); 69 72 Assembly assembly = Assembly.GetExecutingAssembly(); 70 73 var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl")); … … 77 80 WriteStreamToTempFile(stream, path); 78 81 INamedItem item = XmlParser.Deserialize<INamedItem>(path); 79 OnSampleLoaded(item, loadingProgressBar.Maximum/ count);82 OnSampleLoaded(item, 1.0 / count); 80 83 } 81 84 } 82 catch (Exception) { } 85 catch (Exception) { 86 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView); 87 } 83 88 } 84 89 OnAllSamplesLoaded(); 85 90 } 86 private void OnSampleLoaded(INamedItem sample, intprogress) {91 private void OnSampleLoaded(INamedItem sample, double progress) { 87 92 if (InvokeRequired) 88 Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress);93 Invoke(new Action<INamedItem, double>(OnSampleLoaded), sample, progress); 89 94 else { 90 95 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); … … 94 99 item.Tag = sample; 95 100 samplesListView.Items.Add(item); 96 loadingProgressBar.Value += progress;101 this.progress.ProgressValue += progress; 97 102 } 98 103 } … … 106 111 samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 107 112 } 108 loadingPanel.Visible = false;113 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView); 109 114 } 110 115 } -
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Views merged: 9865
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/ShrinkDataAnalysisRunsMenuItem.cs
r9932 r9933 76 76 public override void Execute() { 77 77 IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView; 78 Progress progress = new Progress("Removing duplicate datasets.");79 78 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm; 80 mainForm.AddOperationProgressToContent(activeView.Content, progress);79 mainForm.AddOperationProgressToContent(activeView.Content, "Removing duplicate datasets."); 81 80 82 81 Action<IContentView> action = (view) => {
Note: See TracChangeset
for help on using the changeset viewer.