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