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