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

Last change on this file since 11037 was 11037, checked in by pfleck, 8 years ago

Fixed possible NullReferenceException in DataGridView.

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