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/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}
Note: See TracChangeset for help on using the changeset viewer.