1 |
|
unit Tool_Preview; |
2 |
– |
|
2 |
|
interface |
4 |
– |
|
3 |
|
uses |
4 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
5 |
< |
Dialogs, Math, ExtCtrls, StdCtrls, StrUtils, Menus, |
6 |
< |
Code_Functions, Data, Code_Exporters, Code_OniImgClass, Code_OniDataClass; |
5 |
> |
Dialogs, StdCtrls, Tool_Template, ExtCtrls, Math, StrUtils, |
6 |
> |
Code_OniDataClass, Code_OniImgClass, Data, Menus; |
7 |
|
|
8 |
|
type |
9 |
< |
TForm_Preview = class(TForm) |
10 |
< |
timer: TTimer; |
13 |
< |
panel_preview: TPanel; |
14 |
< |
img: TImage; |
9 |
> |
TForm_Preview = class(TForm_ToolTemplate) |
10 |
> |
lbl_notpossible: TLabel; |
11 |
|
panel_buttons: TPanel; |
12 |
|
btn_dec: TButton; |
13 |
|
btn_startstop: TButton; |
14 |
|
btn_inc: TButton; |
15 |
< |
Splitter1: TSplitter; |
16 |
< |
lbl_notpossible: TLabel; |
17 |
< |
panel_files: TPanel; |
18 |
< |
list: TListBox; |
23 |
< |
panel_extension: TPanel; |
24 |
< |
lbl_filter: TLabel; |
25 |
< |
combo_extension: TComboBox; |
26 |
< |
check_zerobyte: TCheckBox; |
27 |
< |
edit_filtername: TEdit; |
28 |
< |
check_filtername: TCheckBox; |
29 |
< |
procedure LoadFileNames; |
30 |
< |
procedure check_filternameClick(Sender: TObject); |
31 |
< |
procedure check_zerobyteClick(Sender: TObject); |
32 |
< |
procedure combo_extensionClick(Sender: TObject); |
33 |
< |
procedure panel_extensionResize(Sender: TObject); |
34 |
< |
procedure listClick(Sender: TObject); |
35 |
< |
procedure Recreatelist; |
15 |
> |
img: TImage; |
16 |
> |
timer: TTimer; |
17 |
> |
procedure FormCreate(Sender: TObject); |
18 |
> |
procedure NewFile(fileinfo: TFileInfo); |
19 |
|
|
20 |
|
procedure PreviewImage; |
21 |
|
procedure PreviewTXAN; |
22 |
|
procedure btn_incClick(Sender: TObject); |
23 |
|
procedure btn_decClick(Sender: TObject); |
41 |
– |
procedure FormResize(Sender: TObject); |
24 |
|
procedure btn_startstopClick(Sender: TObject); |
43 |
– |
procedure panel_buttonsResize(Sender: TObject); |
25 |
|
procedure timerTimer(Sender: TObject); |
26 |
< |
procedure FormCreate(Sender: TObject); |
46 |
< |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
26 |
> |
procedure panel_buttonsResize(Sender: TObject); |
27 |
|
|
28 |
|
procedure DrawImage(index: Integer); |
29 |
|
procedure SetBitmapCount(Count: Integer); |
30 |
|
procedure LoadImage(fileid, index: Integer); |
51 |
– |
procedure listMouseDown(Sender: TObject; Button: TMouseButton; |
52 |
– |
Shift: TShiftState; X, Y: Integer); |
31 |
|
private |
32 |
|
bitmaps: array of TBitmap; |
33 |
|
actualimg: Byte; |
39 |
|
Form_Preview: TForm_Preview; |
40 |
|
|
41 |
|
implementation |
64 |
– |
|
42 |
|
{$R *.dfm} |
43 |
|
|
67 |
– |
uses Main; |
68 |
– |
|
69 |
– |
|
70 |
– |
|
44 |
|
|
45 |
< |
procedure TForm_Preview.Recreatelist; |
73 |
< |
var |
74 |
< |
i: LongWord; |
75 |
< |
exts: TStringArray; |
45 |
> |
procedure TForm_Preview.FormCreate(Sender: TObject); |
46 |
|
begin |
47 |
< |
combo_extension.Items.Clear; |
48 |
< |
combo_extension.Items.Add('_All files_ (' + |
79 |
< |
IntToStr(OniDataConnection.GetFilesCount) + ')'); |
80 |
< |
exts := OniDataConnection.GetExtensionsList; |
81 |
< |
for i := 0 to High(exts) do |
82 |
< |
combo_extension.Items.Add(exts[i]); |
83 |
< |
combo_extension.ItemIndex := 0; |
84 |
< |
combo_extensionClick(Self); |
47 |
> |
inherited; |
48 |
> |
Self.OnNewFileSelected := NewFile; |
49 |
|
end; |
50 |
|
|
51 |
|
|
52 |
< |
|
89 |
< |
|
90 |
< |
procedure TForm_Preview.LoadFileNames; |
52 |
> |
procedure TForm_Preview.NewFile(fileinfo: TFileInfo); |
53 |
|
var |
54 |
< |
Extension: String[4]; |
55 |
< |
no_zero_bytes: Boolean; |
56 |
< |
pattern: String; |
57 |
< |
files: TStringArray; |
58 |
< |
i: LongWord; |
59 |
< |
begin |
60 |
< |
Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4); |
61 |
< |
no_zero_bytes := not check_zerobyte.Checked; |
62 |
< |
pattern := ''; |
63 |
< |
if check_filtername.Checked then |
64 |
< |
pattern := edit_filtername.Text; |
65 |
< |
if Extension = '_All' then |
66 |
< |
Extension := ''; |
67 |
< |
|
68 |
< |
files := OniDataConnection.GetFilesList(extension, pattern, no_zero_bytes); |
69 |
< |
list.Items.Clear; |
70 |
< |
if Length(files) > 0 then |
109 |
< |
for i := 0 to High(files) do |
110 |
< |
list.Items.Add(files[i]); |
54 |
> |
ext: String; |
55 |
> |
begin |
56 |
> |
_fileid := fileinfo.ID; |
57 |
> |
lbl_notpossible.Visible := False; |
58 |
> |
Self.img.Visible := True; |
59 |
> |
Self.timer.Enabled := False; |
60 |
> |
Self.panel_buttons.Visible := False; |
61 |
> |
ext := fileinfo.Extension; |
62 |
> |
if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then |
63 |
> |
PreviewImage |
64 |
> |
else if ext = 'TXAN' then |
65 |
> |
PreviewTXAN |
66 |
> |
else |
67 |
> |
begin |
68 |
> |
Self.lbl_notpossible.Visible := True; |
69 |
> |
Self.img.Visible := False; |
70 |
> |
end; |
71 |
|
end; |
72 |
|
|
73 |
|
|
114 |
– |
|
115 |
– |
|
74 |
|
procedure TForm_Preview.LoadImage(fileid, index: Integer); |
75 |
|
var |
76 |
|
Data: Tdata; |
91 |
|
end; |
92 |
|
|
93 |
|
|
136 |
– |
|
137 |
– |
|
138 |
– |
procedure TForm_Preview.combo_extensionClick(Sender: TObject); |
139 |
– |
begin |
140 |
– |
LoadFileNames; |
141 |
– |
end; |
142 |
– |
|
143 |
– |
|
144 |
– |
|
94 |
|
procedure TForm_Preview.DrawImage(index: Integer); |
95 |
|
begin |
96 |
|
BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, |
101 |
|
end; |
102 |
|
|
103 |
|
|
155 |
– |
|
156 |
– |
|
104 |
|
procedure TForm_Preview.SetBitmapCount(Count: Integer); |
105 |
|
var |
106 |
|
i: Integer; |
121 |
|
end; |
122 |
|
|
123 |
|
|
177 |
– |
|
178 |
– |
|
179 |
– |
procedure TForm_Preview.check_zerobyteClick(Sender: TObject); |
180 |
– |
begin |
181 |
– |
LoadFileNames; |
182 |
– |
end; |
183 |
– |
|
184 |
– |
|
185 |
– |
|
186 |
– |
|
187 |
– |
procedure TForm_Preview.check_filternameClick(Sender: TObject); |
188 |
– |
begin |
189 |
– |
edit_filtername.Enabled := not check_filtername.Checked; |
190 |
– |
LoadFileNames; |
191 |
– |
end; |
192 |
– |
|
193 |
– |
|
194 |
– |
|
195 |
– |
|
196 |
– |
procedure TForm_Preview.listClick(Sender: TObject); |
197 |
– |
var |
198 |
– |
ext: String; |
199 |
– |
begin |
200 |
– |
_fileid := OniDataConnection.ExtractFileID(list.Items.Strings[list.ItemIndex]); |
201 |
– |
lbl_notpossible.Visible := False; |
202 |
– |
Self.img.Visible := True; |
203 |
– |
Self.timer.Enabled := False; |
204 |
– |
Self.panel_buttons.Visible := False; |
205 |
– |
ext := RightStr(list.Items.Strings[list.ItemIndex], 4); |
206 |
– |
if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then |
207 |
– |
PreviewImage |
208 |
– |
else if ext = 'TXAN' then |
209 |
– |
PreviewTXAN |
210 |
– |
else |
211 |
– |
begin |
212 |
– |
Self.lbl_notpossible.Visible := True; |
213 |
– |
Self.img.Visible := False; |
214 |
– |
end; |
215 |
– |
end; |
216 |
– |
|
217 |
– |
|
218 |
– |
|
219 |
– |
|
220 |
– |
procedure TForm_Preview.listMouseDown(Sender: TObject; Button: TMouseButton; |
221 |
– |
Shift: TShiftState; X, Y: Integer); |
222 |
– |
var |
223 |
– |
pt: TPoint; |
224 |
– |
begin |
225 |
– |
pt.X := x; |
226 |
– |
pt.Y := y; |
227 |
– |
list.ItemIndex := list.ItemAtPos(pt, true); |
228 |
– |
if list.ItemIndex > -1 then |
229 |
– |
Self.listClick(Self); |
230 |
– |
end; |
231 |
– |
|
124 |
|
procedure TForm_Preview.PreviewImage; |
125 |
|
begin |
126 |
|
SetBitmapCount(1); |
129 |
|
end; |
130 |
|
|
131 |
|
|
240 |
– |
|
241 |
– |
|
132 |
|
procedure TForm_Preview.PreviewTXAN; |
133 |
|
var |
134 |
|
loop_speed: Word; |
155 |
|
end; |
156 |
|
|
157 |
|
|
268 |
– |
|
269 |
– |
|
158 |
|
procedure TForm_Preview.timerTimer(Sender: TObject); |
159 |
|
begin |
160 |
|
btn_incClick(Self); |
161 |
|
end; |
162 |
|
|
163 |
|
|
276 |
– |
|
277 |
– |
|
164 |
|
procedure TForm_Preview.btn_startstopClick(Sender: TObject); |
165 |
|
begin |
166 |
|
Self.timer.Enabled := not Self.timer.Enabled; |
173 |
|
end; |
174 |
|
|
175 |
|
|
290 |
– |
|
291 |
– |
|
176 |
|
procedure TForm_Preview.btn_decClick(Sender: TObject); |
177 |
|
begin |
178 |
|
if actualimg > 0 then |
185 |
|
end; |
186 |
|
|
187 |
|
|
304 |
– |
|
305 |
– |
|
188 |
|
procedure TForm_Preview.btn_incClick(Sender: TObject); |
189 |
|
begin |
190 |
|
if actualimg < High(bitmaps) then |
197 |
|
end; |
198 |
|
|
199 |
|
|
318 |
– |
|
319 |
– |
|
200 |
|
procedure TForm_Preview.panel_buttonsResize(Sender: TObject); |
201 |
|
begin |
202 |
|
btn_startstop.Width := panel_buttons.Width - 45; |
204 |
|
end; |
205 |
|
|
206 |
|
|
327 |
– |
|
328 |
– |
|
329 |
– |
procedure TForm_Preview.panel_extensionResize(Sender: TObject); |
207 |
|
begin |
208 |
< |
combo_extension.Width := panel_extension.Width - 5; |
332 |
< |
edit_filtername.Width := panel_extension.Width - 5; |
333 |
< |
end; |
334 |
< |
|
335 |
< |
|
336 |
< |
|
337 |
< |
|
338 |
< |
procedure TForm_Preview.FormResize(Sender: TObject); |
339 |
< |
begin |
340 |
< |
if Self.Width < 300 then |
341 |
< |
Self.Width := 300; |
342 |
< |
if Self.Height < 200 then |
343 |
< |
Self.Height := 200; |
344 |
< |
end; |
345 |
< |
|
346 |
< |
|
347 |
< |
|
348 |
< |
|
349 |
< |
procedure TForm_Preview.FormCreate(Sender: TObject); |
350 |
< |
begin |
351 |
< |
SetLength(bitmaps, 0); |
352 |
< |
Self.Width := 260; |
353 |
< |
Self.Height := 300; |
354 |
< |
end; |
355 |
< |
|
356 |
< |
|
357 |
< |
|
358 |
< |
|
359 |
< |
procedure TForm_Preview.FormClose(Sender: TObject; var Action: TCloseAction); |
360 |
< |
begin |
361 |
< |
Action := caFree; |
362 |
< |
end; |
363 |
< |
|
208 |
> |
AddToolListEntry('preview', 'Preview-Window', ''); |
209 |
|
end. |