Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/20 16:58:03 (5 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, ...)
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
Files:
1 added
6 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}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17444 r17446  
    99
    1010namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    11   public class JsonItemVMBase : INotifyPropertyChanged, IDisposable {
     11  public class JsonItemVMBase : IJsonItemVM {
    1212    public event PropertyChangedEventHandler PropertyChanged;
    1313    public event Action ItemChanged;
     
    7878    }
    7979
    80     public virtual JsonItemBaseControl GetControl() {
    81       return new JsonItemBaseControl(this);
    82     }
    83 
     80    public virtual JsonItemBaseControl Control => new JsonItemBaseControl(this);
     81   
    8482    #region IDisposable Support
    8583    private bool disposedValue = false; // To detect redundant calls
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs

    r17433 r17446  
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    99
    10   public class DoubleMatrixValueVM : MatrixValueVM<double> {
     10  public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> {
    1111    public override Type JsonItemType => typeof(DoubleMatrixJsonItem);
    12     public override JsonItemBaseControl GetControl() =>
     12    public override JsonItemBaseControl Control =>
    1313      new JsonItemDoubleMatrixValueControl(this);
    1414
     
    2626  }
    2727
    28   public abstract class MatrixValueVM<T> : RangedValueBaseVM<T> {
     28  public abstract class MatrixValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IMatrixJsonItemVM
     29    where JsonItemType : IMatrixJsonItem {
     30    public abstract T[][] Value { get; set; }
     31    public bool RowsResizable {
     32      get => ((IMatrixJsonItem)Item).RowsResizable;
     33      set {
     34        ((IMatrixJsonItem)Item).RowsResizable = value;
     35        OnPropertyChange(this, nameof(RowsResizable));
     36      }
     37    }
    2938
    30     public MatrixValueVM() {}
    31     public void SetCellValue(object obj, int col, int row) {
     39    public bool ColumnsResizable {
     40      get => ((IMatrixJsonItem)Item).ColumnsResizable;
     41      set {
     42        ((IMatrixJsonItem)Item).ColumnsResizable = value;
     43        OnPropertyChange(this, nameof(ColumnsResizable));
     44      }
     45    }
     46
     47    public void SetCellValue(T data, int row, int col) {
     48     
    3249      T[][] tmp = Value;
    3350     
     51      // increase y
    3452      if (row >= tmp.Length) { // increasing array
    3553        T[][] newArr = new T[row + 1][];
     
    3856        tmp = newArr;
    3957      }
     58
     59      // increase x
    4060      for(int i = 0; i < tmp.Length; ++i) {
    4161        if(col >= tmp[i].Length) {
     
    4565        }
    4666      }
    47       tmp[row][col] = (T)Convert.ChangeType(obj.ToString().Replace(",","."),
    48                                             typeof(T),
    49                                             System.Globalization.CultureInfo.InvariantCulture);
     67
     68      tmp[row][col] = data;
    5069      Value = tmp;
    5170    }
    52 
    53     public abstract T[][] Value { get; set; }
    54 
    5571  }
    5672}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17420 r17446  
    1515    protected override int MaxTypeValue => int.MaxValue;
    1616
    17     public override JsonItemBaseControl GetControl() =>
     17    public override JsonItemBaseControl Control =>
    1818      new JsonItemRangeControl(this);
    1919  }
     
    2626    protected override double MaxTypeValue => double.MaxValue;
    2727
    28     public override JsonItemBaseControl GetControl() =>
     28    public override JsonItemBaseControl Control =>
    2929      new JsonItemRangeControl(this);
    3030  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs

    r17443 r17446  
    1414    protected override int MaxTypeValue => int.MaxValue;
    1515
    16     public override JsonItemBaseControl GetControl() =>
     16    public override JsonItemBaseControl Control =>
    1717      new JsonItemIntValueControl(this);
    1818  }
     
    2424    protected override double MaxTypeValue => double.MaxValue;
    2525
    26     public override JsonItemBaseControl GetControl() =>
     26    public override JsonItemBaseControl Control =>
    2727       new JsonItemDoubleValueControl(this);
    2828  }
     
    3434    protected override bool MaxTypeValue => true;
    3535
    36     public override JsonItemBaseControl GetControl() =>
     36    public override JsonItemBaseControl Control =>
    3737       new JsonItemBoolControl(this);
    3838  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17443 r17446  
    88  public class StringValueVM : JsonItemVMBase {
    99    public override Type JsonItemType => typeof(StringJsonItem);
    10     public override JsonItemBaseControl GetControl() =>
     10    public override JsonItemBaseControl Control =>
    1111       new JsonItemValidValuesControl(this);
    1212
Note: See TracChangeset for help on using the changeset viewer.