source: oup/releases/0.34a/Tools/Extractor.pas@ 455

Last change on this file since 455 was 200, checked in by alloc, 18 years ago
File size: 3.6 KB
RevLine 
[200]1unit Extractor;
2interface
3uses
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, Template, StdCtrls, ExtCtrls, ComCtrls, Menus, Buttons, StrUtils;
6
7type
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
33var
34 Form_Extractor: TForm_Extractor;
35
36implementation
37{$R *.dfm}
38uses Main, Functions, Data, ConnectionManager, FolderBrowser, Exporters;
39
40
41procedure TForm_Extractor.FormCreate(Sender: TObject);
42begin
43 inherited;
44 Self.AllowMultiSelect := True;
45 edit_path.Text := AppSettings.ExtractPath;
46end;
47
48procedure TForm_Extractor.btn_abortClick(Sender: TObject);
49begin
50 ShowMessage('X');
51end;
52
53procedure TForm_Extractor.btn_pathClick(Sender: TObject);
54var
55 fb: TFolderBrowser;
56begin
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;
67end;
68
69procedure TForm_Extractor.btn_exportClick(Sender: TObject);
70var
71 begintime: Double;
72 files: Integer;
73 i, done: Integer;
74 selonly: Boolean;
75 fileid: Integer;
76 filename: String;
77 path: String;
78begin
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 := ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]);
108 filename := GetWinFilename(filelist.Items.Strings[i]);
109 if check_dat.Checked then
110 ExportDatFile(ConnectionID, fileid, path + filename);
111 if check_raw.Checked then
112 ExportRawFiles(ConnectionID, fileid, path + filename);
113 if check_convert.Checked then
114 ExportConverted(ConnectionID, 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;
129end;
130
131
132begin
133 AddToolListEntry('extractor', 'Extractor', '');
134end.
Note: See TracBrowser for help on using the repository browser.