Changeset 17446 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.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/ArrayValueVM.cs
r17433 r17446 8 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 9 10 public class DoubleArrayValueVM : ArrayValueVM<double > {10 public class DoubleArrayValueVM : ArrayValueVM<double, DoubleArrayJsonItem> { 11 11 public override Type JsonItemType => typeof(DoubleArrayJsonItem); 12 12 … … 15 15 protected override double MaxTypeValue => double.MaxValue; 16 16 17 public override JsonItemBaseControl GetControl() =>17 public override JsonItemBaseControl Control => 18 18 new JsonItemDoubleArrayValueControl(this); 19 19 … … 27 27 } 28 28 29 public class IntArrayValueVM : ArrayValueVM<int > {29 public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> { 30 30 public override Type JsonItemType => typeof(IntArrayJsonItem); 31 31 … … 34 34 protected override int MaxTypeValue => int.MaxValue; 35 35 36 public override JsonItemBaseControl GetControl() =>36 public override JsonItemBaseControl Control => 37 37 new JsonItemIntArrayValueControl(this); 38 38 … … 46 46 } 47 47 48 public abstract class ArrayValueVM<T> : RangedValueBaseVM<T> { 48 public abstract class ArrayValueVM<T, JsonItemType> : RangedValueBaseVM<T>, IArrayJsonItemVM 49 where JsonItemType : IArrayJsonItem { 49 50 50 51 public ArrayValueVM() { } 51 52 52 public void SetIndexValue( object obj, int index) {53 public void SetIndexValue(T data, int index) { 53 54 T[] tmp = Value; 54 55 if(index >= tmp.Length) { // increasing array … … 57 58 tmp = newArr; 58 59 } 59 tmp[index] = (T)Convert.ChangeType(obj, typeof(T));60 tmp[index] = data; 60 61 Value = tmp; 61 62 } 62 63 63 64 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 } 64 72 } 65 73 }
Note: See TracChangeset
for help on using the changeset viewer.