Changeset 10964 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
- Timestamp:
- 06/11/14 10:40:01 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
r10951 r10964 83 83 searchIterator = null; 84 84 } 85 #region methods which override/modify methods from PreprocessingStringConvertibleMatrixView 85 86 86 87 protected override void dataGridView_SelectionChanged(object sender, EventArgs e) { … … 100 101 } 101 102 102 private void dataGridView_MouseUp(object sender, MouseEventArgs e) { 103 if (!updateOnMouseUp) 104 return; 105 106 updateOnMouseUp = false; 107 dataGridView_SelectionChanged(sender, e); 108 } 103 protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 104 if (!dataGridView.ReadOnly) { 105 string errorMessage; 106 if (Content != null) { 107 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) { 108 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode."; 109 } else { 110 Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex); 111 } 112 113 if (!String.IsNullOrEmpty(errorMessage)) { 114 e.Cancel = true; 115 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 116 } 117 } 118 } 119 } 120 121 protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 122 triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e)); 123 } 124 125 protected override void PasteValuesToDataGridView() { 126 triggersOwnEvent(() => base.PasteValuesToDataGridView()); 127 } 128 129 protected override void SetEnabledStateOfControls() { 130 base.SetEnabledStateOfControls(); 131 rowsTextBox.ReadOnly = true; 132 columnsTextBox.ReadOnly = true; 133 } 134 135 protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) { 136 btnApplySort.Enabled = sortedColumns.Any(); 137 return base.Sort(sortedColumns); 138 } 139 140 protected override void ClearSorting() { 141 btnApplySort.Enabled = false; 142 base.ClearSorting(); 143 } 144 145 #endregion 109 146 110 147 protected override void OnContentChanged() { … … 137 174 } 138 175 139 void FilterLogic_FilterChanged(object sender, EventArgs e) {176 private void FilterLogic_FilterChanged(object sender, EventArgs e) { 140 177 OnContentChanged(); 141 178 searchIterator = null; … … 150 187 } 151 188 152 void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {189 private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 153 190 if (notOwnEvent) { 154 191 switch (e.Type) { … … 161 198 break; 162 199 } 163 200 } 164 201 searchIterator = null; 165 202 } 166 203 167 protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 168 if (!dataGridView.ReadOnly) { 169 string errorMessage; 170 if (Content != null) { 171 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) { 172 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode."; 173 } else { 174 Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex); 175 } 176 177 if (!String.IsNullOrEmpty(errorMessage)) { 178 e.Cancel = true; 179 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 180 } 181 } 182 } 183 } 184 185 protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 186 triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e)); 187 } 188 189 protected override void PasteValuesToDataGridView() { 190 triggersOwnEvent(() => base.PasteValuesToDataGridView()); 191 } 192 193 protected override void SetEnabledStateOfControls() { 194 base.SetEnabledStateOfControls(); 195 rowsTextBox.ReadOnly = true; 196 columnsTextBox.ReadOnly = true; 204 private void dataGridView_MouseUp(object sender, MouseEventArgs e) { 205 if (!updateOnMouseUp) 206 return; 207 208 updateOnMouseUp = false; 209 dataGridView_SelectionChanged(sender, e); 197 210 } 198 211 … … 536 549 } 537 550 538 void dataGridView_KeyDown(object sender, KeyEventArgs e) {551 private void dataGridView_KeyDown(object sender, KeyEventArgs e) { 539 552 var selectedRows = dataGridView.SelectedRows; 540 553 if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) { … … 556 569 } 557 570 558 protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {559 btnApplySort.Enabled = sortedColumns.Any();560 return base.Sort(sortedColumns);561 }562 563 protected override void ClearSorting() {564 btnApplySort.Enabled = false;565 base.ClearSorting();566 }567 568 571 private IDictionary<int, IList<int>> GetSelectedCells() { 569 572 IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>(); … … 594 597 } 595 598 596 private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {597 ReplaceTransaction(() => {598 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);599 });600 }601 private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {602 ReplaceTransaction(() => {603 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);604 });605 }606 607 private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {608 ReplaceTransaction(() => {609 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);610 });611 }612 private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {613 ReplaceTransaction(() => {614 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);615 });616 }617 618 private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {619 ReplaceTransaction(() => {620 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);621 });622 }623 private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {624 ReplaceTransaction(() => {625 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);626 });627 }628 629 private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {630 ReplaceTransaction(() => {631 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);632 });633 }634 private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {635 ReplaceTransaction(() => {636 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);637 });638 }639 640 private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {641 ReplaceTransaction(() => {642 Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());643 });644 }645 646 private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {647 ReplaceTransaction(() => {648 Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());649 });650 }651 652 599 private void btnSearch_Click(object sender, EventArgs e) { 653 600 CreateFindAndReplaceDialog(); … … 659 606 findAndReplaceDialog.ActivateReplace(); 660 607 } 608 609 #region ContextMenu Events 610 611 private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) { 612 ReplaceTransaction(() => { 613 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false); 614 }); 615 } 616 private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) { 617 ReplaceTransaction(() => { 618 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true); 619 }); 620 } 621 622 private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) { 623 ReplaceTransaction(() => { 624 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false); 625 }); 626 } 627 private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) { 628 ReplaceTransaction(() => { 629 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true); 630 }); 631 } 632 633 private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) { 634 ReplaceTransaction(() => { 635 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false); 636 }); 637 } 638 private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) { 639 ReplaceTransaction(() => { 640 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true); 641 }); 642 } 643 644 private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) { 645 ReplaceTransaction(() => { 646 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false); 647 }); 648 } 649 private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) { 650 ReplaceTransaction(() => { 651 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true); 652 }); 653 } 654 655 private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) { 656 ReplaceTransaction(() => { 657 Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells()); 658 }); 659 } 660 661 private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) { 662 ReplaceTransaction(() => { 663 Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells()); 664 }); 665 } 666 #endregion 667 668 661 669 } 662 670 }
Note: See TracChangeset
for help on using the changeset viewer.