[93] | 1 | unit Extractor;
|
---|
[220] | 2 |
|
---|
[93] | 3 | interface
|
---|
[220] | 4 |
|
---|
[93] | 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
[321] | 7 | Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls,
|
---|
| 8 | VirtualTrees;
|
---|
[93] | 9 |
|
---|
| 10 | type
|
---|
[220] | 11 | TForm_Extractor = class(TForm_TemplateFileList)
|
---|
[93] | 12 | group_extract: TGroupBox;
|
---|
[220] | 13 | label_export_sel: TLabel;
|
---|
| 14 | label_path: TLabel;
|
---|
[93] | 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;
|
---|
[220] | 28 | procedure btn_abortClick(Sender: TObject);
|
---|
[93] | 29 | procedure FormCreate(Sender: TObject);
|
---|
[220] | 30 | procedure btn_exportClick(Sender: TObject);
|
---|
[93] | 31 | procedure btn_pathClick(Sender: TObject);
|
---|
| 32 | private
|
---|
| 33 | public
|
---|
| 34 | end;
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | implementation
|
---|
| 38 | {$R *.dfm}
|
---|
[220] | 39 | uses
|
---|
| 40 | Data, FolderBrowser, Exporters, _TemplateFile, ConnectionManager, Functions,
|
---|
| 41 | StrUtils;
|
---|
[93] | 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;
|
---|
[111] | 53 | files: Integer;
|
---|
| 54 | i, done: Integer;
|
---|
[93] | 55 | selonly: Boolean;
|
---|
[111] | 56 | fileid: Integer;
|
---|
[93] | 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
|
---|
[105] | 88 | fileid := ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]);
|
---|
[93] | 89 | filename := GetWinFilename(filelist.Items.Strings[i]);
|
---|
| 90 | if check_dat.Checked then
|
---|
[105] | 91 | ExportDatFile(ConnectionID, fileid, path + filename);
|
---|
[93] | 92 | if check_raw.Checked then
|
---|
[105] | 93 | ExportRawFiles(ConnectionID, fileid, path + filename);
|
---|
[93] | 94 | if check_convert.Checked then
|
---|
[105] | 95 | ExportConverted(ConnectionID, fileid, path + filename);
|
---|
[93] | 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 |
|
---|
[220] | 112 | procedure TForm_Extractor.btn_pathClick(Sender: TObject);
|
---|
| 113 | var
|
---|
| 114 | fb: TFolderBrowser;
|
---|
| 115 | begin
|
---|
| 116 | inherited;
|
---|
[93] | 117 |
|
---|
[220] | 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);
|
---|
[93] | 129 | begin
|
---|
[220] | 130 | inherited;
|
---|
| 131 | Self.AllowMultiSelect := True;
|
---|
| 132 | edit_path.Text := AppSettings.ExtractPath;
|
---|
| 133 | end;
|
---|
| 134 |
|
---|
| 135 | begin
|
---|
[93] | 136 | AddToolListEntry('extractor', 'Extractor', '');
|
---|
[220] | 137 | end.
|
---|
| 138 |
|
---|