source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ResultsViewContainer.cs @ 1108

Last change on this file since 1108 was 1108, checked in by gkronber, 12 years ago

worked on CEDMA presentation layer (bubble chart, and collection of results) (#419)

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
10using HeuristicLab.PluginInfrastructure;
11
12namespace HeuristicLab.CEDMA.Core {
13  public partial class ResultsViewContainer : ViewBase {
14    private Results results;
15
16    public ResultsViewContainer(Results results) {
17      this.results = results;
18      InitializeComponent();
19      PopulateViewComboBox();
20      showButton.Enabled = viewComboBox.SelectedItem != null;
21    }
22
23    private void PopulateViewComboBox() {
24      DiscoveryService service = new DiscoveryService();
25      IResultsView[] views = service.GetInstances<IResultsView>();
26      viewComboBox.DataSource = views;
27      viewComboBox.ValueMember = "Name";
28    }
29
30    private void showButton_Click(object sender, EventArgs e) {
31      viewPanel.Controls.Clear();
32      try {
33        IResultsView view = (IResultsView)viewComboBox.SelectedItem;
34        Control control = view.Control;
35        viewPanel.Controls.Add(control);
36        control.Dock = DockStyle.Fill;
37        view.ShowResults(results);
38      }
39      catch (Exception ex) {
40        Label errorLabel = new Label();
41        errorLabel.Text = "Couldn't load selected view: " + viewComboBox.SelectedItem + "\n" + ex.Message;
42        viewPanel.Controls.Add(errorLabel);
43        errorLabel.Dock = DockStyle.Fill;
44      }
45    }
46
47    private void viewComboBox_SelectedValueChanged(object sender, EventArgs e) {
48      showButton.Enabled = viewComboBox.SelectedItem != null;
49    }
50  }
51}
Note: See TracBrowser for help on using the repository browser.