1 | unit Extractor;
|
---|
2 | interface
|
---|
3 | uses
|
---|
4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
5 | Dialogs, Template, StdCtrls, ExtCtrls, ComCtrls, Menus, Buttons, StrUtils;
|
---|
6 |
|
---|
7 | type
|
---|
8 | TForm_Extractor = class(TForm_ToolTemplate)
|
---|
9 | group_extract: TGroupBox;
|
---|
10 | check_dat: TCheckBox;
|
---|
11 | check_raw: TCheckBox;
|
---|
12 | check_convert: TCheckBox;
|
---|
13 | radio_selected: TRadioButton;
|
---|
14 | label_export_sel: TLabel;
|
---|
15 | radio_all: TRadioButton;
|
---|
16 | label_path: TLabel;
|
---|
17 | edit_path: TEdit;
|
---|
18 | btn_path: TButton;
|
---|
19 | btn_export: TButton;
|
---|
20 | group_progress: TGroupBox;
|
---|
21 | lbl_progress: TLabel;
|
---|
22 | lbl_estimated: TLabel;
|
---|
23 | progress: TProgressBar;
|
---|
24 | btn_abort: TButton;
|
---|
25 | procedure FormCreate(Sender: TObject);
|
---|
26 | procedure btn_abortClick(Sender: TObject);
|
---|
27 | procedure btn_pathClick(Sender: TObject);
|
---|
28 | procedure btn_exportClick(Sender: TObject);
|
---|
29 | private
|
---|
30 | public
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | Form_Extractor: TForm_Extractor;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 | {$R *.dfm}
|
---|
38 | uses Main, Functions, Data, OniDataClass, FolderBrowser, Exporters;
|
---|
39 |
|
---|
40 |
|
---|
41 | procedure TForm_Extractor.FormCreate(Sender: TObject);
|
---|
42 | begin
|
---|
43 | inherited;
|
---|
44 | Self.AllowMultiSelect := True;
|
---|
45 | edit_path.Text := AppSettings.ExtractPath;
|
---|
46 | end;
|
---|
47 |
|
---|
48 | procedure TForm_Extractor.btn_abortClick(Sender: TObject);
|
---|
49 | begin
|
---|
50 | ShowMessage('X');
|
---|
51 | end;
|
---|
52 |
|
---|
53 | procedure TForm_Extractor.btn_pathClick(Sender: TObject);
|
---|
54 | var
|
---|
55 | fb: TFolderBrowser;
|
---|
56 | begin
|
---|
57 | inherited;
|
---|
58 |
|
---|
59 | fb := TFolderBrowser.Create(Handle, 'Please select a folder where you want ' +
|
---|
60 | 'the files to be stored...', edit_path.Text, False, True);
|
---|
61 | if fb.Execute then
|
---|
62 | begin
|
---|
63 | edit_path.Text := fb.SelectedItem;
|
---|
64 | AppSettings.ExtractPath := edit_path.Text;
|
---|
65 | end;
|
---|
66 | fb.Free;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TForm_Extractor.btn_exportClick(Sender: TObject);
|
---|
70 | var
|
---|
71 | begintime: Double;
|
---|
72 | files: LongWord;
|
---|
73 | i, done: LongWord;
|
---|
74 | selonly: Boolean;
|
---|
75 | fileid: LongWord;
|
---|
76 | filename: String;
|
---|
77 | path: String;
|
---|
78 | begin
|
---|
79 | inherited;
|
---|
80 | panel_files.Enabled := False;
|
---|
81 | group_extract.Enabled := False;
|
---|
82 | group_progress.Visible := True;
|
---|
83 |
|
---|
84 | path := edit_path.Text;
|
---|
85 | if not EndsText('\', path) then
|
---|
86 | path := path + '\';
|
---|
87 |
|
---|
88 | begintime := Time;
|
---|
89 | lbl_estimated.Caption := 'Estimated finishing time: unknown';
|
---|
90 | progress.Position := 0;
|
---|
91 |
|
---|
92 | selonly := radio_selected.Checked;
|
---|
93 |
|
---|
94 | if selonly then
|
---|
95 | files := filelist.SelCount
|
---|
96 | else
|
---|
97 | files := filelist.Count;
|
---|
98 |
|
---|
99 | lbl_progress.Caption := 'Files done: 0/' + IntToStr(files);
|
---|
100 | progress.Max := files;
|
---|
101 | done := 0;
|
---|
102 |
|
---|
103 | for i := 0 to filelist.Count - 1 do
|
---|
104 | begin
|
---|
105 | if (selonly and filelist.Selected[i]) or not selonly then
|
---|
106 | begin
|
---|
107 | fileid := Connection.ExtractFileID(filelist.Items.Strings[i]);
|
---|
108 | filename := GetWinFilename(filelist.Items.Strings[i]);
|
---|
109 | if check_dat.Checked then
|
---|
110 | ExportDatFile(Connection, fileid, path + filename);
|
---|
111 | if check_raw.Checked then
|
---|
112 | ExportRawFiles(Connection, fileid, path + filename);
|
---|
113 | if check_convert.Checked then
|
---|
114 | ExportConverted(Connection, fileid, path + filename);
|
---|
115 | Inc(done);
|
---|
116 | end;
|
---|
117 | if ((done mod 10) = 0) and (done >= 50) then
|
---|
118 | lbl_estimated.Caption := 'Estimated finishing time: ' + TimeToStr(
|
---|
119 | (Time - begintime) / done * files + begintime);
|
---|
120 |
|
---|
121 | progress.Position := done;
|
---|
122 | lbl_progress.Caption := 'Files done: ' + IntToStr(done) + '/' + IntToStr(files);
|
---|
123 | Application.ProcessMessages;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | panel_files.Enabled := True;
|
---|
127 | group_extract.Enabled := True;
|
---|
128 | group_progress.Visible := False;
|
---|
129 | end;
|
---|
130 |
|
---|
131 |
|
---|
132 | begin
|
---|
133 | AddToolListEntry('extractor', 'Extractor', '');
|
---|
134 | end.
|
---|