Changeset 17451 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views
- Timestamp:
- 02/25/20 17:18:00 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.Designer.cs
r17446 r17451 30 30 this.groupBoxDetails = new System.Windows.Forms.GroupBox(); 31 31 this.panelParameterDetails = new System.Windows.Forms.Panel(); 32 this.resultItems = new System.Windows.Forms.CheckedListBox(); 33 this.groupBox3 = new System.Windows.Forms.GroupBox(); 32 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 34 33 this.treeViewResults = new System.Windows.Forms.TreeView(); 34 this.groupBox = new System.Windows.Forms.GroupBox(); 35 this.panelResultDetails = new System.Windows.Forms.Panel(); 35 36 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 36 37 this.tabControl1 = new System.Windows.Forms.TabControl(); … … 40 41 this.textBoxTemplateName = new System.Windows.Forms.TextBox(); 41 42 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 42 this.splitContainer1 = new System.Windows.Forms.SplitContainer();43 this.groupBox = new System.Windows.Forms.GroupBox();44 this.panelResultDetails = new System.Windows.Forms.Panel();45 43 this.jsonItemBindingSource = new System.Windows.Forms.BindingSource(this.components); 46 44 this.groupBoxDetails.SuspendLayout(); 47 this.groupBox3.SuspendLayout(); 45 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 46 this.splitContainer1.Panel1.SuspendLayout(); 47 this.splitContainer1.Panel2.SuspendLayout(); 48 this.splitContainer1.SuspendLayout(); 49 this.groupBox.SuspendLayout(); 48 50 ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); 49 51 this.splitContainer2.Panel1.SuspendLayout(); … … 54 56 this.tabPage2.SuspendLayout(); 55 57 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 56 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();57 this.splitContainer1.Panel1.SuspendLayout();58 this.splitContainer1.Panel2.SuspendLayout();59 this.splitContainer1.SuspendLayout();60 this.groupBox.SuspendLayout();61 58 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).BeginInit(); 62 59 this.SuspendLayout(); … … 85 82 this.treeView.Location = new System.Drawing.Point(0, 6); 86 83 this.treeView.Name = "treeView"; 87 this.treeView.Size = new System.Drawing.Size(3 70, 493);84 this.treeView.Size = new System.Drawing.Size(380, 492); 88 85 this.treeView.TabIndex = 3; 89 86 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); … … 95 92 this.groupBoxDetails.Location = new System.Drawing.Point(0, 0); 96 93 this.groupBoxDetails.Name = "groupBoxDetails"; 97 this.groupBoxDetails.Size = new System.Drawing.Size(4 22, 499);94 this.groupBoxDetails.Size = new System.Drawing.Size(412, 499); 98 95 this.groupBoxDetails.TabIndex = 4; 99 96 this.groupBoxDetails.TabStop = false; … … 106 103 this.panelParameterDetails.Location = new System.Drawing.Point(3, 16); 107 104 this.panelParameterDetails.Name = "panelParameterDetails"; 108 this.panelParameterDetails.Size = new System.Drawing.Size(4 16, 480);105 this.panelParameterDetails.Size = new System.Drawing.Size(406, 480); 109 106 this.panelParameterDetails.TabIndex = 0; 110 107 // 111 // resultItems 112 // 113 this.resultItems.Dock = System.Windows.Forms.DockStyle.Fill; 114 this.resultItems.FormattingEnabled = true; 115 this.resultItems.Location = new System.Drawing.Point(0, 6); 116 this.resultItems.Name = "resultItems"; 117 this.resultItems.Size = new System.Drawing.Size(373, 393); 118 this.resultItems.TabIndex = 5; 119 this.resultItems.SelectedValueChanged += new System.EventHandler(this.resultItems_SelectedValueChanged); 120 // 121 // groupBox3 122 // 123 this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 124 | System.Windows.Forms.AnchorStyles.Left) 125 | System.Windows.Forms.AnchorStyles.Right))); 126 this.groupBox3.Controls.Add(this.splitContainer1); 127 this.groupBox3.Controls.Add(this.treeViewResults); 128 this.groupBox3.Location = new System.Drawing.Point(6, 6); 129 this.groupBox3.Name = "groupBox3"; 130 this.groupBox3.Size = new System.Drawing.Size(790, 493); 131 this.groupBox3.TabIndex = 7; 132 this.groupBox3.TabStop = false; 133 this.groupBox3.Text = "Result Elements"; 108 // splitContainer1 109 // 110 this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; 111 this.splitContainer1.Location = new System.Drawing.Point(3, 3); 112 this.splitContainer1.Name = "splitContainer1"; 113 // 114 // splitContainer1.Panel1 115 // 116 this.splitContainer1.Panel1.Controls.Add(this.treeViewResults); 117 this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 1); 118 // 119 // splitContainer1.Panel2 120 // 121 this.splitContainer1.Panel2.Controls.Add(this.groupBox); 122 this.splitContainer1.Size = new System.Drawing.Size(796, 499); 123 this.splitContainer1.SplitterDistance = 380; 124 this.splitContainer1.TabIndex = 7; 134 125 // 135 126 // treeViewResults 136 127 // 137 128 this.treeViewResults.CheckBoxes = true; 138 this.treeViewResults.Location = new System.Drawing.Point(6, 19); 129 this.treeViewResults.Dock = System.Windows.Forms.DockStyle.Fill; 130 this.treeViewResults.Location = new System.Drawing.Point(0, 6); 139 131 this.treeViewResults.Name = "treeViewResults"; 140 this.treeViewResults.Size = new System.Drawing.Size( 777, 63);132 this.treeViewResults.Size = new System.Drawing.Size(380, 492); 141 133 this.treeViewResults.TabIndex = 6; 134 this.treeViewResults.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterCheck); 135 this.treeViewResults.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewResults_AfterSelect); 136 // 137 // groupBox 138 // 139 this.groupBox.Controls.Add(this.panelResultDetails); 140 this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill; 141 this.groupBox.Location = new System.Drawing.Point(0, 0); 142 this.groupBox.Name = "groupBox"; 143 this.groupBox.Size = new System.Drawing.Size(412, 499); 144 this.groupBox.TabIndex = 5; 145 this.groupBox.TabStop = false; 146 this.groupBox.Text = "Details"; 147 // 148 // panelResultDetails 149 // 150 this.panelResultDetails.AutoScroll = true; 151 this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill; 152 this.panelResultDetails.Location = new System.Drawing.Point(3, 16); 153 this.panelResultDetails.Name = "panelResultDetails"; 154 this.panelResultDetails.Size = new System.Drawing.Size(406, 480); 155 this.panelResultDetails.TabIndex = 0; 142 156 // 143 157 // splitContainer2 … … 150 164 // 151 165 this.splitContainer2.Panel1.Controls.Add(this.treeView); 152 this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);166 this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 1); 153 167 // 154 168 // splitContainer2.Panel2 … … 156 170 this.splitContainer2.Panel2.Controls.Add(this.groupBoxDetails); 157 171 this.splitContainer2.Size = new System.Drawing.Size(796, 499); 158 this.splitContainer2.SplitterDistance = 3 70;172 this.splitContainer2.SplitterDistance = 380; 159 173 this.splitContainer2.TabIndex = 9; 160 174 // … … 185 199 // tabPage2 186 200 // 187 this.tabPage2.Controls.Add(this. groupBox3);201 this.tabPage2.Controls.Add(this.splitContainer1); 188 202 this.tabPage2.Location = new System.Drawing.Point(4, 22); 189 203 this.tabPage2.Name = "tabPage2"; … … 219 233 this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; 220 234 this.errorProvider.ContainerControl = this; 221 //222 // splitContainer1223 //224 this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)225 | System.Windows.Forms.AnchorStyles.Left)226 | System.Windows.Forms.AnchorStyles.Right)));227 this.splitContainer1.Location = new System.Drawing.Point(6, 88);228 this.splitContainer1.Name = "splitContainer1";229 //230 // splitContainer1.Panel1231 //232 this.splitContainer1.Panel1.Controls.Add(this.resultItems);233 this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);234 //235 // splitContainer1.Panel2236 //237 this.splitContainer1.Panel2.Controls.Add(this.groupBox);238 this.splitContainer1.Size = new System.Drawing.Size(778, 399);239 this.splitContainer1.SplitterDistance = 373;240 this.splitContainer1.TabIndex = 7;241 //242 // groupBox243 //244 this.groupBox.Controls.Add(this.panelResultDetails);245 this.groupBox.Dock = System.Windows.Forms.DockStyle.Fill;246 this.groupBox.Location = new System.Drawing.Point(0, 0);247 this.groupBox.Name = "groupBox";248 this.groupBox.Size = new System.Drawing.Size(401, 399);249 this.groupBox.TabIndex = 5;250 this.groupBox.TabStop = false;251 this.groupBox.Text = "Details";252 //253 // panelResultDetails254 //255 this.panelResultDetails.AutoScroll = true;256 this.panelResultDetails.Dock = System.Windows.Forms.DockStyle.Fill;257 this.panelResultDetails.Location = new System.Drawing.Point(3, 16);258 this.panelResultDetails.Name = "panelResultDetails";259 this.panelResultDetails.Size = new System.Drawing.Size(395, 380);260 this.panelResultDetails.TabIndex = 0;261 235 // 262 236 // jsonItemBindingSource … … 278 252 this.Text = "Export Json"; 279 253 this.groupBoxDetails.ResumeLayout(false); 280 this.groupBox3.ResumeLayout(false); 254 this.splitContainer1.Panel1.ResumeLayout(false); 255 this.splitContainer1.Panel2.ResumeLayout(false); 256 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 257 this.splitContainer1.ResumeLayout(false); 258 this.groupBox.ResumeLayout(false); 281 259 this.splitContainer2.Panel1.ResumeLayout(false); 282 260 this.splitContainer2.Panel2.ResumeLayout(false); … … 287 265 this.tabPage2.ResumeLayout(false); 288 266 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 289 this.splitContainer1.Panel1.ResumeLayout(false);290 this.splitContainer1.Panel2.ResumeLayout(false);291 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();292 this.splitContainer1.ResumeLayout(false);293 this.groupBox.ResumeLayout(false);294 267 ((System.ComponentModel.ISupportInitialize)(this.jsonItemBindingSource)).EndInit(); 295 268 this.ResumeLayout(false); … … 307 280 private System.Windows.Forms.GroupBox groupBoxDetails; 308 281 private System.Windows.Forms.Panel panelParameterDetails; 309 private System.Windows.Forms.CheckedListBox resultItems;310 private System.Windows.Forms.GroupBox groupBox3;311 282 private System.Windows.Forms.SplitContainer splitContainer2; 312 283 private System.Windows.Forms.TabControl tabControl1; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17446 r17451 17 17 public partial class ExportJsonDialog : Form { 18 18 private static FolderBrowserDialog FolderBrowserDialog { get; set; } 19 private IDictionary< int, UserControl> Hash2Control { get; set; } = new Dictionary<int, UserControl>();19 private IDictionary<TreeNode, UserControl> Node2Control { get; set; } = new Dictionary<TreeNode, UserControl>(); 20 20 private IDictionary<TreeNode, IJsonItemVM> Node2VM { get; set; } = new Dictionary<TreeNode, IJsonItemVM>(); 21 private IDictionary<Type, Type> JI2VM { get; set; } 21 22 private IJsonItem Root { get; set; } 22 23 private IOptimizer Optimizer { get; set; } 23 24 private IList<IJsonItemVM> VMs { get; set; } 24 25 private JCGenerator Generator { get; set; } = new JCGenerator(); 25 private IDictionary<string, IJsonItem> ResultItems { get; set; } = new Dictionary<string, IJsonItem>();26 26 27 27 private IContent content; … … 33 33 VMs = new List<IJsonItemVM>(); 34 34 treeView.Nodes.Clear(); 35 ResultItems.Clear(); 36 resultItems.Items.Clear(); 35 treeViewResults.Nodes.Clear(); 37 36 38 37 Optimizer = content as IOptimizer; … … 47 46 } 48 47 49 private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) { 50 if (e.Action != TreeViewAction.Unknown) { 51 if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) { 52 vm.Selected = e.Node.Checked; 53 } 54 } 55 } 48 56 49 57 private IDictionary<Type, Type> JI2VM { get; set; }58 50 59 51 private void InitCache() { … … 71 63 72 64 private void exportButton_Click(object sender, EventArgs e) { 65 // to set default value for disabled items 66 JsonItemConverter.Inject(Optimizer, Root); 67 /* 73 68 foreach (var x in VMs) { 74 if (!(x is ResultItemVM) && !x.Selected) { 75 x.Item.Parent.Children.Remove(x.Item); 69 if (!x.Selected) { 70 x.Item.Parent?.Children?.Remove(x.Item); 71 } else if(x is ResultItemVM) { 72 x.Item.Parent?.Children?.Remove(x.Item); 73 Root.AddChildren(x.Item); 76 74 } 77 75 } 78 79 foreach (var x in ResultItems.Values) { 80 x.Parent.Children.Remove(x); 81 } 82 83 foreach (var x in resultItems.CheckedItems) { 84 if (ResultItems.TryGetValue((string)x, out IJsonItem item)) { 85 Root.AddChildren(item); 86 } 87 } 88 76 */ 77 89 78 IList<IJsonItem> faultyItems = new List<IJsonItem>(); 90 79 … … 110 99 111 100 private void BuildTreeNode(TreeNode node, IJsonItem item) { 112 RegisterItem(node, item );101 RegisterItem(node, item, treeView); 113 102 if (item.Children != null) { 114 103 foreach (var c in item.Children) { 115 104 if (IsDrawableItem(c)) { 116 if (c is ResultItem) { 117 resultItems.Items.Add(c.Name, true); 118 ResultItems.Add(c.Name, c); 105 if (c is ResultJsonItem) { 119 106 TreeNode childNode = new TreeNode(c.Name); 120 107 treeViewResults.Nodes.Add(childNode); 121 RegisterItem(childNode, c); 122 //Hash2Control.Add(c.GetHashCode(), new JsonItemBaseControl(new JsonItemVMBase() { Item = c })); 108 RegisterItem(childNode, c, treeViewResults); 109 if(Node2VM.TryGetValue(childNode, out IJsonItemVM vm)) 110 vm.Selected = true; 123 111 } else { 124 112 TreeNode childNode = new TreeNode(c.Name); … … 131 119 } 132 120 133 private void RegisterItem(TreeNode node, IJsonItem item ) {121 private void RegisterItem(TreeNode node, IJsonItem item, TreeView tv) { 134 122 if (JI2VM.TryGetValue(item.GetType(), out Type vmType)) { 135 123 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); … … 137 125 vm.Item = item; 138 126 vm.TreeNode = node; 139 vm.TreeView = t reeView;140 node.Checked = vm.Selected;127 vm.TreeView = tv; 128 vm.Selected = false; 141 129 142 130 VMs.Add(vm); 143 131 Node2VM.Add(node, vm); 144 132 UserControl control = vm.Control; 145 Hash2Control.Add(node.GetHashCode(), control);133 Node2Control.Add(node, control); 146 134 } 147 135 } … … 155 143 } 156 144 157 return b || (item.Value != null || item.Range != null || item.ActualName != null );145 return b || (item.Value != null || item.Range != null || item.ActualName != null || item is ResultJsonItem); 158 146 } 159 147 160 148 private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { 161 if( Hash2Control.TryGetValue(treeView.SelectedNode.GetHashCode(), out UserControl control)) {149 if(Node2Control.TryGetValue(treeView.SelectedNode, out UserControl control)) { 162 150 SetControlOnPanel(control, panelParameterDetails); 151 } 152 } 153 154 private void treeViewResults_AfterSelect(object sender, TreeViewEventArgs e) { 155 if (Node2Control.TryGetValue(treeViewResults.SelectedNode, out UserControl control)) { 156 SetControlOnPanel(control, panelResultDetails); 163 157 } 164 158 } … … 170 164 } else { 171 165 errorProvider.SetError(textBoxTemplateName, null); 172 }173 }174 175 private void resultItems_SelectedValueChanged(object sender, EventArgs e) {176 if(ResultItems.TryGetValue(resultItems.SelectedItem.ToString(), out IJsonItem item) &&177 Hash2Control.TryGetValue(item.GetHashCode(), out UserControl control)) {178 SetControlOnPanel(control, panelResultDetails);179 166 } 180 167 } … … 191 178 panel.Refresh(); 192 179 } 180 181 private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) { 182 if (e.Action != TreeViewAction.Unknown) { 183 if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) { 184 vm.Selected = e.Node.Checked; 185 } 186 } 187 } 188 189 private void treeViewResults_AfterCheck(object sender, TreeViewEventArgs e) { 190 if (e.Action != TreeViewAction.Unknown) { 191 if (Node2VM.TryGetValue(e.Node, out IJsonItemVM vm)) { 192 vm.Selected = e.Node.Checked; 193 } 194 } 195 } 193 196 } 194 197 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemMultiValueControl.cs
r17446 r17451 10 10 11 11 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 12 12 13 public class JsonItemDoubleNamedMatrixValueControl : JsonItemMultiValueControl<double> { 14 protected override IEnumerable<string> RowNames { 15 get => ((DoubleNamedMatrixValueVM)VM).RowNames; 16 set => ((DoubleNamedMatrixValueVM)VM).RowNames = value; 17 } 18 protected override IEnumerable<string> ColumnNames { 19 get => ((DoubleNamedMatrixValueVM)VM).ColumnNames; 20 set => ((DoubleNamedMatrixValueVM)VM).ColumnNames = value; 21 } 22 23 public JsonItemDoubleNamedMatrixValueControl(DoubleNamedMatrixValueVM vm) : base(vm, vm.Value) { } 24 25 protected override void SaveCellData(double data, int row, int col) { 26 DoubleNamedMatrixValueVM vm = VM as DoubleNamedMatrixValueVM; 27 vm.SetCellValue(data, row, col); 28 } 29 } 30 13 31 public class JsonItemDoubleMatrixValueControl : JsonItemMultiValueControl<double> { 32 protected override IEnumerable<string> RowNames { get => null; set { } } 33 protected override IEnumerable<string> ColumnNames { get => null; set { } } 14 34 15 35 public JsonItemDoubleMatrixValueControl(DoubleMatrixValueVM vm) : base(vm, vm.Value) { } 36 16 37 protected override void SaveCellData(double data, int row, int col) { 17 38 DoubleMatrixValueVM vm = VM as DoubleMatrixValueVM; … … 21 42 22 43 public class JsonItemIntArrayValueControl : JsonItemMultiValueControl<int> { 44 protected override IEnumerable<string> RowNames { get => null; set { } } 45 protected override IEnumerable<string> ColumnNames { get => null; set { } } 46 23 47 public JsonItemIntArrayValueControl(IntArrayValueVM vm) : base(vm, vm.Value) { } 24 48 … … 30 54 31 55 public class JsonItemDoubleArrayValueControl : JsonItemMultiValueControl<double> { 56 protected override IEnumerable<string> RowNames { get => null; set { } } 57 protected override IEnumerable<string> ColumnNames { get => null; set { } } 58 32 59 public JsonItemDoubleArrayValueControl(DoubleArrayValueVM vm) : base(vm, vm.Value) { } 33 60 … … 60 87 private T[][] Matrix { get; set; } 61 88 89 protected abstract IEnumerable<string> RowNames { get; set; } 90 protected abstract IEnumerable<string> ColumnNames { get; set; } 91 62 92 public JsonItemMultiValueControl(IMatrixJsonItemVM vm, T[][] matrix) : base(vm) { 63 93 InitializeComponent(); … … 66 96 checkBoxColumns.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable)); 67 97 68 int rows = matrix.Length;69 int cols = matrix.Max(x => x.Length);98 int cols = matrix.Length; 99 int rows = matrix.Max(x => x.Length); 70 100 71 101 Matrix = matrix; … … 85 115 int length = array.Length; 86 116 87 Matrix = new T[array.Length][]; 117 Matrix = new T[1][]; 118 Matrix[0] = array; 119 /* 88 120 for (int r = 0; r < length; ++r) { 89 121 Matrix[r] = new T[1]; 90 122 Matrix[r][0] = array[r]; 91 123 } 92 124 */ 93 125 _cols = 1; 94 126 _rows = length; … … 125 157 126 158 T[][] tmp = Matrix; 127 Matrix = new T[ Rows][];159 Matrix = new T[Columns][]; 128 160 129 161 // columns must added first 130 for(int c = 0; c < Columns; ++c) { 131 dataGridView.Columns.Add($"Column {c}", $"Column {c}"); 132 } 133 134 for (int r = 0; r < Rows; ++r) { 135 T[] newCol = new T[Columns]; 136 if(r < tmp.Length) 137 Array.Copy(tmp[r], 0, newCol, 0, Math.Min(tmp[r].Length, Columns)); 138 Matrix[r] = newCol; 162 if(RowNames != null && RowNames.Count() == Columns) { 163 foreach(var name in RowNames) { 164 dataGridView.Columns.Add(name, name); 165 } 166 } else { 167 for(int c = 0; c < Columns; ++c) { 168 dataGridView.Columns.Add($"Column {c}", $"Column {c}"); 169 } 170 } 171 172 for (int c = 0; c < Columns; ++c) { 173 T[] newCol = new T[Rows]; 174 if(c < tmp.Length) 175 Array.Copy(tmp[c], 0, newCol, 0, Math.Min(tmp[c].Length, Rows)); 176 Matrix[c] = newCol; 139 177 } 140 178 … … 144 182 for (int r = 0; r < Rows; ++r) { 145 183 //col and row is switched for dataGridView 146 dataGridView[c, r].Value = Matrix[r][c]; 147 dataGridView.Rows[r].HeaderCell.Value = $"Row {r}"; 184 dataGridView[c, r].Value = Matrix[c][r]; 185 if (ColumnNames != null && r < ColumnNames.Count()) 186 dataGridView.Rows[r].HeaderCell.Value = ColumnNames.ElementAt(r); 187 else 188 dataGridView.Rows[r].HeaderCell.Value = $"Row {r}"; 148 189 } 149 190 } … … 214 255 private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { 215 256 object val = dataGridView[e.ColumnIndex, e.RowIndex].Value; 216 Matrix[e. RowIndex][e.ColumnIndex] = (T)Convert.ChangeType(val.ToString().Replace(",", "."),257 Matrix[e.ColumnIndex][e.RowIndex] = (T)Convert.ChangeType(val.ToString().Replace(",", "."), 217 258 typeof(T), 218 259 System.Globalization.CultureInfo.InvariantCulture); 219 SaveCellData(Matrix[e. RowIndex][e.ColumnIndex], e.RowIndex, e.ColumnIndex);260 SaveCellData(Matrix[e.ColumnIndex][e.RowIndex], e.ColumnIndex, e.RowIndex); 220 261 } 221 262 }
Note: See TracChangeset
for help on using the changeset viewer.