- Timestamp:
- 04/21/10 06:14:03 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r3416 r3454 78 78 if (Content == null) { 79 79 repetitionsNumericUpDown.Value = 1; 80 repetitionsNumericUpDown.Enabled = false;81 80 algorithmViewHost.Content = null; 82 81 runsView.Content = null; 83 tabControl.Enabled = false;84 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;85 82 executionTimeTextBox.Text = "-"; 86 executionTimeTextBox.Enabled = false;87 83 } else { 88 84 repetitionsNumericUpDown.Value = Content.Repetitions; 89 repetitionsNumericUpDown.Enabled = true;90 saveAlgorithmButton.Enabled = Content.Algorithm != null;91 85 algorithmViewHost.ViewType = null; 92 86 algorithmViewHost.Content = Content.Algorithm; 93 87 runsView.Content = Content.Runs; 94 tabControl.Enabled = true;95 EnableDisableButtons();96 88 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 97 executionTimeTextBox.Enabled = true;98 89 } 99 90 SetEnableStateOfControls(); … … 104 95 } 105 96 private void SetEnableStateOfControls() { 106 repetitionsNumericUpDown.ReadOnly = ReadOnly; 97 repetitionsNumericUpDown.Enabled = Content != null && !ReadOnly; 98 newAlgorithmButton.Enabled = Content != null && !ReadOnly; 99 openAlgorithmButton.Enabled = Content != null && !ReadOnly; 100 algorithmViewHost.Enabled = Content != null; 107 101 algorithmViewHost.ReadOnly = ReadOnly; 102 runsView.Enabled = Content != null; 108 103 runsView.ReadOnly = ReadOnly; 104 executionTimeTextBox.Enabled = Content != null; 105 SetEnabledStateOfExecutableButtons(); 109 106 } 110 107 … … 121 118 this.ReadOnly = Content.ExecutionState == ExecutionState.Started; 122 119 Locked = Content.ExecutionState == ExecutionState.Started; 123 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = Content.ExecutionState != ExecutionState.Started; 124 EnableDisableButtons(); 120 SetEnabledStateOfExecutableButtons(); 125 121 } 126 122 } … … 143 139 algorithmViewHost.ViewType = null; 144 140 algorithmViewHost.Content = Content.Algorithm; 145 saveAlgorithmButton.Enabled = Content.Algorithm != null;146 141 } 147 142 } … … 182 177 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 183 178 this.Cursor = Cursors.AppStarting; 184 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled =false;179 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = false; 185 180 algorithmViewHost.Enabled = false; 186 181 … … 199 194 Content.Algorithm = algorithm; 200 195 algorithmViewHost.Enabled = true; 201 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = true; 202 this.Cursor = Cursors.Default; 203 })); 204 }, null); 205 } 206 } 207 private void saveAlgorithmButton_Click(object sender, EventArgs e) { 208 saveFileDialog.Title = "Save Algorithm"; 209 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 210 this.Cursor = Cursors.AppStarting; 211 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = false; 212 algorithmViewHost.Enabled = false; 213 214 var call = new Action<IAlgorithm, string, int>(XmlGenerator.Serialize); 215 int compression = 9; 216 if (saveFileDialog.FilterIndex == 1) compression = 0; 217 call.BeginInvoke(Content.Algorithm, saveFileDialog.FileName, compression, delegate(IAsyncResult a) { 218 try { 219 call.EndInvoke(a); 220 } 221 catch (Exception ex) { 222 Auxiliary.ShowErrorMessageBox(ex); 223 } 224 Invoke(new Action(delegate() { 225 algorithmViewHost.Enabled = true; 226 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = true; 196 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = true; 227 197 this.Cursor = Cursors.Default; 228 198 })); … … 272 242 273 243 #region Helpers 274 private void EnableDisableButtons() { 275 startButton.Enabled = (Content.ExecutionState == ExecutionState.Prepared) || (Content.ExecutionState == ExecutionState.Paused); 276 pauseButton.Enabled = Content.ExecutionState == ExecutionState.Started; 277 stopButton.Enabled = (Content.ExecutionState == ExecutionState.Started) || (Content.ExecutionState == ExecutionState.Paused); 278 resetButton.Enabled = Content.ExecutionState != ExecutionState.Started; 244 private void SetEnabledStateOfExecutableButtons() { 245 if (Content == null) { 246 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false; 247 } else { 248 startButton.Enabled = (Content.ExecutionState == ExecutionState.Prepared) || (Content.ExecutionState == ExecutionState.Paused); 249 pauseButton.Enabled = Content.ExecutionState == ExecutionState.Started; 250 stopButton.Enabled = (Content.ExecutionState == ExecutionState.Started) || (Content.ExecutionState == ExecutionState.Paused); 251 resetButton.Enabled = Content.ExecutionState != ExecutionState.Started; 252 } 279 253 } 280 254 #endregion
Note: See TracChangeset
for help on using the changeset viewer.