Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/20 16:58:03 (4 years ago)
Author:
dpiringe
Message:

#3026:

  • made interfaces for array/matrix JsonItems and for their VMs aswell (IArrayJsonItem, IArrayJsonItemVM, IMatrixJsonItem, IMatrixJsonItemVM), incl. base classes (ArrayJsonItemBase, ArrayValueVM, MatrixJsonItemBase, MatrixValueVM)
  • changed inheritance structure for already existing array/matrix JsonItems -> they inherit now from new base array/matrix base classes
  • added input elements to configure the size of an matrix or array in JsonItemMultiValueControl (incl. VM binding and validation)
  • splitted file JsonItems.cs into separate files for their corresponding types (IntJsonItems.cs, DoubleJsonItems.cs, BoolJsonItems.cs, StringJsonItem.cs, DateTimeJsonItem.cs)
  • changed location of deserialization of json values from JsonTemplateInstantiator into IJsonItem (implemented in JsonItem and set to virtual, overridden in MatrixJsonItemBase and ArrayJsonItemBase)
  • added new CLI argument StringArgument
  • some little UI improvements (location fixes, anchor fixes, ...)
File:
1 edited

Legend:

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

    r17433 r17446  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99
    10   public class DoubleArrayValueVM : ArrayValueVM<double> {
     10  public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> {
    1111    public override Type JsonItemType => typeof(DoubleArrayJsonItem);
    1212
     
    1515    protected override double MaxTypeValue => double.MaxValue;
    1616
    17     public override JsonItemBaseControl GetControl() =>
     17    public override JsonItemBaseControl Control =>
    1818      new JsonItemDoubleArrayValueControl(this);
    1919   
     
    2727  }
    2828
    29   public class IntArrayValueVM : ArrayValueVM<int> {
     29  public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> {
    3030    public override Type JsonItemType => typeof(IntArrayJsonItem);
    3131
     
    3434    protected override int MaxTypeValue => int.MaxValue;
    3535
    36     public override JsonItemBaseControl GetControl() =>
     36    public override JsonItemBaseControl Control =>
    3737      new JsonItemIntArrayValueControl(this);
    3838   
     
    4646  }
    4747
    48   public abstract class ArrayValueVM<T> : RangedValueBaseVM<T> {
     48  public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IArrayJsonItemVM
     49    where JsonItemType : IArrayJsonItem {
    4950   
    5051    public ArrayValueVM() { }
    5152
    52     public void SetIndexValue(object obj, int index) {
     53    public void SetIndexValue(T data, int index) {
    5354      T[] tmp = Value;
    5455      if(index >= tmp.Length) { // increasing array
     
    5758        tmp = newArr;
    5859      }
    59       tmp[index] = (T)Convert.ChangeType(obj, typeof(T));
     60      tmp[index] = data;
    6061      Value = tmp;
    6162    }
    6263
    6364    public abstract T[] Value { get; set; }
     65    public bool Resizable {
     66      get => ((IArrayJsonItem)Item).Resizable;
     67      set {
     68        ((IArrayJsonItem)Item).Resizable = value;
     69        OnPropertyChange(this, nameof(IArrayJsonItemVM.Resizable));
     70      }
     71    }
    6472  }
    6573}
Note: See TracChangeset for help on using the changeset viewer.