-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindDialogUnit.pas
163 lines (144 loc) · 4.47 KB
/
FindDialogUnit.pas
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
unit FindDialogUnit;
{$reference 'System.Windows.Forms.dll'}
{$reference 'System.Drawing.dll'}
uses
System,
System.Drawing,
System.Collections,
System.ComponentModel,
System.Windows.Forms;
type
OnFindEvent = procedure(FindText: string; MatchCase: boolean);
FindDialog = class(Form)
private
textBoxFindText: TextBox;
buttonFind: Button;
checkBoxMatchCase: CheckBox;
buttonClose: Button;
labelFindWhat: &Label;
OnFind: OnFindEvent;
procedure InitControls;
begin
self.labelFindWhat := new &Label();
self.textBoxFindText := new TextBox;
self.buttonFind := new Button;
self.checkBoxMatchCase := new CheckBox;
self.buttonClose := new Button;
self.SuspendLayout;
//
// labelFindWhat
//
self.labelFindWhat.Location := new System.Drawing.Point(8, 8);
self.labelFindWhat.AutoSize := true;
self.labelFindWhat.TabIndex := 0;
self.labelFindWhat.Text := 'Èñêàòü';
self.labelFindWhat.TextAlign := ContentAlignment.MiddleLeft;
//
// textBoxFindText
//
self.textBoxFindText.Location := new Point(96, 8);
self.textBoxFindText.Size := new System.Drawing.Size(280, 21);
self.textBoxFindText.TabIndex := 1;
self.textBoxFindText.Text := '';
self.textBoxFindText.TextChanged += self.textBoxFindText_TextChanged;
//
// buttonFind
//
self.buttonFind.Location := new Point(408, 8);
self.buttonFind.TabIndex := 2;
self.buttonFind.Text := 'Èñêàòü';
self.buttonFind.Click += self.buttonFind_Click;
//
// checkBoxMatchCase
//
self.checkBoxMatchCase.Location := new Point(96, 40);
self.checkBoxMatchCase.AutoSize := true;
self.checkBoxMatchCase.TabIndex := 3;
self.checkBoxMatchCase.Text := 'Ó÷èòûâàòü ðåãèñòð';
//
// buttonClose
//
self.buttonClose.Location := new Point(408, 40);
self.buttonClose.TabIndex := 4;
self.buttonClose.Text := 'Îòìåíà';
self.buttonClose.Click += self.buttonClose_Click;
//
// FindDialog
//
self.AutoScaleBaseSize := new System.Drawing.Size(6, 14);
self.ClientSize := new System.Drawing.Size(496, 72);
self.Controls.Add(self.buttonClose);
self.Controls.Add(self.checkBoxMatchCase);
self.Controls.Add(self.buttonFind);
self.Controls.Add(self.textBoxFindText);
self.Controls.Add(self.labelFindWhat);
self.Font := new System.Drawing.Font('Verdana', 8.25, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0)));
self.FormBorderStyle := System.Windows.Forms.FormBorderStyle.FixedToolWindow;
self.KeyPreview := true;
self.ShowInTaskbar := false;
self.Text := 'Ïîèñê';
self.TopMost := true;
self.KeyDown += self.FindDialog_KeyDown;
self.Closing += self.FindDialog_Closing;
self.ResumeLayout(false);
end;
function GetFindText: string;
begin
result := textBoxFindText.Text;
end;
procedure SetFindText(value: string);
begin
textBoxFindText.Text := value;
end;
function GetMatchCase: boolean;
begin
result := checkBoxMatchCase.Checked;
end;
procedure SetMatchCase(value: boolean);
begin
checkBoxMatchCase.Checked := value;
end;
procedure buttonFind_Click(sender: object; e: System.EventArgs);
begin
self.Cursor := Cursors.WaitCursor;
self.OnFind(FindText, MatchCase);
self.Cursor := Cursors.Default;
end;
procedure buttonClose_Click(sender: object; e: System.EventArgs);
begin
self.Close;
end;
procedure textBoxFindText_TextChanged(sender: object; e: System.EventArgs);
begin
if (self.textBoxFindText.Text.Equals(String.Empty)) then
begin
self.buttonFind.Enabled := false;
end
else
begin
self.buttonFind.Enabled := true;
end;
end;
procedure FindDialog_KeyDown(sender: object; e: KeyEventArgs);
begin
if(e .KeyCode = Keys.Escape) then
begin
self.Close;
end;
end;
procedure FindDialog_Closing(sender: object; e: CancelEventArgs);
begin
e.Cancel := True;
Hide;
end;
public
property FindText: string read GetFindText write SetFindText;
property MatchCase: boolean read GetMatchCase write SetMatchCase;
constructor Create(OnFind: OnFindEvent);
begin
InitControls;
self.OnFind:= OnFind;
end;
end;
begin
end.