Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 10938 was 10938, checked in by mleitner, 10 years ago

Improve context menu replace performance by disabling repaint

File size: 23.1 KB
RevLine 
[10539]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
[10534]22using System;
23using System.Collections.Generic;
[10622]24using System.Drawing;
[10534]25using System.Linq;
[10236]26using System.Windows.Forms;
[10672]27using HeuristicLab.Data;
[10719]28using HeuristicLab.DataPreprocessing.Filter;
[10236]29using HeuristicLab.MainForm;
30
[10558]31namespace HeuristicLab.DataPreprocessing.Views {
[10236]32  [View("Data Grid Content View")]
[10311]33  [Content(typeof(IDataGridContent), true)]
[10583]34  public partial class DataGridContentView : CopyOfStringConvertibleMatrixView {
[10236]35
[10583]36    private bool notOwnEvent = true;
[10870]37    private bool isSearching = false;
[10938]38    private bool isReplacing = false;
[10934]39    private bool updateOnMouseUp = false;
[10762]40    private SearchAndReplaceDialog findAndReplaceDialog;
[10698]41    private IFindPreprocessingItemsIterator searchIterator;
[10672]42    private string currentSearchText;
[10870]43    private ComparisonOperation currentComparisonOperation;
[10706]44    private Tuple<int, int> currentCell;
[10583]45
[10236]46    public new IDataGridContent Content {
47      get { return (IDataGridContent)base.Content; }
48      set { base.Content = value; }
49    }
50
[10574]51    private IList<int> _highlightedRowIndices;
[10623]52    public IList<int> HighlightedRowIndices {
[10585]53      get { return _highlightedRowIndices; }
54      set {
55        _highlightedRowIndices = value;
56        Refresh();
57      }
[10574]58    }
59
[10719]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
[10236]69    public DataGridContentView() {
70      InitializeComponent();
[10380]71      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
[10585]72      dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
[10668]73      dataGridView.KeyDown += dataGridView_KeyDown;
[10934]74      dataGridView.MouseUp += dataGridView_MouseUp;
[10380]75      contextMenuCell.Items.Add(ShowHideColumns);
[10623]76      _highlightedRowIndices = new List<int>();
[10719]77      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
[10706]78      currentCell = null;
[10236]79    }
80
[10916]81    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
82      if (Content != null) {
[10938]83        if (!isSearching && !isReplacing) {
[10934]84
85          if (Control.MouseButtons == MouseButtons.Left) {
86            updateOnMouseUp = true;
87            return;
88          }
89           
[10916]90          base.dataGridView_SelectionChanged(sender, e);
[10934]91       
[10916]92          Content.DataGridLogic.SetSelection(GetSelectedCells());
93        }
[10870]94      }
[10804]95    }
96
[10934]97    private void dataGridView_MouseUp(object sender, MouseEventArgs e) {
98      if (!updateOnMouseUp)
99        return;
100
101      updateOnMouseUp = false;
102      dataGridView_SelectionChanged(sender, e);
103    }                                     
104
[10236]105    protected override void OnContentChanged() {
106      base.OnContentChanged();
[10898]107      // ToDo: Temporarily disabled because needs to much performance
108      //DataGridView.AutoResizeColumns();
109      //DataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
[10911]110      DataGridView.RowHeadersWidth = 70;
[10739]111      if (Content == null && findAndReplaceDialog != null) {
112        findAndReplaceDialog.Close();
113      }
[10236]114    }
115
[10571]116    protected override void RegisterContentEvents() {
117      base.RegisterContentEvents();
118      Content.Changed += Content_Changed;
[10900]119      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
[10571]120    }
121
122    protected override void DeregisterContentEvents() {
123      base.DeregisterContentEvents();
124      Content.Changed -= Content_Changed;
[10900]125      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
[10571]126    }
127
[10930]128    void FilterLogic_FilterChanged(object sender, EventArgs e) {
129      OnContentChanged();
130      searchIterator = null;
131      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
132        if (Content.FilterLogic.IsFiltered) {
133          findAndReplaceDialog.DisableReplace();
134        } else {
135          findAndReplaceDialog.EnableReplace();
136        }
137      }
138      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
139    }
140
[10571]141    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
[10583]142      if (notOwnEvent) {
[10622]143        switch (e.Type) {
144          case DataPreprocessingChangedEventType.ChangeColumn:
145          case DataPreprocessingChangedEventType.ChangeItem:
146            dataGridView.Refresh();
147            break;
[10817]148          default:
149            OnContentChanged();
150            break;
[10622]151        }
[10583]152      }
[10852]153      searchIterator = null;
[10571]154    }
155
[10583]156    protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
[10236]157      if (!dataGridView.ReadOnly) {
158        string errorMessage;
[10916]159        if (Content != null) {
[10930]160          if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
[10900]161            errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
162          } else {
163            Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);
164          }
165
166          if (!String.IsNullOrEmpty(errorMessage)) {
167            e.Cancel = true;
168            dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
169          }
[10236]170        }
171      }
172    }
[10253]173
[10583]174    protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) {
[10585]175      triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e));
[10583]176    }
177
178    protected override void PasteValuesToDataGridView() {
[10585]179      triggersOwnEvent(() => base.PasteValuesToDataGridView());
[10583]180    }
181
[10317]182    protected override void SetEnabledStateOfControls() {
183      base.SetEnabledStateOfControls();
184      rowsTextBox.ReadOnly = true;
185      columnsTextBox.ReadOnly = true;
186    }
187
[10253]188    private void btnApplySort_Click(object sender, System.EventArgs e) {
[10585]189      triggersOwnEvent(() => {
[10809]190        Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
[10585]191        OnContentChanged();
192      });
[10253]193    }
[10345]194
[10585]195    private void triggersOwnEvent(Action action) {
196      notOwnEvent = false;
197      action();
198      notOwnEvent = true;
199    }
200
[10698]201    #region FindAndReplaceDialog
[10585]202
[10636]203    private void CreateFindAndReplaceDialog() {
[10876]204      if (findAndReplaceDialog == null || findAndReplaceDialog.IsDisposed) {
205        findAndReplaceDialog = new SearchAndReplaceDialog();
206        findAndReplaceDialog.Show(this);
207        if (AreMultipleCellsSelected()) {
208          ResetHighlightedCellsBackground();
209          HightlightedCellsBackground = GetSelectedCells();
210          dataGridView.ClearSelection();
211        }
212        findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
213        findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
214        findAndReplaceDialog.ReplaceAllEvent += findAndReplaceDialog_ReplaceAllEvent;
215        findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
216        findAndReplaceDialog.FormClosing += findAndReplaceDialog_FormClosing;
217        searchIterator = null;
218        DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
[10930]219        if (Content.FilterLogic.IsFiltered) {
220          findAndReplaceDialog.DisableReplace();
221        }
[10852]222      }
[10636]223    }
224
[10916]225    private void DataGridView_SelectionChanged_FindAndReplace(object sender, EventArgs e) {
[10863]226      if (Content != null) {
[10870]227        if (!isSearching && AreMultipleCellsSelected()) {
[10863]228          ResetHighlightedCellsBackground();
229          HightlightedCellsBackground = GetSelectedCells();
230          searchIterator = null;
231        }
232      }
233    }
234
[10705]235    void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) {
[10719]236      ResetHighlightedCellsBackground();
[10852]237      searchIterator = null;
[10863]238      DataGridView.SelectionChanged -= DataGridView_SelectionChanged_FindAndReplace;
[10705]239    }
240
[10672]241    void findAndReplaceDialog_ReplaceEvent(object sender, EventArgs e) {
[10712]242      if (searchIterator != null && searchIterator.GetCurrent() != null) {
[10706]243        Replace(TransformToDictionary(currentCell));
[10672]244      }
[10636]245    }
246
247    void findAndReplaceDialog_ReplaceAllEvent(object sender, EventArgs e) {
[10672]248      Replace(FindAll(findAndReplaceDialog.GetSearchText()));
[10636]249    }
250
251    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
[10876]252      if (searchIterator == null ||
253        currentSearchText != findAndReplaceDialog.GetSearchText() ||
[10870]254        currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) {
[10698]255        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
256        currentSearchText = findAndReplaceDialog.GetSearchText();
[10870]257        currentComparisonOperation = findAndReplaceDialog.GetComparisonOperation();
[10698]258      }
[10870]259
[10852]260      if (IsOneCellSelected()) {
261        var first = GetSelectedCells().First();
262        searchIterator.SetStartCell(first.Key, first.Value[0]);
263      }
[10712]264
[10705]265      bool moreOccurences = false;
[10870]266      currentCell = searchIterator.GetCurrent();
267      moreOccurences = searchIterator.MoveNext();
268      if (IsOneCellSelected() && currentCell != null) {
269        var first = GetSelectedCells().First();
270        if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) {
271          if (!moreOccurences) {
272            searchIterator.Reset();
[10852]273          }
[10870]274          currentCell = searchIterator.GetCurrent();
275          moreOccurences = searchIterator.MoveNext();
276          if (!moreOccurences) {
277            searchIterator.Reset();
278          }
[10852]279        }
[10870]280      }
[10672]281
[10870]282      dataGridView.ClearSelection();
283
[10705]284      if (currentCell != null) {
[10852]285        dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
[10698]286      }
[10852]287    }
288
289    private bool AreMultipleCellsSelected() {
290      return GetSelectedCellCount() > 1;
291    }
292
293    private bool IsOneCellSelected() {
294      return GetSelectedCellCount() == 1;
295    }
296
297    private int GetSelectedCellCount() {
298      int count = 0;
299      foreach (var column in GetSelectedCells()) {
300        count += column.Value.Count();
[10706]301      }
[10852]302      return count;
[10636]303    }
304
305    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
[10870]306      dataGridView.ClearSelection();
307      isSearching = true;
[10901]308      SuspendRepaint();
[10916]309      var selectedCells = FindAll(findAndReplaceDialog.GetSearchText());
310      foreach (var column in selectedCells) {
[10870]311        foreach (var cell in column.Value) {
312          dataGridView[column.Key, cell].Selected = true;
313        }
314      }
[10901]315      ResumeRepaint(true);
[10870]316      isSearching = false;
[10916]317      Content.DataGridLogic.SetSelection(selectedCells);
318      //update statistic in base
319      base.dataGridView_SelectionChanged(sender, e);
[10636]320    }
321
[10870]322    private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) {
323      Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal;
324      switch (comparisonOperation) {
325        case ComparisonOperation.Equal:
326          constraintOperation = Core.ConstraintOperation.Equal;
327          break;
328        case ComparisonOperation.Greater:
329          constraintOperation = Core.ConstraintOperation.Greater;
330          break;
331        case ComparisonOperation.GreaterOrEqual:
332          constraintOperation = Core.ConstraintOperation.GreaterOrEqual;
333          break;
334        case ComparisonOperation.Less:
335          constraintOperation = Core.ConstraintOperation.Less;
336          break;
337        case ComparisonOperation.LessOrEqual:
338          constraintOperation = Core.ConstraintOperation.LessOrEqual;
339          break;
340        case ComparisonOperation.NotEqual:
341          constraintOperation = Core.ConstraintOperation.NotEqual;
342          break;
343      }
344      return constraintOperation;
345    }
346
[10672]347    private IDictionary<int, IList<int>> FindAll(string match) {
[10719]348      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
[10870]349      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
350      var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, GetConstraintOperation(comparisonOperation), new StringValue(match), true);
[10672]351      var filters = new List<Filter.IFilter>() { comparisonFilter };
352      var foundCells = new Dictionary<int, IList<int>>();
353      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
354        comparisonFilter.ConstraintColumn = i;
[10844]355        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
356        var foundIndices = new List<int>();
357        for (int idx = 0; idx < filteredRows.Length; ++idx) {
358          var notFilteredThusFound = !filteredRows[idx];
359          if (notFilteredThusFound) {
360            foundIndices.Add(idx);
361          }
362        }
363        foundCells[i] = foundIndices;
[10719]364        IList<int> selectedList;
365        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
[10739]366          foundCells[i] = foundCells[i].Intersect(selectedList).ToList<int>();
367        } else if (searchInSelection) {
[10719]368          foundCells[i].Clear();
369        }
[10672]370      }
371      return foundCells;
372    }
373
374    private void Replace(IDictionary<int, IList<int>> cells) {
375      if (findAndReplaceDialog != null) {
[10938]376        ReplaceTransaction(() => {
377          switch (findAndReplaceDialog.GetReplaceAction()) {
378            case ReplaceAction.Value:
379              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
380              break;
381            case ReplaceAction.Average:
382              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
383              break;
384            case ReplaceAction.Median:
385              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
386              break;
387            case ReplaceAction.Random:
388              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
389              break;
390            case ReplaceAction.MostCommon:
391              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
392              break;
393            case ReplaceAction.Interpolation:
394              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
395              break;
396          }
397        });
[10672]398      }
399    }
400
[10698]401    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
[10672]402      var highlightCells = new Dictionary<int, IList<int>>();
[10698]403      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
[10672]404      return highlightCells;
405    }
406
[10719]407    private void ResetHighlightedCellsBackground() {
408      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
409    }
410
[10698]411    #endregion FindAndReplaceDialog
412
[10380]413    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
414      if (Content == null) return;
415      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
416        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
[10769]417          replaceValueOverColumnToolStripMenuItem.Visible = false;
[10627]418          contextMenuCell.Show(MousePosition);
[10380]419        } else {
[10590]420          if (!dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, e.RowIndex])) {
421            dataGridView.ClearSelection();
422            dataGridView[e.ColumnIndex, e.RowIndex].Selected = true;
423          }
[10812]424
[10621]425          var columnIndices = new HashSet<int>();
426          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
427            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
428          }
[10875]429
430          replaceValueOverSelectionToolStripMenuItem.Enabled = AreMultipleCellsSelected();
431
[10812]432          averageToolStripMenuItem_Column.Enabled =
433            averageToolStripMenuItem_Selection.Enabled =
434            medianToolStripMenuItem_Column.Enabled =
435            medianToolStripMenuItem_Selection.Enabled =
436            randomToolStripMenuItem_Column.Enabled =
437            randomToolStripMenuItem_Selection.Enabled = !Content.DataGridLogic.AreAllStringColumns(columnIndices);
438
439          smoothingToolStripMenuItem_Column.Enabled =
[10820]440            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
441            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
[10812]442            && !Content.DataGridLogic.AreAllStringColumns(columnIndices);
443
[10769]444          replaceValueOverColumnToolStripMenuItem.Visible = true;
[10380]445          contextMenuCell.Show(MousePosition);
446        }
447      }
448    }
449
[10585]450    protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
451      if (Content == null) return;
452      if (e.RowIndex < 0) return;
453      if (e.ColumnIndex < 0) return;
454      if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;
455      if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;
[10870]456      if (HighlightedRowIndices == null) return;
[10574]457
[10585]458      int rowIndex = virtualRowIndices[e.RowIndex];
[10574]459
[10585]460      Color backColor = e.CellStyle.BackColor;
[10574]461
[10719]462      if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {
463        backColor = Color.LightGray;
464      }
[10574]465
[10585]466      using (Brush backColorBrush = new SolidBrush(backColor)) {
467        Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
468        e.Graphics.FillRectangle(backColorBrush, bounds);
469      }
[10712]470
[10585]471      using (Brush gridBrush = new SolidBrush(Color.LightGray)) {
472        Pen gridLinePen = new Pen(gridBrush);
473        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
474               e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
475               e.CellBounds.Bottom - 1);
476        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
477            e.CellBounds.Top, e.CellBounds.Right - 1,
478            e.CellBounds.Bottom);
479      }
480
481      e.PaintContent(e.CellBounds);
482      e.Handled = true;
[10574]483    }
484
[10668]485    void dataGridView_KeyDown(object sender, KeyEventArgs e) {
486      var selectedRows = dataGridView.SelectedRows;
487      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
488        List<int> rows = new List<int>();
489        for (int i = 0; i < selectedRows.Count; ++i) {
490          rows.Add(selectedRows[i].Index);
491        }
492        triggersOwnEvent(() => {
493          Content.DataGridLogic.DeleteRow(rows);
494          OnContentChanged();
495        });
496      } else if (e.Control && e.KeyCode == Keys.F) {
497        CreateFindAndReplaceDialog();
498        findAndReplaceDialog.ActivateSearch();
499      } else if (e.Control && e.KeyCode == Keys.R) {
500        CreateFindAndReplaceDialog();
501        findAndReplaceDialog.ActivateReplace();
502      }
503    }
504
[10345]505    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
506      btnApplySort.Enabled = sortedColumns.Any();
507      return base.Sort(sortedColumns);
508    }
509
510    protected override void ClearSorting() {
511      btnApplySort.Enabled = false;
512      base.ClearSorting();
513    }
[10380]514
[10672]515    private IDictionary<int, IList<int>> GetSelectedCells() {
516      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
[10590]517      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
[10622]518        var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
519        if (!selectedCells.ContainsKey(columnIndex)) {
520          selectedCells.Add(columnIndex, new List<int>());
[10590]521        }
522        selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
523      }
524      return selectedCells;
525    }
526
[10938]527    private void StartReplacing() {
528      isReplacing = true;
529      SuspendRepaint();
530    }
531
532    private void StopReplacing() {
533      isReplacing = false;
534      ResumeRepaint(true);
535    }
536
537    private void ReplaceTransaction(Action action) {
538      StartReplacing();
539      action();
540      StopReplacing();
541    }
542
[10769]543    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
[10938]544      ReplaceTransaction(() => {
545        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
546      });
[10380]547    }
[10809]548    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
[10938]549      ReplaceTransaction(() => {
550        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
551      });
[10809]552    }
[10380]553
[10769]554    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
[10938]555      ReplaceTransaction(() => {
556        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
557      });
[10380]558    }
[10809]559    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
[10938]560      ReplaceTransaction(() => {
561        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
562      });
[10809]563    }
[10380]564
[10769]565    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
[10938]566      ReplaceTransaction(() => {
567        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
568      });
[10380]569    }
[10809]570    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
[10938]571      ReplaceTransaction(() => {
572        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
573      });
[10809]574    }
[10380]575
[10769]576    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
[10938]577      ReplaceTransaction(() => {
578        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
579      });
[10380]580    }
[10809]581    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
[10938]582      ReplaceTransaction(() => {
583        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
584      });
[10809]585    }
[10380]586
[10769]587    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
[10938]588      ReplaceTransaction(() => {
589        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
590      });
[10380]591    }
[10769]592
593    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
[10938]594      ReplaceTransaction(() => {
595        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
596      });
[10769]597    }
598
[10764]599    private void btnSearch_Click(object sender, EventArgs e) {
[10762]600      CreateFindAndReplaceDialog();
601      findAndReplaceDialog.ActivateSearch();
602    }
603
604    private void btnReplace_Click(object sender, EventArgs e) {
605      CreateFindAndReplaceDialog();
606      findAndReplaceDialog.ActivateReplace();
607    }
[10236]608  }
609}
Note: See TracBrowser for help on using the repository browser.