Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/NumericRangeControl.cs @ 17843

Last change on this file since 17843 was 17843, checked in by dpiringe, 3 years ago

#3026

  • removed property ConvertableType from all converters
  • removed the option to fixate or loosen the path of JsonItems (obsolete)
  • added a abstract formatter SymbolicRegressionSolutionFormatterBase as base formatter for ISymbolicRegressionSolution
  • unified the construction of exporter controls
  • code cleanup
File size: 2.5 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; }
[17843]18
19    private NumericRangeControl() {
[17405]20      InitializeComponent();
[17843]21      Init();
22    }
23
24    protected NumericRangeControl(IJsonItemVM vm) {
25      InitializeComponent();
26      Init();
27      TBMinRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange));
28      TBMaxRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange));
29      EnableMinRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange),
30        false, DataSourceUpdateMode.OnPropertyChanged);
31      EnableMaxRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange),
32        false, DataSourceUpdateMode.OnPropertyChanged);
33    }
34
35
36    private void Init() {
[17411]37      TBMinRange = textBoxFrom;
38      TBMaxRange = textBoxTo;
39      EnableMinRange = checkBoxFrom;
40      EnableMaxRange = checkBoxTo;
41      checkBoxFrom.CheckedChanged += ToggleFromInput;
42      checkBoxTo.CheckedChanged += ToggleToInput;
[17405]43    }
44
[17411]45    private void ToggleToInput(object sender, EventArgs e) {
[17405]46      textBoxTo.ReadOnly = !checkBoxTo.Checked;
47    }
48
[17411]49    private void ToggleFromInput(object sender, EventArgs e) {
50      textBoxFrom.ReadOnly = !checkBoxFrom.Checked;
[17405]51    }
[17444]52
53    private void textBoxFrom_Validating(object sender, CancelEventArgs e) {
54      if (string.IsNullOrWhiteSpace(textBoxFrom.Text)) {
55        errorProvider.SetError(textBoxFrom, "'From' must not be empty.");
56        e.Cancel = true;
57      } else {
58        errorProvider.SetError(textBoxFrom, null);
59      }
60    }
61
62    private void textBoxTo_Validating(object sender, CancelEventArgs e) {
63      if (string.IsNullOrWhiteSpace(textBoxTo.Text)) {
64        errorProvider.SetError(textBoxTo, "'To' must not be empty.");
65        e.Cancel = true;
66      } else {
67        errorProvider.SetError(textBoxTo, null);
68      }
69    }
[17828]70
[17843]71    public static UserControl Create(IJsonItemVM vm) => new NumericRangeControl(vm);
[17405]72  }
73}
Note: See TracBrowser for help on using the repository browser.