Changeset 17446 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
- Timestamp:
- 02/20/20 16:58:03 (5 years ago)
- 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 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 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17444 r17446 9 9 10 10 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 11 public class JsonItemVMBase : I NotifyPropertyChanged, IDisposable{11 public class JsonItemVMBase : IJsonItemVM { 12 12 public event PropertyChangedEventHandler PropertyChanged; 13 13 public event Action ItemChanged; … … 78 78 } 79 79 80 public virtual JsonItemBaseControl GetControl() { 81 return new JsonItemBaseControl(this); 82 } 83 80 public virtual JsonItemBaseControl Control => new JsonItemBaseControl(this); 81 84 82 #region IDisposable Support 85 83 private bool disposedValue = false; // To detect redundant calls -
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 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
r17420 r17446 15 15 protected override int MaxTypeValue => int.MaxValue; 16 16 17 public override JsonItemBaseControl GetControl()=>17 public override JsonItemBaseControl Control => 18 18 new JsonItemRangeControl(this); 19 19 } … … 26 26 protected override double MaxTypeValue => double.MaxValue; 27 27 28 public override JsonItemBaseControl GetControl()=>28 public override JsonItemBaseControl Control => 29 29 new JsonItemRangeControl(this); 30 30 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs
r17443 r17446 14 14 protected override int MaxTypeValue => int.MaxValue; 15 15 16 public override JsonItemBaseControl GetControl()=>16 public override JsonItemBaseControl Control => 17 17 new JsonItemIntValueControl(this); 18 18 } … … 24 24 protected override double MaxTypeValue => double.MaxValue; 25 25 26 public override JsonItemBaseControl GetControl()=>26 public override JsonItemBaseControl Control => 27 27 new JsonItemDoubleValueControl(this); 28 28 } … … 34 34 protected override bool MaxTypeValue => true; 35 35 36 public override JsonItemBaseControl GetControl()=>36 public override JsonItemBaseControl Control => 37 37 new JsonItemBoolControl(this); 38 38 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs
r17443 r17446 8 8 public class StringValueVM : JsonItemVMBase { 9 9 public override Type JsonItemType => typeof(StringJsonItem); 10 public override JsonItemBaseControl GetControl()=>10 public override JsonItemBaseControl Control => 11 11 new JsonItemValidValuesControl(this); 12 12
Note: See TracChangeset
for help on using the changeset viewer.