Changeset 4178
- Timestamp:
- 08/09/10 15:34:47 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Data.Views/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/ColumnsVisibilityDialog.Designer.cs
r3742 r4178 46 46 private void InitializeComponent() { 47 47 this.checkedListBox = new System.Windows.Forms.CheckedListBox(); 48 this.btnShowAll = new System.Windows.Forms.Button(); 49 this.btnHideAll = new System.Windows.Forms.Button(); 48 50 this.SuspendLayout(); 49 51 // … … 57 59 this.checkedListBox.Location = new System.Drawing.Point(12, 12); 58 60 this.checkedListBox.Name = "checkedListBox"; 59 this.checkedListBox.Size = new System.Drawing.Size( 171, 244);61 this.checkedListBox.Size = new System.Drawing.Size(309, 289); 60 62 this.checkedListBox.TabIndex = 0; 61 63 this.checkedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBox_ItemCheck); 64 // 65 // btnShowAll 66 // 67 this.btnShowAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 68 this.btnShowAll.Location = new System.Drawing.Point(12, 315); 69 this.btnShowAll.Name = "btnShowAll"; 70 this.btnShowAll.Size = new System.Drawing.Size(75, 23); 71 this.btnShowAll.TabIndex = 1; 72 this.btnShowAll.Text = "Show all"; 73 this.btnShowAll.UseVisualStyleBackColor = true; 74 this.btnShowAll.Click += new System.EventHandler(this.btnShowAll_Click); 75 // 76 // btnHideAll 77 // 78 this.btnHideAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 79 this.btnHideAll.Location = new System.Drawing.Point(101, 315); 80 this.btnHideAll.Name = "btnHideAll"; 81 this.btnHideAll.Size = new System.Drawing.Size(75, 23); 82 this.btnHideAll.TabIndex = 2; 83 this.btnHideAll.Text = "Hide all"; 84 this.btnHideAll.UseVisualStyleBackColor = true; 85 this.btnHideAll.Click += new System.EventHandler(this.btnHideAll_Click); 62 86 // 63 87 // ColumnsVisibilityDialog … … 65 89 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 66 90 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 67 this.ClientSize = new System.Drawing.Size(194, 273); 91 this.ClientSize = new System.Drawing.Size(332, 350); 92 this.Controls.Add(this.btnHideAll); 93 this.Controls.Add(this.btnShowAll); 68 94 this.Controls.Add(this.checkedListBox); 69 95 this.MaximizeBox = false; … … 72 98 this.ShowIcon = false; 73 99 this.ShowInTaskbar = false; 74 this.Text = "Show / Hide Columns"; 100 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 101 this.Text = "Show/Hide Columns"; 75 102 this.ResumeLayout(false); 76 103 … … 80 107 81 108 private System.Windows.Forms.CheckedListBox checkedListBox; 109 private System.Windows.Forms.Button btnShowAll; 110 private System.Windows.Forms.Button btnHideAll; 82 111 } 83 112 } -
trunk/sources/HeuristicLab.Data.Views/3.3/ColumnsVisibilityDialog.cs
r4068 r4178 52 52 this.columns[e.Index].Visible = e.NewValue == CheckState.Checked; 53 53 } 54 55 private void btnShowAll_Click(object sender, System.EventArgs e) { 56 for (int i = 0; i < checkedListBox.Items.Count; i++) 57 checkedListBox.SetItemChecked(i, true); 58 } 59 private void btnHideAll_Click(object sender, System.EventArgs e) { 60 for (int i = 0; i < checkedListBox.Items.Count; i++) 61 checkedListBox.SetItemChecked(i, false); 62 } 54 63 } 55 64 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs
r3936 r4178 76 76 this.rowsTextBox.Size = new System.Drawing.Size(355, 20); 77 77 this.rowsTextBox.TabIndex = 1; 78 this.rowsTextBox.Validated += new System.EventHandler(this.rowsTextBox_Validated);79 78 this.rowsTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.rowsTextBox_KeyDown); 80 79 this.rowsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.rowsTextBox_Validating); 80 this.rowsTextBox.Validated += new System.EventHandler(this.rowsTextBox_Validated); 81 81 // 82 82 // dataGridView … … 88 88 | System.Windows.Forms.AnchorStyles.Left) 89 89 | System.Windows.Forms.AnchorStyles.Right))); 90 this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; 90 91 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 91 92 this.dataGridView.Location = new System.Drawing.Point(0, 52); … … 95 96 this.dataGridView.TabIndex = 4; 96 97 this.dataGridView.VirtualMode = true; 97 this.dataGridView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dataGridView_Scroll); 98 this.dataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_ColumnHeaderMouseClick); 99 this.dataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.dataGridView_CellValueNeeded); 98 this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit); 100 99 this.dataGridView.CellParsing += new System.Windows.Forms.DataGridViewCellParsingEventHandler(this.dataGridView_CellParsing); 101 100 this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating); 102 this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit); 101 this.dataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.dataGridView_CellValueNeeded); 102 this.dataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_ColumnHeaderMouseClick); 103 this.dataGridView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dataGridView_Scroll); 103 104 this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown); 104 105 this.dataGridView.Resize += new System.EventHandler(this.dataGridView_Resize); … … 117 118 this.columnsTextBox.Size = new System.Drawing.Size(355, 20); 118 119 this.columnsTextBox.TabIndex = 3; 119 this.columnsTextBox.Validated += new System.EventHandler(this.columnsTextBox_Validated);120 120 this.columnsTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.columnsTextBox_KeyDown); 121 121 this.columnsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.columnsTextBox_Validating); 122 this.columnsTextBox.Validated += new System.EventHandler(this.columnsTextBox_Validated); 122 123 // 123 124 // columnsLabel … … 162 163 163 164 } 164 165 165 #endregion 166 166 -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r4068 r4178 24 24 using System.ComponentModel; 25 25 using System.Linq; 26 using System.Text; 26 27 using System.Windows.Forms; 27 28 using HeuristicLab.Common; … … 103 104 columnsTextBox.Text = Content.Columns.ToString(); 104 105 columnsTextBox.Enabled = true; 105 //DataGridViews with Rows but no columns are not allowed !106 //DataGridViews with rows but no columns are not allowed ! 106 107 if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly) 107 108 Content.Rows = dataGridView.RowCount; … … 116 117 UpdateColumnHeaders(); 117 118 dataGridView.Enabled = true; 119 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 118 120 } 119 121 120 122 private void UpdateColumnHeaders() { 121 int firstDisplayedColumnIndex = this.dataGridView.FirstDisplayedScrollingColumnIndex; 122 if (firstDisplayedColumnIndex == -1) 123 firstDisplayedColumnIndex = 0; 124 int lastDisplayedColumnIndex = firstDisplayedColumnIndex + dataGridView.DisplayedColumnCount(true); 125 for (int i = firstDisplayedColumnIndex; i < lastDisplayedColumnIndex; i++) { 123 for (int i = 0; i < dataGridView.ColumnCount; i++) { 126 124 if (Content.ColumnNames.Count() != 0) 127 125 dataGridView.Columns[i].HeaderText = Content.ColumnNames.ElementAt(i); … … 137 135 firstDisplayedRowIndex = 0; 138 136 int lastDisplaydRowIndex = firstDisplayedRowIndex + dataGridView.DisplayedRowCount(true); 137 139 138 for (int i = firstDisplayedRowIndex; i < lastDisplaydRowIndex; i++) { 140 139 if (Content.RowNames.Count() != 0) … … 143 142 dataGridView.Rows[i].HeaderCell.Value = "Row " + (i + 1); 144 143 } 145 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);146 144 } 147 145 … … 245 243 } 246 244 } 247 private void dataGridView_Scroll(object sender, ScrollEventArgs e) { 248 UpdateRowHeaders();249 UpdateColumnHeaders();245 246 private void dataGridView_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) { 247 this.UpdateRowHeaders(); 250 248 } 251 249 private void dataGridView_Resize(object sender, EventArgs e) { 252 UpdateRowHeaders(); 253 UpdateColumnHeaders(); 250 this.UpdateRowHeaders(); 254 251 } 255 252 256 253 private void dataGridView_KeyDown(object sender, KeyEventArgs e) { 257 if (!ReadOnly && e.Control && e.KeyCode == Keys.V) { //shortcut for values paste 258 string[,] values = SplitClipboardString(Clipboard.GetText()); 259 260 int rowIndex = 0; 261 int columnIndex = 0; 262 if (dataGridView.CurrentCell != null) { 263 rowIndex = dataGridView.CurrentCell.RowIndex; 264 columnIndex = dataGridView.CurrentCell.ColumnIndex; 265 } 266 267 for (int row = 0; row < values.GetLength(1); row++) { 268 if (row + rowIndex >= Content.Rows) 269 Content.Rows = Content.Rows + 1; 270 for (int col = 0; col < values.GetLength(0); col++) { 271 if (col + columnIndex >= Content.Columns) 272 Content.Columns = Content.Columns + 1; 273 Content.SetValue(values[col, row], row + rowIndex, col + columnIndex); 254 if (!ReadOnly && e.Control && e.KeyCode == Keys.V) 255 PasteValuesToDataGridView(); 256 else if (e.Control && e.KeyCode == Keys.C) 257 CopyValuesFromDataGridView(); 258 } 259 260 private void CopyValuesFromDataGridView() { 261 if (dataGridView.SelectedCells.Count == 0) return; 262 StringBuilder s = new StringBuilder(); 263 int minRowIndex = dataGridView.SelectedCells[0].RowIndex; 264 int maxRowIndex = dataGridView.SelectedCells[dataGridView.SelectedCells.Count - 1].RowIndex; 265 int minColIndex = dataGridView.SelectedCells[0].ColumnIndex; 266 int maxColIndex = dataGridView.SelectedCells[dataGridView.SelectedCells.Count - 1].ColumnIndex; 267 268 if (minRowIndex > maxRowIndex) { 269 int temp = minRowIndex; 270 minRowIndex = maxRowIndex; 271 maxRowIndex = temp; 272 } 273 if (minColIndex > maxColIndex) { 274 int temp = minColIndex; 275 minColIndex = maxColIndex; 276 maxColIndex = temp; 277 } 278 279 bool addColumnNames = Content.ColumnNames.Any() && minRowIndex == 0; 280 bool addRowNames = Content.RowNames.Any() && minColIndex == 0; 281 282 //add colum names 283 if (addColumnNames) { 284 if (addRowNames) 285 s.Append('\t'); 286 287 DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible); 288 while (column != null) { 289 s.Append(column.HeaderText); 290 s.Append('\t'); 291 column = dataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None); 292 } 293 s.Remove(s.Length - 1, 1); //remove last tab 294 s.Append(Environment.NewLine); 295 } 296 297 for (int i = minRowIndex; i <= maxRowIndex; i++) { 298 int rowIndex = this.virtualRowIndizes[i]; 299 if (addRowNames) { 300 s.Append(Content.RowNames.ElementAt(rowIndex)); 301 s.Append('\t'); 302 } 303 304 DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible); 305 while (column != null) { 306 DataGridViewCell cell = dataGridView[column.Index, i]; 307 if (cell.Selected) { 308 s.Append(Content.GetValue(rowIndex, column.Index)); 274 309 } 275 } 276 277 ClearSorting(); 278 } 279 } 280 310 s.Append('\t'); 311 column = dataGridView.Columns.GetNextColumn(column, DataGridViewElementStates.Visible, DataGridViewElementStates.None); 312 } 313 s.Remove(s.Length - 1, 1); //remove last tab 314 s.Append(Environment.NewLine); 315 } 316 Clipboard.SetText(s.ToString()); 317 } 318 319 private void PasteValuesToDataGridView() { 320 string[,] values = SplitClipboardString(Clipboard.GetText()); 321 int rowIndex = 0; 322 int columnIndex = 0; 323 if (dataGridView.CurrentCell != null) { 324 rowIndex = dataGridView.CurrentCell.RowIndex; 325 columnIndex = dataGridView.CurrentCell.ColumnIndex; 326 } 327 328 for (int row = 0; row < values.GetLength(1); row++) { 329 if (row + rowIndex >= Content.Rows) 330 Content.Rows = Content.Rows + 1; 331 for (int col = 0; col < values.GetLength(0); col++) { 332 if (col + columnIndex >= Content.Columns) 333 Content.Columns = Content.Columns + 1; 334 Content.SetValue(values[col, row], row + rowIndex, col + columnIndex); 335 } 336 } 337 ClearSorting(); 338 } 281 339 private string[,] SplitClipboardString(string clipboardText) { 282 340 clipboardText = clipboardText.Remove(clipboardText.Length - Environment.NewLine.Length); //remove last newline constant
Note: See TracChangeset
for help on using the changeset viewer.