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

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