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

Last change on this file since 10998 was 10998, checked in by psteiner, 8 years ago

Formatting Sourcecode Views

File size: 25.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using System.Windows.Forms;
27using HeuristicLab.Data;
28using HeuristicLab.DataPreprocessing.Filter;
29using HeuristicLab.MainForm;
30
31namespace HeuristicLab.DataPreprocessing.Views {
32  [View("Data Grid Content View")]
33  [Content(typeof(IDataGridContent), true)]
34  public partial class DataGridContentView : PreprocessingStringConvertibleMatrixView {
35
36    private bool notOwnEvent = true;
37    private bool isSearching = false;
38    private bool isReplacing = false;
39    private bool updateOnMouseUp = false;
40    private SearchAndReplaceDialog findAndReplaceDialog;
41    private IFindPreprocessingItemsIterator searchIterator;
42    private string currentSearchText;
43    private ComparisonOperation currentComparisonOperation;
44    private Tuple<int, int> currentCell;
45
46    public new IDataGridContent Content {
47      get { return (IDataGridContent)base.Content; }
48      set { base.Content = value; }
49    }
50
51    private IList<int> _highlightedRowIndices;
52    public IList<int> HighlightedRowIndices {
53      get { return _highlightedRowIndices; }
54      set {
55        _highlightedRowIndices = value;
56        Refresh();
57      }
58    }
59
60    private IDictionary<int, IList<int>> _highlightedCellsBackground;
61    public IDictionary<int, IList<int>> HightlightedCellsBackground {
62      get { return _highlightedCellsBackground; }
63      set {
64        _highlightedCellsBackground = value;
65        Refresh();
66      }
67    }
68
69    public DataGridContentView() {
70      InitializeComponent();
71      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
72      dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
73      dataGridView.KeyDown += dataGridView_KeyDown;
74      dataGridView.MouseUp += dataGridView_MouseUp;
75      dataGridView.ColumnHeaderMouseClick += dataGridView_ColumnHeaderMouseClick;
76      contextMenuCell.Items.Add(ShowHideColumns);
77      _highlightedRowIndices = new List<int>();
78      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
79      currentCell = null;
80    }
81
82    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        switch (e.Type) {
127          case DataPreprocessingChangedEventType.ChangeColumn:
128          case DataPreprocessingChangedEventType.ChangeItem:
129            dataGridView.Refresh();
130            break;
131          default:
132            OnContentChanged();
133            break;
134        }
135      }
136      searchIterator = null;
137    }
138
139    #region methods which override/modify methods from PreprocessingStringConvertibleMatrixView
140
141    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
142      base.dataGridView_SelectionChanged(sender, e);
143      Content.DataGridLogic.SetSelection(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.DataGridLogic.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    #endregion
190
191    private void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
192      searchIterator = null;
193    }
194
195    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
196      if (!updateOnMouseUp)
197        return;
198
199      updateOnMouseUp = false;
200      dataGridView_SelectionChanged(sender, e);
201    }
202
203    private void btnApplySort_Click(object sender, System.EventArgs e) {
204      triggersOwnEvent(() => {
205        Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
206        OnContentChanged();
207      });
208    }
209
210    private void triggersOwnEvent(Action action) {
211      notOwnEvent = false;
212      action();
213      notOwnEvent = true;
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.DataGridLogic.SetSelection(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.IsType<double>(columnIndex)) {
394        value = new DoubleValue();
395      } else if (preprocessingData.IsType<String>(columnIndex)) {
396        value = new StringValue();
397      } else if (preprocessingData.IsType<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) {
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.DataGridLogic.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.DataGridLogic.AreAllStringColumns(columnIndices);
500
501          replaceValueOverColumnToolStripMenuItem.Visible = true;
502          contextMenuCell.Show(MousePosition);
503        }
504      }
505    }
506
507    protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
508      if (Content == null) return;
509      if (e.RowIndex < 0) return;
510      if (e.ColumnIndex < 0) return;
511      if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;
512      if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;
513      if (HighlightedRowIndices == null) return;
514
515      int rowIndex = virtualRowIndices[e.RowIndex];
516
517      Color backColor = e.CellStyle.BackColor;
518
519      if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {
520        backColor = Color.LightGray;
521      }
522
523      using (Brush backColorBrush = new SolidBrush(backColor)) {
524        Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
525        e.Graphics.FillRectangle(backColorBrush, bounds);
526      }
527
528      using (Brush gridBrush = new SolidBrush(Color.LightGray)) {
529        Pen gridLinePen = new Pen(gridBrush);
530        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
531               e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
532               e.CellBounds.Bottom - 1);
533        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
534            e.CellBounds.Top, e.CellBounds.Right - 1,
535            e.CellBounds.Bottom);
536      }
537      e.PaintContent(e.CellBounds);
538      e.Handled = true;
539    }
540
541    private void dataGridView_KeyDown(object sender, KeyEventArgs e) {
542      var selectedRows = dataGridView.SelectedRows;
543      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
544        List<int> rows = new List<int>();
545        for (int i = 0; i < selectedRows.Count; ++i) {
546          rows.Add(selectedRows[i].Index);
547        }
548        triggersOwnEvent(() => {
549          Content.DataGridLogic.DeleteRow(rows);
550          OnContentChanged();
551        });
552      } else if (e.Control && e.KeyCode == Keys.F) {
553        CreateFindAndReplaceDialog();
554        findAndReplaceDialog.ActivateSearch();
555      } else if (e.Control && e.KeyCode == Keys.R) {
556        CreateFindAndReplaceDialog();
557        findAndReplaceDialog.ActivateReplace();
558      }
559    }
560
561    private IDictionary<int, IList<int>> GetSelectedCells() {
562      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
563
564      //special case if all cells are selected
565      if (dataGridView.AreAllCellsSelected(true)) {
566        for (int i = 0; i < Content.Columns; i++)
567          selectedCells[i] = Enumerable.Range(0, Content.Rows).ToList();
568        return selectedCells;
569      }
570
571      foreach (var selectedCell in dataGridView.SelectedCells) {
572        var cell = (DataGridViewCell) selectedCell;
573        if (!selectedCells.ContainsKey(cell.ColumnIndex))
574          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
575        selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
576      }
577
578      return selectedCells;
579    }
580
581    private void StartReplacing() {
582      isReplacing = true;
583      SuspendRepaint();
584    }
585
586    private void StopReplacing() {
587      isReplacing = false;
588      ResumeRepaint(true);
589    }
590
591    private void ReplaceTransaction(Action action) {
592      StartReplacing();
593      action();
594      StopReplacing();
595    }
596
597    private void btnSearch_Click(object sender, EventArgs e) {
598      CreateFindAndReplaceDialog();
599      findAndReplaceDialog.ActivateSearch();
600    }
601
602    private void btnReplace_Click(object sender, EventArgs e) {
603      CreateFindAndReplaceDialog();
604      findAndReplaceDialog.ActivateReplace();
605    }
606
607    #region ContextMenu Events
608
609    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
610      ReplaceTransaction(() => {
611        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
612      });
613    }
614    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
615      ReplaceTransaction(() => {
616        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
617      });
618    }
619
620    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
621      ReplaceTransaction(() => {
622        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
623      });
624    }
625    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
626      ReplaceTransaction(() => {
627        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
628      });
629    }
630
631    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
632      ReplaceTransaction(() => {
633        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
634      });
635    }
636    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
637      ReplaceTransaction(() => {
638        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
639      });
640    }
641
642    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
643      ReplaceTransaction(() => {
644        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
645      });
646    }
647    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
648      ReplaceTransaction(() => {
649        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
650      });
651    }
652
653    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
654      ReplaceTransaction(() => {
655        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
656      });
657    }
658
659    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
660      ReplaceTransaction(() => {
661        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
662      });
663    }
664    #endregion
665
666  }
667}
Note: See TracBrowser for help on using the repository browser.