Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/21/10 06:14:03 (15 years ago)
Author:
swagner
Message:

Adapted views according the new read-only property (#973)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r3416 r3454  
    7878      if (Content == null) {
    7979        repetitionsNumericUpDown.Value = 1;
    80         repetitionsNumericUpDown.Enabled = false;
    8180        algorithmViewHost.Content = null;
    8281        runsView.Content = null;
    83         tabControl.Enabled = false;
    84         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    8582        executionTimeTextBox.Text = "-";
    86         executionTimeTextBox.Enabled = false;
    8783      } else {
    8884        repetitionsNumericUpDown.Value = Content.Repetitions;
    89         repetitionsNumericUpDown.Enabled = true;
    90         saveAlgorithmButton.Enabled = Content.Algorithm != null;
    9185        algorithmViewHost.ViewType = null;
    9286        algorithmViewHost.Content = Content.Algorithm;
    9387        runsView.Content = Content.Runs;
    94         tabControl.Enabled = true;
    95         EnableDisableButtons();
    9688        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    97         executionTimeTextBox.Enabled = true;
    9889      }
    9990      SetEnableStateOfControls();
     
    10495    }
    10596    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;
    107101      algorithmViewHost.ReadOnly = ReadOnly;
     102      runsView.Enabled = Content != null;
    108103      runsView.ReadOnly = ReadOnly;
     104      executionTimeTextBox.Enabled = Content != null;
     105      SetEnabledStateOfExecutableButtons();
    109106    }
    110107
     
    121118        this.ReadOnly = Content.ExecutionState == ExecutionState.Started;
    122119        Locked = Content.ExecutionState == ExecutionState.Started;
    123         newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = Content.ExecutionState != ExecutionState.Started;
    124         EnableDisableButtons();
     120        SetEnabledStateOfExecutableButtons();
    125121      }
    126122    }
     
    143139        algorithmViewHost.ViewType = null;
    144140        algorithmViewHost.Content = Content.Algorithm;
    145         saveAlgorithmButton.Enabled = Content.Algorithm != null;
    146141      }
    147142    }
     
    182177      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    183178        this.Cursor = Cursors.AppStarting;
    184         newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = false;
     179        newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = false;
    185180        algorithmViewHost.Enabled = false;
    186181
     
    199194              Content.Algorithm = algorithm;
    200195            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;
    227197            this.Cursor = Cursors.Default;
    228198          }));
     
    272242
    273243    #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      }
    279253    }
    280254    #endregion
Note: See TracChangeset for help on using the changeset viewer.