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