1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Threading.Tasks;
|
---|
9 | using System.Windows.Forms;
|
---|
10 | using System.Globalization;
|
---|
11 |
|
---|
12 | namespace 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 | }
|
---|