source: oup/current/Tools/Extractor.pas@ 1111

Last change on this file since 1111 was 321, checked in by alloc, 16 years ago
File size: 3.6 KB
Line 
1unit Extractor;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls,
8 VirtualTrees;
9
10type
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
37implementation
38{$R *.dfm}
39uses
40 Data, FolderBrowser, Exporters, _TemplateFile, ConnectionManager, Functions,
41 StrUtils;
42
43
44
45procedure TForm_Extractor.btn_abortClick(Sender: TObject);
46begin
47 ShowMessage('X');
48end;
49
50procedure TForm_Extractor.btn_exportClick(Sender: TObject);
51var
52 begintime: Double;
53 files: Integer;
54 i, done: Integer;
55 selonly: Boolean;
56 fileid: Integer;
57 filename: String;
58 path: String;
59begin
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;
110end;
111
112procedure TForm_Extractor.btn_pathClick(Sender: TObject);
113var
114 fb: TFolderBrowser;
115begin
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;
126end;
127
128procedure TForm_Extractor.FormCreate(Sender: TObject);
129begin
130 inherited;
131 Self.AllowMultiSelect := True;
132 edit_path.Text := AppSettings.ExtractPath;
133end;
134
135begin
136 AddToolListEntry('extractor', 'Extractor', '');
137end.
138
Note: See TracBrowser for help on using the repository browser.