-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfSetting.pas
241 lines (215 loc) · 6.78 KB
/
fSetting.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
unit fSetting;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls;
const
DefaultExcludeExtension = '.txt,.exe,.dll,.com,.log';
type
TSettingDlg = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
OKBtn: TButton;
CancelBtn: TButton;
MoveDirectoryOpenDlg: TOpenDialog;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
GroupBox2: TGroupBox;
txtExcludeExtension: TEdit;
Label1: TLabel;
btnDefExcludeExtension: TButton;
txtAppName: TLabeledEdit;
txtAppPath: TLabeledEdit;
txtAppArgv: TLabeledEdit;
btnSetAppPath: TButton;
AppPathOpenDlg: TOpenDialog;
lvApps: TListView;
TabSheet3: TTabSheet;
GroupBox1: TGroupBox;
rbFileDeleteD: TRadioButton;
rbFileDeleteM: TRadioButton;
rbFileDeleteNG: TRadioButton;
cbDeleteNoDialog: TCheckBox;
txtFileMoveDirectory: TEdit;
btnSetMoveDirectory: TButton;
chbNoTreeIcon: TCheckBox;
chbUseTimer: TCheckBox;
chbAutoWavHeader: TCheckBox;
chbRawOnlyMode: TCheckBox;
procedure btnSetMoveDirectoryClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure gbDeleteFileClick(Sender: TObject);
procedure btnSetAppPathClick(Sender: TObject);
procedure txtAppChange(Sender: TObject);
procedure lvAppsChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure btnDefExcludeExtensionClick(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure chbRawOnlyModeClick(Sender: TObject);
private
{ Private 錾 }
FbAppChange: Boolean;
FnFileDeleteRadioIndex: Integer;
public
{ Public 錾 }
end;
var
SettingDlg: TSettingDlg;
implementation
uses
Global, IniFiles;
{$R *.dfm}
procedure TSettingDlg.FormCreate(Sender: TObject);
var
i: Integer;
item: TListItem;
begin
With AppGlobal.Ini do
begin
chbNoTreeIcon.Checked := ReadBool('Setting', 'NoTreeIcon', chbNoTreeIcon.Checked);
chbUseTimer.Checked := ReadBool('Play', 'UseTimer', chbUseTimer.Checked);
chbRawOnlyMode.Checked := ReadBool('Setting', 'RawOnlyMode', chbRawOnlyMode.Checked);
chbAutoWavHeader.Checked := ReadBool('Setting', 'AutoWavHeader', chbAutoWavHeader.Checked);
FnFileDeleteRadioIndex := ReadInteger('Setting', 'DeleteFile', 0);
txtFileMoveDirectory.Text := ReadString('Setting', 'DeleteFileDirectory', txtFileMoveDirectory.Text);
cbDeleteNoDialog.Checked := ReadBool('Setting', 'DeleteFileNoPrompt', cbDeleteNoDialog.Checked);
txtExcludeExtension.Text := ReadString('Filter', 'ExcludeExtension', txtExcludeExtension.Text);
if chbRawOnlyMode.Checked then chbAutoWavHeader.Enabled := false;
// ToDo: How to apply icons for Windows10, or Win10-32bit?
//chbNoTreeIcon.Checked := true;
//chbNoTreeIcon.Enabled := false;
end;
gbDeleteFileClick(nil);
case FnFileDeleteRadioIndex of
0: rbFileDeleteD.Checked := true;
1: rbFileDeleteM.Checked := true;
2: rbFileDeleteNG.Checked := true;
end;
for i:= 0 to 3 do
begin
if i < AppGlobal.ExternalAppCount then
begin
item := lvApps.Items.Add;
item.Caption := AppGlobal.ExternalAppData[i, 'Name'];
item.SubItems.Add(AppGlobal.ExternalAppData[i, 'Path']);
item.SubItems.Add(AppGlobal.ExternalAppData[i, 'Argv']);
end
else
begin
item := lvApps.Items.Add;
item.Caption := '';
item.SubItems.Add('');
item.SubItems.Add('');
end;
end;
end;
procedure TSettingDlg.btnSetMoveDirectoryClick(Sender: TObject);
var
path: String;
begin
if DirectoryExists(txtFileMoveDirectory.Text) then
MoveDirectoryOpenDlg.InitialDir := txtFileMoveDirectory.Text
else
MoveDirectoryOpenDlg.InitialDir := AppGlobal.ExePath;
if MoveDirectoryOpenDlg.Execute then
path := ExtractFilePath(MoveDirectoryOpenDlg.FileName);
if DirectoryExists(path) then
txtFileMoveDirectory.Text := path;
end;
procedure TSettingDlg.chbRawOnlyModeClick(Sender: TObject);
begin
if chbRawOnlyMode.Checked then
chbAutoWavHeader.Enabled := false
else
chbAutoWavHeader.Enabled := true;
end;
procedure TSettingDlg.gbDeleteFileClick(Sender: TObject);
begin
if Assigned(Sender) then
FnFileDeleteRadioIndex := (Sender as TRadioButton).Tag;
if FnFileDeleteRadioIndex = 1 then
begin
btnSetMoveDirectory.Enabled := true;
txtFileMoveDirectory.Enabled := true;
end
else
begin
btnSetMoveDirectory.Enabled := false;
txtFileMoveDirectory.Enabled := false;
end;
end;
procedure TSettingDlg.btnSetAppPathClick(Sender: TObject);
var
path: String;
begin
if DirectoryExists(txtAppPath.Text) then
AppPathOpenDlg.InitialDir := ExtractFileDir(txtAppPath.Text)
else
AppPathOpenDlg.InitialDir := AppGlobal.ExePath;
if AppPathOpenDlg.Execute then
path := AppPathOpenDlg.FileName;
if FileExists(path) then
txtAppPath.Text := path;
if txtAppName.Text = '' then
txtAppName.Text := ChangeFileExt(ExtractFileName(path), '');
end;
procedure TSettingDlg.txtAppChange(Sender: TObject);
begin
if (lvApps.ItemIndex = -1) then Exit;
if FbAppChange then Exit;
With lvApps.Selected do
begin
Caption := txtAppName.Text;
SubItems[0] := txtAppPath.Text;
SubItems[1] := txtAppArgv.Text;
end;
end;
procedure TSettingDlg.lvAppsChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
if Change <> ctState then Exit;
FbAppChange := true;
if Assigned(Item) then
begin
txtAppName.Text := Item.Caption;
txtAppPath.Text := Item.SubItems[0];
txtAppArgv.Text := Item.SubItems[1];
end
else
begin
txtAppName.Text := '';
txtAppPath.Text := '';
txtAppArgv.Text := '';
end;
FbAppChange := false;
end;
procedure TSettingDlg.btnDefExcludeExtensionClick(Sender: TObject);
begin
txtExcludeExtension.Text := DefaultExcludeExtension;
end;
procedure TSettingDlg.OKBtnClick(Sender: TObject);
var
i: integer;
begin
With AppGlobal.Ini do
begin
WriteBool('Setting', 'NoTreeIcon', chbNoTreeIcon.Checked);
//WriteBool('Setting', 'NoTreeIcon', true);
WriteBool('Play', 'UseTimer', chbUseTimer.Checked);
WriteBool('Setting', 'RawOnlyMode', chbRawOnlyMode.Checked);
WriteBool('Setting', 'AutoWavHeader', chbAutoWavHeader.Checked);
WriteInteger('Setting', 'DeleteFile', FnFileDeleteRadioIndex);
WriteString('Setting', 'DeleteFileDirectory', txtFileMoveDirectory.Text);
WriteBool('Setting', 'DeleteFileNoPrompt', cbDeleteNoDialog.Checked);
WriteString('Filter', 'ExcludeExtension', txtExcludeExtension.Text);
for i:=0 to 3 do
begin
WriteString('ExternalApps' + IntToStr(i), 'Name', lvApps.Items[i].Caption);
WriteString('ExternalApps' + IntToStr(i), 'Path', lvApps.Items[i].SubItems[0]);
WriteString('ExternalApps' + IntToStr(i), 'Argv', lvApps.Items[i].SubItems[1]);
end;
UpdateFile;
end;
end;
end.