Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11042 was 11042, checked in by mleitner, 10 years ago

Fix add column on content changed

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