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

Last change on this file since 10870 was 10870, checked in by sbreuer, 8 years ago
  • offer search comparison options
File size: 3.0 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 enum ComparisonOperation {
16    Equal,
17    Less,
18    LessOrEqual,
19    Greater,
20    GreaterOrEqual,
21    NotEqual
22  }
23
24  public partial class SearchAndReplaceDialog : Form {
25    private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
26    private string[] cmbComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" };
27
28    public SearchAndReplaceDialog() {
29      InitializeComponent();
30      cmbReplaceWith.Items.AddRange(cmbItemsText);
31      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
32      cmbComparisonOperator.Items.AddRange(cmbComparisonOperatorText);
33      cmbComparisonOperator.SelectedIndex = (int)ComparisonOperation.Equal;
34    }
35
36    public void ActivateSearch() {
37      tabSearchReplace.SelectTab(tabSearch);
38      AddControlsToCurrentTab();
39    }
40
41    public void ActivateReplace() {
42      tabSearchReplace.SelectTab(tabReplace);
43      AddControlsToCurrentTab();
44    }
45
46    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
47      AddControlsToCurrentTab();
48    }
49
50    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
51      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
52    }
53
54    private void AddControlsToCurrentTab() {
55      tabSearchReplace.SelectedTab.Controls.Add(btnFindAll);
56      tabSearchReplace.SelectedTab.Controls.Add(btnFindNext);
57      tabSearchReplace.SelectedTab.Controls.Add(lblSearch);
58      tabSearchReplace.SelectedTab.Controls.Add(txtSearchString);
59      tabSearchReplace.SelectedTab.Controls.Add(cmbComparisonOperator);
60      ActiveControl = txtSearchString;
61      AcceptButton = btnFindNext;
62    }
63
64    public String GetSearchText() {
65      return txtSearchString.Text;
66    }
67
68    public string GetReplaceText() {
69      return txtValue.Text;
70    }
71
72    public ReplaceAction GetReplaceAction() {
73      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
74    }
75
76    public ComparisonOperation GetComparisonOperation() {
77      return (ComparisonOperation)cmbComparisonOperator.SelectedIndex;
78    }
79
80    public event EventHandler FindAllEvent {
81      add { btnFindAll.Click += value; }
82      remove { btnFindAll.Click -= value; }
83    }
84
85    public event EventHandler FindNextEvent {
86      add { btnFindNext.Click += value; }
87      remove { btnFindNext.Click -= value; }
88    }
89
90    public event EventHandler ReplaceAllEvent {
91      add { btnReplaceAll.Click += value; }
92      remove { btnReplaceAll.Click -= value; }
93    }
94
95    public event EventHandler ReplaceNextEvent {
96      add { btnReplace.Click += value; }
97      remove { btnReplace.Click -= value; }
98    }
99     
100  }
101}
Note: See TracBrowser for help on using the repository browser.