Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/SearchAndReplaceDialog.cs @ 10776

Last change on this file since 10776 was 10762, checked in by rstoll, 11 years ago
  • Renamed FindAndReplace to SearchAndReplace
  • Added "Search" and "Replace" buttons to DataGrid
File size: 2.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Windows.Forms;
4
5namespace HeuristicLab.DataPreprocessing.Views {
6  public enum ReplaceAction {
7    Value,
8    Average,
9    Median,
10    Random,
11    MostCommon,
12    Interpolation
13  }
14
15  public partial class SearchAndReplaceDialog : Form {
16    private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
17
18    public SearchAndReplaceDialog() {
19      InitializeComponent();
20      cmbReplaceWith.Items.AddRange(cmbItemsText);
21      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
22    }
23
24    public void ActivateSearch() {
25      tabSearchReplace.SelectTab(tabSearch);
26      AddControlsToCurrentTab();
27    }
28
29    public void ActivateReplace() {
30      tabSearchReplace.SelectTab(tabReplace);
31      AddControlsToCurrentTab();
32    }
33
34    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
35      AddControlsToCurrentTab();
36    }
37
38    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
39      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
40    }
41
42    private void AddControlsToCurrentTab() {
43      tabSearchReplace.SelectedTab.Controls.Add(btnFindAll);
44      tabSearchReplace.SelectedTab.Controls.Add(btnFindNext);
45      tabSearchReplace.SelectedTab.Controls.Add(lblSearch);
46      tabSearchReplace.SelectedTab.Controls.Add(txtSearchString);
47      ActiveControl = txtSearchString;
48      AcceptButton = btnFindNext;
49    }
50
51    public String GetSearchText() {
52      return txtSearchString.Text;
53    }
54
55    public string GetReplaceText() {
56      return txtValue.Text;
57    }
58
59    public ReplaceAction GetReplaceAction() {
60      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
61    }
62
63    public event EventHandler FindAllEvent {
64      add { btnFindAll.Click += value; }
65      remove { btnFindAll.Click -= value; }
66    }
67
68    public event EventHandler FindNextEvent {
69      add { btnFindNext.Click += value; }
70      remove { btnFindNext.Click -= value; }
71    }
72
73    public event EventHandler ReplaceAllEvent {
74      add { btnReplaceAll.Click += value; }
75      remove { btnReplaceAll.Click -= value; }
76    }
77
78    public event EventHandler ReplaceNextEvent {
79      add { btnReplace.Click += value; }
80      remove { btnReplace.Click -= value; }
81    }
82     
83  }
84}
Note: See TracBrowser for help on using the repository browser.