1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Drawing;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Analysis.Views {
|
---|
29 | [View("DataRow Visual Properties")]
|
---|
30 | public partial class DataRowVisualPropertiesControl : UserControl {
|
---|
31 | protected bool SuppressEvents { get; set; }
|
---|
32 |
|
---|
33 | private DataRowVisualProperties content;
|
---|
34 | public DataRowVisualProperties Content {
|
---|
35 | get { return content; }
|
---|
36 | set {
|
---|
37 | bool changed = (value != content);
|
---|
38 | content = value;
|
---|
39 | if (changed) OnContentChanged();
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public DataRowVisualPropertiesControl() {
|
---|
44 | InitializeComponent();
|
---|
45 | chartTypeComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowChartType));
|
---|
46 | }
|
---|
47 |
|
---|
48 | protected virtual void OnContentChanged() {
|
---|
49 | SuppressEvents = true;
|
---|
50 | try {
|
---|
51 | if (Content == null) {
|
---|
52 | chartTypeComboBox.SelectedIndex = -1;
|
---|
53 | colorButton.BackColor = SystemColors.Control;
|
---|
54 | secondYAxisCheckBox.Checked = false;
|
---|
55 | startIndexZeroCheckBox.Checked = false;
|
---|
56 | binsNumericUpDown.Value = 1;
|
---|
57 | exactBinsCheckBox.Checked = false;
|
---|
58 | } else {
|
---|
59 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
60 | colorButton.BackColor = Content.Color;
|
---|
61 | secondYAxisCheckBox.Checked = Content.SecondYAxis;
|
---|
62 | startIndexZeroCheckBox.Checked = Content.StartIndexZero;
|
---|
63 | binsNumericUpDown.Value = Content.Bins;
|
---|
64 | exactBinsCheckBox.Checked = Content.ExactBins;
|
---|
65 | }
|
---|
66 | } finally { SuppressEvents = false; }
|
---|
67 | SetEnabledStateOfControls();
|
---|
68 | }
|
---|
69 |
|
---|
70 | protected virtual void SetEnabledStateOfControls() {
|
---|
71 | commonGroupBox.Enabled = Content != null;
|
---|
72 | histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram;
|
---|
73 | }
|
---|
74 |
|
---|
75 | #region Event Handlers
|
---|
76 | private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
77 | if (!SuppressEvents && Content != null) {
|
---|
78 | Content.ChartType = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue;
|
---|
79 | SetEnabledStateOfControls();
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
84 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
85 | Content.Color = colorDialog.Color;
|
---|
86 | colorButton.BackColor = Content.Color;
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | private void secondYAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
91 | if (!SuppressEvents && Content != null) {
|
---|
92 | Content.SecondYAxis = secondYAxisCheckBox.Checked;
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
97 | if (!SuppressEvents && Content != null) {
|
---|
98 | Content.StartIndexZero = startIndexZeroCheckBox.Checked;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | private void binsNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
103 | if (!SuppressEvents && Content != null) {
|
---|
104 | Content.Bins = (int)binsNumericUpDown.Value;
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | private void exactBinsCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
109 | if (!SuppressEvents && Content != null) {
|
---|
110 | Content.ExactBins = exactBinsCheckBox.Checked;
|
---|
111 | }
|
---|
112 | }
|
---|
113 | #endregion
|
---|
114 | }
|
---|
115 | }
|
---|