[6010] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15584] | 3 | * Copyright (C) 2002-2018 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;
|
---|
[15097] | 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));
|
---|
[15097] | 48 | clearColorButton.BackColor = Color.Transparent;
|
---|
| 49 | clearColorButton.BackgroundImage = VSImageLibrary.Delete;
|
---|
[8015] | 50 | SetEnabledStateOfControls();
|
---|
[6010] | 51 | }
|
---|
| 52 |
|
---|
| 53 | protected virtual void OnContentChanged() {
|
---|
| 54 | SuppressEvents = true;
|
---|
| 55 | try {
|
---|
| 56 | if (Content == null) {
|
---|
| 57 | chartTypeComboBox.SelectedIndex = -1;
|
---|
| 58 | colorButton.BackColor = SystemColors.Control;
|
---|
[6012] | 59 | colorButton.Text = "?";
|
---|
| 60 | yAxisPrimaryRadioButton.Checked = false;
|
---|
| 61 | yAxisSecondaryRadioButton.Checked = false;
|
---|
| 62 | xAxisPrimaryRadioButton.Checked = false;
|
---|
| 63 | xAxisSecondaryRadioButton.Checked = false;
|
---|
| 64 | lineStyleComboBox.SelectedIndex = -1;
|
---|
[6010] | 65 | startIndexZeroCheckBox.Checked = false;
|
---|
[6012] | 66 | lineWidthNumericUpDown.Value = 1;
|
---|
[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;
|
---|
[6628] | 88 | displayNameTextBox.Text = Content.DisplayName;
|
---|
[15097] | 89 | isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
|
---|
[6010] | 90 | }
|
---|
| 91 | } finally { SuppressEvents = false; }
|
---|
| 92 | SetEnabledStateOfControls();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | protected virtual void SetEnabledStateOfControls() {
|
---|
| 96 | commonGroupBox.Enabled = Content != null;
|
---|
[15097] | 97 | clearColorButton.Visible = Content != null && !Content.Color.IsEmpty;
|
---|
[6012] | 98 | lineChartGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Line;
|
---|
[15097] | 99 | isVisibleInLegendCheckBox.Enabled = Content != null;
|
---|
[6010] | 100 | }
|
---|
| 101 |
|
---|
| 102 | #region Event Handlers
|
---|
| 103 | private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 104 | if (!SuppressEvents && Content != null) {
|
---|
[6016] | 105 | DataRowVisualProperties.DataRowChartType selected = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue;
|
---|
| 106 | Content.ChartType = selected;
|
---|
| 107 | if (Content.ChartType != selected) {
|
---|
| 108 | 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());
|
---|
| 109 | SuppressEvents = true;
|
---|
| 110 | try {
|
---|
| 111 | chartTypeComboBox.SelectedItem = Content.ChartType;
|
---|
| 112 | } finally { SuppressEvents = false; }
|
---|
| 113 | }
|
---|
[6010] | 114 | SetEnabledStateOfControls();
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
| 119 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 120 | Content.Color = colorDialog.Color;
|
---|
| 121 | colorButton.BackColor = Content.Color;
|
---|
[6011] | 122 | colorButton.Text = String.Empty;
|
---|
[15097] | 123 | clearColorButton.Visible = true;
|
---|
[6010] | 124 | }
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[15097] | 127 | private void clearColorButton_Click(object sender, EventArgs e) {
|
---|
| 128 | if (!SuppressEvents && Content != null) {
|
---|
| 129 | SuppressEvents = true;
|
---|
| 130 | try {
|
---|
| 131 | Content.Color = Color.Empty;
|
---|
| 132 | colorButton.BackColor = SystemColors.Control;
|
---|
| 133 | colorButton.Text = "?";
|
---|
| 134 | clearColorButton.Visible = false;
|
---|
| 135 | } finally { SuppressEvents = false; }
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[6012] | 139 | private void yAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6010] | 140 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 141 | SuppressEvents = true;
|
---|
| 142 | try {
|
---|
| 143 | Content.SecondYAxis = yAxisSecondaryRadioButton.Checked;
|
---|
| 144 | } finally { SuppressEvents = false; }
|
---|
[6010] | 145 | }
|
---|
| 146 | }
|
---|
| 147 |
|
---|
[6012] | 148 | private void xAxisRadioButton_CheckedChanged(object sender, EventArgs e) {
|
---|
[6011] | 149 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 150 | SuppressEvents = true;
|
---|
| 151 | try {
|
---|
| 152 | Content.SecondXAxis = xAxisSecondaryRadioButton.Checked;
|
---|
| 153 | } finally { SuppressEvents = false; }
|
---|
[6011] | 154 | }
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[6012] | 157 | private void lineStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 158 | if (!SuppressEvents && Content != null) {
|
---|
| 159 | Content.LineStyle = (DataRowVisualProperties.DataRowLineStyle)lineStyleComboBox.SelectedValue;
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 |
|
---|
[6010] | 163 | private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 164 | if (!SuppressEvents && Content != null) {
|
---|
| 165 | Content.StartIndexZero = startIndexZeroCheckBox.Checked;
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 |
|
---|
[6012] | 169 | private void lineWidthNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 170 | if (!SuppressEvents && Content != null) {
|
---|
| 171 | Content.LineWidth = (int)lineWidthNumericUpDown.Value;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[15097] | 175 | private void displayNameTextBox_Validated(object sender, EventArgs e) {
|
---|
[6010] | 176 | if (!SuppressEvents && Content != null) {
|
---|
[6012] | 177 | SuppressEvents = true;
|
---|
| 178 | try {
|
---|
[15097] | 179 | Content.DisplayName = displayNameTextBox.Text;
|
---|
[6012] | 180 | } finally { SuppressEvents = false; }
|
---|
[6010] | 181 | }
|
---|
| 182 | }
|
---|
[6628] | 183 |
|
---|
[15097] | 184 | private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
[6628] | 185 | if (!SuppressEvents && Content != null) {
|
---|
[15097] | 186 | Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
|
---|
[6628] | 187 | }
|
---|
| 188 | }
|
---|
[6010] | 189 | #endregion
|
---|
| 190 | }
|
---|
| 191 | }
|
---|