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