- Timestamp:
- 05/05/10 17:02:39 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r3566 r3643 107 107 private void UpdateData() { 108 108 sortedColumnIndizes.Clear(); 109 Sort();110 109 rowsTextBox.Text = Content.Rows.ToString(); 111 110 rowsTextBox.Enabled = true; … … 123 122 dataGridView.ColumnCount = Content.Columns; 124 123 124 Sort(); 125 125 UpdateRowHeaders(); 126 126 UpdateColumnHeaders(); … … 250 250 private void dataGridView_Resize(object sender, EventArgs e) { 251 251 UpdateRowHeaders(); 252 } 253 254 private void dataGridView_KeyDown(object sender, KeyEventArgs e) { 255 if (!ReadOnly && e.Control && e.KeyCode == Keys.V) { //shortcut for values paste 256 string[,] values = SplitClipboardString(Clipboard.GetText()); 257 258 int rowIndex = 0; 259 int columnIndex = 0; 260 if (dataGridView.CurrentCell != null) { 261 rowIndex = dataGridView.CurrentCell.RowIndex; 262 columnIndex = dataGridView.CurrentCell.ColumnIndex; 263 } 264 265 for (int row = 0; row < values.GetLength(1); row++) { 266 if (row + rowIndex >= Content.Rows) 267 Content.Rows = Content.Rows + 1; 268 for (int col = 0; col < values.GetLength(0); col++) { 269 if (col + columnIndex >= Content.Columns) 270 Content.Columns = Content.Columns + 1; 271 Content.SetValue(values[col, row], row + rowIndex, col + columnIndex); 272 } 273 } 274 275 ClearSorting(); 276 } 277 } 278 279 private string[,] SplitClipboardString(string clipboardText) { 280 clipboardText = clipboardText.Remove(clipboardText.Length - Environment.NewLine.Length); //remove last newline constant 281 string[,] values = null; 282 string[] lines = clipboardText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 283 string[] cells; 284 for (int i = 0; i < lines.Length; i++) { 285 cells = lines[i].Split('\t'); 286 if (values == null) 287 values = new string[cells.Length, lines.Length]; 288 for (int j = 0; j < cells.Length; j++) 289 values[j, i] = string.IsNullOrEmpty(cells[j]) ? string.Empty : cells[j]; 290 } 291 return values; 252 292 } 253 293 … … 281 321 } 282 322 } 323 } 324 325 protected void ClearSorting() { 326 virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray(); 327 sortedColumnIndizes.Clear(); 328 UpdateSortGlyph(); 283 329 } 284 330
Note: See TracChangeset
for help on using the changeset viewer.