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

Last change on this file since 10947 was 10947, checked in by rstoll, 8 years ago
  • Changed ComparisonFilter, using DoubleValue and DateTime rather than just StringValue
  • Included better input validation for ComparisonFilterView
  • Bug "Search and Sorted DataGridContentView" fixed
File size: 24.8 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 : CopyOfStringConvertibleMatrixView {
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    private void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
83      searchIterator = null;
84    }
85
86    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
87      if (Content != null) {
88        if (!isSearching && !isReplacing) {
89
90          if (Control.MouseButtons == MouseButtons.Left) {
91            updateOnMouseUp = true;
92            return;
93          }
94
95          base.dataGridView_SelectionChanged(sender, e);
96
97          Content.DataGridLogic.SetSelection(GetSelectedCells());
98        }
99      }
100    }
101
102    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
103      if (!updateOnMouseUp)
104        return;
105
106      updateOnMouseUp = false;
107      dataGridView_SelectionChanged(sender, e);
108    }
109
110    protected override void OnContentChanged() {
111      base.OnContentChanged();
112      // ToDo: Temporarily disabled because needs to much performance
113      //DataGridView.AutoResizeColumns();
114      //DataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
115      DataGridView.RowHeadersWidth = 70;
116      if (Content == null && findAndReplaceDialog != null) {
117        findAndReplaceDialog.Close();
118      }
119    }
120
121    protected override void RegisterContentEvents() {
122      base.RegisterContentEvents();
123      Content.Changed += Content_Changed;
124      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
125    }
126
127    protected override void DeregisterContentEvents() {
128      base.DeregisterContentEvents();
129      Content.Changed -= Content_Changed;
130      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
131    }
132
133    void FilterLogic_FilterChanged(object sender, EventArgs e) {
134      OnContentChanged();
135      searchIterator = null;
136      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
137        if (Content.FilterLogic.IsFiltered) {
138          findAndReplaceDialog.DisableReplace();
139        } else {
140          findAndReplaceDialog.EnableReplace();
141        }
142      }
143      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
144    }
145
146    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
147      if (notOwnEvent) {
148        switch (e.Type) {
149          case DataPreprocessingChangedEventType.ChangeColumn:
150          case DataPreprocessingChangedEventType.ChangeItem:
151            dataGridView.Refresh();
152            break;
153          default:
154            OnContentChanged();
155            break;
156        }
157      }
158      searchIterator = null;
159    }
160
161    protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
162      if (!dataGridView.ReadOnly) {
163        string errorMessage;
164        if (Content != null) {
165          if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
166            errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
167          } else {
168            Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);
169          }
170
171          if (!String.IsNullOrEmpty(errorMessage)) {
172            e.Cancel = true;
173            dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
174          }
175        }
176      }
177    }
178
179    protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) {
180      triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e));
181    }
182
183    protected override void PasteValuesToDataGridView() {
184      triggersOwnEvent(() => base.PasteValuesToDataGridView());
185    }
186
187    protected override void SetEnabledStateOfControls() {
188      base.SetEnabledStateOfControls();
189      rowsTextBox.ReadOnly = true;
190      columnsTextBox.ReadOnly = true;
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.DataGridLogic.SetSelection(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.DataGridLogic.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.DataGridLogic.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
528      e.PaintContent(e.CellBounds);
529      e.Handled = true;
530    }
531
532    void dataGridView_KeyDown(object sender, KeyEventArgs e) {
533      var selectedRows = dataGridView.SelectedRows;
534      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
535        List<int> rows = new List<int>();
536        for (int i = 0; i < selectedRows.Count; ++i) {
537          rows.Add(selectedRows[i].Index);
538        }
539        triggersOwnEvent(() => {
540          Content.DataGridLogic.DeleteRow(rows);
541          OnContentChanged();
542        });
543      } else if (e.Control && e.KeyCode == Keys.F) {
544        CreateFindAndReplaceDialog();
545        findAndReplaceDialog.ActivateSearch();
546      } else if (e.Control && e.KeyCode == Keys.R) {
547        CreateFindAndReplaceDialog();
548        findAndReplaceDialog.ActivateReplace();
549      }
550    }
551
552    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
553      btnApplySort.Enabled = sortedColumns.Any();
554      return base.Sort(sortedColumns);
555    }
556
557    protected override void ClearSorting() {
558      btnApplySort.Enabled = false;
559      base.ClearSorting();
560    }
561
562    private IDictionary<int, IList<int>> GetSelectedCells() {
563      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
564      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
565        var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
566        if (!selectedCells.ContainsKey(columnIndex)) {
567          selectedCells.Add(columnIndex, new List<int>());
568        }
569        selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
570      }
571      return selectedCells;
572    }
573
574    private void StartReplacing() {
575      isReplacing = true;
576      SuspendRepaint();
577    }
578
579    private void StopReplacing() {
580      isReplacing = false;
581      ResumeRepaint(true);
582    }
583
584    private void ReplaceTransaction(Action action) {
585      StartReplacing();
586      action();
587      StopReplacing();
588    }
589
590    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
591      ReplaceTransaction(() => {
592        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
593      });
594    }
595    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
596      ReplaceTransaction(() => {
597        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
598      });
599    }
600
601    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
602      ReplaceTransaction(() => {
603        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
604      });
605    }
606    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
607      ReplaceTransaction(() => {
608        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
609      });
610    }
611
612    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
613      ReplaceTransaction(() => {
614        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
615      });
616    }
617    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
618      ReplaceTransaction(() => {
619        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
620      });
621    }
622
623    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
624      ReplaceTransaction(() => {
625        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
626      });
627    }
628    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
629      ReplaceTransaction(() => {
630        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
631      });
632    }
633
634    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
635      ReplaceTransaction(() => {
636        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
637      });
638    }
639
640    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
641      ReplaceTransaction(() => {
642        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
643      });
644    }
645
646    private void btnSearch_Click(object sender, EventArgs e) {
647      CreateFindAndReplaceDialog();
648      findAndReplaceDialog.ActivateSearch();
649    }
650
651    private void btnReplace_Click(object sender, EventArgs e) {
652      CreateFindAndReplaceDialog();
653      findAndReplaceDialog.ActivateReplace();
654    }
655  }
656}
Note: See TracBrowser for help on using the repository browser.