Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 10946 was 10946, checked in by sbreuer, 10 years ago
  • always show selected cell
File size: 23.2 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;
[10946]286        dataGridView.CurrentCell = dataGridView[currentCell.Item1, currentCell.Item2];
[10698]287      }
[10852]288    }
289
290    private bool AreMultipleCellsSelected() {
291      return GetSelectedCellCount() > 1;
292    }
293
294    private bool IsOneCellSelected() {
295      return GetSelectedCellCount() == 1;
296    }
297
298    private int GetSelectedCellCount() {
299      int count = 0;
300      foreach (var column in GetSelectedCells()) {
301        count += column.Value.Count();
[10706]302      }
[10852]303      return count;
[10636]304    }
305
306    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
[10870]307      dataGridView.ClearSelection();
308      isSearching = true;
[10901]309      SuspendRepaint();
[10916]310      var selectedCells = FindAll(findAndReplaceDialog.GetSearchText());
311      foreach (var column in selectedCells) {
[10870]312        foreach (var cell in column.Value) {
313          dataGridView[column.Key, cell].Selected = true;
314        }
315      }
[10901]316      ResumeRepaint(true);
[10870]317      isSearching = false;
[10916]318      Content.DataGridLogic.SetSelection(selectedCells);
319      //update statistic in base
320      base.dataGridView_SelectionChanged(sender, e);
[10636]321    }
322
[10870]323    private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) {
324      Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal;
325      switch (comparisonOperation) {
326        case ComparisonOperation.Equal:
327          constraintOperation = Core.ConstraintOperation.Equal;
328          break;
329        case ComparisonOperation.Greater:
330          constraintOperation = Core.ConstraintOperation.Greater;
331          break;
332        case ComparisonOperation.GreaterOrEqual:
333          constraintOperation = Core.ConstraintOperation.GreaterOrEqual;
334          break;
335        case ComparisonOperation.Less:
336          constraintOperation = Core.ConstraintOperation.Less;
337          break;
338        case ComparisonOperation.LessOrEqual:
339          constraintOperation = Core.ConstraintOperation.LessOrEqual;
340          break;
341        case ComparisonOperation.NotEqual:
342          constraintOperation = Core.ConstraintOperation.NotEqual;
343          break;
344      }
345      return constraintOperation;
346    }
347
[10672]348    private IDictionary<int, IList<int>> FindAll(string match) {
[10719]349      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
[10870]350      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
351      var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, GetConstraintOperation(comparisonOperation), new StringValue(match), true);
[10672]352      var filters = new List<Filter.IFilter>() { comparisonFilter };
353      var foundCells = new Dictionary<int, IList<int>>();
354      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
355        comparisonFilter.ConstraintColumn = i;
[10844]356        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
357        var foundIndices = new List<int>();
358        for (int idx = 0; idx < filteredRows.Length; ++idx) {
359          var notFilteredThusFound = !filteredRows[idx];
360          if (notFilteredThusFound) {
361            foundIndices.Add(idx);
362          }
363        }
364        foundCells[i] = foundIndices;
[10719]365        IList<int> selectedList;
366        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
[10739]367          foundCells[i] = foundCells[i].Intersect(selectedList).ToList<int>();
368        } else if (searchInSelection) {
[10719]369          foundCells[i].Clear();
370        }
[10672]371      }
372      return foundCells;
373    }
374
375    private void Replace(IDictionary<int, IList<int>> cells) {
376      if (findAndReplaceDialog != null) {
[10938]377        ReplaceTransaction(() => {
378          switch (findAndReplaceDialog.GetReplaceAction()) {
379            case ReplaceAction.Value:
380              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
381              break;
382            case ReplaceAction.Average:
383              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
384              break;
385            case ReplaceAction.Median:
386              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
387              break;
388            case ReplaceAction.Random:
389              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
390              break;
391            case ReplaceAction.MostCommon:
392              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
393              break;
394            case ReplaceAction.Interpolation:
395              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
396              break;
397          }
398        });
[10672]399      }
400    }
401
[10698]402    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
[10672]403      var highlightCells = new Dictionary<int, IList<int>>();
[10698]404      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
[10672]405      return highlightCells;
406    }
407
[10719]408    private void ResetHighlightedCellsBackground() {
409      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
410    }
411
[10698]412    #endregion FindAndReplaceDialog
413
[10380]414    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
415      if (Content == null) return;
416      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
417        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
[10769]418          replaceValueOverColumnToolStripMenuItem.Visible = false;
[10627]419          contextMenuCell.Show(MousePosition);
[10380]420        } else {
[10590]421          if (!dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, e.RowIndex])) {
422            dataGridView.ClearSelection();
423            dataGridView[e.ColumnIndex, e.RowIndex].Selected = true;
424          }
[10812]425
[10621]426          var columnIndices = new HashSet<int>();
427          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
428            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
429          }
[10875]430
431          replaceValueOverSelectionToolStripMenuItem.Enabled = AreMultipleCellsSelected();
432
[10812]433          averageToolStripMenuItem_Column.Enabled =
434            averageToolStripMenuItem_Selection.Enabled =
435            medianToolStripMenuItem_Column.Enabled =
436            medianToolStripMenuItem_Selection.Enabled =
437            randomToolStripMenuItem_Column.Enabled =
438            randomToolStripMenuItem_Selection.Enabled = !Content.DataGridLogic.AreAllStringColumns(columnIndices);
439
440          smoothingToolStripMenuItem_Column.Enabled =
[10820]441            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
442            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
[10812]443            && !Content.DataGridLogic.AreAllStringColumns(columnIndices);
444
[10769]445          replaceValueOverColumnToolStripMenuItem.Visible = true;
[10380]446          contextMenuCell.Show(MousePosition);
447        }
448      }
449    }
450
[10585]451    protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
452      if (Content == null) return;
453      if (e.RowIndex < 0) return;
454      if (e.ColumnIndex < 0) return;
455      if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;
456      if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;
[10870]457      if (HighlightedRowIndices == null) return;
[10574]458
[10585]459      int rowIndex = virtualRowIndices[e.RowIndex];
[10574]460
[10585]461      Color backColor = e.CellStyle.BackColor;
[10574]462
[10719]463      if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {
464        backColor = Color.LightGray;
465      }
[10574]466
[10585]467      using (Brush backColorBrush = new SolidBrush(backColor)) {
468        Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
469        e.Graphics.FillRectangle(backColorBrush, bounds);
470      }
[10712]471
[10585]472      using (Brush gridBrush = new SolidBrush(Color.LightGray)) {
473        Pen gridLinePen = new Pen(gridBrush);
474        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
475               e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
476               e.CellBounds.Bottom - 1);
477        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
478            e.CellBounds.Top, e.CellBounds.Right - 1,
479            e.CellBounds.Bottom);
480      }
481
482      e.PaintContent(e.CellBounds);
483      e.Handled = true;
[10574]484    }
485
[10668]486    void dataGridView_KeyDown(object sender, KeyEventArgs e) {
487      var selectedRows = dataGridView.SelectedRows;
488      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
489        List<int> rows = new List<int>();
490        for (int i = 0; i < selectedRows.Count; ++i) {
491          rows.Add(selectedRows[i].Index);
492        }
493        triggersOwnEvent(() => {
494          Content.DataGridLogic.DeleteRow(rows);
495          OnContentChanged();
496        });
497      } else if (e.Control && e.KeyCode == Keys.F) {
498        CreateFindAndReplaceDialog();
499        findAndReplaceDialog.ActivateSearch();
500      } else if (e.Control && e.KeyCode == Keys.R) {
501        CreateFindAndReplaceDialog();
502        findAndReplaceDialog.ActivateReplace();
503      }
504    }
505
[10345]506    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
507      btnApplySort.Enabled = sortedColumns.Any();
508      return base.Sort(sortedColumns);
509    }
510
511    protected override void ClearSorting() {
512      btnApplySort.Enabled = false;
513      base.ClearSorting();
514    }
[10380]515
[10672]516    private IDictionary<int, IList<int>> GetSelectedCells() {
517      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
[10590]518      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
[10622]519        var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
520        if (!selectedCells.ContainsKey(columnIndex)) {
521          selectedCells.Add(columnIndex, new List<int>());
[10590]522        }
523        selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
524      }
525      return selectedCells;
526    }
527
[10938]528    private void StartReplacing() {
529      isReplacing = true;
530      SuspendRepaint();
531    }
532
533    private void StopReplacing() {
534      isReplacing = false;
535      ResumeRepaint(true);
536    }
537
538    private void ReplaceTransaction(Action action) {
539      StartReplacing();
540      action();
541      StopReplacing();
542    }
543
[10769]544    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
[10938]545      ReplaceTransaction(() => {
546        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
547      });
[10380]548    }
[10809]549    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
[10938]550      ReplaceTransaction(() => {
551        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
552      });
[10809]553    }
[10380]554
[10769]555    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
[10938]556      ReplaceTransaction(() => {
557        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
558      });
[10380]559    }
[10809]560    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
[10938]561      ReplaceTransaction(() => {
562        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
563      });
[10809]564    }
[10380]565
[10769]566    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
[10938]567      ReplaceTransaction(() => {
568        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
569      });
[10380]570    }
[10809]571    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
[10938]572      ReplaceTransaction(() => {
573        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
574      });
[10809]575    }
[10380]576
[10769]577    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
[10938]578      ReplaceTransaction(() => {
579        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
580      });
[10380]581    }
[10809]582    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
[10938]583      ReplaceTransaction(() => {
584        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
585      });
[10809]586    }
[10380]587
[10769]588    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
[10938]589      ReplaceTransaction(() => {
590        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
591      });
[10380]592    }
[10769]593
594    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
[10938]595      ReplaceTransaction(() => {
596        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
597      });
[10769]598    }
599
[10764]600    private void btnSearch_Click(object sender, EventArgs e) {
[10762]601      CreateFindAndReplaceDialog();
602      findAndReplaceDialog.ActivateSearch();
603    }
604
605    private void btnReplace_Click(object sender, EventArgs e) {
606      CreateFindAndReplaceDialog();
607      findAndReplaceDialog.ActivateReplace();
608    }
[10236]609  }
610}
Note: See TracBrowser for help on using the repository browser.