Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11114 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
RevLine 
[10636]1using System;
2using System.Windows.Forms;
[10630]3
4namespace HeuristicLab.DataPreprocessing.Views {
[10672]5  public enum ReplaceAction {
6    Value,
7    Average,
8    Median,
9    Random,
10    MostCommon,
11    Interpolation
12  }
13
[10870]14  public enum ComparisonOperation {
15    Equal,
16    Less,
17    LessOrEqual,
18    Greater,
19    GreaterOrEqual,
20    NotEqual
21  }
22
[10930]23
24
[10762]25  public partial class SearchAndReplaceDialog : Form {
[10672]26    private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
[10870]27    private string[] cmbComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" };
[10672]28
[10762]29    public SearchAndReplaceDialog() {
[10630]30      InitializeComponent();
[10672]31      cmbReplaceWith.Items.AddRange(cmbItemsText);
32      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
[10870]33      cmbComparisonOperator.Items.AddRange(cmbComparisonOperatorText);
34      cmbComparisonOperator.SelectedIndex = (int)ComparisonOperation.Equal;
[10630]35    }
36
[10633]37    public void ActivateSearch() {
[10739]38      tabSearchReplace.SelectTab(tabSearch);
[10636]39      AddControlsToCurrentTab();
[10633]40    }
41
42    public void ActivateReplace() {
[10739]43      tabSearchReplace.SelectTab(tabReplace);
[10636]44      AddControlsToCurrentTab();
[10633]45    }
46
[10930]47    public void DisableReplace() {
48      tabSearchReplace.SelectTab(tabSearch);
49      tabReplace.Enabled = false;
50    }
51
52    public void EnableReplace() {
53      tabReplace.Enabled = true;
54    }
55
[10636]56    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
57      AddControlsToCurrentTab();
[10630]58    }
59
[10672]60    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
61      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
62    }
63
[10636]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);
[10870]69      tabSearchReplace.SelectedTab.Controls.Add(cmbComparisonOperator);
[10739]70      ActiveControl = txtSearchString;
71      AcceptButton = btnFindNext;
[10636]72    }
73
[10672]74    public String GetSearchText() {
[10636]75      return txtSearchString.Text;
76    }
77
78    public string GetReplaceText() {
79      return txtValue.Text;
80    }
81
[10672]82    public ReplaceAction GetReplaceAction() {
83      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
[10636]84    }
85
[10870]86    public ComparisonOperation GetComparisonOperation() {
87      return (ComparisonOperation)cmbComparisonOperator.SelectedIndex;
88    }
89
[10636]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 {
[10672]106      add { btnReplace.Click += value; }
107      remove { btnReplace.Click -= value; }
[10636]108    }
[10630]109  }
110}
Note: See TracBrowser for help on using the repository browser.