Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs @ 12986

Last change on this file since 12986 was 12986, checked in by pfleck, 8 years ago

#2486

  • Added buttons for adding columns and rows.
  • Fixed a bug with row names.
File size: 24.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Linq;
25using System.Windows.Forms;
26using HeuristicLab.Data;
27using HeuristicLab.Data.Views;
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 : StringConvertibleMatrixView {
35
36    private bool isSearching = false;
37    private bool updateOnMouseUp = false;
38    private SearchAndReplaceDialog findAndReplaceDialog;
39    private IFindPreprocessingItemsIterator searchIterator;
40    private string currentSearchText;
41    private ComparisonOperation currentComparisonOperation;
42    private Tuple<int, int> currentCell;
43
44    public new IDataGridContent Content {
45      get { return (IDataGridContent)base.Content; }
46      set { base.Content = value; }
47    }
48
49    private IDictionary<int, IList<int>> _highlightedCellsBackground;
50    public IDictionary<int, IList<int>> HightlightedCellsBackground {
51      get { return _highlightedCellsBackground; }
52      set {
53        _highlightedCellsBackground = value;
54        Refresh();
55      }
56    }
57
58    public DataGridContentView() {
59      InitializeComponent();
60      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
61      dataGridView.KeyDown += dataGridView_KeyDown;
62      dataGridView.MouseUp += dataGridView_MouseUp;
63      contextMenuCell.Items.Add(ShowHideColumns);
64      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
65      currentCell = null;
66    }
67
68    protected override void OnContentChanged() {
69      List<KeyValuePair<int, SortOrder>> order = new List<KeyValuePair<int, SortOrder>>(base.sortedColumnIndices);
70      base.OnContentChanged();
71
72      DataGridView.RowHeadersWidth = 70;
73
74      if (Content == null && findAndReplaceDialog != null) {
75        findAndReplaceDialog.Close();
76      }
77
78      if (Content != null) {
79        base.sortedColumnIndices = order;
80        base.Sort();
81      }
82
83    }
84
85    protected override void RegisterContentEvents() {
86      base.RegisterContentEvents();
87      Content.Changed += Content_Changed;
88      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
89    }
90
91    protected override void DeregisterContentEvents() {
92      base.DeregisterContentEvents();
93      Content.Changed -= Content_Changed;
94      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
95    }
96
97    private void FilterLogic_FilterChanged(object sender, EventArgs e) {
98      OnContentChanged();
99      searchIterator = null;
100      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
101        if (Content.FilterLogic.IsFiltered) {
102          findAndReplaceDialog.DisableReplace();
103        } else {
104          findAndReplaceDialog.EnableReplace();
105        }
106      }
107      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
108    }
109
110    private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
111      OnContentChanged();
112      searchIterator = null;
113    }
114
115    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
116      base.dataGridView_SelectionChanged(sender, e);
117      if (Content != null && dataGridView.RowCount != 0 && dataGridView.ColumnCount != 0)
118        Content.Selection = GetSelectedCells();
119    }
120
121    //couldn't use base.dataGridView_CellValidating as the values have to be validated per column individually
122    protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
123      if (dataGridView.ReadOnly) return;
124      if (Content == null) return;
125      if (Content.Rows == 0 || Content.Columns == 0) return;
126
127      string errorMessage;
128      if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) {
129        if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
130          errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
131        } else {
132          Content.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);
133        }
134
135        if (!String.IsNullOrEmpty(errorMessage)) {
136          e.Cancel = true;
137          dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
138        }
139
140      }
141    }
142
143
144    protected override void PasteValuesToDataGridView() {
145      string[,] values = SplitClipboardString(Clipboard.GetText());
146      int rowIndex = 0;
147      int columnIndex = 0;
148      if (dataGridView.CurrentCell != null) {
149        rowIndex = dataGridView.CurrentCell.RowIndex;
150        columnIndex = dataGridView.CurrentCell.ColumnIndex;
151      }
152      if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;
153      if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;
154
155      ReplaceTransaction(() => {
156        Content.PreProcessingData.InTransaction(() => {
157          for (int row = 0; row < values.GetLength(1); row++) {
158            for (int col = 0; col < values.GetLength(0); col++) {
159              Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);
160            }
161          }
162        });
163      });
164
165      ClearSorting();
166    }
167
168    protected override void SetEnabledStateOfControls() {
169      base.SetEnabledStateOfControls();
170      rowsTextBox.ReadOnly = true;
171      columnsTextBox.ReadOnly = true;
172    }
173
174    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
175      btnApplySort.Enabled = sortedColumns.Any();
176      return base.Sort(sortedColumns);
177    }
178
179    protected override void ClearSorting() {
180      btnApplySort.Enabled = false;
181      base.ClearSorting();
182    }
183
184    protected override void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
185      if (Content != null) {
186        if (e.Button == System.Windows.Forms.MouseButtons.Left) {
187          dataGridView.Focus();
188          dataGridView.ClearSelection();
189          dataGridView.SelectionChanged -= dataGridView_SelectionChanged;
190          for (int i = 0; i < dataGridView.RowCount; i++) {
191            if (i + 1 == dataGridView.RowCount)
192              dataGridView.SelectionChanged += dataGridView_SelectionChanged;
193            dataGridView[e.ColumnIndex, i].Selected = true;
194          }
195        } else if (Content.SortableView) {
196          SortColumn(e.ColumnIndex);
197        }
198      }
199      searchIterator = null;
200    }
201
202    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
203      if (!updateOnMouseUp)
204        return;
205
206      updateOnMouseUp = false;
207      dataGridView_SelectionChanged(sender, e);
208    }
209
210    private void btnApplySort_Click(object sender, System.EventArgs e) {
211      Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
212      OnContentChanged();
213    }
214
215    #region FindAndReplaceDialog
216
217    private void CreateFindAndReplaceDialog() {
218      if (findAndReplaceDialog == null || findAndReplaceDialog.IsDisposed) {
219        findAndReplaceDialog = new SearchAndReplaceDialog();
220        findAndReplaceDialog.Show(this);
221        if (AreMultipleCellsSelected()) {
222          ResetHighlightedCellsBackground();
223          HightlightedCellsBackground = GetSelectedCells();
224          dataGridView.ClearSelection();
225        }
226        findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
227        findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
228        findAndReplaceDialog.ReplaceAllEvent += findAndReplaceDialog_ReplaceAllEvent;
229        findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
230        findAndReplaceDialog.FormClosing += findAndReplaceDialog_FormClosing;
231        searchIterator = null;
232        DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
233        if (Content.FilterLogic.IsFiltered) {
234          findAndReplaceDialog.DisableReplace();
235        }
236      }
237    }
238
239    private void DataGridView_SelectionChanged_FindAndReplace(object sender, EventArgs e) {
240      if (Content != null) {
241        if (!isSearching && AreMultipleCellsSelected()) {
242          ResetHighlightedCellsBackground();
243          HightlightedCellsBackground = GetSelectedCells();
244          searchIterator = null;
245        }
246      }
247    }
248
249    void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) {
250      ResetHighlightedCellsBackground();
251      searchIterator = null;
252      DataGridView.SelectionChanged -= DataGridView_SelectionChanged_FindAndReplace;
253    }
254
255    void findAndReplaceDialog_ReplaceEvent(object sender, EventArgs e) {
256      if (searchIterator != null && searchIterator.GetCurrent() != null) {
257        Replace(TransformToDictionary(currentCell));
258      }
259    }
260
261    void findAndReplaceDialog_ReplaceAllEvent(object sender, EventArgs e) {
262      Replace(FindAll(findAndReplaceDialog.GetSearchText()));
263    }
264
265    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
266      if (searchIterator == null
267        || currentSearchText != findAndReplaceDialog.GetSearchText()
268        || currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
269
270        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
271        currentSearchText = findAndReplaceDialog.GetSearchText();
272        currentComparisonOperation = findAndReplaceDialog.GetComparisonOperation();
273      }
274
275      if (IsOneCellSelected()) {
276        var first = GetSelectedCells().First();
277        searchIterator.SetStartCell(first.Key, first.Value[0]);
278      }
279
280      bool moreOccurences = false;
281      currentCell = searchIterator.GetCurrent();
282      moreOccurences = searchIterator.MoveNext();
283      if (IsOneCellSelected() && currentCell != null) {
284        var first = GetSelectedCells().First();
285        if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) {
286          if (!moreOccurences) {
287            searchIterator.Reset();
288          }
289          currentCell = searchIterator.GetCurrent();
290          moreOccurences = searchIterator.MoveNext();
291          if (!moreOccurences) {
292            searchIterator.Reset();
293          }
294        }
295      }
296
297      dataGridView.ClearSelection();
298
299      if (currentCell != null) {
300        dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
301        dataGridView.CurrentCell = dataGridView[currentCell.Item1, currentCell.Item2];
302      }
303    }
304
305    private bool AreMultipleCellsSelected() {
306      return GetSelectedCellCount() > 1;
307    }
308
309    private bool IsOneCellSelected() {
310      return GetSelectedCellCount() == 1;
311    }
312
313    private int GetSelectedCellCount() {
314      int count = 0;
315      foreach (var column in GetSelectedCells()) {
316        count += column.Value.Count();
317      }
318      return count;
319    }
320
321    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
322      dataGridView.ClearSelection();
323      isSearching = true;
324      SuspendRepaint();
325      var selectedCells = FindAll(findAndReplaceDialog.GetSearchText());
326      foreach (var column in selectedCells) {
327        foreach (var cell in column.Value) {
328          dataGridView[column.Key, cell].Selected = true;
329        }
330      }
331      ResumeRepaint(true);
332      isSearching = false;
333      Content.Selection = selectedCells;
334      //update statistic in base
335      base.dataGridView_SelectionChanged(sender, e);
336    }
337
338    private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) {
339      Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal;
340      switch (comparisonOperation) {
341        case ComparisonOperation.Equal:
342          constraintOperation = Core.ConstraintOperation.Equal;
343          break;
344        case ComparisonOperation.Greater:
345          constraintOperation = Core.ConstraintOperation.Greater;
346          break;
347        case ComparisonOperation.GreaterOrEqual:
348          constraintOperation = Core.ConstraintOperation.GreaterOrEqual;
349          break;
350        case ComparisonOperation.Less:
351          constraintOperation = Core.ConstraintOperation.Less;
352          break;
353        case ComparisonOperation.LessOrEqual:
354          constraintOperation = Core.ConstraintOperation.LessOrEqual;
355          break;
356        case ComparisonOperation.NotEqual:
357          constraintOperation = Core.ConstraintOperation.NotEqual;
358          break;
359      }
360      return constraintOperation;
361    }
362
363    private IDictionary<int, IList<int>> FindAll(string match) {
364      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
365      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
366      var foundCells = new Dictionary<int, IList<int>>();
367      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
368        var filters = CreateFilters(match, comparisonOperation, i);
369
370        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
371        var foundIndices = new List<int>();
372        for (int idx = 0; idx < filteredRows.Length; ++idx) {
373          var notFilteredThusFound = !filteredRows[idx];
374          if (notFilteredThusFound) {
375            foundIndices.Add(idx);
376          }
377        }
378        foundCells[i] = foundIndices;
379        IList<int> selectedList;
380        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
381          foundCells[i] = foundCells[i].Intersect(selectedList).ToList<int>();
382        } else if (searchInSelection) {
383          foundCells[i].Clear();
384        }
385      }
386      return MapToSorting(foundCells);
387    }
388
389    private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
390      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
391      IStringConvertibleValue value;
392      if (preprocessingData.VariableHasType<double>(columnIndex)) {
393        value = new DoubleValue();
394      } else if (preprocessingData.VariableHasType<String>(columnIndex)) {
395        value = new StringValue();
396      } else if (preprocessingData.VariableHasType<DateTime>(columnIndex)) {
397        value = new DateTimeValue();
398      } else {
399        throw new ArgumentException("unsupported type");
400      }
401      value.SetValue(match);
402      var comparisonFilter = new ComparisonFilter(preprocessingData, GetConstraintOperation(comparisonOperation), value, true);
403      comparisonFilter.ConstraintColumn = columnIndex;
404      return new List<Filter.IFilter>() { comparisonFilter };
405    }
406
407    private IDictionary<int, IList<int>> MapToSorting(Dictionary<int, IList<int>> foundCells) {
408      if (sortedColumnIndices.Count == 0) {
409        return foundCells;
410      } else {
411        var sortedFoundCells = new Dictionary<int, IList<int>>();
412
413        var indicesToVirtual = new Dictionary<int, int>();
414        for (int i = 0; i < virtualRowIndices.Length; ++i) {
415          indicesToVirtual.Add(virtualRowIndices[i], i);
416        }
417
418        foreach (var entry in foundCells) {
419          var cells = new List<int>();
420          foreach (var cell in entry.Value) {
421            cells.Add(indicesToVirtual[cell]);
422          }
423          cells.Sort();
424          sortedFoundCells.Add(entry.Key, cells);
425        }
426        return sortedFoundCells;
427      }
428    }
429
430    private void Replace(IDictionary<int, IList<int>> cells) {
431      if (findAndReplaceDialog != null) {
432        ReplaceTransaction(() => {
433          switch (findAndReplaceDialog.GetReplaceAction()) {
434            case ReplaceAction.Value:
435              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
436              break;
437            case ReplaceAction.Average:
438              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
439              break;
440            case ReplaceAction.Median:
441              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
442              break;
443            case ReplaceAction.Random:
444              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
445              break;
446            case ReplaceAction.MostCommon:
447              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
448              break;
449            case ReplaceAction.Interpolation:
450              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
451              break;
452          }
453        });
454      }
455    }
456
457    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
458      var highlightCells = new Dictionary<int, IList<int>>();
459      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
460      return highlightCells;
461    }
462
463    private void ResetHighlightedCellsBackground() {
464      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
465    }
466
467    #endregion FindAndReplaceDialog
468
469    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
470      if (Content == null) return;
471      if (e.Button == System.Windows.Forms.MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
472        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
473          replaceValueOverColumnToolStripMenuItem.Visible = false;
474          contextMenuCell.Show(MousePosition);
475        } else {
476          if (!dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, e.RowIndex])) {
477            dataGridView.ClearSelection();
478            dataGridView[e.ColumnIndex, e.RowIndex].Selected = true;
479          }
480
481          var columnIndices = new HashSet<int>();
482          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
483            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
484          }
485
486          replaceValueOverSelectionToolStripMenuItem.Enabled = AreMultipleCellsSelected();
487
488          averageToolStripMenuItem_Column.Enabled =
489            averageToolStripMenuItem_Selection.Enabled =
490            medianToolStripMenuItem_Column.Enabled =
491            medianToolStripMenuItem_Selection.Enabled =
492            randomToolStripMenuItem_Column.Enabled =
493            randomToolStripMenuItem_Selection.Enabled = !Content.PreProcessingData.AreAllStringColumns(columnIndices);
494
495          smoothingToolStripMenuItem_Column.Enabled =
496            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
497            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
498            && !Content.PreProcessingData.AreAllStringColumns(columnIndices);
499
500          replaceValueOverColumnToolStripMenuItem.Visible = true;
501          contextMenuCell.Show(MousePosition);
502        }
503      }
504    }
505
506    private void dataGridView_KeyDown(object sender, KeyEventArgs e) {
507      var selectedRows = dataGridView.SelectedRows;
508      var selectedCells = dataGridView.SelectedCells;
509      if (!Content.FilterLogic.IsFiltered) { //data is in read only mode....
510        if (e.KeyCode == Keys.Delete && selectedCells.Count == Content.Rows && selectedCells.Count > 0) {
511          Content.DeleteColumn(selectedCells[0].ColumnIndex);
512        } else if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
513          List<int> rows = new List<int>();
514          for (int i = 0; i < selectedRows.Count; ++i) {
515            int index = (sortedColumnIndices.Count != 0) ? (Convert.ToInt32(selectedRows[i].HeaderCell.Value) - 1) :
516              selectedRows[i].Index;
517            rows.Add(index);
518          }
519          Content.DeleteRows(rows);
520        } else if (e.Control && e.KeyCode == Keys.F) {
521          CreateFindAndReplaceDialog();
522          findAndReplaceDialog.ActivateSearch();
523        } else if (e.Control && e.KeyCode == Keys.R) {
524          CreateFindAndReplaceDialog();
525          findAndReplaceDialog.ActivateReplace();
526        }
527      }
528    }
529
530    private IDictionary<int, IList<int>> GetSelectedCells() {
531      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
532
533      //special case if all cells are selected
534      if (dataGridView.AreAllCellsSelected(true)) {
535        for (int i = 0; i < Content.Columns; i++)
536          selectedCells[i] = Enumerable.Range(0, Content.Rows).ToList();
537        return selectedCells;
538      }
539
540      foreach (var selectedCell in dataGridView.SelectedCells) {
541        var cell = (DataGridViewCell)selectedCell;
542        if (!selectedCells.ContainsKey(cell.ColumnIndex))
543          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
544        selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
545      }
546
547      return selectedCells;
548    }
549
550    private void StartReplacing() {
551      SuspendRepaint();
552    }
553
554    private void StopReplacing() {
555      ResumeRepaint(true);
556    }
557
558    private void ReplaceTransaction(Action action) {
559      StartReplacing();
560      action();
561      StopReplacing();
562    }
563
564    private void btnSearch_Click(object sender, EventArgs e) {
565      CreateFindAndReplaceDialog();
566      findAndReplaceDialog.ActivateSearch();
567    }
568
569    private void btnReplace_Click(object sender, EventArgs e) {
570      CreateFindAndReplaceDialog();
571      findAndReplaceDialog.ActivateReplace();
572    }
573
574    #region ContextMenu Events
575
576    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
577      ReplaceTransaction(() => {
578        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
579      });
580    }
581    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
582      ReplaceTransaction(() => {
583        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
584      });
585    }
586
587    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
588      ReplaceTransaction(() => {
589        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
590      });
591    }
592    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
593      ReplaceTransaction(() => {
594        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
595      });
596    }
597
598    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
599      ReplaceTransaction(() => {
600        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
601      });
602    }
603    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
604      ReplaceTransaction(() => {
605        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
606      });
607    }
608
609    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
610      ReplaceTransaction(() => {
611        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
612      });
613    }
614    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
615      ReplaceTransaction(() => {
616        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
617      });
618    }
619
620    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
621      ReplaceTransaction(() => {
622        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
623      });
624    }
625
626    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
627      ReplaceTransaction(() => {
628        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
629      });
630    }
631    #endregion
632
633    private void addLineButton_Click(object sender, EventArgs e) {
634      Content.PreProcessingData.InsertRow(Content.Rows);
635    }
636
637    private void addColumnButton_Click(object sender, EventArgs e) {
638      Content.PreProcessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
639    }
640
641  }
642}
Note: See TracBrowser for help on using the repository browser.