[6010] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[6010] | 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));
|
---|
[6012] | 46 | lineStyleComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowLineStyle));
|
---|
[8085] | 47 | SetEnabledStateOfControls();
|
---|
[6010] | 48 | }
|
---|
| 49 |
|
---|
| 50 | protected virtual void OnContentChanged() {
|
---|
| 51 | SuppressEvents = true;
|
---|
| 52 | try {
|
---|
| 53 | if (Content == null) {
|
---|
| 54 | chartTypeComboBox.SelectedIndex = -1;
|
---|
| 55 | colorButton.BackColor = SystemColors.Control;
|
---|
[6012] | 56 | colorButton.Text = "?";
|
---|
| 57 | yAxisPrimaryRadioButton.Checked = false;
|
---|
| 58 | yAxisSecondaryRadioButton.Checked = false;
|
---|
| 59 | xAxisPrimaryRadioButton.Checked = false;
|
---|
| 60 | xAxisSecondaryRadioButton.Checked = false;
|
---|
| 61 | lineStyleComboBox.SelectedIndex = -1;
|
---|
[6010] | 62 | startIndexZeroCheckBox.Checked = false;
|
---|
[6012] | 63 | lineWidthNumericUpDown.Value = 1;
|
---|
[6010] | 64 | binsNumericUpDown.Value = 1;
|
---|
[6012] | 65 | binsApproximatelyRadioButton.Checked = false;
|
---|
| 66 | binsExactRadioButton.Checked = false;
|
---|
[6628] | 67 | displayNameTextBox.Text = String.Empty;
|
---|
[6010] | 68 | } else {
|
---|
| 69 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
[6011] | 70 | if (Content.Color.IsEmpty) {
|
---|
| 71 | colorButton.BackColor = SystemColors.Control;
|
---|
| 72 | colorButton.Text = "?";
|
---|
[6012] | 73 | } else {
|
---|
| 74 | colorButton.BackColor = Content.Color;
|
---|
| 75 | colorButton.Text = String.Empty;
|
---|
| 76 | }
|
---|
| 77 | yAxisPrimaryRadioButton.Checked = !Content.SecondYAxis;
|
---|
| 78 | yAxisSecondaryRadioButton.Checked = Content.SecondYAxis;
|
---|
| 79 | xAxisPrimaryRadioButton.Checked = !Content.SecondXAxis;
|
---|
| 80 | xAxisSecondaryRadioButton.Checked = Content.SecondXAxis;
|
---|
| 81 | lineStyleComboBox.SelectedItem = Content.LineStyle;
|
---|
[6010] | 82 | startIndexZeroCheckBox.Checked = Content.StartIndexZero;
|
---|
[6676] | 83 | if (Content.LineWidth < lineWidthNumericUpDown.Minimum)
|
---|
| 84 | lineWidthNumericUpDown.Value = lineWidthNumericUpDown.Minimum;
|
---|
| 85 | else if (Content.LineWidth > lineWidthNumericUpDown.Maximum)
|
---|
| 86 | lineWidthNumericUpDown.Value = lineWidthNumericUpDown.Maximum;
|
---|
| 87 | else lineWidthNumericUpDown.Value = Content.LineWidth;
|
---|
| 88 | if (Content.Bins < binsNumericUpDown.Minimum)
|
---|
| 89 | binsNumericUpDown.Value = binsNumericUpDown.Minimum;
|
---|
| 90 | else if (Content.Bins > binsNumericUpDown.Maximum)
|
---|
| 91 | binsNumericUpDown.Value = binsNumericUpDown.Maximum;
|
---|
| 92 | else binsNumericUpDown.Value = Content.Bins;
|
---|
[6012] | 93 | binsApproximatelyRadioButton.Checked = !Content.ExactBins;
|
---|
| 94 | binsExactRadioButton.Checked = Content.ExactBins;
|
---|
[6628] | 95 | displayNameTextBox.Text = Content.DisplayName;
|
---|
[6010] | 96 | }
|
---|
| 97 | } finally { SuppressEvents = false; }
|
---|
| 98 | SetEnabledStateOfControls();
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | protected virtual void SetEnabledStateOfControls() {
|
---|
| 102 | commonGroupBox.Enabled = Content != null;
|
---|
[6012] | 103 | lineChartGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Line;
|
---|
[6010] | 104 | histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | #region Event Handlers
|
---|
| 108 | private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 109 | if (!SuppressEvents && Content != null) {
|
---|
[6016] | 110 | DataRowVisualProperties.DataRowChartType selected = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue;
|
---|
| 111 | Content.ChartType = selected;
|
---|
| 112 | if (Content.ChartType != selected) {
|
---|
| 113 | MessageBox.Show("There may be incompatibilities with other series or the data is not suited to be displayed as " + selected.ToString() + ".", "Failed to set type to " + selected.ToString());
|
---|
| 114 | SuppressEvents = true;
|
---|
| 115 | try {
|
---|
| 116 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
| 117 | } finally { SuppressEvents = false; }
|
---|
| 118 | }
|
---|
[6010] | 119 | SetEnabledStateOfControls();
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
| 124 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 125 | Content.Color = colorDialog.Color;
|
---|
| 126 | colorButton.BackColor = Content.Color;
|
---|
[6011] | 127 | colorButton.Text = String.Empty;
|
---|
[6010] | 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[6012] | 131 | private void yAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 132 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 133 | SuppressEvents = true;
|
---|
| 134 | try {
|
---|
| 135 | Content.SecondYAxis = yAxisSecondaryRadioButton.Checked;
|
---|
| 136 | } finally { SuppressEvents = false; }
|
---|
[6010] | 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[6012] | 140 | private void xAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6011] | 141 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 142 | SuppressEvents = true;
|
---|
| 143 | try {
|
---|
| 144 | Content.SecondXAxis = xAxisSecondaryRadioButton.Checked;
|
---|
| 145 | } finally { SuppressEvents = false; }
|
---|
[6011] | 146 | }
|
---|
| 147 | }
|
---|
| 148 |
|
---|
[6012] | 149 | private void lineStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 150 | if (!SuppressEvents && Content != null) {
|
---|
| 151 | Content.LineStyle = (DataRowVisualProperties.DataRowLineStyle)lineStyleComboBox.SelectedValue;
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[6010] | 155 | private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 156 | if (!SuppressEvents && Content != null) {
|
---|
| 157 | Content.StartIndexZero = startIndexZeroCheckBox.Checked;
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 |
|
---|
[6012] | 161 | private void lineWidthNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 162 | if (!SuppressEvents && Content != null) {
|
---|
| 163 | Content.LineWidth = (int)lineWidthNumericUpDown.Value;
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[6010] | 167 | private void binsNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 168 | if (!SuppressEvents && Content != null) {
|
---|
| 169 | Content.Bins = (int)binsNumericUpDown.Value;
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 |
|
---|
[6012] | 173 | private void binNumberRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 174 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 175 | SuppressEvents = true;
|
---|
| 176 | try {
|
---|
| 177 | Content.ExactBins = binsExactRadioButton.Checked;
|
---|
| 178 | } finally { SuppressEvents = false; }
|
---|
[6010] | 179 | }
|
---|
| 180 | }
|
---|
[6628] | 181 |
|
---|
| 182 | private void displayNameTextBox_Validated(object sender, EventArgs e) {
|
---|
| 183 | if (!SuppressEvents && Content != null) {
|
---|
| 184 | SuppressEvents = true;
|
---|
| 185 | try {
|
---|
| 186 | Content.DisplayName = displayNameTextBox.Text;
|
---|
| 187 | } finally { SuppressEvents = false; }
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
[6010] | 190 | #endregion
|
---|
| 191 | }
|
---|
| 192 | }
|
---|