Repository navigation
Expand file tree
/
Copy pathFormSearch.cs
More file actions
86 lines (75 loc) · 2.26 KB
/
Copy pathFormSearch.cs
File metadata and controls
86 lines (75 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using ORCToolKit.Search;
namespace ORCToolKit
{
public partial class FormSearch: LocalizedForm
{
public event SearchEventHandler? OnSearch;
public FormSearch()
{
InitializeComponent();
LocalizeComponent();
}
public override LocalizedControl[] LocalizedControls
{
get
{
return [
new LocalizedControl { Object = this, ObjectName = this.Name, FieldName = "Text" },
new LocalizedControl { Object = SearchLabel, ObjectName = SearchLabel.Name, FieldName = "Text" },
new LocalizedControl { Object = SearchBackwardButton, ObjectName = SearchBackwardButton.Name, FieldName = "Text" },
new LocalizedControl { Object = SearchForwardButton, ObjectName = SearchForwardButton.Name, FieldName = "Text" },
new LocalizedControl { Object = WholeWordCheckBox, ObjectName = WholeWordCheckBox.Name, FieldName = "Text" },
new LocalizedControl { Object = CaseSensitiveCheckBox, ObjectName = CaseSensitiveCheckBox.Name, FieldName = "Text" },
];
}
}
private void InvokeSearch( SearchDirection direction )
{
if ( string.IsNullOrEmpty( SearchTextBox.Text ) )
return;
if ( OnSearch != null )
OnSearch( this, new SearchEventArgs( direction, SearchTextBox.Text, WholeWordCheckBox.Checked, CaseSensitiveCheckBox.Checked ) );
}
private void FormSearch_FormClosing( object sender, FormClosingEventArgs e )
{
// don't remove ourselves!
Hide();
e.Cancel = true;
}
private void FormSearch_VisibleChanged( object sender, EventArgs e )
{
if ( Visible )
{
BeginInvoke( (MethodInvoker)delegate
{
SearchTextBox.Focus();
SearchTextBox.SelectAll();
} );
}
}
private void FormSearch_KeyDown( object sender, KeyEventArgs e )
{
if ( e.KeyCode == Keys.Escape )
Hide();
}
private void SearchBackwardButton_Click( object sender, EventArgs e )
{
InvokeSearch( SearchDirection.Backward );
}
private void SearchForwardButton_Click( object sender, EventArgs e )
{
InvokeSearch( SearchDirection.Forward );
}
private void SearchTextBox_KeyDown( object sender, KeyEventArgs e )
{
if ( e.KeyCode == Keys.Enter )
{
if ( e.Shift )
InvokeSearch( SearchDirection.Backward );
else
InvokeSearch( SearchDirection.Forward );
e.Handled = true;
}
}
}
}