Changeset 17431 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
- Timestamp:
- 02/10/20 16:46:09 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs
r17420 r17431 16 16 17 17 public override JsonItemBaseControl GetControl() => new JsonItemDoubleArrayValueControl(this); 18 19 p rotected override void OnItemChanged(){20 IList<IndexedArrayValueVM> list = new List<IndexedArrayValueVM>();21 var arr = ((DoubleArrayJsonItem)Item).Value;22 for(int i = 0; i < arr.Length; ++i) {23 list.Add(new IndexedArrayValueVM(arr, i));18 19 public override double[] Value { 20 get => ((DoubleArrayJsonItem)Item).Value; 21 set { 22 ((DoubleArrayJsonItem)Item).Value = value; 23 OnPropertyChange(this, nameof(Value)); 24 24 } 25 Value = list.ToArray();26 25 } 27 26 } … … 35 34 36 35 public override JsonItemBaseControl GetControl() => new JsonItemIntArrayValueControl(this); 37 38 p rotected override void OnItemChanged(){39 IList<IndexedArrayValueVM> list = new List<IndexedArrayValueVM>();40 var arr = ((IntArrayJsonItem)Item).Value;41 for (int i = 0; i < arr.Length; ++i) {42 list.Add(new IndexedArrayValueVM(arr, i));36 37 public override int[] Value { 38 get => ((IntArrayJsonItem)Item).Value; 39 set { 40 ((IntArrayJsonItem)Item).Value = value; 41 OnPropertyChange(this, nameof(Value)); 43 42 } 44 Value = list.ToArray();45 43 } 46 44 } 47 45 48 46 public abstract class ArrayValueVM<T> : RangedValueBaseVM<T> { 49 50 public class IndexedArrayValueVM : INotifyPropertyChanged { 51 private T[] arr; 52 private int index; 53 54 public IndexedArrayValueVM(T[] arr, int index) { 55 this.arr = arr; 56 this.index = index; 57 } 58 59 public T Value { 60 get => arr[index]; 61 set { 62 arr[index] = value; 63 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Value))); 64 } 65 } 66 67 public event PropertyChangedEventHandler PropertyChanged; 47 48 public ArrayValueVM() { 49 //base.ItemChanged += OnItemChanged; 68 50 } 69 51 70 public ArrayValueVM() { 71 base.ItemChanged += OnItemChanged; 52 public void SetIndexValue(object obj, int index) { 53 T[] tmp = Value; 54 if(index >= tmp.Length) { // increasing array 55 T[] newArr = new T[index+1]; 56 Array.Copy(tmp, 0, newArr, 0, tmp.Length); 57 tmp = newArr; 58 } 59 tmp[index] = (T)Convert.ChangeType(obj, typeof(T)); 60 Value = tmp; 72 61 } 73 62 74 protected abstract void OnItemChanged(); 75 76 IndexedArrayValueVM[] vms; 77 public IndexedArrayValueVM[] Value { 78 get => vms; 79 set { 80 vms = value; 81 OnPropertyChange(this, nameof(Value)); 82 } 83 } 63 public abstract T[] Value { get; set; } 84 64 } 85 65 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17420 r17431 2 2 using System.Collections.Generic; 3 3 using System.ComponentModel; 4 using System.Drawing; 4 5 using System.Linq; 5 6 using System.Text; 6 7 using System.Threading.Tasks; 8 using System.Windows.Forms; 7 9 8 10 namespace HeuristicLab.JsonInterface.OptimizerIntegration { … … 19 21 } 20 22 } 23 24 public TreeNode TreeNode { get; set; } 25 public TreeView TreeView { get; set; } 21 26 22 27 protected void OnPropertyChange(object sender, string propertyName) { … … 37 42 set { 38 43 selected = value; 44 if(TreeNode != null) 45 TreeNode.ForeColor = (selected ? Color.Black : Color.Red); 46 if (TreeView != null) 47 TreeView.Refresh(); 39 48 OnPropertyChange(this, nameof(Selected)); 40 49 }
Note: See TracChangeset
for help on using the changeset viewer.