Changeset 17420 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
- Timestamp:
- 02/03/20 17:32:50 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
r17412 r17420 9 9 10 10 public class IntRangeVM : RangeVM<int> { 11 public override Type JsonItemType => typeof(IntArrayJsonItem); 12 } 11 public override Type JsonItemType => typeof(IntRangeJsonItem); 13 12 14 public class DoubleRangeVM : RangeVM<double> { 15 public override Type JsonItemType => typeof(DoubleArrayJsonItem); 13 protected override int MinTypeValue => int.MinValue; 14 15 protected override int MaxTypeValue => int.MaxValue; 16 16 17 public override JsonItemBaseControl GetControl() => 17 18 new JsonItemRangeControl(this); 18 19 } 19 20 20 public abstract class RangeVM<T> : JsonItemVMBase { 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 GetControl() => 29 new JsonItemRangeControl(this); 30 } 31 32 public abstract class RangeVM<T> : RangedValueBaseVM<T> { 21 33 22 34 public T MinValue { … … 36 48 } 37 49 38 public T MinRange {39 get => Cast(Item.Range.First());40 set {41 SetRange(value, Item.Range.Last());42 OnPropertyChange(this, nameof(MinRange));43 }44 }45 46 public T MaxRange {47 get => Cast(Item.Range.Last());48 set {49 SetRange(Item.Range.First(), value);50 OnPropertyChange(this, nameof(MaxRange));51 }52 }53 54 private T Cast(object obj) => (T)Convert.ChangeType(obj, typeof(T));55 56 50 private void SetValue(object min, object max) => 57 51 Item.Value = new object[] { min, max }; 58 59 private void SetRange(object min, object max) =>60 Item.Range = new object[] { min, max };61 52 } 62 53 }
Note: See TracChangeset
for help on using the changeset viewer.