[6010] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 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));
|
---|
[8015] | 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;
|
---|
[14437] | 96 | isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
|
---|
[6010] | 97 | }
|
---|
| 98 | } finally { SuppressEvents = false; }
|
---|
| 99 | SetEnabledStateOfControls();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | protected virtual void SetEnabledStateOfControls() {
|
---|
| 103 | commonGroupBox.Enabled = Content != null;
|
---|
[6012] | 104 | lineChartGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Line;
|
---|
[6010] | 105 | histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram;
|
---|
[14437] | 106 | isVisibleInLegendCheckBox.Enabled = Content != null;
|
---|
[6010] | 107 | }
|
---|
| 108 |
|
---|
| 109 | #region Event Handlers
|
---|
| 110 | private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 111 | if (!SuppressEvents && Content != null) {
|
---|
[6016] | 112 | DataRowVisualProperties.DataRowChartType selected = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue;
|
---|
| 113 | Content.ChartType = selected;
|
---|
| 114 | if (Content.ChartType != selected) {
|
---|
| 115 | 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());
|
---|
| 116 | SuppressEvents = true;
|
---|
| 117 | try {
|
---|
| 118 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
| 119 | } finally { SuppressEvents = false; }
|
---|
| 120 | }
|
---|
[6010] | 121 | SetEnabledStateOfControls();
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
| 126 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 127 | Content.Color = colorDialog.Color;
|
---|
| 128 | colorButton.BackColor = Content.Color;
|
---|
[6011] | 129 | colorButton.Text = String.Empty;
|
---|
[6010] | 130 | }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
[6012] | 133 | private void yAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 134 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 135 | SuppressEvents = true;
|
---|
| 136 | try {
|
---|
| 137 | Content.SecondYAxis = yAxisSecondaryRadioButton.Checked;
|
---|
| 138 | } finally { SuppressEvents = false; }
|
---|
[6010] | 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[6012] | 142 | private void xAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6011] | 143 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 144 | SuppressEvents = true;
|
---|
| 145 | try {
|
---|
| 146 | Content.SecondXAxis = xAxisSecondaryRadioButton.Checked;
|
---|
| 147 | } finally { SuppressEvents = false; }
|
---|
[6011] | 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
[6012] | 151 | private void lineStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 152 | if (!SuppressEvents && Content != null) {
|
---|
| 153 | Content.LineStyle = (DataRowVisualProperties.DataRowLineStyle)lineStyleComboBox.SelectedValue;
|
---|
| 154 | }
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[6010] | 157 | private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 158 | if (!SuppressEvents && Content != null) {
|
---|
| 159 | Content.StartIndexZero = startIndexZeroCheckBox.Checked;
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 |
|
---|
[6012] | 163 | private void lineWidthNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 164 | if (!SuppressEvents && Content != null) {
|
---|
| 165 | Content.LineWidth = (int)lineWidthNumericUpDown.Value;
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 |
|
---|
[6010] | 169 | private void binsNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 170 | if (!SuppressEvents && Content != null) {
|
---|
| 171 | Content.Bins = (int)binsNumericUpDown.Value;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[6012] | 175 | private void binNumberRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 176 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 177 | SuppressEvents = true;
|
---|
| 178 | try {
|
---|
| 179 | Content.ExactBins = binsExactRadioButton.Checked;
|
---|
| 180 | } finally { SuppressEvents = false; }
|
---|
[6010] | 181 | }
|
---|
| 182 | }
|
---|
[6628] | 183 |
|
---|
| 184 | private void displayNameTextBox_Validated(object sender, EventArgs e) {
|
---|
| 185 | if (!SuppressEvents && Content != null) {
|
---|
| 186 | SuppressEvents = true;
|
---|
| 187 | try {
|
---|
| 188 | Content.DisplayName = displayNameTextBox.Text;
|
---|
| 189 | } finally { SuppressEvents = false; }
|
---|
| 190 | }
|
---|
| 191 | }
|
---|
[14437] | 192 |
|
---|
| 193 | private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 194 | if (!SuppressEvents && Content != null) {
|
---|
| 195 | Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
[6010] | 198 | #endregion
|
---|
| 199 | }
|
---|
| 200 | }
|
---|