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.Analysis;
|
---|
10 | using HeuristicLab.Analysis.Views;
|
---|
11 | using HeuristicLab.Collections;
|
---|
12 | using HeuristicLab.Core;
|
---|
13 | using HeuristicLab.Core.Views;
|
---|
14 | using HeuristicLab.Data;
|
---|
15 | using HeuristicLab.DataPreprocessing.Implementations;
|
---|
16 | using HeuristicLab.MainForm;
|
---|
17 |
|
---|
18 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
19 |
|
---|
20 | [View("Scatter Plot Single View")]
|
---|
21 | [Content(typeof(ScatterPlotContent), true)]
|
---|
22 | public partial class ScatterPlotSingleView : ItemView {
|
---|
23 |
|
---|
24 | public ScatterPlotSingleView() {
|
---|
25 | InitializeComponent();
|
---|
26 | }
|
---|
27 |
|
---|
28 | public new ScatterPlotContent Content {
|
---|
29 | get { return (ScatterPlotContent)base.Content; }
|
---|
30 | set { base.Content = value; }
|
---|
31 | }
|
---|
32 |
|
---|
33 | public void InitData() {
|
---|
34 |
|
---|
35 | IEnumerable<string> variables = Content.GetVariableNames();
|
---|
36 |
|
---|
37 | // add variables to combo boxes
|
---|
38 | comboBoxXVariable.Items.Clear();
|
---|
39 | comboBoxYVariable.Items.Clear();
|
---|
40 | comboBoxXVariable.Items.AddRange(variables.ToArray());
|
---|
41 | comboBoxYVariable.Items.AddRange(variables.ToArray());
|
---|
42 |
|
---|
43 | // use x and y variable from content
|
---|
44 | if (Content.SelectedXVariable != null && Content.SelectedYVariable != null) {
|
---|
45 | comboBoxXVariable.SelectedItem = Content.SelectedXVariable;
|
---|
46 | comboBoxYVariable.SelectedItem = Content.SelectedYVariable;
|
---|
47 | } else {
|
---|
48 | if (variables.Count() >= 2) {
|
---|
49 | comboBoxXVariable.SelectedIndex = 0;
|
---|
50 | comboBoxYVariable.SelectedIndex = 1;
|
---|
51 | UpdateScatterPlot();
|
---|
52 |
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | protected override void OnContentChanged() {
|
---|
58 | base.OnContentChanged();
|
---|
59 | if (Content != null) {
|
---|
60 | InitData();
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | private void comboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
65 | UpdateScatterPlot();
|
---|
66 | }
|
---|
67 |
|
---|
68 | private void UpdateScatterPlot() {
|
---|
69 | if (comboBoxXVariable.SelectedItem != null && comboBoxYVariable.SelectedItem != null) {
|
---|
70 | //get scatter plot with selected x and y variable
|
---|
71 | ScatterPlot scatterPlot = Content.CreateScatterPlot((string)comboBoxXVariable.SelectedItem, (string)comboBoxYVariable.SelectedItem);
|
---|
72 | scatterPlotView.Content = scatterPlot;
|
---|
73 |
|
---|
74 | //save selected x and y variable in content
|
---|
75 | this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
|
---|
76 | this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | }
|
---|