[13853] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2016 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Globalization;
|
---|
| 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
| 28 | public partial class GradientChartConfigurationDialog : Form {
|
---|
| 29 | private readonly GradientChart chart;
|
---|
| 30 |
|
---|
| 31 | private IFormatProvider FormatProvider {
|
---|
| 32 | get { return CultureInfo.CurrentUICulture.NumberFormat; }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public GradientChartConfigurationDialog(GradientChart chart) {
|
---|
| 36 | this.chart = chart;
|
---|
| 37 | InitializeComponent();
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | private void GradientChartConfigurationDialog_Shown(object sender, EventArgs e) {
|
---|
| 41 | if (chart.FixedXAxisMin.HasValue && chart.FixedXAxisMax.HasValue) {
|
---|
| 42 | xAutomaticCheckBox.Checked = false;
|
---|
| 43 | minXTextBox.Text = chart.FixedXAxisMin.Value.ToString(FormatProvider);
|
---|
| 44 | maxXTextBox.Text = chart.FixedXAxisMax.Value.ToString(FormatProvider);
|
---|
| 45 | } else xAutomaticCheckBox.Checked = true;
|
---|
| 46 | if (chart.FixedYAxisMin.HasValue && chart.FixedYAxisMax.HasValue) {
|
---|
| 47 | yAutomaticCheckBox.Checked = false;
|
---|
| 48 | minYTextBox.Text = chart.FixedYAxisMin.Value.ToString(FormatProvider);
|
---|
| 49 | maxYTextBox.Text = chart.FixedYAxisMax.Value.ToString(FormatProvider);
|
---|
| 50 | } else yAutomaticCheckBox.Checked = true;
|
---|
| 51 | StepsNumericUpDown.Value = chart.DrawingSteps;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | private async void okButton_Click(object sender, System.EventArgs e) {
|
---|
| 55 | try {
|
---|
| 56 | chart.SuspendRepaint();
|
---|
| 57 | if (xAutomaticCheckBox.Checked) {
|
---|
| 58 | chart.FixedXAxisMin = null;
|
---|
| 59 | chart.FixedXAxisMax = null;
|
---|
| 60 | } else {
|
---|
| 61 | var min = Convert.ToDouble(minXTextBox.Text, FormatProvider);
|
---|
| 62 | var max = Convert.ToDouble(maxXTextBox.Text, FormatProvider);
|
---|
| 63 | chart.FixedXAxisMin = min;
|
---|
| 64 | chart.FixedXAxisMax = max;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | if (yAutomaticCheckBox.Checked) {
|
---|
| 68 | chart.FixedYAxisMin = null;
|
---|
| 69 | chart.FixedYAxisMax = null;
|
---|
| 70 | } else {
|
---|
| 71 | var min = Convert.ToDouble(minYTextBox.Text, FormatProvider);
|
---|
| 72 | var max = Convert.ToDouble(maxYTextBox.Text, FormatProvider);
|
---|
| 73 | chart.FixedYAxisMin = min;
|
---|
| 74 | chart.FixedYAxisMax = max;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | chart.DrawingSteps = (int)StepsNumericUpDown.Value;
|
---|
| 78 |
|
---|
| 79 | await chart.RecalculateAsync(resetYAxis: false);
|
---|
| 80 |
|
---|
| 81 | Close();
|
---|
| 82 | }
|
---|
| 83 | catch (FormatException fe) {
|
---|
| 84 | MessageBox.Show(this, "Illegal number format: {0}", fe.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
| 85 | }
|
---|
| 86 | finally {
|
---|
| 87 | chart.ResumeRepaint(true);
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | private void automaticCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 92 | minXTextBox.Enabled = !xAutomaticCheckBox.Checked;
|
---|
| 93 | maxXTextBox.Enabled = !xAutomaticCheckBox.Checked;
|
---|
| 94 |
|
---|
| 95 | minYTextBox.Enabled = !yAutomaticCheckBox.Checked;
|
---|
| 96 | maxYTextBox.Enabled = !yAutomaticCheckBox.Checked;
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 | }
|
---|