Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/20 17:32:50 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • refactored ranged based VMs -> created new 'base' class for ranged based VMs RangedValueBaseVM
  • renamed AddChilds to AddChildren
  • implemented ArrayValueVM and JsonItemArrayValueControl
  • added ranges for array and matrix values
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17412 r17420  
    99
    1010  public class IntRangeVM : RangeVM<int> {
    11     public override Type JsonItemType => typeof(IntArrayJsonItem);
    12   }
     11    public override Type JsonItemType => typeof(IntRangeJsonItem);
    1312
    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
    1617    public override JsonItemBaseControl GetControl() =>
    1718      new JsonItemRangeControl(this);
    1819  }
    1920
    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> {
    2133
    2234    public T MinValue {
     
    3648    }
    3749
    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 
    5650    private void SetValue(object min, object max) =>
    5751      Item.Value = new object[] { min, max };
    58 
    59     private void SetRange(object min, object max) =>
    60       Item.Range = new object[] { min, max };
    6152  }
    6253}
Note: See TracChangeset for help on using the changeset viewer.