Changeset 15477
- Timestamp:
- 11/16/17 10:30:21 (7 years ago)
- Location:
- branches/EnhancedProgress
- Files:
-
- 28 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/EnhancedProgress/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs
r15446 r15477 173 173 174 174 private void addLineToChart_Click(object sender, EventArgs e) { 175 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Adding fitted lines to charts...");175 Progress.ShowMarquee(this, "Adding fitted lines to charts..."); 176 176 177 177 string resultName = (string)dataTableComboBox.SelectedItem; … … 181 181 182 182 task.ContinueWith((t) => { 183 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);183 Progress.Hide(this); 184 184 ErrorHandling.ShowErrorDialog("An error occured while adding lines to charts. ", t.Exception); 185 185 }, TaskContinuationOptions.OnlyOnFaulted); 186 186 187 187 task.ContinueWith((t) => { 188 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);188 Progress.Hide(this); 189 189 }, TaskContinuationOptions.OnlyOnRanToCompletion); 190 190 } … … 273 273 var task = Task.Factory.StartNew(() => { 274 274 sem.Wait(); 275 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...", 0);275 progress = Progress.Show(this, "Calculating values..."); 276 276 RebuildDataTable(resultName, rowName); 277 277 }); 278 278 279 279 task.ContinueWith((t) => { 280 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);280 Progress.Hide(this); 281 281 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 282 282 sem.Release(); … … 284 284 285 285 task.ContinueWith((t) => { 286 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);286 Progress.Hide(this); 287 287 sem.Release(); 288 288 }, TaskContinuationOptions.OnlyOnRanToCompletion); -
branches/EnhancedProgress/HeuristicLab.Analysis.Statistics.Views/3.3/StatisticalTestsView.cs
r14185 r15477 356 356 357 357 if (data != null && data.All(x => x != null)) { 358 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>() 359 .AddOperationProgressToView(this, "Calculating..."); 358 Progress.ShowMarquee(this, "Calculating..."); 360 359 361 360 string curItem = (string)groupCompComboBox.SelectedItem; … … 369 368 CalculatePairwiseTest(groupName); 370 369 371 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);370 Progress.Hide(this); 372 371 } 373 372 … … 377 376 return; 378 377 379 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(pairwiseTestGroupBox, "Calculating...");378 Progress.ShowMarquee(pairwiseTestGroupBox, "Calculating..."); 380 379 Task.Factory.StartNew(() => CalculatePairwiseAsync(groupName)); 381 380 } … … 384 383 CalculatePairwiseTest(groupName); 385 384 386 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(pairwiseTestGroupBox);385 Progress.Hide(pairwiseTestGroupBox); 387 386 } 388 387 -
branches/EnhancedProgress/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs
r14185 r15477 77 77 public void StartProgressView() { 78 78 var message = "Downloading client information. Please be patient."; 79 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);79 Progress.ShowMarquee(this, message); 80 80 } 81 81 82 82 public void FinishProgressView() { 83 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);83 Progress.Hide(this); 84 84 } 85 85 } -
branches/EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/RunInHiveMenuItem.cs
r14185 r15477 82 82 task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; 83 83 84 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive...");84 progress = Progress.ShowMarquee(this.content, "Uploading to Hive..."); 85 85 rJob.Progress = progress; 86 86 progress.ProgressStateChanged += progress_ProgressStateChanged; … … 91 91 private void progress_ProgressStateChanged(object sender, EventArgs e) { 92 92 if (progress.ProgressState != ProgressState.Started) { 93 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromContent(content);93 Progress.Hide(content); 94 94 progress.ProgressStateChanged -= progress_ProgressStateChanged; 95 95 } … … 97 97 98 98 private void HandleEx(Exception ex) { 99 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromContent(content);99 Progress.Hide(content); 100 100 progress.ProgressStateChanged -= progress_ProgressStateChanged; 101 101 ErrorHandling.ShowErrorDialog("Error uploading tasks", ex); -
branches/EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r14185 r15477 68 68 Invoke(new Action(StartProgressView)); 69 69 } else { 70 var message = "Downloading resources. Please be patient."; 71 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 70 Progress.ShowMarquee(this, "Downloading resources. Please be patient."); 72 71 } 73 72 } … … 77 76 Invoke(new Action(FinishProgressView)); 78 77 } else { 79 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);78 Progress.Hide(this); 80 79 } 81 80 } -
branches/EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r14185 r15477 109 109 110 110 task.ContinueWith((t) => { 111 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);111 Progress.Hide(this); 112 112 ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception); 113 113 }, TaskContinuationOptions.OnlyOnFaulted); … … 120 120 121 121 private void DeleteHiveJobsAsync(object items) { 122 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Deleting job...");122 Progress.ShowMarquee(this, "Deleting job..."); 123 123 foreach (RefreshableJob item in (List<RefreshableJob>)items) { 124 124 Content.Remove(item); 125 125 } 126 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);126 Progress.Hide(this); 127 127 } 128 128 -
branches/EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r14901 r15477 71 71 Content.Loaded += new EventHandler(Content_Loaded); 72 72 Content.TaskReceived += new EventHandler(Content_TaskReceived); 73 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().Add OperationProgressToView(this, Content.Progress);73 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddProgressToView(this, Content.Progress); 74 74 } 75 75 … … 86 86 Content.Loaded -= new EventHandler(Content_Loaded); 87 87 Content.TaskReceived -= new EventHandler(Content_TaskReceived); 88 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().Remove OperationProgressFromView(this, false);88 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveProgressFromView(this, false); 89 89 DeregisterHiveExperimentEvents(); 90 90 DeregisterHiveTasksEvents(); … … 137 137 } 138 138 } 139 } 140 finally { 139 } finally { 141 140 SuppressEvents = false; 142 141 } … … 381 380 382 381 private void PauseJobAsync(object job) { 383 Content.Progress.Start ("Pausing job...");382 Content.Progress.StartMarquee("Pausing job..."); 384 383 HiveClient.PauseJob((RefreshableJob)job); 385 384 Content.Progress.Finish(); … … 387 386 388 387 private void StopJobAsync(object job) { 389 Content.Progress.Start ("Stopping job...");388 Content.Progress.StartMarquee("Stopping job..."); 390 389 HiveClient.StopJob((RefreshableJob)job); 391 390 Content.Progress.Finish(); … … 393 392 394 393 private void ResumeJobAsync(object job) { 395 Content.Progress.Start ("Resuming job...");394 Content.Progress.StartMarquee("Resuming job..."); 396 395 HiveClient.ResumeJob((RefreshableJob)job); 397 396 Content.Progress.Finish(); … … 417 416 try { 418 417 invoker.EndInvoke(ar); 419 } 420 catch (Exception ex) { 421 ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 418 } catch (Exception ex) { 419 ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 422 420 } 423 421 }, null); … … 506 504 if (subTask is OptimizerHiveTask) { 507 505 OptimizerHiveTask ohTask = subTask as OptimizerHiveTask; 508 ohTask.ExecuteReadActionOnItemTask(new Action(delegate () {506 ohTask.ExecuteReadActionOnItemTask(new Action(delegate () { 509 507 runs.AddRange(ohTask.ItemTask.Item.Runs); 510 508 })); -
branches/EnhancedProgress/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r15121 r15477 46 46 protected override void Job_ItemChanged(object sender, EventArgs e) { 47 47 if (Content != null && Content.Task != null && Content.ItemTask.Item != null) { 48 Content.ExecuteReadActionOnItemTask(new Action(delegate () {48 Content.ExecuteReadActionOnItemTask(new Action(delegate () { 49 49 runCollectionViewHost.Content = Content.ItemTask.Item.Runs; 50 50 })); … … 58 58 base.RegisterContentEvents(); 59 59 Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged); 60 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().Add OperationProgressToView(this, Content.Progress);60 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddProgressToView(this, Content.Progress); 61 61 } 62 62 63 63 protected override void DeregisterContentEvents() { 64 64 Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged); 65 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().Remove OperationProgressFromView(this, false);65 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveProgressFromView(this, false); 66 66 base.DeregisterContentEvents(); 67 67 } … … 99 99 100 100 private void PauseTaskAsync() { 101 Content.Progress.Start ("Pausing task. Please be patient for the command to take effect.");101 Content.Progress.StartMarquee("Pausing task. Please be patient for the command to take effect."); 102 102 Content.Pause(); 103 103 Content.Progress.Finish(); … … 105 105 106 106 private void StopTaskAsync() { 107 Content.Progress.Start ("Stopping task. Please be patient for the command to take effect.");107 Content.Progress.StartMarquee("Stopping task. Please be patient for the command to take effect."); 108 108 Content.Stop(); 109 109 Content.Progress.Finish(); … … 111 111 112 112 private void ResumeTaskAsync() { 113 Content.Progress.Start ("Resuming task. Please be patient for the command to take effect.");113 Content.Progress.StartMarquee("Resuming task. Please be patient for the command to take effect."); 114 114 Content.Restart(); 115 115 Content.Progress.Finish(); -
branches/EnhancedProgress/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj
r14738 r15477 229 229 <Private>False</Private> 230 230 </ProjectReference> 231 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj"> 232 <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project> 233 <Name>HeuristicLab.MainForm.WindowsForms-3.3</Name> 234 <Private>False</Private> 235 </ProjectReference> 231 236 <ProjectReference Include="..\..\HeuristicLab.MainForm\3.3\HeuristicLab.MainForm-3.3.csproj"> 232 237 <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project> -
branches/EnhancedProgress/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15446 r15477 249 249 try { 250 250 refreshableJob.IsProgressing = true; 251 refreshableJob.Progress.Start ("Connecting to server...");251 refreshableJob.Progress.StartMarquee("Connecting to server..."); 252 252 IEnumerable<string> resourceNames = ToResourceNameList(refreshableJob.Job.ResourceNames); 253 253 var resourceIds = new List<Guid>(); … … 414 414 415 415 // fetch all task objects to create the full tree of tree of HiveTask objects 416 refreshableJob.Progress.Start ("Downloading list of tasks...");416 refreshableJob.Progress.StartMarquee("Downloading list of tasks..."); 417 417 allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(hiveExperiment.Id)); 418 418 totalJobCount = allTasks.Count(); -
branches/EnhancedProgress/HeuristicLab.Clients.Hive/3.3/Plugin.cs.frame
r14195 r15477 36 36 [PluginDependency("HeuristicLab.Hive", "3.3")] 37 37 [PluginDependency("HeuristicLab.MainForm", "3.3")] 38 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 38 39 [PluginDependency("HeuristicLab.Optimization", "3.3")] 39 40 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/EnhancedProgress/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r15446 r15477 188 188 if (InvokeRequired) { Invoke((Action<object, EventArgs>)RunCreationClient_Refreshing, sender, e); return; } 189 189 var message = "Refreshing algorithms and problems..."; 190 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);190 Progress.ShowMarquee(this, message); 191 191 refreshing = true; 192 192 SetEnabledStateOfControls(); … … 195 195 private void RunCreationClient_Refreshed(object sender, EventArgs e) { 196 196 if (InvokeRequired) { Invoke((Action<object, EventArgs>)RunCreationClient_Refreshed, sender, e); return; } 197 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);197 Progress.Hide(this); 198 198 refreshing = false; 199 199 SetEnabledStateOfControls(); … … 203 203 var task = System.Threading.Tasks.Task.Factory.StartNew(UploadAsync); 204 204 task.ContinueWith((t) => { 205 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);205 Progress.Hide(this); 206 206 PluginInfrastructure.ErrorHandling.ShowErrorDialog("An exception occured while uploading the runs to the OKB.", t.Exception); 207 207 }, TaskContinuationOptions.OnlyOnFaulted); … … 210 210 private void UploadAsync() { 211 211 var message = "Uploading runs to OKB..."; 212 IProgress progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message, 0);212 IProgress progress = Progress.Show(this, message); 213 213 double count = dataGridView.Rows.Count; 214 214 int i = 0; … … 226 226 progress.ProgressValue = ((double)i) / count; 227 227 } 228 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);228 Progress.Hide(this); 229 229 ClearRuns(); 230 230 } -
branches/EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs
r15446 r15477 169 169 await Task.Run(() => { 170 170 TProblemData instance; 171 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;172 171 // lock active view and show progress bar 173 var activeView = (IContentView)MainFormManager.MainForm.ActiveView;174 172 175 173 try { 176 var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.", 0); 177 174 var progress = Progress.Show(Content, "Loading problem instance."); 178 175 instanceProvider.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; }; 179 176 … … 181 178 } catch (IOException ex) { 182 179 MessageBox.Show(string.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error); 183 mainForm.RemoveOperationProgressFromContent(activeView.Content);180 Progress.Hide(Content); 184 181 return; 185 182 } … … 189 186 MessageBox.Show(string.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(importDialog.Path), Environment.NewLine + ex.Message), "Cannot load instance"); 190 187 } finally { 191 mainForm.RemoveOperationProgressFromContent(activeView.Content);188 Progress.Hide(Content); 192 189 } 193 190 }); … … 226 223 var storable = itemCreator() as IStorableContent; 227 224 if (storable != null) { 228 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;229 var activeView = (IContentView)MainFormManager.MainForm.ActiveView;230 225 try { 231 mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data.");226 Progress.ShowMarquee(Content, "Exporting data."); 232 227 ContentManager.Save(storable, saveFileDialog.FileName, compressed); 233 228 } finally { 234 mainForm.RemoveOperationProgressFromContent(activeView.Content);229 Progress.Hide(Content); 235 230 } 236 231 } … … 248 243 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 249 244 Task.Run(() => { 250 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;251 var activeView = (IContentView)MainFormManager.MainForm.ActiveView;252 245 try { 253 246 var problemData = Content.CreateNewProblemData(); 254 mainForm.AddOperationProgressToContent(activeView.Content, "Exporting data.");247 Progress.ShowMarquee(Content, "Exporting data."); 255 248 if (problemData is TimeSeriesPrognosisProblemData) 256 249 Export(new TimeSeriesPrognosisCSVInstanceProvider(), problemData, saveFileDialog.FileName); … … 260 253 Export(new ClassificationCSVInstanceProvider(), problemData, saveFileDialog.FileName); 261 254 } finally { 262 mainForm.RemoveOperationProgressFromContent(activeView.Content);255 Progress.Hide(Content); 263 256 } 264 257 }); -
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj
r11623 r15477 151 151 </Compile> 152 152 <Compile Include="Plugin.cs" /> 153 <Compile Include="Progress.cs" /> 153 154 <Compile Include="Views\AsynchronousContentView.cs"> 154 155 <SubType>UserControl</SubType> -
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r15446 r15477 350 350 private readonly List<ProgressView> progressViews = new List<ProgressView>(); 351 351 352 public IProgress AddOperationProgressToContent(IContent content, string progressMessage, double? initialProgressValue = null, bool addToObjectGraphObjects = true) {353 var progress = new Progress();354 if (initialProgressValue.HasValue)355 progress.Start(progressMessage, initialProgressValue.Value);356 else357 progress.Start(progressMessage);358 AddOperationProgressToContent(content, progress, addToObjectGraphObjects);359 return progress;360 }361 352 /// <summary> 362 353 /// Adds a <see cref="ProgressView"/> to the <see cref="ContentView"/>s showing the specified content. 363 354 /// </summary> 364 public void Add OperationProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) {355 public void AddProgressToContent(IContent content, IProgress progress, bool addToObjectGraphObjects = true) { 365 356 if (InvokeRequired) { 366 Invoke((Action<IContent, IProgress, bool>)Add OperationProgressToContent, content, progress, addToObjectGraphObjects);357 Invoke((Action<IContent, IProgress, bool>)AddProgressToContent, content, progress, addToObjectGraphObjects); 367 358 return; 368 359 } … … 387 378 } 388 379 389 public IProgress AddOperationProgressToView(Control control, string progressMessage, double? initialProgressValue = null) {390 var progress = new Progress();391 if (initialProgressValue.HasValue)392 progress.Start(progressMessage, initialProgressValue.Value);393 else394 progress.Start(progressMessage);395 AddOperationProgressToView(control, progress);396 return progress;397 }398 380 /// <summary> 399 381 /// Adds a <see cref="ProgressView"/> to the specified view. 400 382 /// </summary> 401 public void Add OperationProgressToView(Control control, IProgress progress) {383 public void AddProgressToView(Control control, IProgress progress) { 402 384 if (InvokeRequired) { 403 Invoke((Action<Control, IProgress>)Add OperationProgressToView, control, progress);385 Invoke((Action<Control, IProgress>)AddProgressToView, control, progress); 404 386 return; 405 387 } … … 423 405 /// Removes an existing <see cref="ProgressView"/> from the <see cref="ContentView"/>s showing the specified content. 424 406 /// </summary> 425 public void Remove OperationProgressFromContent(IContent content, bool finishProgress = true) {407 public void RemoveProgressFromContent(IContent content, bool finishProgress = true) { 426 408 if (InvokeRequired) { 427 Invoke((Action<IContent, bool>)Remove OperationProgressFromContent, content, finishProgress);409 Invoke((Action<IContent, bool>)RemoveProgressFromContent, content, finishProgress); 428 410 return; 429 411 } … … 439 421 } 440 422 contentProgressLookup.Remove(content); 441 442 423 } 443 424 … … 445 426 /// Removes an existing <see cref="ProgressView"/> from the specified view. 446 427 /// </summary> 447 public void Remove OperationProgressFromView(Control control, bool finishProgress = true) {428 public void RemoveProgressFromView(Control control, bool finishProgress = true) { 448 429 if (InvokeRequired) { 449 Invoke((Action<Control, bool>)Remove OperationProgressFromView, control, finishProgress);430 Invoke((Action<Control, bool>)RemoveProgressFromView, control, finishProgress); 450 431 return; 451 432 } -
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Progress.cs
r15466 r15477 21 21 22 22 using System; 23 using System.Windows.Forms; 24 using HeuristicLab.Common; 23 25 24 26 namespace HeuristicLab.MainForm { … … 100 102 } 101 103 102 /// <summary> 103 /// Starts or restarts an "undefined" progress in marquee-mode 104 /// </summary> 105 public void Start(string message) { 106 ProgressState = ProgressState.Started; 107 ProgressBarMode = ProgressBarMode.Marquee; 108 Message = message; 109 } 110 /// <summary> 111 /// Starts or restarts a progress in continuous-mode 112 /// </summary> 113 public void Start(string message, double progressValue) { 104 public void Start(string message, double progressValue = 0) { 114 105 ProgressState = ProgressState.Started; 115 106 ProgressBarMode = ProgressBarMode.Continuous; 116 107 ProgressValue = progressValue; 108 Message = message; 109 } 110 public void StartMarquee(string message) { 111 ProgressState = ProgressState.Started; 112 ProgressBarMode = ProgressBarMode.Marquee; 117 113 Message = message; 118 114 } … … 137 133 } 138 134 135 #region Show/Hide Progress 136 /// <summary> 137 /// Shows a started Progress in Continuous-mode on all Views of the specified content. 138 /// </summary> 139 public static IProgress Show(IContent content, string progressMessage, double initialProgressValue = 0, bool addToObjectGraphObjects = true) { 140 var progress = new Progress(); 141 progress.Start(progressMessage, initialProgressValue); 142 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(content, progress, addToObjectGraphObjects); 143 return progress; 144 } 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) { 149 var progress = new Progress(); 150 progress.StartMarquee(progressMessage); 151 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToContent(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) { 159 var progress = new Progress(); 160 progress.Start(progressMessage, initialProgressValue); 161 MainFormManager.GetMainForm<WindowsForms.MainForm>().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 MainFormManager.GetMainForm<WindowsForms.MainForm>().AddProgressToView(control, progress); 171 return progress; 172 } 173 174 /// <summary> 175 /// Hides the Progress fom all Views of the specified content. 176 /// </summary> 177 public static void Hide(IContent content) { 178 MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromContent(content); 179 } 180 /// <summary> 181 /// Hides the Progress fom the specified view. 182 /// </summary> 183 public static void Hide(Control control) { 184 MainFormManager.GetMainForm<WindowsForms.MainForm>().RemoveProgressFromView(control); 185 } 186 #endregion 187 139 188 #region Event Handler 140 189 public event EventHandler ProgressStateChanged; -
branches/EnhancedProgress/HeuristicLab.MainForm/3.3/HeuristicLab.MainForm-3.3.csproj
r11623 r15477 124 124 <Compile Include="Interfaces\IProgress.cs" /> 125 125 <Compile Include="Plugin.cs" /> 126 <Compile Include="Progress.cs" />127 126 <Compile Include="ViewAttribute.cs" /> 128 127 <Compile Include="Interfaces\IContentView.cs" /> -
branches/EnhancedProgress/HeuristicLab.MainForm/3.3/Interfaces/IProgress.cs
r15417 r15477 35 35 /// Changing the ProgressValue when ProgressBarMode is Marquee raises an Exception. 36 36 /// </summary> 37 /// <exception cref="InvalidOperationException">Setting the ProgressValue-property while in the Marquee state is invalid.</exception> 37 38 double ProgressValue { get; set; } 38 39 bool CanBeStopped { get; } … … 40 41 41 42 /// <summary> 42 /// Start (or Restart) a progress with ProgressBarMode Marquee 43 /// Start (or Restart) a progress in ProgressBarMode Continues to display specific progress values (from 0 to 1). 44 /// A new progress value is reported by setting the ProgressValue-property. 43 45 /// </summary> 44 void Start(string message); 46 void Start(string message, double progressValue = 0); 47 45 48 /// <summary> 46 /// Start (or Restart) a progress with ProgressBarMode Continues 49 /// Start (or Restart) a progress in ProgressBarMode Marquee to define an "unknown" progress state. 50 /// Consider using marquee when the progress is not measurable but the user should be notified that something is still happening. 51 /// Setting the ProgressValue-property in the Marquee state throws an exception. 47 52 /// </summary> 48 void Start(string message, double progressValue); 53 void StartMarquee(string message); 54 49 55 void Finish(); 50 56 void Stop(); -
branches/EnhancedProgress/HeuristicLab.Optimizer/3.3/FileManager.cs
r14185 r15477 161 161 mainForm.Invoke((Action)delegate { 162 162 if (showProgress) { 163 mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename)));163 Progress.ShowMarquee(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename))); 164 164 } else 165 mainForm.RemoveOperationProgressFromContent(content);165 Progress.Hide(content); 166 166 }); 167 167 #endregion -
branches/EnhancedProgress/HeuristicLab.Optimizer/3.3/StartPage.cs
r15446 r15477 88 88 89 89 private void LoadSamples(object state) { 90 progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...", 0);90 progress = Progress.Show(samplesListView, "Loading..."); 91 91 try { 92 92 var assembly = Assembly.GetExecutingAssembly(); … … 112 112 OnAllSamplesLoaded(); 113 113 } finally { 114 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);114 Progress.Hide(samplesListView); 115 115 } 116 116 } -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicClassificationSolutionView.cs
r14185 r15477 60 60 var name = exportFileDialog.FileName; 61 61 using (BackgroundWorker bg = new BackgroundWorker()) { 62 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");62 Progress.ShowMarquee(this, "Exportion solution to " + name + "."); 63 63 bg.DoWork += (o, a) => exporter.Export(Content, name); 64 bg.RunWorkerCompleted += (o, a) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);64 bg.RunWorkerCompleted += (o, a) => Progress.Hide(this); 65 65 bg.RunWorkerAsync(); 66 66 } -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs
r14185 r15477 59 59 var name = exportFileDialog.FileName; 60 60 using (BackgroundWorker bg = new BackgroundWorker()) { 61 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");61 Progress.ShowMarquee(this, "Exportion solution to " + name + "."); 62 62 bg.DoWork += (o, a) => exporter.Export(Content, name); 63 bg.RunWorkerCompleted += (o, a) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);63 bg.RunWorkerCompleted += (o, a) => Progress.Hide(this); 64 64 bg.RunWorkerAsync(); 65 65 } -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs
r15371 r15477 61 61 var name = exportFileDialog.FileName; 62 62 using (BackgroundWorker bg = new BackgroundWorker()) { 63 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exporting solution to " + name + ".");63 Progress.ShowMarquee(this, "Exporting solution to " + name + "."); 64 64 bg.DoWork += (o, a) => exporter.Export(Content, name); 65 bg.RunWorkerCompleted += (o, a) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);65 bg.RunWorkerCompleted += (o, a) => Progress.Hide(this); 66 66 bg.RunWorkerAsync(); 67 67 } -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r15444 r15477 154 154 Content.ProblemDataChanged += Content_Changed; 155 155 treeChart.Repainted += treeChart_Repainted; 156 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().Add OperationProgressToView(grpSimplify, progress);156 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddProgressToView(grpSimplify, progress); 157 157 progress.StopRequested += progress_StopRequested; 158 158 } … … 162 162 Content.ProblemDataChanged -= Content_Changed; 163 163 treeChart.Repainted -= treeChart_Repainted; 164 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().Remove OperationProgressFromView(grpSimplify, false);164 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveProgressFromView(grpSimplify, false); 165 165 progress.StopRequested -= progress_StopRequested; 166 166 } … … 191 191 treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 192 192 193 progress.Start("Calculate Impact and Replacement Values ..." , 0);193 progress.Start("Calculate Impact and Replacement Values ..."); 194 194 progress.CanBeStopped = true; 195 195 cancellationTokenSource = new CancellationTokenSource(); … … 312 312 313 313 private async void btnOptimizeConstants_Click(object sender, EventArgs e) { 314 progress.Start("Optimizing Constants ..." , 0);314 progress.Start("Optimizing Constants ..."); 315 315 var tree = (ISymbolicExpressionTree)Content.Model.SymbolicExpressionTree.Clone(); 316 316 var newTree = await Task.Run(() => OptimizeConstants(tree, progress)); -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/ShrinkDataAnalysisRunsMenuItem.cs
r14185 r15477 76 76 public override void Execute() { 77 77 IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView; 78 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;79 mainForm.AddOperationProgressToContent(activeView.Content, "Removing duplicate datasets.");78 var content = activeView.Content; 79 Progress.ShowMarquee(content, "Removing duplicate datasets."); 80 80 81 81 Action<IContentView> action = (view) => { … … 90 90 }; 91 91 92 action.BeginInvoke(activeView, delegate (IAsyncResult result) {92 action.BeginInvoke(activeView, delegate (IAsyncResult result) { 93 93 action.EndInvoke(result); 94 mainForm.RemoveOperationProgressFromContent(activeView.Content);94 Progress.Hide(content); 95 95 }, null); 96 96 } -
branches/EnhancedProgress/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r14826 r15477 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.MainForm; 26 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;27 26 28 27 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 80 79 || factorVarReplComboBox.SelectedIndex < 0 81 80 || dataPartitionComboBox.SelectedIndex < 0) return; 82 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;83 81 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 84 82 var replMethod = … … 93 91 Task.Factory.StartNew(() => { 94 92 try { 95 mainForm.AddOperationProgressToView(this, "Calculating variable impacts for " + Content.Name);93 Progress.ShowMarquee(this, "Calculating variable impacts for " + Content.Name); 96 94 97 95 var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content, dataPartition, replMethod, factorReplMethod); … … 100 98 variableImactsArrayView.Content = (DoubleArray)impactArray.AsReadOnly(); 101 99 } finally { 102 mainForm.RemoveOperationProgressFromView(this);100 Progress.Hide(this); 103 101 } 104 102 }); -
branches/EnhancedProgress/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionInstanceProviderView.cs
r15446 r15477 46 46 47 47 Task.Factory.StartNew(() => { 48 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm; 48 var activeView = (IContentView)MainFormManager.MainForm.ActiveView; 49 var content = activeView.Content; 49 50 // lock active view and show progress bar 50 IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView; 51 try { 52 var progress = Progress.Show(content, "Loading problem instance."); 51 53 52 try { 53 var progress = mainForm.AddOperationProgressToContent(activeView.Content, 54 "Loading problem instance.", 0); 54 Content.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; }; 55 55 56 Content.ProgressChanged += 57 (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; }; 58 59 instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, 60 importTypeDialog.CSVFormat); 56 instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat); 61 57 } catch (Exception ex) { 62 58 ErrorWhileParsing(ex); 63 59 return; 64 60 } finally { 65 mainForm.RemoveOperationProgressFromContent(activeView.Content);61 Progress.Hide(content); 66 62 } 67 63 -
branches/EnhancedProgress/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs
r14185 r15477 121 121 122 122 IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView; 123 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;123 var content = activeView.Content; 124 124 // lock active view and show progress bar 125 mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");125 Progress.ShowMarquee(content, "Loading problem instance."); 126 126 127 127 Task.Factory.StartNew(() => { … … 131 131 } catch (Exception ex) { 132 132 ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex); 133 mainForm.RemoveOperationProgressFromContent(activeView.Content);133 Progress.Hide(content); 134 134 return; 135 135 } … … 139 139 ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex); 140 140 } finally { 141 mainForm.RemoveOperationProgressFromContent(activeView.Content);141 Progress.Hide(content); 142 142 } 143 143 }); -
branches/EnhancedProgress/HeuristicLab.Scripting.Views/3.3/ScriptView.cs
r14185 r15477 178 178 179 179 private void AddProgressView(string progressMessage) { 180 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 181 mainForm.AddOperationProgressToView(this, progressMessage); 180 Progress.ShowMarquee(this, progressMessage); 182 181 progressViewCreated = true; 183 182 } … … 185 184 private void RemoveProgressView() { 186 185 if (!progressViewCreated) return; 187 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 188 mainForm.RemoveOperationProgressFromView(this); 186 Progress.Hide(this); 189 187 progressViewCreated = false; 190 188 }
Note: See TracChangeset
for help on using the changeset viewer.