Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceOverhaul/HeuristicLab.DataPreprocessing.Views/3.4/SearchAndReplaceDialog.cs @ 18242

Last change on this file since 18242 was 10930, checked in by rstoll, 10 years ago
  • Disabled Replace tab in SearchAndReplaceDialog if a filter is active
  • Disabled Replace button in DataGridview if filter is active
  • Refactored/Changed IFilterLogic#IsFiltered from method to property
File size: 3.1 KB
Line 
1using System;
2using System.Windows.Forms;
3
4namespace HeuristicLab.DataPreprocessing.Views {
5  public enum ReplaceAction {
6    Value,
7    Average,
8    Median,
9    Random,
10    MostCommon,
11    Interpolation
12  }
13
14  public enum ComparisonOperation {
15    Equal,
16    Less,
17    LessOrEqual,
18    Greater,
19    GreaterOrEqual,
20    NotEqual
21  }
22
23
24
25  public partial class SearchAndReplaceDialog : Form {
26    private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
27    private string[] cmbComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" };
28
29    public SearchAndReplaceDialog() {
30      InitializeComponent();
31      cmbReplaceWith.Items.AddRange(cmbItemsText);
32      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
33      cmbComparisonOperator.Items.AddRange(cmbComparisonOperatorText);
34      cmbComparisonOperator.SelectedIndex = (int)ComparisonOperation.Equal;
35    }
36
37    public void ActivateSearch() {
38      tabSearchReplace.SelectTab(tabSearch);
39      AddControlsToCurrentTab();
40    }
41
42    public void ActivateReplace() {
43      tabSearchReplace.SelectTab(tabReplace);
44      AddControlsToCurrentTab();
45    }
46
47    public void DisableReplace() {
48      tabSearchReplace.SelectTab(tabSearch);
49      tabReplace.Enabled = false;
50    }
51
52    public void EnableReplace() {
53      tabReplace.Enabled = true;
54    }
55
56    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
57      AddControlsToCurrentTab();
58    }
59
60    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
61      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
62    }
63
64    private void AddControlsToCurrentTab() {
65      tabSearchReplace.SelectedTab.Controls.Add(btnFindAll);
66      tabSearchReplace.SelectedTab.Controls.Add(btnFindNext);
67      tabSearchReplace.SelectedTab.Controls.Add(lblSearch);
68      tabSearchReplace.SelectedTab.Controls.Add(txtSearchString);
69      tabSearchReplace.SelectedTab.Controls.Add(cmbComparisonOperator);
70      ActiveControl = txtSearchString;
71      AcceptButton = btnFindNext;
72    }
73
74    public String GetSearchText() {
75      return txtSearchString.Text;
76    }
77
78    public string GetReplaceText() {
79      return txtValue.Text;
80    }
81
82    public ReplaceAction GetReplaceAction() {
83      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
84    }
85
86    public ComparisonOperation GetComparisonOperation() {
87      return (ComparisonOperation)cmbComparisonOperator.SelectedIndex;
88    }
89
90    public event EventHandler FindAllEvent {
91      add { btnFindAll.Click += value; }
92      remove { btnFindAll.Click -= value; }
93    }
94
95    public event EventHandler FindNextEvent {
96      add { btnFindNext.Click += value; }
97      remove { btnFindNext.Click -= value; }
98    }
99
100    public event EventHandler ReplaceAllEvent {
101      add { btnReplaceAll.Click += value; }
102      remove { btnReplaceAll.Click -= value; }
103    }
104
105    public event EventHandler ReplaceNextEvent {
106      add { btnReplace.Click += value; }
107      remove { btnReplace.Click -= value; }
108    }
109  }
110}
Note: See TracBrowser for help on using the repository browser.