Free cookie consent management tool by TermsFeed Policy Generator

source: branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesControl.cs @ 6014

Last change on this file since 6014 was 6014, checked in by abeham, 12 years ago

#1465

  • added option to set fixed minimum and maximum for all four possible axis
  • added an icon to the properties context menu entry
    • added dependency from ChartControlsExtensions to Common.Resources
File size: 15.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Windows.Forms;
23using HeuristicLab.MainForm;
24using HeuristicLab.MainForm.WindowsForms;
25
26namespace HeuristicLab.Analysis.Views {
27  [View("DataRow Visual Properties")]
28  public partial class DataTableVisualPropertiesControl : UserControl {
29    protected bool SuppressEvents { get; set; }
30
31    private DataTableVisualProperties content;
32    public DataTableVisualProperties Content {
33      get { return content; }
34      set {
35        bool changed = (value != content);
36        content = value;
37        if (changed) OnContentChanged();
38      }
39    }
40
41    public DataTableVisualPropertiesControl() {
42      InitializeComponent();
43    }
44
45    protected virtual void OnContentChanged() {
46      SuppressEvents = true;
47      try {
48        if (Content == null) {
49          xAxisPrimaryTitleTextBox.Text = string.Empty;
50          xAxisPrimaryMinimumAutoRadioButton.Checked = false;
51          xAxisPrimaryMinimumFixedRadioButton.Checked = false;
52          xAxisPrimaryMinimumFixedTextBox.Text = string.Empty;
53          xAxisPrimaryMaximumAutoRadioButton.Checked = false;
54          xAxisPrimaryMaximumFixedRadioButton.Checked = false;
55          xAxisPrimaryMaximumFixedTextBox.Text = string.Empty;
56          xAxisSecondaryTitleTextBox.Text = string.Empty;
57          xAxisSecondaryMinimumAutoRadioButton.Checked = false;
58          xAxisSecondaryMinimumFixedRadioButton.Checked = false;
59          xAxisSecondaryMinimumFixedTextBox.Text = string.Empty;
60          xAxisSecondaryMaximumAutoRadioButton.Checked = false;
61          xAxisSecondaryMaximumFixedRadioButton.Checked = false;
62          xAxisSecondaryMaximumFixedTextBox.Text = string.Empty;
63
64          yAxisPrimaryTitleTextBox.Text = string.Empty;
65          yAxisPrimaryMinimumAutoRadioButton.Checked = false;
66          yAxisPrimaryMinimumFixedRadioButton.Checked = false;
67          yAxisPrimaryMinimumFixedTextBox.Text = string.Empty;
68          yAxisPrimaryMaximumAutoRadioButton.Checked = false;
69          yAxisPrimaryMaximumFixedRadioButton.Checked = false;
70          yAxisPrimaryMaximumFixedTextBox.Text = string.Empty;
71          yAxisSecondaryTitleTextBox.Text = string.Empty;
72          yAxisSecondaryMinimumAutoRadioButton.Checked = false;
73          yAxisSecondaryMinimumFixedRadioButton.Checked = false;
74          yAxisSecondaryMinimumFixedTextBox.Text = string.Empty;
75          yAxisSecondaryMaximumAutoRadioButton.Checked = false;
76          yAxisSecondaryMaximumFixedRadioButton.Checked = false;
77          yAxisSecondaryMaximumFixedTextBox.Text = string.Empty;
78        } else {
79          xAxisPrimaryTitleTextBox.Text = Content.XAxisTitle;
80          xAxisPrimaryMinimumAutoRadioButton.Checked = Content.XAxisMinimumAuto;
81          xAxisPrimaryMinimumFixedRadioButton.Checked = !Content.XAxisMinimumAuto;
82          xAxisPrimaryMinimumFixedTextBox.Text = Content.XAxisMinimumFixedValue.ToString();
83          xAxisPrimaryMaximumAutoRadioButton.Checked = Content.XAxisMaximumAuto;
84          xAxisPrimaryMaximumFixedRadioButton.Checked = !Content.XAxisMaximumAuto;
85          xAxisPrimaryMaximumFixedTextBox.Text = Content.XAxisMaximumFixedValue.ToString();
86          xAxisSecondaryTitleTextBox.Text = Content.SecondXAxisTitle;
87          xAxisSecondaryMinimumAutoRadioButton.Checked = Content.SecondXAxisMinimumAuto;
88          xAxisSecondaryMinimumFixedRadioButton.Checked = !Content.SecondXAxisMinimumAuto;
89          xAxisSecondaryMinimumFixedTextBox.Text = Content.SecondXAxisMinimumFixedValue.ToString();
90          xAxisSecondaryMaximumAutoRadioButton.Checked = Content.SecondXAxisMaximumAuto;
91          xAxisSecondaryMaximumFixedRadioButton.Checked = !Content.SecondXAxisMaximumAuto;
92          xAxisSecondaryMaximumFixedTextBox.Text = Content.SecondXAxisMaximumFixedValue.ToString();
93
94          yAxisPrimaryTitleTextBox.Text = Content.YAxisTitle;
95          yAxisPrimaryMinimumAutoRadioButton.Checked = Content.YAxisMinimumAuto;
96          yAxisPrimaryMinimumFixedRadioButton.Checked = !Content.YAxisMinimumAuto;
97          yAxisPrimaryMinimumFixedTextBox.Text = Content.YAxisMinimumFixedValue.ToString();
98          yAxisPrimaryMaximumAutoRadioButton.Checked = Content.YAxisMaximumAuto;
99          yAxisPrimaryMaximumFixedRadioButton.Checked = !Content.YAxisMaximumAuto;
100          yAxisPrimaryMaximumFixedTextBox.Text = Content.YAxisMaximumFixedValue.ToString();
101          yAxisSecondaryTitleTextBox.Text = Content.SecondYAxisTitle;
102          yAxisSecondaryMinimumAutoRadioButton.Checked = Content.SecondYAxisMinimumAuto;
103          yAxisSecondaryMinimumFixedRadioButton.Checked = !Content.SecondYAxisMinimumAuto;
104          yAxisSecondaryMinimumFixedTextBox.Text = Content.SecondYAxisMinimumFixedValue.ToString();
105          yAxisSecondaryMaximumAutoRadioButton.Checked = Content.SecondYAxisMaximumAuto;
106          yAxisSecondaryMaximumFixedRadioButton.Checked = !Content.SecondYAxisMaximumAuto;
107          yAxisSecondaryMaximumFixedTextBox.Text = Content.SecondYAxisMaximumFixedValue.ToString();
108        }
109      } finally { SuppressEvents = false; }
110      SetEnabledStateOfControls();
111    }
112
113    protected virtual void SetEnabledStateOfControls() {
114      axisTabControl.Enabled = Content != null;
115      xAxisPrimaryMinimumFixedTextBox.Enabled = xAxisPrimaryMinimumFixedRadioButton.Checked;
116      xAxisPrimaryMaximumFixedTextBox.Enabled = xAxisPrimaryMaximumFixedRadioButton.Checked;
117      xAxisSecondaryMinimumFixedTextBox.Enabled = xAxisSecondaryMinimumFixedRadioButton.Checked;
118      xAxisSecondaryMaximumFixedTextBox.Enabled = xAxisSecondaryMaximumFixedRadioButton.Checked;
119
120      yAxisPrimaryMinimumFixedTextBox.Enabled = yAxisPrimaryMinimumFixedRadioButton.Checked;
121      yAxisPrimaryMaximumFixedTextBox.Enabled = yAxisPrimaryMaximumFixedRadioButton.Checked;
122      yAxisSecondaryMinimumFixedTextBox.Enabled = yAxisSecondaryMinimumFixedRadioButton.Checked;
123      yAxisSecondaryMaximumFixedTextBox.Enabled = yAxisSecondaryMaximumFixedRadioButton.Checked;
124    }
125
126    #region Event Handlers
127    private void yPrimaryTitleTextBox_Validated(object sender, System.EventArgs e) {
128      if (!SuppressEvents && Content != null) {
129        Content.YAxisTitle = yAxisPrimaryTitleTextBox.Text;
130      }
131    }
132
133    private void ySecondaryTitleTextBox_Validated(object sender, System.EventArgs e) {
134      if (!SuppressEvents && Content != null) {
135        Content.SecondYAxisTitle = yAxisSecondaryTitleTextBox.Text;
136      }
137    }
138
139    private void xPrimaryTitleTextBox_Validated(object sender, System.EventArgs e) {
140      if (!SuppressEvents && Content != null) {
141        Content.XAxisTitle = xAxisPrimaryTitleTextBox.Text;
142      }
143    }
144
145    private void xSecondaryTitleTextBox_Validated(object sender, System.EventArgs e) {
146      if (!SuppressEvents && Content != null) {
147        Content.SecondXAxisTitle = xAxisSecondaryTitleTextBox.Text;
148      }
149    }
150
151    private void xAxisPrimaryMinimumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
152      if (!SuppressEvents && Content != null) {
153        TextBox tb = (TextBox)sender;
154        double val;
155        if (double.TryParse(tb.Text, out val)) {
156          Content.XAxisMinimumFixedValue = val;
157          errorProvider.SetError(tb, string.Empty);
158        } else {
159          errorProvider.SetError(tb, "Not a valid number.");
160          e.Cancel = true;
161        }
162      }
163    }
164
165    private void xAxisPrimaryMaximumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
166      if (!SuppressEvents && Content != null) {
167        TextBox tb = (TextBox)sender;
168        double val;
169        if (double.TryParse(tb.Text, out val)) {
170          Content.XAxisMaximumFixedValue = val;
171          errorProvider.SetError(tb, string.Empty);
172        } else {
173          errorProvider.SetError(tb, "Not a valid number.");
174          e.Cancel = true;
175        }
176      }
177    }
178
179    private void xAxisSecondaryMinimumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
180      if (!SuppressEvents && Content != null) {
181        TextBox tb = (TextBox)sender;
182        double val;
183        if (double.TryParse(tb.Text, out val)) {
184          Content.SecondXAxisMinimumFixedValue = val;
185          errorProvider.SetError(tb, string.Empty);
186        } else {
187          errorProvider.SetError(tb, "Not a valid number.");
188          e.Cancel = true;
189        }
190      }
191    }
192
193    private void xAxisSecondaryMaximumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
194      if (!SuppressEvents && Content != null) {
195        TextBox tb = (TextBox)sender;
196        double val;
197        if (double.TryParse(tb.Text, out val)) {
198          Content.SecondXAxisMaximumFixedValue = val;
199          errorProvider.SetError(tb, string.Empty);
200        } else {
201          errorProvider.SetError(tb, "Not a valid number.");
202          e.Cancel = true;
203        }
204      }
205    }
206
207    private void yAxisPrimaryMinimumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
208      if (!SuppressEvents && Content != null) {
209        TextBox tb = (TextBox)sender;
210        double val;
211        if (double.TryParse(tb.Text, out val)) {
212          Content.YAxisMinimumFixedValue = val;
213          errorProvider.SetError(tb, string.Empty);
214        } else {
215          errorProvider.SetError(tb, "Not a valid number.");
216          e.Cancel = true;
217        }
218      }
219    }
220
221    private void yAxisPrimaryMaximumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
222      if (!SuppressEvents && Content != null) {
223        TextBox tb = (TextBox)sender;
224        double val;
225        if (double.TryParse(tb.Text, out val)) {
226          Content.YAxisMaximumFixedValue = val;
227          errorProvider.SetError(tb, string.Empty);
228        } else {
229          errorProvider.SetError(tb, "Not a valid number.");
230          e.Cancel = true;
231        }
232      }
233    }
234
235    private void yAxisSecondaryMinimumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
236      if (!SuppressEvents && Content != null) {
237        TextBox tb = (TextBox)sender;
238        double val;
239        if (double.TryParse(tb.Text, out val)) {
240          Content.SecondYAxisMinimumFixedValue = val;
241          errorProvider.SetError(tb, string.Empty);
242        } else {
243          errorProvider.SetError(tb, "Not a valid number.");
244          e.Cancel = true;
245        }
246      }
247    }
248
249    private void yAxisSecondaryMaximumFixedTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
250      if (!SuppressEvents && Content != null) {
251        TextBox tb = (TextBox)sender;
252        double val;
253        if (double.TryParse(tb.Text, out val)) {
254          Content.SecondYAxisMaximumFixedValue = val;
255          errorProvider.SetError(tb, string.Empty);
256        } else {
257          errorProvider.SetError(tb, "Not a valid number.");
258          e.Cancel = true;
259        }
260      }
261    }
262
263    private void xAxisPrimaryMinimumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
264      if (!SuppressEvents && Content != null) {
265        SuppressEvents = true;
266        try {
267          Content.XAxisMinimumAuto = xAxisPrimaryMinimumAutoRadioButton.Checked;
268          if (Content.XAxisMinimumAuto) xAxisPrimaryMinimumFixedTextBox.Text = double.NaN.ToString();
269        } finally { SuppressEvents = false; }
270        SetEnabledStateOfControls();
271      }
272    }
273
274    private void xAxisPrimaryMaximumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
275      if (!SuppressEvents && Content != null) {
276        SuppressEvents = true;
277        try {
278          Content.XAxisMaximumAuto = xAxisPrimaryMaximumAutoRadioButton.Checked;
279          if (Content.XAxisMaximumAuto) xAxisPrimaryMaximumFixedTextBox.Text = double.NaN.ToString();
280        } finally { SuppressEvents = false; }
281        SetEnabledStateOfControls();
282      }
283    }
284
285    private void xAxisSecondaryMinimumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
286      if (!SuppressEvents && Content != null) {
287        SuppressEvents = true;
288        try {
289          Content.SecondXAxisMinimumAuto = xAxisSecondaryMinimumAutoRadioButton.Checked;
290          if (Content.SecondXAxisMinimumAuto) xAxisSecondaryMinimumFixedTextBox.Text = double.NaN.ToString();
291        } finally { SuppressEvents = false; }
292        SetEnabledStateOfControls();
293      }
294    }
295
296    private void xAxisSecondaryMaximumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
297      if (!SuppressEvents && Content != null) {
298        SuppressEvents = true;
299        try {
300          Content.SecondXAxisMaximumAuto = xAxisSecondaryMaximumAutoRadioButton.Checked;
301          if (Content.SecondXAxisMaximumAuto) xAxisSecondaryMaximumFixedTextBox.Text = double.NaN.ToString();
302        } finally { SuppressEvents = false; }
303        SetEnabledStateOfControls();
304      }
305    }
306
307    private void yAxisPrimaryMinimumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
308      if (!SuppressEvents && Content != null) {
309        SuppressEvents = true;
310        try {
311          Content.YAxisMinimumAuto = yAxisPrimaryMinimumAutoRadioButton.Checked;
312          if (Content.YAxisMinimumAuto) yAxisPrimaryMinimumFixedTextBox.Text = double.NaN.ToString();
313        } finally { SuppressEvents = false; }
314        SetEnabledStateOfControls();
315      }
316    }
317
318    private void yAxisPrimaryMaximumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
319      if (!SuppressEvents && Content != null) {
320        SuppressEvents = true;
321        try {
322          Content.YAxisMaximumAuto = yAxisPrimaryMaximumAutoRadioButton.Checked;
323          if (Content.YAxisMaximumAuto) yAxisPrimaryMaximumFixedTextBox.Text = double.NaN.ToString();
324        } finally { SuppressEvents = false; }
325        SetEnabledStateOfControls();
326      }
327    }
328
329    private void yAxisSecondaryMinimumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
330      if (!SuppressEvents && Content != null) {
331        SuppressEvents = true;
332        try {
333          Content.SecondYAxisMinimumAuto = yAxisSecondaryMinimumAutoRadioButton.Checked;
334          if (Content.SecondYAxisMinimumAuto) yAxisSecondaryMinimumFixedTextBox.Text = double.NaN.ToString();
335        } finally { SuppressEvents = false; }
336        SetEnabledStateOfControls();
337      }
338    }
339
340    private void yAxisSecondaryMaximumRadioButton_CheckedChanged(object sender, System.EventArgs e) {
341      if (!SuppressEvents && Content != null) {
342        SuppressEvents = true;
343        try {
344          Content.SecondYAxisMaximumAuto = yAxisSecondaryMaximumAutoRadioButton.Checked;
345          if (Content.SecondYAxisMaximumAuto) yAxisSecondaryMaximumFixedTextBox.Text = double.NaN.ToString();
346        } finally { SuppressEvents = false; }
347        SetEnabledStateOfControls();
348      }
349    }
350    #endregion
351  }
352}
Note: See TracBrowser for help on using the repository browser.