Changeset 17484
- Timestamp:
- 03/23/20 15:16:55 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 6 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 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17481 r17484 46 46 treeView.Nodes.Add(parent); 47 47 treeView.ExpandAll(); 48 48 panelParameterDetails.Controls.Clear(); 49 panelResultDetails.Controls.Clear(); 50 49 51 } 50 52 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs
r17473 r17484 14 14 public JsonItemDoubleMatrixValueControl(DoubleMatrixValueVM vm) : base(vm, vm.Value) { } 15 15 16 protected override void Save CellData(double data, int row, int col) {16 protected override void Save() { 17 17 DoubleMatrixValueVM vm = VM as DoubleMatrixValueVM; 18 vm. SetCellValue(data, row, col);18 vm.Value = Matrix; 19 19 } 20 20 … … 24 24 public JsonItemIntArrayValueControl(IntArrayValueVM vm) : base(vm, vm.Value) { } 25 25 26 protected override void Save CellData(int data, int row, int col) {26 protected override void Save() { 27 27 IntArrayValueVM vm = VM as IntArrayValueVM; 28 vm. SetIndexValue(data, row);28 vm.Value = Matrix[0]; 29 29 } 30 30 … … 34 34 public JsonItemDoubleArrayValueControl(DoubleArrayValueVM vm) : base(vm, vm.Value) { } 35 35 36 protected override void Save CellData(double data, int row, int col) {36 protected override void Save() { 37 37 DoubleArrayValueVM vm = VM as DoubleArrayValueVM; 38 vm. SetIndexValue(data, row);38 vm.Value = Matrix[0]; 39 39 } 40 40 … … 47 47 private int Columns { get; set; } 48 48 49 pr ivateT[][] Matrix { get; set; }49 protected T[][] Matrix { get; set; } 50 50 51 51 protected IEnumerable<string> RowNames { … … 108 108 } 109 109 110 protected abstract void SaveCellData(T data, int row, int col); 111 112 private void InitSizeConfiguration(int? rows, int? columns) { 113 if(rows != null) { 114 checkBoxRows.CheckedChanged += CheckBoxRows_CheckedChanged; 115 textBoxRows.Text = rows.ToString(); 116 } else { 117 checkBoxRows.Enabled = false; 118 textBoxRows.ReadOnly = true; 119 } 120 121 if (columns != null) { 122 checkBoxColumns.CheckedChanged += CheckBoxColumns_CheckedChanged; 123 textBoxColumns.Text = columns.ToString(); 124 } else { 125 checkBoxColumns.Enabled = false; 126 textBoxColumns.ReadOnly = true; 127 } 128 } 110 protected abstract void Save(); 129 111 130 112 private void RefreshMatrix() { … … 135 117 Matrix = new T[Columns][]; 136 118 119 // add columns 137 120 for (int c = 0; c < Columns; ++c) { 138 121 string name = $"Column {c}"; … … 142 125 } 143 126 127 // copy data from old matrix into new 144 128 for (int c = 0; c < Columns; ++c) { 145 129 T[] newCol = new T[Rows]; … … 149 133 } 150 134 135 // add rows 151 136 if(Rows > 0 && Columns > 0) { 152 137 dataGridView.Rows.Add(Rows); … … 165 150 } 166 151 152 #region Init 153 private void InitSizeConfiguration(int? rows, int? columns) { 154 if (rows != null) { 155 checkBoxRows.CheckedChanged += CheckBoxRows_CheckedChanged; 156 textBoxRows.Text = rows.ToString(); 157 } else { 158 checkBoxRows.Enabled = false; 159 textBoxRows.ReadOnly = true; 160 } 161 162 if (columns != null) { 163 checkBoxColumns.CheckedChanged += CheckBoxColumns_CheckedChanged; 164 textBoxColumns.Text = columns.ToString(); 165 } else { 166 checkBoxColumns.Enabled = false; 167 textBoxColumns.ReadOnly = true; 168 } 169 } 170 167 171 private void InitRangeBinding() { 168 172 NumericRangeControl = numericRangeControl1; … … 174 178 false, DataSourceUpdateMode.OnPropertyChanged); 175 179 } 176 180 #endregion 181 182 #region Validation 177 183 private void textBoxRows_Validating(object sender, CancelEventArgs e) { 178 184 if (string.IsNullOrWhiteSpace(textBoxRows.Text)) { … … 204 210 } 205 211 } 206 212 #endregion 213 214 #region Events 207 215 private void textBoxRows_TextChanged(object sender, EventArgs e) { 208 216 if(!textBoxRows.ReadOnly && int.TryParse(textBoxRows.Text, out int r) && Rows != r) { 209 217 Rows = r; 210 218 RefreshMatrix(); 219 Save(); 211 220 } 212 221 } … … 216 225 Columns = c; 217 226 RefreshMatrix(); 227 Save(); 218 228 } 219 229 } … … 232 242 typeof(T), 233 243 System.Globalization.CultureInfo.InvariantCulture); 234 SaveCellData(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex); 235 } 244 //Save(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex); 245 Save(); 246 } 247 #endregion 236 248 } 237 249 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r17473 r17484 44 44 } 45 45 46 47 46 #region Helper 48 47 private bool GetOperatorState(string name, IJsonItem data) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17473 r17484 29 29 dynamic val = (dynamic)item; 30 30 object dataset = (object)val.Dataset; 31 var rows = dataset.GetType().GetField("rows", flags); 32 rows.SetValue(dataset, matrix.Value[0].Length); 33 34 var variableNames = dataset.GetType().GetField("variableNames", flags); 35 variableNames.SetValue(dataset, matrix.RowNames); 36 31 37 var dataInfo = dataset.GetType().GetField("variableValues", flags); 32 38 dataInfo.SetValue(dataset, dictTmp);
Note: See TracChangeset
for help on using the changeset viewer.