source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs @ 10951

Last change on this file since 10951 was 10951, checked in by mleitner, 8 years ago

Remove todo comment

File size: 24.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using System.Windows.Forms;
27using HeuristicLab.Data;
28using HeuristicLab.DataPreprocessing.Filter;
29using HeuristicLab.MainForm;
30
31namespace HeuristicLab.DataPreprocessing.Views {
32  [View("Data Grid Content View")]
33  [Content(typeof(IDataGridContent), true)]
34  public partial class DataGridContentView : PreprocessingStringConvertibleMatrixView {
35
36    private bool notOwnEvent = true;
37    private bool isSearching = false;
38    private bool isReplacing = false;
39    private bool updateOnMouseUp = false;
40    private SearchAndReplaceDialog findAndReplaceDialog;
41    private IFindPreprocessingItemsIterator searchIterator;
42    private string currentSearchText;
43    private ComparisonOperation currentComparisonOperation;
44    private Tuple<int, int> currentCell;
45
46    public new IDataGridContent Content {
47      get { return (IDataGridContent)base.Content; }
48      set { base.Content = value; }
49    }
50
51    private IList<int> _highlightedRowIndices;
52    public IList<int> HighlightedRowIndices {
53      get { return _highlightedRowIndices; }
54      set {
55        _highlightedRowIndices = value;
56        Refresh();
57      }
58    }
59
60    private IDictionary<int, IList<int>> _highlightedCellsBackground;
61    public IDictionary<int, IList<int>> HightlightedCellsBackground {
62      get { return _highlightedCellsBackground; }
63      set {
64        _highlightedCellsBackground = value;
65        Refresh();
66      }
67    }
68
69    public DataGridContentView() {
70      InitializeComponent();
71      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
72      dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
73      dataGridView.KeyDown += dataGridView_KeyDown;
74      dataGridView.MouseUp += dataGridView_MouseUp;
75      dataGridView.ColumnHeaderMouseClick += dataGridView_ColumnHeaderMouseClick;
76      contextMenuCell.Items.Add(ShowHideColumns);
77      _highlightedRowIndices = new List<int>();
78      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
79      currentCell = null;
80    }
81
82    private void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
83      searchIterator = null;
84    }
85
86    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
87      if (Content != null) {
88        if (!isSearching && !isReplacing) {
89
90          if (Control.MouseButtons == MouseButtons.Left) {
91            updateOnMouseUp = true;
92            return;
93          }
94
95          base.dataGridView_SelectionChanged(sender, e);
96
97          Content.DataGridLogic.SetSelection(GetSelectedCells());
98        }
99      }
100    }
101
102    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
103      if (!updateOnMouseUp)
104        return;
105
106      updateOnMouseUp = false;
107      dataGridView_SelectionChanged(sender, e);
108    }
109
110    protected override void OnContentChanged() {
111      List<KeyValuePair<int, SortOrder>> order = new List<KeyValuePair<int, SortOrder>>(base.sortedColumnIndices);
112      base.OnContentChanged();
113
114      DataGridView.RowHeadersWidth = 70;
115
116      if (Content == null && findAndReplaceDialog != null) {
117        findAndReplaceDialog.Close();
118      }
119
120      if (Content != null) {
121        base.sortedColumnIndices = order;
122        base.Sort();
123      }
124
125    }
126
127    protected override void RegisterContentEvents() {
128      base.RegisterContentEvents();
129      Content.Changed += Content_Changed;
130      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
131    }
132
133    protected override void DeregisterContentEvents() {
134      base.DeregisterContentEvents();
135      Content.Changed -= Content_Changed;
136      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
137    }
138
139    void FilterLogic_FilterChanged(object sender, EventArgs e) {
140      OnContentChanged();
141      searchIterator = null;
142      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
143        if (Content.FilterLogic.IsFiltered) {
144          findAndReplaceDialog.DisableReplace();
145        } else {
146          findAndReplaceDialog.EnableReplace();
147        }
148      }
149      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
150    }
151
152    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
153      if (notOwnEvent) {
154        switch (e.Type) {
155          case DataPreprocessingChangedEventType.ChangeColumn:
156          case DataPreprocessingChangedEventType.ChangeItem:
157            dataGridView.Refresh();
158            break;
159          default:
160            OnContentChanged();
161            break;
162        }
163       }
164      searchIterator = null;
165    }
166
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;
197    }
198
199    private void btnApplySort_Click(object sender, System.EventArgs e) {
200      triggersOwnEvent(() => {
201        Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
202        OnContentChanged();
203      });
204    }
205
206    private void triggersOwnEvent(Action action) {
207      notOwnEvent = false;
208      action();
209      notOwnEvent = true;
210    }
211
212    #region FindAndReplaceDialog
213
214    private void CreateFindAndReplaceDialog() {
215      if (findAndReplaceDialog == null || findAndReplaceDialog.IsDisposed) {
216        findAndReplaceDialog = new SearchAndReplaceDialog();
217        findAndReplaceDialog.Show(this);
218        if (AreMultipleCellsSelected()) {
219          ResetHighlightedCellsBackground();
220          HightlightedCellsBackground = GetSelectedCells();
221          dataGridView.ClearSelection();
222        }
223        findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
224        findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
225        findAndReplaceDialog.ReplaceAllEvent += findAndReplaceDialog_ReplaceAllEvent;
226        findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
227        findAndReplaceDialog.FormClosing += findAndReplaceDialog_FormClosing;
228        searchIterator = null;
229        DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
230        if (Content.FilterLogic.IsFiltered) {
231          findAndReplaceDialog.DisableReplace();
232        }
233      }
234    }
235
236    private void DataGridView_SelectionChanged_FindAndReplace(object sender, EventArgs e) {
237      if (Content != null) {
238        if (!isSearching && AreMultipleCellsSelected()) {
239          ResetHighlightedCellsBackground();
240          HightlightedCellsBackground = GetSelectedCells();
241          searchIterator = null;
242        }
243      }
244    }
245
246    void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) {
247      ResetHighlightedCellsBackground();
248      searchIterator = null;
249      DataGridView.SelectionChanged -= DataGridView_SelectionChanged_FindAndReplace;
250    }
251
252    void findAndReplaceDialog_ReplaceEvent(object sender, EventArgs e) {
253      if (searchIterator != null && searchIterator.GetCurrent() != null) {
254        Replace(TransformToDictionary(currentCell));
255      }
256    }
257
258    void findAndReplaceDialog_ReplaceAllEvent(object sender, EventArgs e) {
259      Replace(FindAll(findAndReplaceDialog.GetSearchText()));
260    }
261
262    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
263      if (searchIterator == null
264        || currentSearchText != findAndReplaceDialog.GetSearchText()
265        || currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
266
267        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
268        currentSearchText = findAndReplaceDialog.GetSearchText();
269        currentComparisonOperation = findAndReplaceDialog.GetComparisonOperation();
270      }
271
272      if (IsOneCellSelected()) {
273        var first = GetSelectedCells().First();
274        searchIterator.SetStartCell(first.Key, first.Value[0]);
275      }
276
277      bool moreOccurences = false;
278      currentCell = searchIterator.GetCurrent();
279      moreOccurences = searchIterator.MoveNext();
280      if (IsOneCellSelected() && currentCell != null) {
281        var first = GetSelectedCells().First();
282        if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) {
283          if (!moreOccurences) {
284            searchIterator.Reset();
285          }
286          currentCell = searchIterator.GetCurrent();
287          moreOccurences = searchIterator.MoveNext();
288          if (!moreOccurences) {
289            searchIterator.Reset();
290          }
291        }
292      }
293
294      dataGridView.ClearSelection();
295
296      if (currentCell != null) {
297        dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
298        dataGridView.CurrentCell = dataGridView[currentCell.Item1, currentCell.Item2];
299      }
300    }
301
302    private bool AreMultipleCellsSelected() {
303      return GetSelectedCellCount() > 1;
304    }
305
306    private bool IsOneCellSelected() {
307      return GetSelectedCellCount() == 1;
308    }
309
310    private int GetSelectedCellCount() {
311      int count = 0;
312      foreach (var column in GetSelectedCells()) {
313        count += column.Value.Count();
314      }
315      return count;
316    }
317
318    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
319      dataGridView.ClearSelection();
320      isSearching = true;
321      SuspendRepaint();
322      var selectedCells = FindAll(findAndReplaceDialog.GetSearchText());
323      foreach (var column in selectedCells) {
324        foreach (var cell in column.Value) {
325          dataGridView[column.Key, cell].Selected = true;
326        }
327      }
328      ResumeRepaint(true);
329      isSearching = false;
330      Content.DataGridLogic.SetSelection(selectedCells);
331      //update statistic in base
332      base.dataGridView_SelectionChanged(sender, e);
333    }
334
335    private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) {
336      Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal;
337      switch (comparisonOperation) {
338        case ComparisonOperation.Equal:
339          constraintOperation = Core.ConstraintOperation.Equal;
340          break;
341        case ComparisonOperation.Greater:
342          constraintOperation = Core.ConstraintOperation.Greater;
343          break;
344        case ComparisonOperation.GreaterOrEqual:
345          constraintOperation = Core.ConstraintOperation.GreaterOrEqual;
346          break;
347        case ComparisonOperation.Less:
348          constraintOperation = Core.ConstraintOperation.Less;
349          break;
350        case ComparisonOperation.LessOrEqual:
351          constraintOperation = Core.ConstraintOperation.LessOrEqual;
352          break;
353        case ComparisonOperation.NotEqual:
354          constraintOperation = Core.ConstraintOperation.NotEqual;
355          break;
356      }
357      return constraintOperation;
358    }
359
360    private IDictionary<int, IList<int>> FindAll(string match) {
361      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
362      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
363      var foundCells = new Dictionary<int, IList<int>>();
364      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
365        var filters = CreateFilters(match, comparisonOperation, i);
366
367        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
368        var foundIndices = new List<int>();
369        for (int idx = 0; idx < filteredRows.Length; ++idx) {
370          var notFilteredThusFound = !filteredRows[idx];
371          if (notFilteredThusFound) {
372            foundIndices.Add(idx);
373          }
374        }
375        foundCells[i] = foundIndices;
376        IList<int> selectedList;
377        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
378          foundCells[i] = foundCells[i].Intersect(selectedList).ToList<int>();
379        } else if (searchInSelection) {
380          foundCells[i].Clear();
381        }
382      }
383      return MapToSorting(foundCells);
384    }
385
386    private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
387      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
388      IStringConvertibleValue value;
389      if (preprocessingData.IsType<double>(columnIndex)) {
390        value = new DoubleValue();
391      } else if (preprocessingData.IsType<String>(columnIndex)) {
392        value = new StringValue();
393      } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
394        value = new DateTimeValue();
395      } else {
396        throw new ArgumentException("unsupported type");
397      }
398      value.SetValue(match);
399      var comparisonFilter = new ComparisonFilter(preprocessingData, GetConstraintOperation(comparisonOperation), value, true);
400      comparisonFilter.ConstraintColumn = columnIndex;
401      return new List<Filter.IFilter>() { comparisonFilter };
402    }
403
404    private IDictionary<int, IList<int>> MapToSorting(Dictionary<int, IList<int>> foundCells) {
405      if (sortedColumnIndices.Count == 0) {
406        return foundCells;
407      } else {
408        var sortedFoundCells = new Dictionary<int, IList<int>>();
409
410        var indicesToVirtual = new Dictionary<int, int>();
411        for (int i = 0; i < virtualRowIndices.Length; ++i) {
412          indicesToVirtual.Add(virtualRowIndices[i], i);
413        }
414
415        foreach (var entry in foundCells) {
416          var cells = new List<int>();
417          foreach (var cell in entry.Value) {
418            cells.Add(indicesToVirtual[cell]);
419          }
420          cells.Sort();
421          sortedFoundCells.Add(entry.Key, cells);
422        }
423        return sortedFoundCells;
424      }
425    }
426
427    private void Replace(IDictionary<int, IList<int>> cells) {
428      if (findAndReplaceDialog != null) {
429        ReplaceTransaction(() => {
430          switch (findAndReplaceDialog.GetReplaceAction()) {
431            case ReplaceAction.Value:
432              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
433              break;
434            case ReplaceAction.Average:
435              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
436              break;
437            case ReplaceAction.Median:
438              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
439              break;
440            case ReplaceAction.Random:
441              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
442              break;
443            case ReplaceAction.MostCommon:
444              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
445              break;
446            case ReplaceAction.Interpolation:
447              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
448              break;
449          }
450        });
451      }
452    }
453
454    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
455      var highlightCells = new Dictionary<int, IList<int>>();
456      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
457      return highlightCells;
458    }
459
460    private void ResetHighlightedCellsBackground() {
461      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
462    }
463
464    #endregion FindAndReplaceDialog
465
466    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
467      if (Content == null) return;
468      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
469        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
470          replaceValueOverColumnToolStripMenuItem.Visible = false;
471          contextMenuCell.Show(MousePosition);
472        } else {
473          if (!dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, e.RowIndex])) {
474            dataGridView.ClearSelection();
475            dataGridView[e.ColumnIndex, e.RowIndex].Selected = true;
476          }
477
478          var columnIndices = new HashSet<int>();
479          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
480            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
481          }
482
483          replaceValueOverSelectionToolStripMenuItem.Enabled = AreMultipleCellsSelected();
484
485          averageToolStripMenuItem_Column.Enabled =
486            averageToolStripMenuItem_Selection.Enabled =
487            medianToolStripMenuItem_Column.Enabled =
488            medianToolStripMenuItem_Selection.Enabled =
489            randomToolStripMenuItem_Column.Enabled =
490            randomToolStripMenuItem_Selection.Enabled = !Content.DataGridLogic.AreAllStringColumns(columnIndices);
491
492          smoothingToolStripMenuItem_Column.Enabled =
493            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
494            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
495            && !Content.DataGridLogic.AreAllStringColumns(columnIndices);
496
497          replaceValueOverColumnToolStripMenuItem.Visible = true;
498          contextMenuCell.Show(MousePosition);
499        }
500      }
501    }
502
503    protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
504      if (Content == null) return;
505      if (e.RowIndex < 0) return;
506      if (e.ColumnIndex < 0) return;
507      if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;
508      if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;
509      if (HighlightedRowIndices == null) return;
510
511      int rowIndex = virtualRowIndices[e.RowIndex];
512
513      Color backColor = e.CellStyle.BackColor;
514
515      if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {
516        backColor = Color.LightGray;
517      }
518
519      using (Brush backColorBrush = new SolidBrush(backColor)) {
520        Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
521        e.Graphics.FillRectangle(backColorBrush, bounds);
522      }
523
524      using (Brush gridBrush = new SolidBrush(Color.LightGray)) {
525        Pen gridLinePen = new Pen(gridBrush);
526        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
527               e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
528               e.CellBounds.Bottom - 1);
529        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
530            e.CellBounds.Top, e.CellBounds.Right - 1,
531            e.CellBounds.Bottom);
532      }
533
534      e.PaintContent(e.CellBounds);
535      e.Handled = true;
536    }
537
538    void dataGridView_KeyDown(object sender, KeyEventArgs e) {
539      var selectedRows = dataGridView.SelectedRows;
540      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
541        List<int> rows = new List<int>();
542        for (int i = 0; i < selectedRows.Count; ++i) {
543          rows.Add(selectedRows[i].Index);
544        }
545        triggersOwnEvent(() => {
546          Content.DataGridLogic.DeleteRow(rows);
547          OnContentChanged();
548        });
549      } else if (e.Control && e.KeyCode == Keys.F) {
550        CreateFindAndReplaceDialog();
551        findAndReplaceDialog.ActivateSearch();
552      } else if (e.Control && e.KeyCode == Keys.R) {
553        CreateFindAndReplaceDialog();
554        findAndReplaceDialog.ActivateReplace();
555      }
556    }
557
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    private IDictionary<int, IList<int>> GetSelectedCells() {
569      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
570      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
571        var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
572        if (!selectedCells.ContainsKey(columnIndex)) {
573          selectedCells.Add(columnIndex, new List<int>());
574        }
575        selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
576      }
577      return selectedCells;
578    }
579
580    private void StartReplacing() {
581      isReplacing = true;
582      SuspendRepaint();
583    }
584
585    private void StopReplacing() {
586      isReplacing = false;
587      ResumeRepaint(true);
588    }
589
590    private void ReplaceTransaction(Action action) {
591      StartReplacing();
592      action();
593      StopReplacing();
594    }
595
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    private void btnSearch_Click(object sender, EventArgs e) {
653      CreateFindAndReplaceDialog();
654      findAndReplaceDialog.ActivateSearch();
655    }
656
657    private void btnReplace_Click(object sender, EventArgs e) {
658      CreateFindAndReplaceDialog();
659      findAndReplaceDialog.ActivateReplace();
660    }
661  }
662}
Note: See TracBrowser for help on using the repository browser.