Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Analysis.Views/3.3/ScatterPlotDataRowVisualPropertiesControl.cs @ 14554

Last change on this file since 14554 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 4.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using System.Drawing;
24using System.Windows.Forms;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace 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));
46      SetEnabledStateOfControls();
47    }
48
49    protected virtual void OnContentChanged() {
50      SuppressEvents = true;
51      try {
52        if (Content == null) {
53          pointStyleComboBox.SelectedIndex = -1;
54          colorButton.BackColor = SystemColors.Control;
55          colorButton.Text = "?";
56          isVisibleInLegendCheckBox.Checked = false;
57          pointSizeNumericUpDown.Value = 1;
58          displayNameTextBox.Text = String.Empty;
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;
71        }
72      }
73      finally { SuppressEvents = false; }
74      SetEnabledStateOfControls();
75    }
76
77    protected virtual void SetEnabledStateOfControls() {
78      pointStyleComboBox.Enabled = Content != null;
79      colorButton.Enabled = Content != null;
80      colorButton.Enabled = Content != null;
81      isVisibleInLegendCheckBox.Enabled = Content != null;
82      pointSizeNumericUpDown.Enabled = Content != null;
83      displayNameTextBox.Enabled = Content != null;
84    }
85
86    #region Event Handlers
87    private void pointStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
88      if (!SuppressEvents && Content != null) {
89        ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle)pointStyleComboBox.SelectedValue;
90        Content.PointStyle = selected;
91      }
92    }
93
94    private void colorButton_Click(object sender, EventArgs e) {
95      if (colorDialog.ShowDialog() == DialogResult.OK) {
96        Content.Color = colorDialog.Color;
97        colorButton.BackColor = Content.Color;
98        colorButton.Text = String.Empty;
99      }
100    }
101
102    private void displayNameTextBox_Validated(object sender, EventArgs e) {
103      if (!SuppressEvents && Content != null) {
104        SuppressEvents = true;
105        try {
106          Content.DisplayName = displayNameTextBox.Text;
107        }
108        finally { SuppressEvents = false; }
109      }
110    }
111
112    private void pointSizeNumericUpDown_ValueChanged(object sender, EventArgs e) {
113      if (!SuppressEvents && Content != null) {
114        Content.PointSize = (int)pointSizeNumericUpDown.Value;
115      }
116    }
117
118    private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
119      if (!SuppressEvents && Content != null) {
120        Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
121      }
122    }
123    #endregion
124  }
125}
Note: See TracBrowser for help on using the repository browser.