- Timestamp:
- 10/06/10 02:51:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/OKBExperimentView.cs
r4553 r4558 47 47 OKBClient.Instance.Refreshing += new EventHandler(OKBClient_Refreshing); 48 48 OKBClient.Instance.Refreshed += new EventHandler(OKBClient_Refreshed); 49 // TODO: do not forget to deregister events 49 50 PopulateComboBoxes(); 50 51 } 51 52 52 53 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); 54 56 Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 55 57 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 63 65 protected override void RegisterContentEvents() { 64 66 base.RegisterContentEvents(); 65 Content.Changed += new EventHandler(Content_Changed); 67 Content.AlgorithmIdChanged += new EventHandler(Content_AlgorithmIdChanged); 68 Content.ProblemIdChanged += new EventHandler(Content_ProblemIdChanged); 66 69 Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 67 70 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); … … 76 79 base.OnContentChanged(); 77 80 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; 80 85 resultsViewHost.Content = null; 81 86 runsViewHost.Content = null; 82 87 executionTimeTextBox.Text = "-"; 83 88 } 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; 86 93 resultsViewHost.Content = Content.Results; 87 94 runsViewHost.Content = Content.Runs; … … 99 106 100 107 private void PopulateComboBoxes() { 108 algorithmComboBox.DataSource = null; 109 problemComboBox.DataSource = null; 101 110 Platform platform = OKBClient.Instance.Platforms.FirstOrDefault(x => x.Name == "HeuristicLab 3.3"); 102 111 if (platform != null) { 103 112 algorithmComboBox.DataSource = OKBClient.Instance.Algorithms.Where(x => x.PlatformId == platform.Id).ToList(); 104 113 algorithmComboBox.DisplayMember = "Name"; 105 algorithmComboBox.SelectedIndex = -1;106 114 problemComboBox.DataSource = OKBClient.Instance.Problems.Where(x => x.PlatformId == platform.Id).ToList(); 107 115 problemComboBox.DisplayMember = "Name"; 108 problemComboBox.SelectedIndex = -1;109 116 } 110 117 } … … 120 127 } else { 121 128 Cursor = Cursors.AppStarting; 122 Enabled = false;129 algorithmComboBox.Enabled = problemComboBox.Enabled = tabControl.Enabled = prepareButton.Enabled = startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = executionTimeTextBox.Enabled = false; 123 130 } 124 131 } … … 128 135 } else { 129 136 PopulateComboBoxes(); 130 Enabled = true;137 SetEnabledStateOfControls(); 131 138 Cursor = Cursors.Default; 132 139 } … … 134 141 135 142 #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 } 139 163 } 140 164 private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) { … … 219 243 #region Helpers 220 244 private void SetEnabledStateOfExecutableButtons() { 221 if ( Content == null) {245 if ((Content == null) || (Content.AlgorithmId == 0) || (Content.ProblemId == 0)) { 222 246 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = prepareButton.Enabled = false; 223 247 } else {
Note: See TracChangeset
for help on using the changeset viewer.