Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlotConfigurationDialog.cs @ 17495

Last change on this file since 17495 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 4.6 KB
RevLine 
[13853]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[13853]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;
[13855]23using System.ComponentModel;
[13853]24using System.Globalization;
25using System.Windows.Forms;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace HeuristicLab.Problems.DataAnalysis.Views {
[14852]29  public partial class PartialDependencePlotConfigurationDialog : Form {
30    private readonly PartialDependencePlot chart;
[13853]31
[14852]32    public PartialDependencePlotConfigurationDialog(PartialDependencePlot chart) {
[13853]33      this.chart = chart;
34      InitializeComponent();
35    }
36
[14852]37    private void PartialDependencePlotConfigurationDialog_Shown(object sender, EventArgs e) {
[13853]38      if (chart.FixedXAxisMin.HasValue && chart.FixedXAxisMax.HasValue) {
39        xAutomaticCheckBox.Checked = false;
[13855]40        minXTextBox.Text = chart.FixedXAxisMin.Value.ToString(CultureInfo.CurrentUICulture);
41        maxXTextBox.Text = chart.FixedXAxisMax.Value.ToString(CultureInfo.CurrentUICulture);
[13853]42      } else xAutomaticCheckBox.Checked = true;
43      if (chart.FixedYAxisMin.HasValue && chart.FixedYAxisMax.HasValue) {
44        yAutomaticCheckBox.Checked = false;
[13855]45        minYTextBox.Text = chart.FixedYAxisMin.Value.ToString(CultureInfo.CurrentUICulture);
46        maxYTextBox.Text = chart.FixedYAxisMax.Value.ToString(CultureInfo.CurrentUICulture);
[13853]47      } else yAutomaticCheckBox.Checked = true;
48      StepsNumericUpDown.Value = chart.DrawingSteps;
49    }
50
51    private async void okButton_Click(object sender, System.EventArgs e) {
52      try {
[14118]53        Enabled = false;
[13853]54        chart.SuspendRepaint();
55        if (xAutomaticCheckBox.Checked) {
56          chart.FixedXAxisMin = null;
57          chart.FixedXAxisMax = null;
58        } else {
[13855]59          var min = double.Parse(minXTextBox.Text, CultureInfo.CurrentUICulture);
60          var max = double.Parse(maxXTextBox.Text, CultureInfo.CurrentUICulture);
[13853]61          chart.FixedXAxisMin = min;
62          chart.FixedXAxisMax = max;
63        }
64
65        if (yAutomaticCheckBox.Checked) {
66          chart.FixedYAxisMin = null;
67          chart.FixedYAxisMax = null;
68        } else {
[13855]69          var min = double.Parse(minYTextBox.Text, CultureInfo.CurrentUICulture);
70          var max = double.Parse(maxYTextBox.Text, CultureInfo.CurrentUICulture);
[13853]71          chart.FixedYAxisMin = min;
72          chart.FixedYAxisMax = max;
73        }
74
75        chart.DrawingSteps = (int)StepsNumericUpDown.Value;
76
77        await chart.RecalculateAsync(resetYAxis: false);
78
79        Close();
80      }
[13855]81      catch (FormatException) {
82        MessageBox.Show(this, "Illegal number format", "Wrong format", MessageBoxButtons.OK, MessageBoxIcon.Error);
[13853]83      }
84      finally {
[14118]85        Enabled = true;
[13853]86        chart.ResumeRepaint(true);
87      }
88    }
89
90    private void automaticCheckBox_CheckedChanged(object sender, EventArgs e) {
91      minXTextBox.Enabled = !xAutomaticCheckBox.Checked;
92      maxXTextBox.Enabled = !xAutomaticCheckBox.Checked;
93
94      minYTextBox.Enabled = !yAutomaticCheckBox.Checked;
95      maxYTextBox.Enabled = !yAutomaticCheckBox.Checked;
96    }
[13855]97
98    private void numberTextBox_Validating(object sender, CancelEventArgs e) {
99      var textBox = sender as TextBox;
100      if (textBox != null) {
101        double number;
102        if (!double.TryParse(textBox.Text, NumberStyles.Any, CultureInfo.CurrentUICulture, out number)) {
103          e.Cancel = true;
104          applyButton.Enabled = false;
105          errorProvider.SetIconAlignment(textBox, ErrorIconAlignment.MiddleLeft);
106          errorProvider.SetIconPadding(textBox, 2);
107          errorProvider.SetError(textBox, "Illegal number format");
108          textBox.SelectAll();
109        }
110      }
111    }
112
113    private void numberTextBox_Validated(object sender, EventArgs e) {
114      var textBox = sender as TextBox;
115      if (textBox != null) {
116        errorProvider.SetError(textBox, string.Empty);
117        applyButton.Enabled = true;
118      }
119    }
[13853]120  }
121}
Note: See TracBrowser for help on using the repository browser.