Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FindAndReplaceDialog.cs @ 10705

Last change on this file since 10705 was 10705, checked in by sbreuer, 10 years ago
  • enhanced usability
File size: 2.5 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 partial class FindAndReplaceDialog : Form {
16    private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" };
17
18    public FindAndReplaceDialog() {
19      InitializeComponent();
20      cmbReplaceWith.Items.AddRange(cmbItemsText);
21      cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value;
22      SetEndReached(false);
23    }
24
25    public void ActivateSearch() {
26      tabSearch.Focus();
27      AddControlsToCurrentTab();
28    }
29
30    public void ActivateReplace() {
31      tabReplace.Focus();
32      AddControlsToCurrentTab();
33    }
34
35    public void SetEndReached(bool endReached) {
36      lblEndReached.Visible = endReached;
37    }
38
39    private void tabSearchReplace_SelectedIndexChanged(object sender, System.EventArgs e) {
40      AddControlsToCurrentTab();
41    }
42
43    private void cmbReplaceWith_SelectedIndexChanged(object sender, System.EventArgs e) {
44      lblValue.Visible = txtValue.Visible = cmbReplaceWith.SelectedIndex == (int)ReplaceAction.Value;
45    }
46
47    private void AddControlsToCurrentTab() {
48      tabSearchReplace.SelectedTab.Controls.Add(btnFindAll);
49      tabSearchReplace.SelectedTab.Controls.Add(btnFindNext);
50      tabSearchReplace.SelectedTab.Controls.Add(lblSearch);
51      tabSearchReplace.SelectedTab.Controls.Add(txtSearchString);
52      tabSearchReplace.SelectedTab.Controls.Add(lblEndReached);
53    }
54
55    public String GetSearchText() {
56      return txtSearchString.Text;
57    }
58
59    public string GetReplaceText() {
60      return txtValue.Text;
61    }
62
63    public ReplaceAction GetReplaceAction() {
64      return (ReplaceAction)cmbReplaceWith.SelectedIndex;
65    }
66
67    public event EventHandler FindAllEvent {
68      add { btnFindAll.Click += value; }
69      remove { btnFindAll.Click -= value; }
70    }
71
72    public event EventHandler FindNextEvent {
73      add { btnFindNext.Click += value; }
74      remove { btnFindNext.Click -= value; }
75    }
76
77    public event EventHandler ReplaceAllEvent {
78      add { btnReplaceAll.Click += value; }
79      remove { btnReplaceAll.Click -= value; }
80    }
81
82    public event EventHandler ReplaceNextEvent {
83      add { btnReplace.Click += value; }
84      remove { btnReplace.Click -= value; }
85    }
86     
87  }
88}
Note: See TracBrowser for help on using the repository browser.