Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11070 was 11070, checked in by mkommend, 10 years ago

#2206: Clean up of data preprocessing code (removed unused code, used more appropriate collections, hiding of the backtransform button of symreg models).

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