1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.Core;
|
---|
10 | using HeuristicLab.PluginInfrastructure;
|
---|
11 |
|
---|
12 | namespace 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 | }
|
---|