forked from HuichanKIM/Ollama-Delphi-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit_RequestDialog.pas
114 lines (98 loc) · 2.53 KB
/
Unit_RequestDialog.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
unit Unit_RequestDialog;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.Buttons;
type
TForm_RequestDialog = class(TForm)
Memo_Request: TMemo;
Button_OK: TButton;
Label1: TLabel;
Label_Clear: TLabel;
SpeedButton_Trans: TSpeedButton;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure Label_ClearClick(Sender: TObject);
procedure SpeedButton_TransClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
FPreLoader: string;
FCode_From: Integer;
FCode_to: Integer;
procedure SetPreLoader(const Value: string);
public
// property ...
property PreLoader: string read FPreLoader write SetPreLoader;
property Code_From: Integer read FCode_From write FCode_From;
property Code_to: Integer read FCode_to write FCode_To;
end;
var
Form_RequestDialog: TForm_RequestDialog;
implementation
uses
System.RegularExpressions,
Unit_Translator,
Unit_Main,
Unit_Common;
{$R *.dfm}
procedure TForm_RequestDialog.FormCreate(Sender: TObject);
begin
Memo_Request.lines.clear;
end;
procedure TForm_RequestDialog.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #27 then
begin
Key := #0;
ModalResult := mrCancel;
end;
end;
procedure TForm_RequestDialog.FormShow(Sender: TObject);
begin
if Memo_Request.CanFocus then // Change Style Event ?
begin
Memo_Request.SetFocus;
Memo_Request.SelectAll;
end;
end;
procedure TForm_RequestDialog.Label_ClearClick(Sender: TObject);
begin
Memo_Request.Lines.Clear;
end;
procedure TForm_RequestDialog.SetPreLoader(const Value: string);
begin
FPreLoader := Value;
Memo_Request.Lines.Text := Value;
end;
procedure TForm_RequestDialog.SpeedButton_TransClick(Sender: TObject);
begin
var _ItemStr := Trim(Memo_Request.Lines.Text);
if _ItemStr = '' then
begin
ShowMessage('Can not translate for empty string');
Exit;
end;
var _codefrom := FCode_From;
var _codeto := FCode_to;
if Is_Hangul(_ItemStr) then
begin
_codefrom := 1;
_codeto := 0;
end;
if _ItemStr <> '' then
begin
_ItemStr := Get_ReplaceSpecialChar4Trans(_ItemStr);
Memo_Request.lines.Text := Get_GoogleTranslatorEx(0, _codefrom, _codeto, _ItemStr);
end;
end;
end.