- Timestamp:
- 07/13/21 10:55:09 (3 years ago)
- Location:
- branches/3087_Ceres_Integration
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3087_Ceres_Integration
- Property svn:mergeinfo changed
-
branches/3087_Ceres_Integration/HeuristicLab.Data.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data.Views (added) merged: 17840-17841,17921
- Property svn:mergeinfo changed
-
branches/3087_Ceres_Integration/HeuristicLab.Data.Views/3.3
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data.Views/3.3 (added) merged: 17840-17841,17921
- Property svn:mergeinfo changed
-
branches/3087_Ceres_Integration/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs
r17180 r18006 71 71 // rowsTextBox 72 72 // 73 this.rowsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 74 73 this.rowsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 74 | System.Windows.Forms.AnchorStyles.Right))); 75 75 this.rowsTextBox.Location = new System.Drawing.Point(69, 0); 76 76 this.rowsTextBox.Name = "rowsTextBox"; … … 86 86 this.dataGridView.AllowUserToDeleteRows = false; 87 87 this.dataGridView.AllowUserToOrderColumns = true; 88 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 89 | System.Windows.Forms.AnchorStyles.Left)90 91 this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode. Disable;88 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 89 | System.Windows.Forms.AnchorStyles.Left) 90 | System.Windows.Forms.AnchorStyles.Right))); 91 this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText; 92 92 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; 93 93 this.dataGridView.Location = new System.Drawing.Point(0, 52); … … 115 115 // columnsTextBox 116 116 // 117 this.columnsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 118 117 this.columnsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 118 | System.Windows.Forms.AnchorStyles.Right))); 119 119 this.columnsTextBox.Location = new System.Drawing.Point(69, 26); 120 120 this.columnsTextBox.Name = "columnsTextBox"; … … 136 136 // contextMenu 137 137 // 138 this.contextMenu.ImageScalingSize = new System.Drawing.Size(20, 20); 138 139 this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 139 140 this.ShowHideColumns}); … … 150 151 // statisticsTextBox 151 152 // 152 this.statisticsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 153 153 this.statisticsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 154 | System.Windows.Forms.AnchorStyles.Right))); 154 155 this.statisticsTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; 155 156 this.statisticsTextBox.Location = new System.Drawing.Point(3, 388); … … 161 162 // StringConvertibleMatrixView 162 163 // 163 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);164 164 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 165 165 this.Controls.Add(this.columnsTextBox); -
branches/3087_Ceres_Integration/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r17180 r18006 298 298 299 299 protected virtual void dataGridView_KeyDown(object sender, KeyEventArgs e) { 300 if (!ReadOnly && e.Control && e.KeyCode == Keys.V) 300 if (!ReadOnly && e.Control && e.KeyCode == Keys.V) { 301 301 PasteValuesToDataGridView(); 302 else if (e.Control && e.KeyCode == Keys.C) 302 e.Handled = true; 303 } else if (e.Control && e.KeyCode == Keys.C) { 303 304 CopyValuesFromDataGridView(); 305 e.Handled = true; 306 } 304 307 } 305 308 306 309 private void CopyValuesFromDataGridView() { 307 310 if (dataGridView.SelectedCells.Count == 0) return; 311 312 //if not all cells are selected use the built-in functionality for copying values to the clipboard 313 if (!dataGridView.AreAllCellsSelected(false)) { 314 dataGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; 315 var data = dataGridView.GetClipboardContent(); 316 Clipboard.SetDataObject(data); 317 return; 318 } 319 320 //If all cells are selected we want to include row and column headers if they are set in the content. 321 //This is not possible with the built-in functionality, because only both headers can be added. 322 //Furthermore, the current implementation of the view with the virtual DataGridView does set 323 //Row headers only when they are displayed (see UpdateRowHeaders) and otherwise leaves them empty. 324 308 325 StringBuilder s = new StringBuilder(); 309 int minRowIndex = dataGridView.SelectedCells[0].RowIndex; 310 int maxRowIndex = dataGridView.SelectedCells[dataGridView.SelectedCells.Count - 1].RowIndex; 311 int minColIndex = dataGridView.SelectedCells[0].ColumnIndex; 312 int maxColIndex = dataGridView.SelectedCells[dataGridView.SelectedCells.Count - 1].ColumnIndex; 313 314 if (minRowIndex > maxRowIndex) { 315 int temp = minRowIndex; 316 minRowIndex = maxRowIndex; 317 maxRowIndex = temp; 318 } 319 if (minColIndex > maxColIndex) { 320 int temp = minColIndex; 321 minColIndex = maxColIndex; 322 maxColIndex = temp; 323 } 324 325 bool addRowNames = dataGridView.AreAllCellsSelected(false) && Content.RowNames.Count() > 0; 326 bool addColumnNames = dataGridView.AreAllCellsSelected(false) && Content.ColumnNames.Count() > 0; 327 328 //add colum names 326 327 bool addColumnNames = Content.ColumnNames.Any(); 328 bool addRowNames = Content.RowNames.Any(); 329 330 //add first row with column headers 329 331 if (addColumnNames) { 330 if (addRowNames) 331 s.Append('\t'); 332 332 var columnNames = Content.ColumnNames.ToArray(); 333 if (addRowNames) s.Append('\t'); //there is no column header for the row headers 333 334 DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible); 334 335 while (column != null) { 335 s.Append(column .HeaderText);336 s.Append(columnNames[column.Index]); 336 337 s.Append('\t'); 338 337 339 column = dataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None); 338 340 } 341 s.Append(Environment.NewLine); 342 } 343 344 var rowNames = Content.RowNames.ToArray(); 345 for (int r = 0; r < dataGridView.RowCount; r++) { 346 if (!dataGridView.Rows[r].Visible) continue; //skip invisible rows 347 348 int rowIndex = virtualRowIndices[r]; 349 if (addRowNames) { 350 s.Append(rowNames[rowIndex]); 351 s.Append('\t'); 352 } 353 354 DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible); 355 while (column != null) { 356 s.Append(Content.GetValue(rowIndex, column.Index)); 357 s.Append('\t'); 358 359 column = dataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None); 360 } 361 339 362 s.Remove(s.Length - 1, 1); //remove last tab 340 363 s.Append(Environment.NewLine); 341 364 } 342 365 343 for (int i = minRowIndex; i <= maxRowIndex; i++) {344 if (!dataGridView.Rows[i].Visible) continue;345 346 int rowIndex = this.virtualRowIndices[i];347 if (addRowNames) {348 s.Append(Content.RowNames.ElementAt(rowIndex));349 s.Append('\t');350 }351 352 DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible);353 while (column != null) {354 DataGridViewCell cell = dataGridView[column.Index, i];355 if (cell.Selected) {356 s.Append(Content.GetValue(rowIndex, column.Index));357 s.Append('\t');358 }359 360 column = dataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None);361 }362 s.Remove(s.Length - 1, 1); //remove last tab363 s.Append(Environment.NewLine);364 }365 366 Clipboard.SetText(s.ToString()); 366 367 }
Note: See TracChangeset
for help on using the changeset viewer.