1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using System.Windows.Forms;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.JsonInterface.OptimizerIntegration {
|
---|
10 |
|
---|
11 | public class IntRangeVM : RangeVM<int> {
|
---|
12 | public override Type JsonItemType => typeof(IntRangeJsonItem);
|
---|
13 |
|
---|
14 | protected override int MinTypeValue => int.MinValue;
|
---|
15 |
|
---|
16 | protected override int MaxTypeValue => int.MaxValue;
|
---|
17 |
|
---|
18 | public override UserControl Control =>
|
---|
19 | new JsonItemRangeControl(this);
|
---|
20 | }
|
---|
21 |
|
---|
22 | public class DoubleRangeVM : RangeVM<double> {
|
---|
23 | public override Type JsonItemType => typeof(DoubleRangeJsonItem);
|
---|
24 |
|
---|
25 | protected override double MinTypeValue => double.MinValue;
|
---|
26 |
|
---|
27 | protected override double MaxTypeValue => double.MaxValue;
|
---|
28 |
|
---|
29 | public override UserControl Control =>
|
---|
30 | new JsonItemRangeControl(this);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public abstract class RangeVM<T> : RangedValueBaseVM<T> {
|
---|
34 |
|
---|
35 | public T MinValue {
|
---|
36 | get => Cast(((Array)Item.Value).GetValue(0));
|
---|
37 | set {
|
---|
38 | SetValue(value, (T)((Array)Item.Value).GetValue(1));
|
---|
39 | OnPropertyChange(this, nameof(MinValue));
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public T MaxValue {
|
---|
44 | get => Cast(((Array)Item.Value).GetValue(1));
|
---|
45 | set {
|
---|
46 | SetValue((T)((Array)Item.Value).GetValue(0), value);
|
---|
47 | OnPropertyChange(this, nameof(MaxValue));
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | private void SetValue(T min, T max) =>
|
---|
52 | Item.Value = new T[] { min, max };
|
---|
53 | }
|
---|
54 | }
|
---|