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

Last change on this file since 252 was 220, checked in by alloc, 17 years ago
File size: 3.6 KB
RevLine 
[93]1unit Extractor;
[220]2
[93]3interface
[220]4
[93]5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
[220]7 Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls;
[93]8
9type
[220]10 TForm_Extractor = class(TForm_TemplateFileList)
[93]11 group_extract: TGroupBox;
[220]12 label_export_sel: TLabel;
13 label_path: TLabel;
[93]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;
[220]27 procedure btn_abortClick(Sender: TObject);
[93]28 procedure FormCreate(Sender: TObject);
[220]29 procedure btn_exportClick(Sender: TObject);
[93]30 procedure btn_pathClick(Sender: TObject);
31 private
32 public
33 end;
34
35
36implementation
37{$R *.dfm}
[220]38uses
39 Data, FolderBrowser, Exporters, _TemplateFile, ConnectionManager, Functions,
40 StrUtils;
[93]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;
[111]52 files: Integer;
53 i, done: Integer;
[93]54 selonly: Boolean;
[111]55 fileid: Integer;
[93]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
[105]87 fileid := ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]);
[93]88 filename := GetWinFilename(filelist.Items.Strings[i]);
89 if check_dat.Checked then
[105]90 ExportDatFile(ConnectionID, fileid, path + filename);
[93]91 if check_raw.Checked then
[105]92 ExportRawFiles(ConnectionID, fileid, path + filename);
[93]93 if check_convert.Checked then
[105]94 ExportConverted(ConnectionID, fileid, path + filename);
[93]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
[220]111procedure TForm_Extractor.btn_pathClick(Sender: TObject);
112var
113 fb: TFolderBrowser;
114begin
115 inherited;
[93]116
[220]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);
[93]128begin
[220]129 inherited;
130 Self.AllowMultiSelect := True;
131 edit_path.Text := AppSettings.ExtractPath;
132end;
133
134begin
[93]135 AddToolListEntry('extractor', 'Extractor', '');
[220]136end.
137
Note: See TracBrowser for help on using the repository browser.