Changeset 17484 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
- Timestamp:
- 03/23/20 15:16:55 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs
r17473 r17484 20 20 21 21 public override double[] Value { 22 get => ((DoubleArrayJsonItem)Item).Value;22 get => Item.Value; 23 23 set { 24 ((DoubleArrayJsonItem)Item).Value = value;24 Item.Value = value; 25 25 OnPropertyChange(this, nameof(Value)); 26 26 } … … 39 39 40 40 public override int[] Value { 41 get => ((IntArrayJsonItem)Item).Value;41 get => Item.Value; 42 42 set { 43 ((IntArrayJsonItem)Item).Value = value;43 Item.Value = value; 44 44 OnPropertyChange(this, nameof(Value)); 45 45 } … … 52 52 53 53 public ArrayValueVM() { } 54 55 public void SetIndexValue(T data, int index) { 56 T[] tmp = Value; 57 if(index >= tmp.Length) { // increasing array 58 T[] newArr = new T[index+1]; 59 Array.Copy(tmp, 0, newArr, 0, tmp.Length); 60 tmp = newArr; 61 } 62 tmp[index] = data; 63 Value = tmp; 64 } 65 54 66 55 public abstract T[] Value { get; set; } 67 56 public bool Resizable { 68 get => ((IArrayJsonItem)Item).Resizable;57 get => Item.Resizable; 69 58 set { 70 ((IArrayJsonItem)Item).Resizable = value;59 Item.Resizable = value; 71 60 OnPropertyChange(this, nameof(IArrayJsonItemVM.Resizable)); 72 61 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
r17473 r17484 15 15 16 16 public override double[][] Value { 17 get => ((DoubleMatrixJsonItem)Item).Value;17 get => Item.Value; 18 18 set { 19 ((DoubleMatrixJsonItem)Item).Value = value;19 Item.Value = value; 20 20 OnPropertyChange(this, nameof(Value)); 21 21 } … … 32 32 public abstract T[][] Value { get; set; } 33 33 public bool RowsResizable { 34 get => ((IMatrixJsonItem)Item).RowsResizable;34 get => Item.RowsResizable; 35 35 set { 36 ((IMatrixJsonItem)Item).RowsResizable = value;36 Item.RowsResizable = value; 37 37 OnPropertyChange(this, nameof(RowsResizable)); 38 38 } … … 40 40 41 41 public bool ColumnsResizable { 42 get => ((IMatrixJsonItem)Item).ColumnsResizable;42 get => Item.ColumnsResizable; 43 43 set { 44 ((IMatrixJsonItem)Item).ColumnsResizable = value;44 Item.ColumnsResizable = value; 45 45 OnPropertyChange(this, nameof(ColumnsResizable)); 46 46 } … … 48 48 49 49 public IEnumerable<string> RowNames { 50 get => ((JsonItemType)Item).RowNames;50 get => Item.RowNames; 51 51 set { 52 ((JsonItemType)Item).RowNames = value;52 Item.RowNames = value; 53 53 OnPropertyChange(this, nameof(RowNames)); 54 54 } 55 55 } 56 56 public IEnumerable<string> ColumnNames { 57 get => ((JsonItemType)Item).ColumnNames;57 get => Item.ColumnNames; 58 58 set { 59 ((JsonItemType)Item).ColumnNames = value;59 Item.ColumnNames = value; 60 60 OnPropertyChange(this, nameof(ColumnNames)); 61 61 } 62 62 } 63 64 public void SetCellValue(T data, int row, int col) {65 66 T[][] tmp = Value;67 68 // increase y69 if (row >= tmp.Length) { // increasing array70 T[][] newArr = new T[row + 1][];71 Array.Copy(tmp, 0, newArr, 0, tmp.Length);72 newArr[row] = new T[0];73 tmp = newArr;74 }75 76 // increase x77 for(int i = 0; i < tmp.Length; ++i) {78 if(col >= tmp[i].Length) {79 T[] newArr = new T[col + 1];80 Array.Copy(tmp[i], 0, newArr, 0, tmp[i].Length);81 tmp[i] = newArr;82 }83 }84 85 tmp[row][col] = data;86 Value = tmp;87 }88 63 } 89 64 }
Note: See TracChangeset
for help on using the changeset viewer.