Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.DataPreprocessing.Views/3.4/SearchAndReplaceDialog.cs @ 17507

Last change on this file since 17507 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

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