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