using System; using System.Collections.Generic; using System.Windows.Forms; namespace HeuristicLab.DataPreprocessing.Views { public enum ReplaceAction { Value, Average, Median, Random, MostCommon, Interpolation } public partial class SearchAndReplaceDialog : Form { private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" }; public SearchAndReplaceDialog() { InitializeComponent(); cmbReplaceWith.Items.AddRange(cmbItemsText); cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value; } public void ActivateSearch() { tabSearchReplace.SelectTab(tabSearch); AddControlsToCurrentTab(); } public void ActivateReplace() { tabSearchReplace.SelectTab(tabReplace); AddControlsToCurrentTab(); } private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) { AddControlsToCurrentTab(); } private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) { lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value; } private void AddControlsToCurrentTab() { tabSearchReplace.SelectedTab.Controls.Add(btnFindAll); tabSearchReplace.SelectedTab.Controls.Add(btnFindNext); tabSearchReplace.SelectedTab.Controls.Add(lblSearch); tabSearchReplace.SelectedTab.Controls.Add(txtSearchString); ActiveControl = txtSearchString; AcceptButton = btnFindNext; } public String GetSearchText() { return txtSearchString.Text; } public string GetReplaceText() { return txtValue.Text; } public ReplaceAction GetReplaceAction() { return (ReplaceAction)cmbReplaceWith.SelectedIndex; } public event EventHandler FindAllEvent { add { btnFindAll.Click += value; } remove { btnFindAll.Click -= value; } } public event EventHandler FindNextEvent { add { btnFindNext.Click += value; } remove { btnFindNext.Click -= value; } } public event EventHandler ReplaceAllEvent { add { btnReplaceAll.Click += value; } remove { btnReplaceAll.Click -= value; } } public event EventHandler ReplaceNextEvent { add { btnReplace.Click += value; } remove { btnReplace.Click -= value; } } } }