[6010] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14600] | 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;
|
---|
[14600] | 25 | using HeuristicLab.Common.Resources;
|
---|
[6010] | 26 | using HeuristicLab.MainForm;
|
---|
| 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Analysis.Views {
|
---|
| 30 | [View("DataRow Visual Properties")]
|
---|
| 31 | public partial class DataRowVisualPropertiesControl : UserControl {
|
---|
| 32 | protected bool SuppressEvents { get; set; }
|
---|
| 33 |
|
---|
| 34 | private DataRowVisualProperties content;
|
---|
| 35 | public DataRowVisualProperties Content {
|
---|
| 36 | get { return content; }
|
---|
| 37 | set {
|
---|
| 38 | bool changed = (value != content);
|
---|
| 39 | content = value;
|
---|
| 40 | if (changed) OnContentChanged();
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public DataRowVisualPropertiesControl() {
|
---|
| 45 | InitializeComponent();
|
---|
| 46 | chartTypeComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowChartType));
|
---|
[6012] | 47 | lineStyleComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowLineStyle));
|
---|
[14600] | 48 | aggregationComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowHistogramAggregation));
|
---|
| 49 | clearColorButton.BackColor = Color.Transparent;
|
---|
| 50 | clearColorButton.BackgroundImage = VSImageLibrary.Delete;
|
---|
[8015] | 51 | SetEnabledStateOfControls();
|
---|
[6010] | 52 | }
|
---|
| 53 |
|
---|
| 54 | protected virtual void OnContentChanged() {
|
---|
| 55 | SuppressEvents = true;
|
---|
| 56 | try {
|
---|
| 57 | if (Content == null) {
|
---|
| 58 | chartTypeComboBox.SelectedIndex = -1;
|
---|
| 59 | colorButton.BackColor = SystemColors.Control;
|
---|
[6012] | 60 | colorButton.Text = "?";
|
---|
| 61 | yAxisPrimaryRadioButton.Checked = false;
|
---|
| 62 | yAxisSecondaryRadioButton.Checked = false;
|
---|
| 63 | xAxisPrimaryRadioButton.Checked = false;
|
---|
| 64 | xAxisSecondaryRadioButton.Checked = false;
|
---|
| 65 | lineStyleComboBox.SelectedIndex = -1;
|
---|
[6010] | 66 | startIndexZeroCheckBox.Checked = false;
|
---|
[6012] | 67 | lineWidthNumericUpDown.Value = 1;
|
---|
[6010] | 68 | binsNumericUpDown.Value = 1;
|
---|
[6012] | 69 | binsApproximatelyRadioButton.Checked = false;
|
---|
| 70 | binsExactRadioButton.Checked = false;
|
---|
[14600] | 71 | aggregationComboBox.SelectedIndex = -1;
|
---|
[6628] | 72 | displayNameTextBox.Text = String.Empty;
|
---|
[6010] | 73 | } else {
|
---|
| 74 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
[6011] | 75 | if (Content.Color.IsEmpty) {
|
---|
| 76 | colorButton.BackColor = SystemColors.Control;
|
---|
| 77 | colorButton.Text = "?";
|
---|
[6012] | 78 | } else {
|
---|
| 79 | colorButton.BackColor = Content.Color;
|
---|
| 80 | colorButton.Text = String.Empty;
|
---|
| 81 | }
|
---|
| 82 | yAxisPrimaryRadioButton.Checked = !Content.SecondYAxis;
|
---|
| 83 | yAxisSecondaryRadioButton.Checked = Content.SecondYAxis;
|
---|
| 84 | xAxisPrimaryRadioButton.Checked = !Content.SecondXAxis;
|
---|
| 85 | xAxisSecondaryRadioButton.Checked = Content.SecondXAxis;
|
---|
| 86 | lineStyleComboBox.SelectedItem = Content.LineStyle;
|
---|
[6010] | 87 | startIndexZeroCheckBox.Checked = Content.StartIndexZero;
|
---|
[6676] | 88 | if (Content.LineWidth < lineWidthNumericUpDown.Minimum)
|
---|
| 89 | lineWidthNumericUpDown.Value = lineWidthNumericUpDown.Minimum;
|
---|
| 90 | else if (Content.LineWidth > lineWidthNumericUpDown.Maximum)
|
---|
| 91 | lineWidthNumericUpDown.Value = lineWidthNumericUpDown.Maximum;
|
---|
| 92 | else lineWidthNumericUpDown.Value = Content.LineWidth;
|
---|
| 93 | if (Content.Bins < binsNumericUpDown.Minimum)
|
---|
| 94 | binsNumericUpDown.Value = binsNumericUpDown.Minimum;
|
---|
| 95 | else if (Content.Bins > binsNumericUpDown.Maximum)
|
---|
| 96 | binsNumericUpDown.Value = binsNumericUpDown.Maximum;
|
---|
| 97 | else binsNumericUpDown.Value = Content.Bins;
|
---|
[6012] | 98 | binsApproximatelyRadioButton.Checked = !Content.ExactBins;
|
---|
| 99 | binsExactRadioButton.Checked = Content.ExactBins;
|
---|
[14600] | 100 | aggregationComboBox.SelectedItem = Content.Aggregation;
|
---|
[6628] | 101 | displayNameTextBox.Text = Content.DisplayName;
|
---|
[14600] | 102 | isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
|
---|
[6010] | 103 | }
|
---|
| 104 | } finally { SuppressEvents = false; }
|
---|
| 105 | SetEnabledStateOfControls();
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | protected virtual void SetEnabledStateOfControls() {
|
---|
| 109 | commonGroupBox.Enabled = Content != null;
|
---|
[14600] | 110 | clearColorButton.Visible = Content != null && !Content.Color.IsEmpty;
|
---|
[6012] | 111 | lineChartGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Line;
|
---|
[6010] | 112 | histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram;
|
---|
[14600] | 113 | isVisibleInLegendCheckBox.Enabled = Content != null;
|
---|
[6010] | 114 | }
|
---|
| 115 |
|
---|
| 116 | #region Event Handlers
|
---|
| 117 | private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 118 | if (!SuppressEvents && Content != null) {
|
---|
[6016] | 119 | DataRowVisualProperties.DataRowChartType selected = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue;
|
---|
| 120 | Content.ChartType = selected;
|
---|
| 121 | if (Content.ChartType != selected) {
|
---|
| 122 | 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());
|
---|
| 123 | SuppressEvents = true;
|
---|
| 124 | try {
|
---|
| 125 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
| 126 | } finally { SuppressEvents = false; }
|
---|
| 127 | }
|
---|
[6010] | 128 | SetEnabledStateOfControls();
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
| 133 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 134 | Content.Color = colorDialog.Color;
|
---|
| 135 | colorButton.BackColor = Content.Color;
|
---|
[6011] | 136 | colorButton.Text = String.Empty;
|
---|
[14600] | 137 | clearColorButton.Visible = true;
|
---|
[6010] | 138 | }
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[14600] | 141 | private void clearColorButton_Click(object sender, EventArgs e) {
|
---|
| 142 | if (!SuppressEvents && Content != null) {
|
---|
| 143 | SuppressEvents = true;
|
---|
| 144 | try {
|
---|
| 145 | Content.Color = Color.Empty;
|
---|
| 146 | colorButton.BackColor = SystemColors.Control;
|
---|
| 147 | colorButton.Text = "?";
|
---|
| 148 | clearColorButton.Visible = false;
|
---|
| 149 | } finally { SuppressEvents = false; }
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
| 152 |
|
---|
[6012] | 153 | private void yAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 154 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 155 | SuppressEvents = true;
|
---|
| 156 | try {
|
---|
| 157 | Content.SecondYAxis = yAxisSecondaryRadioButton.Checked;
|
---|
| 158 | } finally { SuppressEvents = false; }
|
---|
[6010] | 159 | }
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[6012] | 162 | private void xAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6011] | 163 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 164 | SuppressEvents = true;
|
---|
| 165 | try {
|
---|
| 166 | Content.SecondXAxis = xAxisSecondaryRadioButton.Checked;
|
---|
| 167 | } finally { SuppressEvents = false; }
|
---|
[6011] | 168 | }
|
---|
| 169 | }
|
---|
| 170 |
|
---|
[6012] | 171 | private void lineStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 172 | if (!SuppressEvents && Content != null) {
|
---|
| 173 | Content.LineStyle = (DataRowVisualProperties.DataRowLineStyle)lineStyleComboBox.SelectedValue;
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 |
|
---|
[6010] | 177 | private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 178 | if (!SuppressEvents && Content != null) {
|
---|
| 179 | Content.StartIndexZero = startIndexZeroCheckBox.Checked;
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 |
|
---|
[6012] | 183 | private void lineWidthNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 184 | if (!SuppressEvents && Content != null) {
|
---|
| 185 | Content.LineWidth = (int)lineWidthNumericUpDown.Value;
|
---|
| 186 | }
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[6010] | 189 | private void binsNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 190 | if (!SuppressEvents && Content != null) {
|
---|
| 191 | Content.Bins = (int)binsNumericUpDown.Value;
|
---|
| 192 | }
|
---|
| 193 | }
|
---|
| 194 |
|
---|
[6012] | 195 | private void binNumberRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 196 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 197 | SuppressEvents = true;
|
---|
| 198 | try {
|
---|
| 199 | Content.ExactBins = binsExactRadioButton.Checked;
|
---|
| 200 | } finally { SuppressEvents = false; }
|
---|
[6010] | 201 | }
|
---|
| 202 | }
|
---|
[6628] | 203 |
|
---|
[14600] | 204 | private void aggregationComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 205 | if (!SuppressEvents && Content != null) {
|
---|
| 206 | SuppressEvents = true;
|
---|
| 207 | try {
|
---|
| 208 | Content.Aggregation = (DataRowVisualProperties.DataRowHistogramAggregation)aggregationComboBox.SelectedValue;
|
---|
| 209 | } finally { SuppressEvents = false; }
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 |
|
---|
[6628] | 213 | private void displayNameTextBox_Validated(object sender, EventArgs e) {
|
---|
| 214 | if (!SuppressEvents && Content != null) {
|
---|
| 215 | SuppressEvents = true;
|
---|
| 216 | try {
|
---|
| 217 | Content.DisplayName = displayNameTextBox.Text;
|
---|
| 218 | } finally { SuppressEvents = false; }
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
[14600] | 221 |
|
---|
| 222 | private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 223 | if (!SuppressEvents && Content != null) {
|
---|
| 224 | Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
[6010] | 227 | #endregion
|
---|
| 228 | }
|
---|
| 229 | }
|
---|