#region License Information /* HeuristicLab * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Globalization; using System.Windows.Forms; using HeuristicLab.MainForm.WindowsForms; namespace HeuristicLab.Problems.DataAnalysis.Views { public partial class GradientChartConfigurationDialog : Form { private readonly GradientChart chart; private IFormatProvider FormatProvider { get { return CultureInfo.CurrentUICulture.NumberFormat; } } public GradientChartConfigurationDialog(GradientChart chart) { this.chart = chart; InitializeComponent(); } private void GradientChartConfigurationDialog_Shown(object sender, EventArgs e) { if (chart.FixedXAxisMin.HasValue && chart.FixedXAxisMax.HasValue) { xAutomaticCheckBox.Checked = false; minXTextBox.Text = chart.FixedXAxisMin.Value.ToString(FormatProvider); maxXTextBox.Text = chart.FixedXAxisMax.Value.ToString(FormatProvider); } else xAutomaticCheckBox.Checked = true; if (chart.FixedYAxisMin.HasValue && chart.FixedYAxisMax.HasValue) { yAutomaticCheckBox.Checked = false; minYTextBox.Text = chart.FixedYAxisMin.Value.ToString(FormatProvider); maxYTextBox.Text = chart.FixedYAxisMax.Value.ToString(FormatProvider); } else yAutomaticCheckBox.Checked = true; StepsNumericUpDown.Value = chart.DrawingSteps; } private async void okButton_Click(object sender, System.EventArgs e) { try { chart.SuspendRepaint(); if (xAutomaticCheckBox.Checked) { chart.FixedXAxisMin = null; chart.FixedXAxisMax = null; } else { var min = Convert.ToDouble(minXTextBox.Text, FormatProvider); var max = Convert.ToDouble(maxXTextBox.Text, FormatProvider); chart.FixedXAxisMin = min; chart.FixedXAxisMax = max; } if (yAutomaticCheckBox.Checked) { chart.FixedYAxisMin = null; chart.FixedYAxisMax = null; } else { var min = Convert.ToDouble(minYTextBox.Text, FormatProvider); var max = Convert.ToDouble(maxYTextBox.Text, FormatProvider); chart.FixedYAxisMin = min; chart.FixedYAxisMax = max; } chart.DrawingSteps = (int)StepsNumericUpDown.Value; await chart.RecalculateAsync(resetYAxis: false); Close(); } catch (FormatException fe) { MessageBox.Show(this, "Illegal number format: {0}", fe.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { chart.ResumeRepaint(true); } } private void automaticCheckBox_CheckedChanged(object sender, EventArgs e) { minXTextBox.Enabled = !xAutomaticCheckBox.Checked; maxXTextBox.Enabled = !xAutomaticCheckBox.Checked; minYTextBox.Enabled = !yAutomaticCheckBox.Checked; maxYTextBox.Enabled = !yAutomaticCheckBox.Checked; } } }