[13502] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 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 |
|
---|
| 22 | using System;
|
---|
[10636] | 23 | using System.Windows.Forms;
|
---|
[10630] | 24 |
|
---|
| 25 | namespace 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 {
|
---|
[10672] | 45 | private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
|
---|
[10870] | 46 | private string[] cmbComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" };
|
---|
[10672] | 47 |
|
---|
[10762] | 48 | public SearchAndReplaceDialog() {
|
---|
[10630] | 49 | InitializeComponent();
|
---|
[10672] | 50 | cmbReplaceWith.Items.AddRange(cmbItemsText);
|
---|
| 51 | cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
|
---|
[10870] | 52 | cmbComparisonOperator.Items.AddRange(cmbComparisonOperatorText);
|
---|
| 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 | }
|
---|