Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17473 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
Line 
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
12namespace HeuristicLab.JsonInterface.OptimizerIntegration {
13  public partial class NumericRangeControl : UserControl {
14    public TextBox TBMinRange { get; set; }
15    public TextBox TBMaxRange { get; set; }
16    public CheckBox EnableMinRange { get; set; }
17    public CheckBox EnableMaxRange { get; set; }
18    public NumericRangeControl() {
19      InitializeComponent();
20      TBMinRange = textBoxFrom;
21      TBMaxRange = textBoxTo;
22      EnableMinRange = checkBoxFrom;
23      EnableMaxRange = checkBoxTo;
24      checkBoxFrom.CheckedChanged += ToggleFromInput;
25      checkBoxTo.CheckedChanged += ToggleToInput;
26    }
27
28    private void ToggleToInput(object sender, EventArgs e) {
29      textBoxTo.ReadOnly = !checkBoxTo.Checked;
30    }
31
32    private void ToggleFromInput(object sender, EventArgs e) {
33      textBoxFrom.ReadOnly = !checkBoxFrom.Checked;
34    }
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    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.