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 JsonItemRangeControl : UserControl {
|
---|
14 | IJsonItemVM VM { get; set; }
|
---|
15 |
|
---|
16 |
|
---|
17 | public JsonItemRangeControl(DoubleRangeVM vm) {
|
---|
18 | InitializeComponent();
|
---|
19 | VM = vm;
|
---|
20 | textBoxValueFrom.DataBindings.Add("Text", vm, nameof(vm.MinValue));
|
---|
21 | textBoxValueTo.DataBindings.Add("Text", vm, nameof(vm.MaxValue));
|
---|
22 | InitNumbericRangeControl();
|
---|
23 |
|
---|
24 | }
|
---|
25 | public JsonItemRangeControl(IntRangeVM vm) {
|
---|
26 | InitializeComponent();
|
---|
27 | VM = vm;
|
---|
28 | textBoxValueFrom.DataBindings.Add("Text", vm, nameof(vm.MinValue));
|
---|
29 | textBoxValueTo.DataBindings.Add("Text", vm, nameof(vm.MaxValue));
|
---|
30 | InitNumbericRangeControl();
|
---|
31 | }
|
---|
32 |
|
---|
33 | private void InitNumbericRangeControl() {
|
---|
34 | numericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange));
|
---|
35 | numericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange));
|
---|
36 | numericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange),
|
---|
37 | false, DataSourceUpdateMode.OnPropertyChanged);
|
---|
38 | numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange),
|
---|
39 | false, DataSourceUpdateMode.OnPropertyChanged);
|
---|
40 | }
|
---|
41 |
|
---|
42 | /*
|
---|
43 | protected abstract object Parse(string s);
|
---|
44 |
|
---|
45 | private void SetValue() {
|
---|
46 | if (!string.IsNullOrWhiteSpace(textBoxValueFrom.Text))
|
---|
47 | value[0] = Parse(textBoxValueFrom.Text);
|
---|
48 | else
|
---|
49 | value[0] = ((Array)VM.Item.Value).GetValue(0);
|
---|
50 |
|
---|
51 | if (!string.IsNullOrWhiteSpace(textBoxValueTo.Text))
|
---|
52 | value[1] = Parse(textBoxValueTo.Text);
|
---|
53 | else
|
---|
54 | value[1] = ((Array)VM.Item.Value).GetValue(1);
|
---|
55 | VM.Item.Value = value;
|
---|
56 | }
|
---|
57 |
|
---|
58 | private void textBoxValueFrom_Leave(object sender, EventArgs e) {
|
---|
59 | SetValue();
|
---|
60 | }
|
---|
61 |
|
---|
62 | private void textBoxValueTo_Leave(object sender, EventArgs e) {
|
---|
63 | SetValue();
|
---|
64 | }
|
---|
65 |
|
---|
66 | private void numericRangeControl1_Load(object sender, EventArgs e) {
|
---|
67 | numericRangeControl1.IsDouble = isDouble;
|
---|
68 | numericRangeControl1.VM = VM;
|
---|
69 | }
|
---|
70 | */
|
---|
71 | }
|
---|
72 | }
|
---|