Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Shared/NumericRangeControl.cs @ 17530

Last change on this file since 17530 was 17444, checked in by dpiringe, 5 years ago

#3026:

  • added two new methods in IJsonItem -> FixatePath and LoosenPath to fixate/loosen the path (to enable name changing without effects on path)
  • set IsInRange to virtual and made overrides for IntMatrixJsonItem and DoubleMatrixJsonItem (IsInRange is a bad name and needs to be renamed in future versions)
  • implemented basic validation feedback with ErrorProvider for some inputs (templateName, Name, Range)
  • now all items gets validated before export (validation errors are shown with ErrorHandling.ShowErrorDialog)
  • added a check in AlgorithmConverter to prevent an exception for accessing the first element of an empty IEnumerable
File size: 1.7 KB
RevLine 
[17405]1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10using System.Globalization;
11
[17410]12namespace HeuristicLab.JsonInterface.OptimizerIntegration {
[17405]13  public partial class NumericRangeControl : UserControl {
[17411]14    public TextBox TBMinRange { get; set; }
15    public TextBox TBMaxRange { get; set; }
16    public CheckBox EnableMinRange { get; set; }
17    public CheckBox EnableMaxRange { get; set; }
[17405]18    public NumericRangeControl() {
19      InitializeComponent();
[17411]20      TBMinRange = textBoxFrom;
21      TBMaxRange = textBoxTo;
22      EnableMinRange = checkBoxFrom;
23      EnableMaxRange = checkBoxTo;
24      checkBoxFrom.CheckedChanged += ToggleFromInput;
25      checkBoxTo.CheckedChanged += ToggleToInput;
[17405]26    }
27
[17411]28    private void ToggleToInput(object sender, EventArgs e) {
[17405]29      textBoxTo.ReadOnly = !checkBoxTo.Checked;
30    }
31
[17411]32    private void ToggleFromInput(object sender, EventArgs e) {
33      textBoxFrom.ReadOnly = !checkBoxFrom.Checked;
[17405]34    }
[17444]35
36    private void textBoxFrom_Validating(object sender, CancelEventArgs e) {
37      if (string.IsNullOrWhiteSpace(textBoxFrom.Text)) {
38        errorProvider.SetError(textBoxFrom, "'From' must not be empty.");
39        e.Cancel = true;
40      } else {
41        errorProvider.SetError(textBoxFrom, null);
42      }
43    }
44
45    private void textBoxTo_Validating(object sender, CancelEventArgs e) {
46      if (string.IsNullOrWhiteSpace(textBoxTo.Text)) {
47        errorProvider.SetError(textBoxTo, "'To' must not be empty.");
48        e.Cancel = true;
49      } else {
50        errorProvider.SetError(textBoxTo, null);
51      }
52    }
[17405]53  }
54}
Note: See TracBrowser for help on using the repository browser.