Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13855


Ignore:
Timestamp:
05/20/16 13:01:24 (8 years ago)
Author:
pfleck
Message:

#2597

  • Added validation in GradientChartConfigurationDialog and DensityTrackbar.
  • Added optional configuration button for GradientChart.
Location:
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/DensityTrackbar.Designer.cs

    r13850 r13855  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.radioButton = new System.Windows.Forms.RadioButton();
    4849      this.trackBar = new System.Windows.Forms.TrackBar();
     
    5152      this.groupBox = new System.Windows.Forms.GroupBox();
    5253      this.doubleLimitView = new HeuristicLab.Problems.DataAnalysis.Views.DoubleLimitView();
     54      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    5355      ((System.ComponentModel.ISupportInitialize)(this.trackBar)).BeginInit();
    5456      this.groupBox.SuspendLayout();
     57      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5558      this.SuspendLayout();
    5659      //
     
    9699      this.textBox.Location = new System.Drawing.Point(6, 35);
    97100      this.textBox.Name = "textBox";
    98       this.textBox.ReadOnly = true;
    99101      this.textBox.Size = new System.Drawing.Size(132, 20);
    100102      this.textBox.TabIndex = 4;
     103      this.textBox.Validating += new System.ComponentModel.CancelEventHandler(this.textBox_Validating);
     104      this.textBox.Validated += new System.EventHandler(this.textBox_Validated);
    101105      //
    102106      // groupBox
     
    125129      this.doubleLimitView.TabIndex = 2;
    126130      //
     131      // errorProvider
     132      //
     133      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     134      this.errorProvider.ContainerControl = this;
     135      //
    127136      // DensityTrackbar
    128137      //
     
    134143      this.groupBox.ResumeLayout(false);
    135144      this.groupBox.PerformLayout();
     145      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    136146      this.ResumeLayout(false);
    137147
     
    146156    private System.Windows.Forms.TextBox textBox;
    147157    private System.Windows.Forms.GroupBox groupBox;
     158    private System.Windows.Forms.ErrorProvider errorProvider;
    148159  }
    149160}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/DensityTrackbar.cs

    r13853 r13855  
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Globalization;
     
    4950    private IList<double> trainingValues;
    5051
    51     // For VisualStudio Designer
    52     internal DensityTrackbar() {
    53       InitializeComponent();
    54     }
    55 
    5652    public DensityTrackbar(string name, DoubleLimit limit, IList<double> trainingValues) {
    5753      InitializeComponent();
     
    8076    #region Event Handlers
    8177    private void trackBar_ValueChanged(object sender, EventArgs e) {
    82       textBox.Text = Value.ToString(CultureInfo.InvariantCulture);
     78      textBox.Text = Value.ToString(CultureInfo.CurrentUICulture);
     79      textBox.Update();
    8380      OnValueChanged();
    8481    }
     
    9188      Checked = radioButton.Checked;
    9289      trackBar.Enabled = !Checked;
    93       textBox.Text = Checked ? "Plotted" : Value.ToString(CultureInfo.InvariantCulture);
     90      textBox.Enabled = !Checked;
     91      textBox.Text = Checked ? "Plotted" : Value.ToString(CultureInfo.CurrentUICulture);
    9492      radioButton.BackColor = Checked ? SystemColors.ActiveCaption : SystemColors.Control;
    9593      OnCheckedChanged();
     
    9896      base.OnTextChanged(e);
    9997      radioButton.Text = Text;
     98    }
     99
     100    private void textBox_Validating(object sender, CancelEventArgs e) {
     101      if (Checked) return;
     102      decimal number;
     103      if (!decimal.TryParse(textBox.Text, NumberStyles.Any, CultureInfo.CurrentUICulture.NumberFormat, out number)) {
     104        e.Cancel = true;
     105        errorProvider.SetIconAlignment(textBox, ErrorIconAlignment.MiddleLeft);
     106        errorProvider.SetIconPadding(textBox, 2);
     107        errorProvider.SetError(textBox, "Illegal number format");
     108      }
     109    }
     110
     111    private void textBox_Validated(object sender, EventArgs e) {
     112      if (Checked) return;
     113      errorProvider.SetError(textBox, string.Empty);
     114      Value = decimal.Parse(textBox.Text, NumberStyles.Any, CultureInfo.CurrentUICulture.NumberFormat);
    100115    }
    101116    #endregion
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.Designer.cs

    r13853 r13855  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
     27      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GradientChart));
    2728      System.Windows.Forms.DataVisualization.Charting.VerticalLineAnnotation verticalLineAnnotation1 = new System.Windows.Forms.DataVisualization.Charting.VerticalLineAnnotation();
    2829      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     
    3334      this.calculationPendingTimer = new System.Windows.Forms.Timer(this.components);
    3435      this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     36      this.configurationButton = new System.Windows.Forms.Button();
     37      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    3538      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    3639      this.SuspendLayout();
     
    9093      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    9194      //
     95      // configurationButton
     96      //
     97      this.configurationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     98      this.configurationButton.AutoSize = true;
     99      this.configurationButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties;
     100      this.configurationButton.Location = new System.Drawing.Point(426, 3);
     101      this.configurationButton.Name = "configurationButton";
     102      this.configurationButton.Size = new System.Drawing.Size(24, 24);
     103      this.configurationButton.TabIndex = 2;
     104      this.configurationButton.TabStop = false;
     105      this.toolTip.SetToolTip(this.configurationButton, "Configuration");
     106      this.configurationButton.UseVisualStyleBackColor = true;
     107      this.configurationButton.Click += new System.EventHandler(this.config_Click);
     108      //
    92109      // GradientChart
    93110      //
    94111      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    95112      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     113      this.Controls.Add(this.configurationButton);
    96114      this.Controls.Add(this.calculationPendingLabel);
    97115      this.Controls.Add(this.chart);
     
    100118      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    101119      this.ResumeLayout(false);
     120      this.PerformLayout();
    102121
    103122    }
     
    108127    private System.Windows.Forms.Label calculationPendingLabel;
    109128    private System.Windows.Forms.Timer calculationPendingTimer;
     129    private System.Windows.Forms.Button configurationButton;
     130    private System.Windows.Forms.ToolTip toolTip;
    110131  }
    111132}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs

    r13853 r13855  
    6060    }
    6161
     62    public bool ShowConfigButton {
     63      get { return configurationButton.Visible; }
     64      set { configurationButton.Visible = value; }
     65    }
     66
    6267    private int xAxisTicks = 5;
    6368    public int XAxisTicks {
     
    190195
    191196      configToolStripMenuItem = new ToolStripMenuItem("Configuration");
    192       configToolStripMenuItem.Click += configToolStripMenuItem_Click;
     197      configToolStripMenuItem.Click += config_Click;
    193198      chart.ContextMenuStrip.Items.Add(new ToolStripSeparator());
    194199      chart.ContextMenuStrip.Items.Add(configToolStripMenuItem);
     
    596601    }
    597602
    598     private void configToolStripMenuItem_Click(object sender, EventArgs e) {
     603    private void config_Click(object sender, EventArgs e) {
    599604      configurationDialog.ShowDialog(this);
    600605    }
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChartConfigurationDialog.Designer.cs

    r13853 r13855  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.xAxisGroupBox = new System.Windows.Forms.GroupBox();
    4849      this.maxXTextBox = new System.Windows.Forms.TextBox();
     50      this.xAutomaticCheckBox = new System.Windows.Forms.CheckBox();
    4951      this.minXTextBox = new System.Windows.Forms.TextBox();
    5052      this.maxXLabel = new System.Windows.Forms.Label();
     
    5759      this.minYLabel = new System.Windows.Forms.Label();
    5860      this.miscGroupBox = new System.Windows.Forms.GroupBox();
     61      this.StepsNumericUpDown = new System.Windows.Forms.NumericUpDown();
    5962      this.stepsLabel = new System.Windows.Forms.Label();
    6063      this.applyButton = new System.Windows.Forms.Button();
    6164      this.cancelButton = new System.Windows.Forms.Button();
    62       this.xAutomaticCheckBox = new System.Windows.Forms.CheckBox();
    63       this.StepsNumericUpDown = new System.Windows.Forms.NumericUpDown();
     65      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
    6466      this.xAxisGroupBox.SuspendLayout();
    6567      this.yAxisGroupBox.SuspendLayout();
    6668      this.miscGroupBox.SuspendLayout();
    6769      ((System.ComponentModel.ISupportInitialize)(this.StepsNumericUpDown)).BeginInit();
     70      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6871      this.SuspendLayout();
    6972      //
     
    9295      this.maxXTextBox.Size = new System.Drawing.Size(167, 20);
    9396      this.maxXTextBox.TabIndex = 3;
     97      this.maxXTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberTextBox_Validating);
     98      this.maxXTextBox.Validated += new System.EventHandler(this.numberTextBox_Validated);
     99      //
     100      // xAutomaticCheckBox
     101      //
     102      this.xAutomaticCheckBox.AutoSize = true;
     103      this.xAutomaticCheckBox.Location = new System.Drawing.Point(48, -1);
     104      this.xAutomaticCheckBox.Name = "xAutomaticCheckBox";
     105      this.xAutomaticCheckBox.Size = new System.Drawing.Size(73, 17);
     106      this.xAutomaticCheckBox.TabIndex = 1;
     107      this.xAutomaticCheckBox.Text = "Automatic";
     108      this.xAutomaticCheckBox.UseVisualStyleBackColor = true;
     109      this.xAutomaticCheckBox.CheckedChanged += new System.EventHandler(this.automaticCheckBox_CheckedChanged);
    94110      //
    95111      // minXTextBox
     
    101117      this.minXTextBox.Size = new System.Drawing.Size(167, 20);
    102118      this.minXTextBox.TabIndex = 2;
     119      this.minXTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberTextBox_Validating);
     120      this.minXTextBox.Validated += new System.EventHandler(this.numberTextBox_Validated);
    103121      //
    104122      // maxXLabel
     
    144162      this.maxYTextBox.Size = new System.Drawing.Size(167, 20);
    145163      this.maxYTextBox.TabIndex = 3;
     164      this.maxYTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberTextBox_Validating);
     165      this.maxYTextBox.Validated += new System.EventHandler(this.numberTextBox_Validated);
    146166      //
    147167      // yAutomaticCheckBox
     
    164184      this.minYTextBox.Size = new System.Drawing.Size(167, 20);
    165185      this.minYTextBox.TabIndex = 2;
     186      this.minYTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.numberTextBox_Validating);
     187      this.minYTextBox.Validated += new System.EventHandler(this.numberTextBox_Validated);
    166188      //
    167189      // maxYLabel
     
    194216      this.miscGroupBox.TabIndex = 4;
    195217      this.miscGroupBox.TabStop = false;
    196       //
    197       // stepsLabel
    198       //
    199       this.stepsLabel.AutoSize = true;
    200       this.stepsLabel.Location = new System.Drawing.Point(6, 22);
    201       this.stepsLabel.Name = "stepsLabel";
    202       this.stepsLabel.Size = new System.Drawing.Size(34, 13);
    203       this.stepsLabel.TabIndex = 1;
    204       this.stepsLabel.Text = "Steps";
    205       //
    206       // applyButton
    207       //
    208       this.applyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    209       this.applyButton.Location = new System.Drawing.Point(91, 239);
    210       this.applyButton.Name = "applyButton";
    211       this.applyButton.Size = new System.Drawing.Size(75, 23);
    212       this.applyButton.TabIndex = 5;
    213       this.applyButton.Text = "Apply";
    214       this.applyButton.UseVisualStyleBackColor = true;
    215       this.applyButton.Click += new System.EventHandler(this.okButton_Click);
    216       //
    217       // cancelButton
    218       //
    219       this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    220       this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    221       this.cancelButton.Location = new System.Drawing.Point(172, 239);
    222       this.cancelButton.Name = "cancelButton";
    223       this.cancelButton.Size = new System.Drawing.Size(75, 23);
    224       this.cancelButton.TabIndex = 6;
    225       this.cancelButton.Text = "Cancel";
    226       this.cancelButton.UseVisualStyleBackColor = true;
    227       //
    228       // xAutomaticCheckBox
    229       //
    230       this.xAutomaticCheckBox.AutoSize = true;
    231       this.xAutomaticCheckBox.Location = new System.Drawing.Point(48, -1);
    232       this.xAutomaticCheckBox.Name = "xAutomaticCheckBox";
    233       this.xAutomaticCheckBox.Size = new System.Drawing.Size(73, 17);
    234       this.xAutomaticCheckBox.TabIndex = 1;
    235       this.xAutomaticCheckBox.Text = "Automatic";
    236       this.xAutomaticCheckBox.UseVisualStyleBackColor = true;
    237       this.xAutomaticCheckBox.CheckedChanged += new System.EventHandler(this.automaticCheckBox_CheckedChanged);
    238218      //
    239219      // StepsNumericUpDown
     
    255235      this.StepsNumericUpDown.Size = new System.Drawing.Size(166, 20);
    256236      this.StepsNumericUpDown.TabIndex = 4;
     237      //
     238      // stepsLabel
     239      //
     240      this.stepsLabel.AutoSize = true;
     241      this.stepsLabel.Location = new System.Drawing.Point(6, 22);
     242      this.stepsLabel.Name = "stepsLabel";
     243      this.stepsLabel.Size = new System.Drawing.Size(34, 13);
     244      this.stepsLabel.TabIndex = 1;
     245      this.stepsLabel.Text = "Steps";
     246      //
     247      // applyButton
     248      //
     249      this.applyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     250      this.applyButton.Location = new System.Drawing.Point(91, 239);
     251      this.applyButton.Name = "applyButton";
     252      this.applyButton.Size = new System.Drawing.Size(75, 23);
     253      this.applyButton.TabIndex = 5;
     254      this.applyButton.Text = "Apply";
     255      this.applyButton.UseVisualStyleBackColor = true;
     256      this.applyButton.Click += new System.EventHandler(this.okButton_Click);
     257      //
     258      // cancelButton
     259      //
     260      this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     261      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     262      this.cancelButton.Location = new System.Drawing.Point(172, 239);
     263      this.cancelButton.Name = "cancelButton";
     264      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     265      this.cancelButton.TabIndex = 6;
     266      this.cancelButton.Text = "Cancel";
     267      this.cancelButton.UseVisualStyleBackColor = true;
     268      //
     269      // errorProvider
     270      //
     271      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     272      this.errorProvider.ContainerControl = this;
    257273      //
    258274      // GradientChartConfigurationDialog
     
    279295      this.miscGroupBox.PerformLayout();
    280296      ((System.ComponentModel.ISupportInitialize)(this.StepsNumericUpDown)).EndInit();
     297      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    281298      this.ResumeLayout(false);
    282299
     
    302319    private System.Windows.Forms.CheckBox xAutomaticCheckBox;
    303320    private System.Windows.Forms.NumericUpDown StepsNumericUpDown;
     321    private System.Windows.Forms.ErrorProvider errorProvider;
    304322  }
    305323}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChartConfigurationDialog.cs

    r13853 r13855  
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Globalization;
    2425using System.Windows.Forms;
     
    2829  public partial class GradientChartConfigurationDialog : Form {
    2930    private readonly GradientChart chart;
    30 
    31     private IFormatProvider FormatProvider {
    32       get { return CultureInfo.CurrentUICulture.NumberFormat; }
    33     }
    3431
    3532    public GradientChartConfigurationDialog(GradientChart chart) {
     
    4138      if (chart.FixedXAxisMin.HasValue && chart.FixedXAxisMax.HasValue) {
    4239        xAutomaticCheckBox.Checked = false;
    43         minXTextBox.Text = chart.FixedXAxisMin.Value.ToString(FormatProvider);
    44         maxXTextBox.Text = chart.FixedXAxisMax.Value.ToString(FormatProvider);
     40        minXTextBox.Text = chart.FixedXAxisMin.Value.ToString(CultureInfo.CurrentUICulture);
     41        maxXTextBox.Text = chart.FixedXAxisMax.Value.ToString(CultureInfo.CurrentUICulture);
    4542      } else xAutomaticCheckBox.Checked = true;
    4643      if (chart.FixedYAxisMin.HasValue && chart.FixedYAxisMax.HasValue) {
    4744        yAutomaticCheckBox.Checked = false;
    48         minYTextBox.Text = chart.FixedYAxisMin.Value.ToString(FormatProvider);
    49         maxYTextBox.Text = chart.FixedYAxisMax.Value.ToString(FormatProvider);
     45        minYTextBox.Text = chart.FixedYAxisMin.Value.ToString(CultureInfo.CurrentUICulture);
     46        maxYTextBox.Text = chart.FixedYAxisMax.Value.ToString(CultureInfo.CurrentUICulture);
    5047      } else yAutomaticCheckBox.Checked = true;
    5148      StepsNumericUpDown.Value = chart.DrawingSteps;
     
    5956          chart.FixedXAxisMax = null;
    6057        } else {
    61           var min = Convert.ToDouble(minXTextBox.Text, FormatProvider);
    62           var max = Convert.ToDouble(maxXTextBox.Text, FormatProvider);
     58          var min = double.Parse(minXTextBox.Text, CultureInfo.CurrentUICulture);
     59          var max = double.Parse(maxXTextBox.Text, CultureInfo.CurrentUICulture);
    6360          chart.FixedXAxisMin = min;
    6461          chart.FixedXAxisMax = max;
     
    6966          chart.FixedYAxisMax = null;
    7067        } else {
    71           var min = Convert.ToDouble(minYTextBox.Text, FormatProvider);
    72           var max = Convert.ToDouble(maxYTextBox.Text, FormatProvider);
     68          var min = double.Parse(minYTextBox.Text, CultureInfo.CurrentUICulture);
     69          var max = double.Parse(maxYTextBox.Text, CultureInfo.CurrentUICulture);
    7370          chart.FixedYAxisMin = min;
    7471          chart.FixedYAxisMax = max;
     
    8178        Close();
    8279      }
    83       catch (FormatException fe) {
    84         MessageBox.Show(this, "Illegal number format: {0}", fe.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     80      catch (FormatException) {
     81        MessageBox.Show(this, "Illegal number format", "Wrong format", MessageBoxButtons.OK, MessageBoxIcon.Error);
    8582      }
    8683      finally {
     
    9693      maxYTextBox.Enabled = !yAutomaticCheckBox.Checked;
    9794    }
     95
     96    private void numberTextBox_Validating(object sender, CancelEventArgs e) {
     97      var textBox = sender as TextBox;
     98      if (textBox != null) {
     99        double number;
     100        if (!double.TryParse(textBox.Text, NumberStyles.Any, CultureInfo.CurrentUICulture, out number)) {
     101          e.Cancel = true;
     102          applyButton.Enabled = false;
     103          errorProvider.SetIconAlignment(textBox, ErrorIconAlignment.MiddleLeft);
     104          errorProvider.SetIconPadding(textBox, 2);
     105          errorProvider.SetError(textBox, "Illegal number format");
     106          textBox.SelectAll();
     107        }
     108      }
     109    }
     110
     111    private void numberTextBox_Validated(object sender, EventArgs e) {
     112      var textBox = sender as TextBox;
     113      if (textBox != null) {
     114        errorProvider.SetError(textBox, string.Empty);
     115        applyButton.Enabled = true;
     116      }
     117    }
    98118  }
    99119}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionTargetResponseGradientView.cs

    r13853 r13855  
    126126
    127127        var densityChart = new DensityChart() {
    128           //Dock = DockStyle.Top,
    129           //Location = new Point(0, 0),
    130128          Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right,
    131129          Margin = Padding.Empty,
     
    160158        ShowLegend = false,
    161159        ShowCursor = true,
     160        ShowConfigButton = false,
    162161        YAxisTicks = 5,
    163162      };
Note: See TracChangeset for help on using the changeset viewer.