Changeset 8331 for branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
- Timestamp:
- 07/26/12 09:51:13 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs
r7582 r8331 31 31 [Content(typeof(OptimizerHiveTask), true)] 32 32 public partial class OptimizerHiveTaskView : HiveTaskView { 33 private Progress progress; 33 34 private ProgressView progressView; 34 35 … … 44 45 public OptimizerHiveTaskView() { 45 46 InitializeComponent(); 47 progress = new Progress() { 48 CanBeCanceled = false, 49 ProgressState = ProgressState.Finished 50 }; 46 51 } 47 52 … … 57 62 base.RegisterContentEvents(); 58 63 Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged); 64 progressView = new ProgressView(this, progress); 59 65 } 60 66 61 67 protected override void DeregisterContentEvents() { 62 68 Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged); 69 if (progressView != null) { 70 progressView.Content = null; 71 progressView.Dispose(); 72 progressView = null; 73 } 63 74 base.DeregisterContentEvents(); 64 75 } … … 74 85 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync); 75 86 task.ContinueWith((t) => { 76 FinishProgressView();87 progress.Finish(); 77 88 ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception); 78 89 }, TaskContinuationOptions.OnlyOnFaulted); … … 82 93 var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync); 83 94 task.ContinueWith((t) => { 84 FinishProgressView();95 progress.Finish(); 85 96 ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception); 86 97 }, TaskContinuationOptions.OnlyOnFaulted); … … 90 101 var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync); 91 102 task.ContinueWith((t) => { 92 FinishProgressView();103 progress.Finish(); 93 104 ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception); 94 105 }, TaskContinuationOptions.OnlyOnFaulted); … … 97 108 98 109 private void PauseTaskAsync() { 99 IProgress prog = new Progress(); 100 prog.Status = "Pausing task. Please be patient for the command to take effect."; 101 SetProgressView(prog); 110 progress.Status = "Pausing task. Please be patient for the command to take effect."; 111 progress.ProgressState = ProgressState.Started; 102 112 Content.Pause(); 103 FinishProgressView();113 progress.Finish(); 104 114 } 105 115 106 116 private void StopTaskAsync() { 107 IProgress prog = new Progress(); 108 prog.Status = "Stopping task. Please be patient for the command to take effect."; 109 SetProgressView(prog); 117 progress.Status = "Stopping task. Please be patient for the command to take effect."; 118 progress.ProgressState = ProgressState.Started; 110 119 Content.Stop(); 111 FinishProgressView();120 progress.Finish(); 112 121 } 113 122 114 123 private void ResumeTaskAsync() { 115 IProgress prog = new Progress(); 116 prog.Status = "Resuming task. Please be patient for the command to take effect."; 117 SetProgressView(prog); 124 progress.Status = "Resuming task. Please be patient for the command to take effect."; 125 progress.ProgressState = ProgressState.Started; 118 126 Content.Restart(); 119 FinishProgressView(); 120 } 121 122 private void SetProgressView(IProgress progress) { 123 if (InvokeRequired) { 124 Invoke(new Action<IProgress>(SetProgressView), progress); 125 } else { 126 if (progressView == null) { 127 progressView = new ProgressView(this, progress); 128 } else { 129 progressView.Progress = progress; 130 } 131 } 132 } 133 134 private void FinishProgressView() { 135 if (InvokeRequired) { 136 Invoke(new Action(FinishProgressView)); 137 } else { 138 if (progressView != null) { 139 progressView.Finish(); 140 progressView = null; 141 SetEnabledStateOfControls(); 142 } 143 } 127 progress.Finish(); 144 128 } 145 129
Note: See TracChangeset
for help on using the changeset viewer.