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

Last change on this file since 17828 was 17828, checked in by dpiringe, 16 months ago

#3026

  • removed the option to set the value for JsonItems via exporter
    • reworked some base controls
    • added new controls for JsonItem specific properties (e.g. ArrayResizable)
    • deleted a lot of obsolet controls
  • removed the Enable checkbox in the detail view of JsonItems
  • exporter now clones the IOptimizer object
  • added a check + message for unsupported exports
  • list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
  • refactored the converter type check
    • now every converter has to specify its supported type(s)
File size: 2.5 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    public static UserControl Create(IJsonItemVM vm) {
55      NumericRangeControl numericRangeControl = new NumericRangeControl();
56      numericRangeControl.TBMinRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange));
57      numericRangeControl.TBMaxRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange));
58      numericRangeControl.EnableMinRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange),
59        false, DataSourceUpdateMode.OnPropertyChanged);
60      numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange),
61        false, DataSourceUpdateMode.OnPropertyChanged);
62      return numericRangeControl;
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.