Free cookie consent management tool by TermsFeed Policy Generator

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

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