Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/06/10 02:51:43 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/OKBExperimentView.cs

    r4553 r4558  
    4747      OKBClient.Instance.Refreshing += new EventHandler(OKBClient_Refreshing);
    4848      OKBClient.Instance.Refreshed += new EventHandler(OKBClient_Refreshed);
     49      // TODO: do not forget to deregister events
    4950      PopulateComboBoxes();
    5051    }
    5152
    5253    protected override void DeregisterContentEvents() {
    53       Content.Changed -= new EventHandler(Content_Changed);
     54      Content.AlgorithmIdChanged -= new EventHandler(Content_AlgorithmIdChanged);
     55      Content.ProblemIdChanged -= new EventHandler(Content_ProblemIdChanged);
    5456      Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    5557      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     
    6365    protected override void RegisterContentEvents() {
    6466      base.RegisterContentEvents();
    65       Content.Changed += new EventHandler(Content_Changed);
     67      Content.AlgorithmIdChanged += new EventHandler(Content_AlgorithmIdChanged);
     68      Content.ProblemIdChanged += new EventHandler(Content_ProblemIdChanged);
    6669      Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    6770      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     
    7679      base.OnContentChanged();
    7780      if (Content == null) {
    78         problemViewHost.Content = null;
    79         parametersViewHost.Content = null;
     81        algorithmComboBox.SelectedIndex = -1;
     82        problemComboBox.SelectedIndex = -1;
     83        problemParametersViewHost.Content = null;
     84        algorithmParametersViewHost.Content = null;
    8085        resultsViewHost.Content = null;
    8186        runsViewHost.Content = null;
    8287        executionTimeTextBox.Text = "-";
    8388      } else {
    84         problemViewHost.Content = Content.Problem;
    85         parametersViewHost.Content = Content.Parameters;
     89        algorithmComboBox.SelectedItem = OKBClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
     90        problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     91        problemParametersViewHost.Content = Content.ProblemParameters;
     92        algorithmParametersViewHost.Content = Content.AlgorithmParameters;
    8693        resultsViewHost.Content = Content.Results;
    8794        runsViewHost.Content = Content.Runs;
     
    99106
    100107    private void PopulateComboBoxes() {
     108      algorithmComboBox.DataSource = null;
     109      problemComboBox.DataSource = null;
    101110      Platform platform = OKBClient.Instance.Platforms.FirstOrDefault(x => x.Name == "HeuristicLab 3.3");
    102111      if (platform != null) {
    103112        algorithmComboBox.DataSource = OKBClient.Instance.Algorithms.Where(x => x.PlatformId == platform.Id).ToList();
    104113        algorithmComboBox.DisplayMember = "Name";
    105         algorithmComboBox.SelectedIndex = -1;
    106114        problemComboBox.DataSource = OKBClient.Instance.Problems.Where(x => x.PlatformId == platform.Id).ToList();
    107115        problemComboBox.DisplayMember = "Name";
    108         problemComboBox.SelectedIndex = -1;
    109116      }
    110117    }
     
    120127      } else {
    121128        Cursor = Cursors.AppStarting;
    122         Enabled = false;
     129        algorithmComboBox.Enabled = problemComboBox.Enabled = tabControl.Enabled = prepareButton.Enabled = startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = executionTimeTextBox.Enabled = false;
    123130      }
    124131    }
     
    128135      } else {
    129136        PopulateComboBoxes();
    130         Enabled = true;
     137        SetEnabledStateOfControls();
    131138        Cursor = Cursors.Default;
    132139      }
     
    134141
    135142    #region Content Events
    136     private void Content_Changed(object sender, EventArgs e) {
    137       OnContentChanged();
    138       SetEnabledStateOfControls();
     143    private void Content_AlgorithmIdChanged(object sender, EventArgs e) {
     144      if (InvokeRequired)
     145        Invoke(new EventHandler(Content_AlgorithmIdChanged), sender, e);
     146      else {
     147        algorithmComboBox.SelectedItem = OKBClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
     148        algorithmParametersViewHost.Content = Content.AlgorithmParameters;
     149        resultsViewHost.Content = Content.Results;
     150        runsViewHost.Content = Content.Runs;
     151        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     152        SetEnabledStateOfExecutableButtons();
     153      }
     154    }
     155    private void Content_ProblemIdChanged(object sender, EventArgs e) {
     156      if (InvokeRequired)
     157        Invoke(new EventHandler(Content_ProblemIdChanged), sender, e);
     158      else {
     159        problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     160        problemParametersViewHost.Content = Content.ProblemParameters;
     161        SetEnabledStateOfExecutableButtons();
     162      }
    139163    }
    140164    private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     
    219243    #region Helpers
    220244    private void SetEnabledStateOfExecutableButtons() {
    221       if (Content == null) {
     245      if ((Content == null) || (Content.AlgorithmId == 0) || (Content.ProblemId == 0)) {
    222246        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = prepareButton.Enabled = false;
    223247      } else {
Note: See TracChangeset for help on using the changeset viewer.