- Timestamp:
- 06/11/14 10:40:01 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 3 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 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs
r10900 r10964 35 35 private readonly IFilterLogic filterLogic; 36 36 37 public DataGridContent(IDataGridLogic theDataGridLogic, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {38 dataGridLogic = theDataGridLogic;39 manipulationLogic = theManipulationLogic;40 filterLogic = theFilterLogic;41 }42 43 public DataGridContent(DataGridContent dataGridContent, Cloner cloner)44 : base(dataGridContent, cloner) {45 }46 47 37 public IManipulationLogic ManipulationLogic { 48 38 get { return manipulationLogic; } … … 63 53 public static new Image StaticItemImage { 64 54 get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; } 65 }66 67 public override IDeepCloneable Clone(Cloner cloner) {68 return new DataGridContent(this, cloner);69 55 } 70 56 … … 118 104 } 119 105 120 public bool Validate(string value, out string errorMessage) { 121 errorMessage = string.Empty; 122 return true; 106 public DataGridContent(IDataGridLogic theDataGridLogic, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) { 107 dataGridLogic = theDataGridLogic; 108 manipulationLogic = theManipulationLogic; 109 filterLogic = theFilterLogic; 110 } 111 112 public DataGridContent(DataGridContent dataGridContent, Cloner cloner) 113 : base(dataGridContent, cloner) { 114 115 } 116 117 public override IDeepCloneable Clone(Cloner cloner) { 118 return new DataGridContent(this, cloner); 123 119 } 124 120 … … 129 125 public bool SetValue(string value, int rowIndex, int columnIndex) { 130 126 return dataGridLogic.SetValue(value, columnIndex, rowIndex); 127 } 128 129 public event DataPreprocessingChangedEventHandler Changed { 130 add { dataGridLogic.Changed += value; } 131 remove { dataGridLogic.Changed -= value; } 132 } 133 134 135 136 #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix 137 138 // Is not used since DataGridContentView overrides dataGridView_CellValidating and uses 139 // DataGridLogic#Validate(string value, out string errorMessage, int columnIndex) 140 public bool Validate(string value, out string errorMessage) { 141 errorMessage = string.Empty; 142 return true; 131 143 } 132 144 … … 144 156 145 157 public event EventHandler Reset; 158 #endregion 146 159 147 public event DataPreprocessingChangedEventHandler Changed {148 add { dataGridLogic.Changed += value; }149 remove { dataGridLogic.Changed -= value; }150 }151 160 } 152 161 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterContent.cs
r10877 r10964 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using System.Collections.Generic;26 25 using HeuristicLab.DataPreprocessing.Filter; 27 26 … … 40 39 public bool isAndCombination = true; 41 40 42 public FilterContent(IFilterLogic theFilterLogic) {43 filterLogic = theFilterLogic;44 }45 41 46 42 public IFilterLogic FilterLogic { … … 50 46 } 51 47 52 public ICheckedItemCollection<IFilter> Filters 53 { 54 get 55 { 48 public ICheckedItemCollection<IFilter> Filters { 49 get { 56 50 return this.filters; 57 51 } 58 set 59 { 52 set { 60 53 this.filters = value; 61 54 } 62 55 } 63 56 64 public bool IsAndCombination 65 { 66 get 67 { 57 public bool IsAndCombination { 58 get { 68 59 return this.isAndCombination; 69 60 } 70 set 71 { 61 set { 72 62 this.isAndCombination = value; 73 63 } 74 64 } 75 65 76 public FilterContent(FilterContent content, Cloner cloner) 66 public FilterContent(IFilterLogic theFilterLogic) { 67 filterLogic = theFilterLogic; 68 } 69 70 protected FilterContent(FilterContent content, Cloner cloner) 77 71 : base(content, cloner) { 78 79 72 } 80 73 … … 82 75 return new FilterContent(this, cloner); 83 76 } 84 85 86 87 77 } 88 78 }
Note: See TracChangeset
for help on using the changeset viewer.