Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2893_BNLR/HeuristicLab.DataPreprocessing.Views/3.4/SearchAndReplaceDialog.cs @ 17305

Last change on this file since 17305 was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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
22using System;
23using System.Windows.Forms;
24
25namespace HeuristicLab.DataPreprocessing.Views {
26  public enum ReplaceAction {
27    Value,
28    Average,
29    Median,
30    Random,
31    MostCommon,
32    Interpolation
33  }
34
35  public enum ComparisonOperation {
36    Equal,
37    Less,
38    LessOrEqual,
39    Greater,
40    GreaterOrEqual,
41    NotEqual
42  }
43
44  public partial class SearchAndReplaceDialog : Form {
45    private static readonly string[] ItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
46    private static readonly string[] ComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" };
47
48    public SearchAndReplaceDialog() {
49      InitializeComponent();
50      cmbReplaceWith.Items.AddRange(ItemsText);
51      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
52      cmbComparisonOperator.Items.AddRange(ComparisonOperatorText);
53      cmbComparisonOperator.SelectedIndex = (int)ComparisonOperation.Equal;
54    }
55
56    public void ActivateSearch() {
57      tabSearchReplace.SelectTab(tabSearch);
58      AddControlsToCurrentTab();
59    }
60
61    public void ActivateReplace() {
62      tabSearchReplace.SelectTab(tabReplace);
63      AddControlsToCurrentTab();
64    }
65
66    public void DisableReplace() {
67      tabSearchReplace.SelectTab(tabSearch);
68      tabReplace.Enabled = false;
69    }
70
71    public void EnableReplace() {
72      tabReplace.Enabled = true;
73    }
74
75    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
76      AddControlsToCurrentTab();
77    }
78
79    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
80      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
81    }
82
83    private void AddControlsToCurrentTab() {
84      tabSearchReplace.SelectedTab.Controls.Add(btnFindAll);
85      tabSearchReplace.SelectedTab.Controls.Add(btnFindNext);
86      tabSearchReplace.SelectedTab.Controls.Add(lblSearch);
87      tabSearchReplace.SelectedTab.Controls.Add(txtSearchString);
88      tabSearchReplace.SelectedTab.Controls.Add(cmbComparisonOperator);
89      ActiveControl = txtSearchString;
90      AcceptButton = btnFindNext;
91    }
92
93    public String GetSearchText() {
94      return txtSearchString.Text;
95    }
96
97    public string GetReplaceText() {
98      return txtValue.Text;
99    }
100
101    public ReplaceAction GetReplaceAction() {
102      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
103    }
104
105    public ComparisonOperation GetComparisonOperation() {
106      return (ComparisonOperation)cmbComparisonOperator.SelectedIndex;
107    }
108
109    public event EventHandler FindAllEvent {
110      add { btnFindAll.Click += value; }
111      remove { btnFindAll.Click -= value; }
112    }
113
114    public event EventHandler FindNextEvent {
115      add { btnFindNext.Click += value; }
116      remove { btnFindNext.Click -= value; }
117    }
118
119    public event EventHandler ReplaceAllEvent {
120      add { btnReplaceAll.Click += value; }
121      remove { btnReplaceAll.Click -= value; }
122    }
123
124    public event EventHandler ReplaceNextEvent {
125      add { btnReplace.Click += value; }
126      remove { btnReplace.Click -= value; }
127    }
128  }
129}
Note: See TracBrowser for help on using the repository browser.