[8907] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15584] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8907] | 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;
|
---|
[8907] | 26 | using HeuristicLab.MainForm;
|
---|
| 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Analysis.Views {
|
---|
| 30 | [View("ScatterPlot DataRow Visual Properties")]
|
---|
| 31 | public partial class ScatterPlotDataRowVisualPropertiesControl : UserControl {
|
---|
| 32 | protected bool SuppressEvents { get; set; }
|
---|
| 33 |
|
---|
| 34 | private ScatterPlotDataRowVisualProperties content;
|
---|
| 35 | public ScatterPlotDataRowVisualProperties Content {
|
---|
| 36 | get { return content; }
|
---|
| 37 | set {
|
---|
| 38 | bool changed = (value != content);
|
---|
| 39 | content = value;
|
---|
| 40 | if (changed) OnContentChanged();
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public ScatterPlotDataRowVisualPropertiesControl() {
|
---|
| 45 | InitializeComponent();
|
---|
| 46 | pointStyleComboBox.DataSource = Enum.GetValues(typeof(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle));
|
---|
[15097] | 47 | regressionTypeComboBox.DataSource = Enum.GetValues(typeof(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType));
|
---|
| 48 | clearColorButton.BackColor = Color.Transparent;
|
---|
| 49 | clearColorButton.BackgroundImage = VSImageLibrary.Delete;
|
---|
[8907] | 50 | SetEnabledStateOfControls();
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | protected virtual void OnContentChanged() {
|
---|
| 54 | SuppressEvents = true;
|
---|
| 55 | try {
|
---|
| 56 | if (Content == null) {
|
---|
| 57 | pointStyleComboBox.SelectedIndex = -1;
|
---|
| 58 | colorButton.BackColor = SystemColors.Control;
|
---|
| 59 | colorButton.Text = "?";
|
---|
| 60 | isVisibleInLegendCheckBox.Checked = false;
|
---|
| 61 | pointSizeNumericUpDown.Value = 1;
|
---|
| 62 | displayNameTextBox.Text = String.Empty;
|
---|
[15097] | 63 | regressionTypeComboBox.SelectedIndex = -1;
|
---|
| 64 | polynomialRegressionOrderNumericUpDown.Value = 2;
|
---|
| 65 | isRegressionVisibleInLegendCheckBox.Checked = false;
|
---|
| 66 | regressionLegendTextBox.Text = string.Empty;
|
---|
[8907] | 67 | } else {
|
---|
| 68 | displayNameTextBox.Text = Content.DisplayName;
|
---|
| 69 | pointStyleComboBox.SelectedItem = Content.PointStyle;
|
---|
| 70 | if (Content.Color.IsEmpty) {
|
---|
| 71 | colorButton.BackColor = SystemColors.Control;
|
---|
| 72 | colorButton.Text = "?";
|
---|
| 73 | } else {
|
---|
| 74 | colorButton.BackColor = Content.Color;
|
---|
| 75 | colorButton.Text = String.Empty;
|
---|
| 76 | }
|
---|
| 77 | pointSizeNumericUpDown.Value = Content.PointSize;
|
---|
| 78 | isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
|
---|
[15097] | 79 | regressionTypeComboBox.SelectedItem = Content.RegressionType;
|
---|
| 80 | polynomialRegressionOrderNumericUpDown.Value = Content.PolynomialRegressionOrder;
|
---|
| 81 | isRegressionVisibleInLegendCheckBox.Checked = Content.IsRegressionVisibleInLegend;
|
---|
| 82 | regressionLegendTextBox.Text = content.RegressionDisplayName;
|
---|
[8907] | 83 | }
|
---|
| 84 | }
|
---|
| 85 | finally { SuppressEvents = false; }
|
---|
| 86 | SetEnabledStateOfControls();
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | protected virtual void SetEnabledStateOfControls() {
|
---|
| 90 | pointStyleComboBox.Enabled = Content != null;
|
---|
| 91 | colorButton.Enabled = Content != null;
|
---|
[15097] | 92 | clearColorButton.Visible = Content != null && !Content.Color.IsEmpty;
|
---|
[8907] | 93 | isVisibleInLegendCheckBox.Enabled = Content != null;
|
---|
| 94 | pointSizeNumericUpDown.Enabled = Content != null;
|
---|
| 95 | displayNameTextBox.Enabled = Content != null;
|
---|
[15097] | 96 | regressionTypeComboBox.Enabled = Content != null;
|
---|
| 97 | polynomialRegressionOrderNumericUpDown.Enabled = Content != null && Content.RegressionType == ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.Polynomial;
|
---|
| 98 | orderLabel.Enabled = polynomialRegressionOrderNumericUpDown.Enabled;
|
---|
| 99 | isRegressionVisibleInLegendCheckBox.Enabled = Content != null && Content.RegressionType != ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.None;
|
---|
| 100 | regressionLegendTextBox.Enabled = Content != null && Content.RegressionType != ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.None;
|
---|
[8907] | 101 | }
|
---|
| 102 |
|
---|
| 103 | #region Event Handlers
|
---|
| 104 | private void pointStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 105 | if (!SuppressEvents && Content != null) {
|
---|
[15097] | 106 | var selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle)pointStyleComboBox.SelectedValue;
|
---|
[8907] | 107 | Content.PointStyle = selected;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | private void colorButton_Click(object sender, EventArgs e) {
|
---|
| 112 | if (colorDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 113 | Content.Color = colorDialog.Color;
|
---|
| 114 | colorButton.BackColor = Content.Color;
|
---|
| 115 | colorButton.Text = String.Empty;
|
---|
[15097] | 116 | clearColorButton.Visible = true;
|
---|
[8907] | 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[15097] | 120 | private void clearColorButton_Click(object sender, EventArgs e) {
|
---|
| 121 | if (!SuppressEvents && Content != null) {
|
---|
| 122 | Content.Color = Color.Empty;
|
---|
| 123 | colorButton.BackColor = SystemColors.Control;
|
---|
| 124 | colorButton.Text = "?";
|
---|
| 125 | clearColorButton.Visible = false;
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[8907] | 129 | private void displayNameTextBox_Validated(object sender, EventArgs e) {
|
---|
| 130 | if (!SuppressEvents && Content != null) {
|
---|
| 131 | SuppressEvents = true;
|
---|
| 132 | try {
|
---|
| 133 | Content.DisplayName = displayNameTextBox.Text;
|
---|
| 134 | }
|
---|
| 135 | finally { SuppressEvents = false; }
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | private void pointSizeNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 140 | if (!SuppressEvents && Content != null) {
|
---|
| 141 | Content.PointSize = (int)pointSizeNumericUpDown.Value;
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 146 | if (!SuppressEvents && Content != null) {
|
---|
| 147 | Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
[15097] | 150 |
|
---|
| 151 | private void regressionTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 152 | if (!SuppressEvents && Content != null) {
|
---|
| 153 | var selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType)regressionTypeComboBox.SelectedValue;
|
---|
| 154 | Content.RegressionType = selected;
|
---|
| 155 | SetEnabledStateOfControls();
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | private void polynomialRegressionOrderNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 160 | if (!SuppressEvents && Content != null) {
|
---|
| 161 | Content.PolynomialRegressionOrder = (int)polynomialRegressionOrderNumericUpDown.Value;
|
---|
| 162 | }
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | private void isRegressionVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 166 | if (!SuppressEvents && Content != null) {
|
---|
| 167 | Content.IsRegressionVisibleInLegend = isRegressionVisibleInLegendCheckBox.Checked;
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | private void regressionLegendTextBox_Validated(object sender, EventArgs e) {
|
---|
| 172 | if (!SuppressEvents && Content != null) {
|
---|
| 173 | Content.RegressionDisplayName = regressionLegendTextBox.Text;
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
[8907] | 176 | #endregion
|
---|
| 177 | }
|
---|
| 178 | }
|
---|