Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PerformanceComparison/HeuristicLab.Analysis.Views/3.3/ScatterPlotDataRowVisualPropertiesControl.cs @ 13780

Last change on this file since 13780 was 13722, checked in by abeham, 9 years ago

#2457:

  • Renamed remaining files from ExpertSystem to KnowledgeCenter
  • Added ability to scatter plot to display a regression line
  • Allowed to execute multiple instances at once and displaying either only final result or tracking result
  • Split runs in seeded runs and instance runs
File size: 4.9 KB
RevLine 
[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
[13722]22using HeuristicLab.MainForm;
[8907]23using System;
24using System.Drawing;
25using System.Windows.Forms;
26
27namespace HeuristicLab.Analysis.Views {
28  [View("ScatterPlot DataRow Visual Properties")]
29  public partial class ScatterPlotDataRowVisualPropertiesControl : UserControl {
30    protected bool SuppressEvents { get; set; }
31
32    private ScatterPlotDataRowVisualProperties content;
33    public ScatterPlotDataRowVisualProperties Content {
34      get { return content; }
35      set {
36        bool changed = (value != content);
37        content = value;
38        if (changed) OnContentChanged();
39      }
40    }
41
42    public ScatterPlotDataRowVisualPropertiesControl() {
43      InitializeComponent();
44      pointStyleComboBox.DataSource = Enum.GetValues(typeof(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle));
45      SetEnabledStateOfControls();
46    }
47
48    protected virtual void OnContentChanged() {
49      SuppressEvents = true;
50      try {
51        if (Content == null) {
52          pointStyleComboBox.SelectedIndex = -1;
53          colorButton.BackColor = SystemColors.Control;
54          colorButton.Text = "?";
55          isVisibleInLegendCheckBox.Checked = false;
56          pointSizeNumericUpDown.Value = 1;
57          displayNameTextBox.Text = String.Empty;
[13722]58          regressionLineCheckBox.Checked = false;
[8907]59        } else {
60          displayNameTextBox.Text = Content.DisplayName;
61          pointStyleComboBox.SelectedItem = Content.PointStyle;
62          if (Content.Color.IsEmpty) {
63            colorButton.BackColor = SystemColors.Control;
64            colorButton.Text = "?";
65          } else {
66            colorButton.BackColor = Content.Color;
67            colorButton.Text = String.Empty;
68          }
69          pointSizeNumericUpDown.Value = Content.PointSize;
70          isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
[13722]71          regressionLineCheckBox.Checked = Content.ShowRegressionLine;
[8907]72        }
73      }
74      finally { SuppressEvents = false; }
75      SetEnabledStateOfControls();
76    }
77
78    protected virtual void SetEnabledStateOfControls() {
79      pointStyleComboBox.Enabled = Content != null;
80      colorButton.Enabled = Content != null;
81      colorButton.Enabled = Content != null;
82      isVisibleInLegendCheckBox.Enabled = Content != null;
83      pointSizeNumericUpDown.Enabled = Content != null;
84      displayNameTextBox.Enabled = Content != null;
[13722]85      regressionLineCheckBox.Enabled = Content != null;
[8907]86    }
87
88    #region Event Handlers
89    private void pointStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
90      if (!SuppressEvents && Content != null) {
91        ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle)pointStyleComboBox.SelectedValue;
92        Content.PointStyle = selected;
93      }
94    }
95
96    private void colorButton_Click(object sender, EventArgs e) {
97      if (colorDialog.ShowDialog() == DialogResult.OK) {
98        Content.Color = colorDialog.Color;
99        colorButton.BackColor = Content.Color;
100        colorButton.Text = String.Empty;
101      }
102    }
103
104    private void displayNameTextBox_Validated(object sender, EventArgs e) {
105      if (!SuppressEvents && Content != null) {
106        SuppressEvents = true;
107        try {
108          Content.DisplayName = displayNameTextBox.Text;
109        }
110        finally { SuppressEvents = false; }
111      }
112    }
113
114    private void pointSizeNumericUpDown_ValueChanged(object sender, EventArgs e) {
115      if (!SuppressEvents && Content != null) {
116        Content.PointSize = (int)pointSizeNumericUpDown.Value;
117      }
118    }
119
120    private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
121      if (!SuppressEvents && Content != null) {
122        Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
123      }
124    }
[13722]125
126    private void regressionLineCheckBox_CheckedChanged(object sender, EventArgs e) {
127      if (!SuppressEvents && Content != null) {
128        Content.ShowRegressionLine = regressionLineCheckBox.Checked;
129      }
130    }
[8907]131    #endregion
132  }
133}
Note: See TracBrowser for help on using the repository browser.