-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.pas
executable file
·117 lines (102 loc) · 3.19 KB
/
main.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
unit main;
{$ifdef fpc}{$mode objfpc}{$H+} {$endif}
interface
uses
{$ifdef fpc} Process, strutils, FileUtil, ZStream, {$endif}
{$ifndef fpc} ShellAPI,messages, strutils, {$endif}
SysUtils, Forms, Controls, Dialogs, Buttons,
StdCtrls, ExtCtrls, Classes, mat;
type
{ TForm1 }
TForm1 = class(TForm)
AppendSeriesTypeIDCheck: TCheckBox;
CompressFileCheck: TCheckBox;
ConvertBtn: TButton;
ConvertLabel: TLabel;
FOVx10Check: TCheckBox;
OnlyConvert3DCheck: TCheckBox;
VerboseCheck: TCheckBox;
AppendProtocolNameCheck: TCheckBox;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
procedure ConvertBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ConvertFile(FName: string);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
procedure FormShow(Sender: TObject);
private
{ private declarations }
{$ifndef fpc} procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES; {$endif}
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$ifdef fpc}
{$R *.lfm}
{$else}
{$R *.DFM}
{$endif}
{ TForm1 }
procedure Showmsg(lStr: string);
begin
Form1.Memo1.lines.Add(lStr);
end;
{$include common.inc}
procedure TForm1.ConvertFile(FName: string);
begin
{$ifdef fpc}
BrConvertBatch (FName,'', FOVx10Check.checked, VerboseCheck.Checked, OnlyConvert3DCheck.Checked, AppendProtocolNameCheck.Checked, AppendSeriesTypeIDCheck.Checked, CompressFileCheck.checked);
{$else}
BrConvertBatch (FName,'', FOVx10Check.checked, VerboseCheck.Checked, OnlyConvert3DCheck.Checked, AppendProtocolNameCheck.Checked, AppendSeriesTypeIDCheck.Checked, false);
{$endif}
end;
procedure TForm1.ConvertBtnClick(Sender: TObject);
begin
opendialog1.Filter := '"subject" or "acqp"|subject;acqp';
opendialog1.Title:='Select Bruker format file';
if not opendialog1.Execute then exit;
Form1.Memo1.lines.Clear;
ConvertFile (opendialog1.FileName);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Showmsg(kVers);
{$ifdef fpc}
DefaultFormatSettings.DecimalSeparator := '.'; //e.g. German users write "1,23", but Bruker requires "1.23"
{$else}
DragAcceptFiles(Handle, True);
DecimalSeparator := '.'; //e.g. German users write "1,23", but Bruker requires "1.23"
{$endif}
end;
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);
var
lI: integer;
begin
Form1.Memo1.lines.Clear;
for lI := 0 to (length(FileNames)-1) do
ConvertFile(Filenames[lI]);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
//BrConvertBatch ('/Users/rorden/tst/2','/Users/rorden/tst', FOVx10Check.checked, VerboseCheck.Checked, OnlyConvert3DCheck.Checked, AppendProtocolNameCheck.Checked, AppendSeriesTypeIDCheck.Checked);
end;
{$ifndef fpc}
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles); //implement drag and drop
const
MAX_PATH = 1024;
var CFileName: array[0..MAX_PATH] of Char;
begin
try
if DragQueryFile(Msg.Drop, 0, CFileName, MAX_PATH) > 0 then begin
ConvertFile(CFilename);
Msg.Result := 0;
end;
finally
DragFinish(Msg.Drop);
end;
end; //WMDropFiles
{$endif}
end.