Changeset 17446 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
- Timestamp:
- 02/20/20 16:58:03 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
r17433 r17446 8 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 9 10 public class DoubleMatrixValueVM : MatrixValueVM<double > {10 public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> { 11 11 public override Type JsonItemType => typeof(DoubleMatrixJsonItem); 12 public override JsonItemBaseControl GetControl() =>12 public override JsonItemBaseControl Control => 13 13 new JsonItemDoubleMatrixValueControl(this); 14 14 … … 26 26 } 27 27 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 } 29 38 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 32 49 T[][] tmp = Value; 33 50 51 // increase y 34 52 if (row >= tmp.Length) { // increasing array 35 53 T[][] newArr = new T[row + 1][]; … … 38 56 tmp = newArr; 39 57 } 58 59 // increase x 40 60 for(int i = 0; i < tmp.Length; ++i) { 41 61 if(col >= tmp[i].Length) { … … 45 65 } 46 66 } 47 tmp[row][col] = (T)Convert.ChangeType(obj.ToString().Replace(",","."), 48 typeof(T), 49 System.Globalization.CultureInfo.InvariantCulture); 67 68 tmp[row][col] = data; 50 69 Value = tmp; 51 70 } 52 53 public abstract T[][] Value { get; set; }54 55 71 } 56 72 }
Note: See TracChangeset
for help on using the changeset viewer.