Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs @ 12983

Last change on this file since 12983 was 12983, checked in by pfleck, 9 years ago

#2486
Allows pasting of multiple values that extend the current data limits (rows and/or columns).
In case, additional rows and columns are added with the default value of the column's type.

File size: 24.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Linq;
25using System.Windows.Forms;
26using HeuristicLab.Data;
27using HeuristicLab.Data.Views;
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 : StringConvertibleMatrixView {
35
36    private bool isSearching = false;
37    private bool updateOnMouseUp = false;
38    private SearchAndReplaceDialog findAndReplaceDialog;
39    private IFindPreprocessingItemsIterator searchIterator;
40    private string currentSearchText;
41    private ComparisonOperation currentComparisonOperation;
42    private Tuple<int, int> currentCell;
43
44    public new IDataGridContent Content {
45      get { return (IDataGridContent)base.Content; }
46      set { base.Content = value; }
47    }
48
49    private IDictionary<int, IList<int>> _highlightedCellsBackground;
50    public IDictionary<int, IList<int>> HightlightedCellsBackground {
51      get { return _highlightedCellsBackground; }
52      set {
53        _highlightedCellsBackground = value;
54        Refresh();
55      }
56    }
57
58    public DataGridContentView() {
59      InitializeComponent();
60      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
61      dataGridView.KeyDown += dataGridView_KeyDown;
62      dataGridView.MouseUp += dataGridView_MouseUp;
63      contextMenuCell.Items.Add(ShowHideColumns);
64      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
65      currentCell = null;
66    }
67
68    protected override void OnContentChanged() {
69      List<KeyValuePair<int, SortOrder>> order = new List<KeyValuePair<int, SortOrder>>(base.sortedColumnIndices);
70      base.OnContentChanged();
71
72      DataGridView.RowHeadersWidth = 70;
73
74      if (Content == null && findAndReplaceDialog != null) {
75        findAndReplaceDialog.Close();
76      }
77
78      if (Content != null) {
79        base.sortedColumnIndices = order;
80        base.Sort();
81      }
82
83    }
84
85    protected override void RegisterContentEvents() {
86      base.RegisterContentEvents();
87      Content.Changed += Content_Changed;
88      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
89    }
90
91    protected override void DeregisterContentEvents() {
92      base.DeregisterContentEvents();
93      Content.Changed -= Content_Changed;
94      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
95    }
96
97    private void FilterLogic_FilterChanged(object sender, EventArgs e) {
98      OnContentChanged();
99      searchIterator = null;
100      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
101        if (Content.FilterLogic.IsFiltered) {
102          findAndReplaceDialog.DisableReplace();
103        } else {
104          findAndReplaceDialog.EnableReplace();
105        }
106      }
107      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
108    }
109
110    private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
111      OnContentChanged();
112      searchIterator = null;
113    }
114
115    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
116      base.dataGridView_SelectionChanged(sender, e);
117      if (Content != null && dataGridView.RowCount != 0 && dataGridView.ColumnCount != 0)
118        Content.Selection = GetSelectedCells();
119    }
120
121    //couldn't use base.dataGridView_CellValidating as the values have to be validated per column individually
122    protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
123      if (dataGridView.ReadOnly) return;
124      if (Content == null) return;
125      if (Content.Rows == 0 || Content.Columns == 0) return;
126
127      string errorMessage;
128      if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) {
129        if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
130          errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
131        } else {
132          Content.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);
133        }
134
135        if (!String.IsNullOrEmpty(errorMessage)) {
136          e.Cancel = true;
137          dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
138        }
139
140      }
141    }
142
143
144    protected override void PasteValuesToDataGridView() {
145      string[,] values = SplitClipboardString(Clipboard.GetText());
146      int rowIndex = 0;
147      int columnIndex = 0;
148      if (dataGridView.CurrentCell != null) {
149        rowIndex = dataGridView.CurrentCell.RowIndex;
150        columnIndex = dataGridView.CurrentCell.ColumnIndex;
151      }
152      if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;
153      if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;
154
155      ReplaceTransaction(() => {
156        Content.PreProcessingData.InTransaction(() => {
157          for (int row = 0; row < values.GetLength(1); row++) {
158            for (int col = 0; col < values.GetLength(0); col++) {
159              Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);
160            }
161          }
162        });
163      });
164
165      ClearSorting();
166      //UpdateData(); // rownames are created on DataGrid creation. Therefore, no update possible, yet.
167    }
168
169    protected override void SetEnabledStateOfControls() {
170      base.SetEnabledStateOfControls();
171      rowsTextBox.ReadOnly = true;
172      columnsTextBox.ReadOnly = true;
173    }
174
175    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
176      btnApplySort.Enabled = sortedColumns.Any();
177      return base.Sort(sortedColumns);
178    }
179
180    protected override void ClearSorting() {
181      btnApplySort.Enabled = false;
182      base.ClearSorting();
183    }
184
185    protected override void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
186      if (Content != null) {
187        if (e.Button == System.Windows.Forms.MouseButtons.Left) {
188          dataGridView.Focus();
189          dataGridView.ClearSelection();
190          dataGridView.SelectionChanged -= dataGridView_SelectionChanged;
191          for (int i = 0; i < dataGridView.RowCount; i++) {
192            if (i + 1 == dataGridView.RowCount)
193              dataGridView.SelectionChanged += dataGridView_SelectionChanged;
194            dataGridView[e.ColumnIndex, i].Selected = true;
195          }
196        } else if (Content.SortableView) {
197          SortColumn(e.ColumnIndex);
198        }
199      }
200      searchIterator = null;
201    }
202
203    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
204      if (!updateOnMouseUp)
205        return;
206
207      updateOnMouseUp = false;
208      dataGridView_SelectionChanged(sender, e);
209    }
210
211    private void btnApplySort_Click(object sender, System.EventArgs e) {
212      Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
213      OnContentChanged();
214    }
215
216    #region FindAndReplaceDialog
217
218    private void CreateFindAndReplaceDialog() {
219      if (findAndReplaceDialog == null || findAndReplaceDialog.IsDisposed) {
220        findAndReplaceDialog = new SearchAndReplaceDialog();
221        findAndReplaceDialog.Show(this);
222        if (AreMultipleCellsSelected()) {
223          ResetHighlightedCellsBackground();
224          HightlightedCellsBackground = GetSelectedCells();
225          dataGridView.ClearSelection();
226        }
227        findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
228        findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
229        findAndReplaceDialog.ReplaceAllEvent += findAndReplaceDialog_ReplaceAllEvent;
230        findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
231        findAndReplaceDialog.FormClosing += findAndReplaceDialog_FormClosing;
232        searchIterator = null;
233        DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
234        if (Content.FilterLogic.IsFiltered) {
235          findAndReplaceDialog.DisableReplace();
236        }
237      }
238    }
239
240    private void DataGridView_SelectionChanged_FindAndReplace(object sender, EventArgs e) {
241      if (Content != null) {
242        if (!isSearching && AreMultipleCellsSelected()) {
243          ResetHighlightedCellsBackground();
244          HightlightedCellsBackground = GetSelectedCells();
245          searchIterator = null;
246        }
247      }
248    }
249
250    void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) {
251      ResetHighlightedCellsBackground();
252      searchIterator = null;
253      DataGridView.SelectionChanged -= DataGridView_SelectionChanged_FindAndReplace;
254    }
255
256    void findAndReplaceDialog_ReplaceEvent(object sender, EventArgs e) {
257      if (searchIterator != null && searchIterator.GetCurrent() != null) {
258        Replace(TransformToDictionary(currentCell));
259      }
260    }
261
262    void findAndReplaceDialog_ReplaceAllEvent(object sender, EventArgs e) {
263      Replace(FindAll(findAndReplaceDialog.GetSearchText()));
264    }
265
266    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
267      if (searchIterator == null
268        || currentSearchText != findAndReplaceDialog.GetSearchText()
269        || currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
270
271        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
272        currentSearchText = findAndReplaceDialog.GetSearchText();
273        currentComparisonOperation = findAndReplaceDialog.GetComparisonOperation();
274      }
275
276      if (IsOneCellSelected()) {
277        var first = GetSelectedCells().First();
278        searchIterator.SetStartCell(first.Key, first.Value[0]);
279      }
280
281      bool moreOccurences = false;
282      currentCell = searchIterator.GetCurrent();
283      moreOccurences = searchIterator.MoveNext();
284      if (IsOneCellSelected() && currentCell != null) {
285        var first = GetSelectedCells().First();
286        if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) {
287          if (!moreOccurences) {
288            searchIterator.Reset();
289          }
290          currentCell = searchIterator.GetCurrent();
291          moreOccurences = searchIterator.MoveNext();
292          if (!moreOccurences) {
293            searchIterator.Reset();
294          }
295        }
296      }
297
298      dataGridView.ClearSelection();
299
300      if (currentCell != null) {
301        dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
302        dataGridView.CurrentCell = dataGridView[currentCell.Item1, currentCell.Item2];
303      }
304    }
305
306    private bool AreMultipleCellsSelected() {
307      return GetSelectedCellCount() > 1;
308    }
309
310    private bool IsOneCellSelected() {
311      return GetSelectedCellCount() == 1;
312    }
313
314    private int GetSelectedCellCount() {
315      int count = 0;
316      foreach (var column in GetSelectedCells()) {
317        count += column.Value.Count();
318      }
319      return count;
320    }
321
322    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
323      dataGridView.ClearSelection();
324      isSearching = true;
325      SuspendRepaint();
326      var selectedCells = FindAll(findAndReplaceDialog.GetSearchText());
327      foreach (var column in selectedCells) {
328        foreach (var cell in column.Value) {
329          dataGridView[column.Key, cell].Selected = true;
330        }
331      }
332      ResumeRepaint(true);
333      isSearching = false;
334      Content.Selection = selectedCells;
335      //update statistic in base
336      base.dataGridView_SelectionChanged(sender, e);
337    }
338
339    private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) {
340      Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal;
341      switch (comparisonOperation) {
342        case ComparisonOperation.Equal:
343          constraintOperation = Core.ConstraintOperation.Equal;
344          break;
345        case ComparisonOperation.Greater:
346          constraintOperation = Core.ConstraintOperation.Greater;
347          break;
348        case ComparisonOperation.GreaterOrEqual:
349          constraintOperation = Core.ConstraintOperation.GreaterOrEqual;
350          break;
351        case ComparisonOperation.Less:
352          constraintOperation = Core.ConstraintOperation.Less;
353          break;
354        case ComparisonOperation.LessOrEqual:
355          constraintOperation = Core.ConstraintOperation.LessOrEqual;
356          break;
357        case ComparisonOperation.NotEqual:
358          constraintOperation = Core.ConstraintOperation.NotEqual;
359          break;
360      }
361      return constraintOperation;
362    }
363
364    private IDictionary<int, IList<int>> FindAll(string match) {
365      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
366      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
367      var foundCells = new Dictionary<int, IList<int>>();
368      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
369        var filters = CreateFilters(match, comparisonOperation, i);
370
371        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
372        var foundIndices = new List<int>();
373        for (int idx = 0; idx < filteredRows.Length; ++idx) {
374          var notFilteredThusFound = !filteredRows[idx];
375          if (notFilteredThusFound) {
376            foundIndices.Add(idx);
377          }
378        }
379        foundCells[i] = foundIndices;
380        IList<int> selectedList;
381        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
382          foundCells[i] = foundCells[i].Intersect(selectedList).ToList<int>();
383        } else if (searchInSelection) {
384          foundCells[i].Clear();
385        }
386      }
387      return MapToSorting(foundCells);
388    }
389
390    private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
391      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
392      IStringConvertibleValue value;
393      if (preprocessingData.VariableHasType<double>(columnIndex)) {
394        value = new DoubleValue();
395      } else if (preprocessingData.VariableHasType<String>(columnIndex)) {
396        value = new StringValue();
397      } else if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
398        value = new DateTimeValue();
399      } else {
400        throw new ArgumentException("unsupported type");
401      }
402      value.SetValue(match);
403      var comparisonFilter = new ComparisonFilter(preprocessingData, GetConstraintOperation(comparisonOperation), value, true);
404      comparisonFilter.ConstraintColumn = columnIndex;
405      return new List<Filter.IFilter>() { comparisonFilter };
406    }
407
408    private IDictionary<int, IList<int>> MapToSorting(Dictionary<int, IList<int>> foundCells) {
409      if (sortedColumnIndices.Count == 0) {
410        return foundCells;
411      } else {
412        var sortedFoundCells = new Dictionary<int, IList<int>>();
413
414        var indicesToVirtual = new Dictionary<int, int>();
415        for (int i = 0; i < virtualRowIndices.Length; ++i) {
416          indicesToVirtual.Add(virtualRowIndices[i], i);
417        }
418
419        foreach (var entry in foundCells) {
420          var cells = new List<int>();
421          foreach (var cell in entry.Value) {
422            cells.Add(indicesToVirtual[cell]);
423          }
424          cells.Sort();
425          sortedFoundCells.Add(entry.Key, cells);
426        }
427        return sortedFoundCells;
428      }
429    }
430
431    private void Replace(IDictionary<int, IList<int>> cells) {
432      if (findAndReplaceDialog != null) {
433        ReplaceTransaction(() => {
434          switch (findAndReplaceDialog.GetReplaceAction()) {
435            case ReplaceAction.Value:
436              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
437              break;
438            case ReplaceAction.Average:
439              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
440              break;
441            case ReplaceAction.Median:
442              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
443              break;
444            case ReplaceAction.Random:
445              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
446              break;
447            case ReplaceAction.MostCommon:
448              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
449              break;
450            case ReplaceAction.Interpolation:
451              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
452              break;
453          }
454        });
455      }
456    }
457
458    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
459      var highlightCells = new Dictionary<int, IList<int>>();
460      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
461      return highlightCells;
462    }
463
464    private void ResetHighlightedCellsBackground() {
465      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
466    }
467
468    #endregion FindAndReplaceDialog
469
470    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
471      if (Content == null) return;
472      if (e.Button == System.Windows.Forms.MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
473        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
474          replaceValueOverColumnToolStripMenuItem.Visible = false;
475          contextMenuCell.Show(MousePosition);
476        } else {
477          if (!dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, e.RowIndex])) {
478            dataGridView.ClearSelection();
479            dataGridView[e.ColumnIndex, e.RowIndex].Selected = true;
480          }
481
482          var columnIndices = new HashSet<int>();
483          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
484            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
485          }
486
487          replaceValueOverSelectionToolStripMenuItem.Enabled = AreMultipleCellsSelected();
488
489          averageToolStripMenuItem_Column.Enabled =
490            averageToolStripMenuItem_Selection.Enabled =
491            medianToolStripMenuItem_Column.Enabled =
492            medianToolStripMenuItem_Selection.Enabled =
493            randomToolStripMenuItem_Column.Enabled =
494            randomToolStripMenuItem_Selection.Enabled = !Content.PreProcessingData.AreAllStringColumns(columnIndices);
495
496          smoothingToolStripMenuItem_Column.Enabled =
497            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
498            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
499            && !Content.PreProcessingData.AreAllStringColumns(columnIndices);
500
501          replaceValueOverColumnToolStripMenuItem.Visible = true;
502          contextMenuCell.Show(MousePosition);
503        }
504      }
505    }
506
507    private void dataGridView_KeyDown(object sender, KeyEventArgs e) {
508      var selectedRows = dataGridView.SelectedRows;
509      var selectedCells = dataGridView.SelectedCells;
510      if (!Content.FilterLogic.IsFiltered) { //data is in read only mode....
511        if (e.KeyCode == Keys.Delete && selectedCells.Count == Content.Rows && selectedCells.Count > 0) {
512          Content.DeleteColumn(selectedCells[0].ColumnIndex);
513        } else if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
514          List<int> rows = new List<int>();
515          for (int i = 0; i < selectedRows.Count; ++i) {
516            int index = (sortedColumnIndices.Count != 0) ? (Convert.ToInt32(selectedRows[i].HeaderCell.Value) - 1) :
517              selectedRows[i].Index;
518            rows.Add(index);
519          }
520          Content.DeleteRows(rows);
521        } else if (e.Control && e.KeyCode == Keys.F) {
522          CreateFindAndReplaceDialog();
523          findAndReplaceDialog.ActivateSearch();
524        } else if (e.Control && e.KeyCode == Keys.R) {
525          CreateFindAndReplaceDialog();
526          findAndReplaceDialog.ActivateReplace();
527        }
528      }
529    }
530
531    private IDictionary<int, IList<int>> GetSelectedCells() {
532      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
533
534      //special case if all cells are selected
535      if (dataGridView.AreAllCellsSelected(true)) {
536        for (int i = 0; i < Content.Columns; i++)
537          selectedCells[i] = Enumerable.Range(0, Content.Rows).ToList();
538        return selectedCells;
539      }
540
541      foreach (var selectedCell in dataGridView.SelectedCells) {
542        var cell = (DataGridViewCell)selectedCell;
543        if (!selectedCells.ContainsKey(cell.ColumnIndex))
544          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
545        selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
546      }
547
548      return selectedCells;
549    }
550
551    private void StartReplacing() {
552      SuspendRepaint();
553    }
554
555    private void StopReplacing() {
556      ResumeRepaint(true);
557    }
558
559    private void ReplaceTransaction(Action action) {
560      StartReplacing();
561      action();
562      StopReplacing();
563    }
564
565    private void btnSearch_Click(object sender, EventArgs e) {
566      CreateFindAndReplaceDialog();
567      findAndReplaceDialog.ActivateSearch();
568    }
569
570    private void btnReplace_Click(object sender, EventArgs e) {
571      CreateFindAndReplaceDialog();
572      findAndReplaceDialog.ActivateReplace();
573    }
574
575    #region ContextMenu Events
576
577    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
578      ReplaceTransaction(() => {
579        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
580      });
581    }
582    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
583      ReplaceTransaction(() => {
584        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
585      });
586    }
587
588    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
589      ReplaceTransaction(() => {
590        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
591      });
592    }
593    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
594      ReplaceTransaction(() => {
595        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
596      });
597    }
598
599    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
600      ReplaceTransaction(() => {
601        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
602      });
603    }
604    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
605      ReplaceTransaction(() => {
606        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
607      });
608    }
609
610    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
611      ReplaceTransaction(() => {
612        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
613      });
614    }
615    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
616      ReplaceTransaction(() => {
617        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
618      });
619    }
620
621    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
622      ReplaceTransaction(() => {
623        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
624      });
625    }
626
627    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
628      ReplaceTransaction(() => {
629        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
630      });
631    }
632    #endregion
633
634  }
635}
Note: See TracBrowser for help on using the repository browser.