-
Notifications
You must be signed in to change notification settings - Fork 0
/
uDM.pas
167 lines (147 loc) · 4.44 KB
/
uDM.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
unit uDM;
interface
uses
System.SysUtils, System.Classes, System.Actions, Vcl.ActnList, Vcl.PlatformDefaultStyleActnCtrls, Vcl.ActnMan,
Vcl.ImgList, Vcl.Controls, inifiles, Vcl.Forms, OverbyteIcsWndControl, OverbyteIcsFtpCli;
type
PFTPData = ^TFTPData;
TFTPData = record
Name: string;
Size: integer;
Level: integer;
Dir: boolean;
ModifiedDate: string;
FullPath: string;
end;
PMapFile = ^TMapFile;
TMapFile = record
FileName: string;
Size: integer;
DateTime: string;
end;
Tdm = class(TDataModule)
ActionManager1: TActionManager;
actExit: TAction;
actSettings: TAction;
TreeImages: TImageList;
actAbout: TAction;
procedure actExitExecute(Sender: TObject);
procedure actSettingsExecute(Sender: TObject);
procedure actAboutExecute(Sender: TObject);
procedure DataModuleCreate(Sender: TObject);
// procedure ftpWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
// procedure ftpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
// procedure ftpWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
private
FIniFile : TIniFile;
FHost: string;
FUsername: string;
FPassword: string;
FPort: integer;
FCurrentFileSize: integer;
FPassive: boolean;
public
property Host: string read FHost write FHost;
property Username: string read FUsername write FUsername;
property Password: string read FPassword write FPassword;
property Port: integer read FPort write FPort;
property Passive: boolean read FPassive write FPassive;
procedure WriteIniFile;
function FormatByteSize(const bytes: Longint): string;
property CurrentFileSize: integer read FCurrentFileSize write FCurrentFileSize;
end;
var
dm: Tdm;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
uses
uFrmSettings, uFrmMain, uFrmAbout;
procedure Tdm.actAboutExecute(Sender: TObject);
begin
frmAbout.ShowModal;
end;
procedure Tdm.actExitExecute(Sender: TObject);
begin
frmMain.Close;
end;
procedure Tdm.actSettingsExecute(Sender: TObject);
begin
frmSettings.ShowModal;
end;
procedure Tdm.DataModuleCreate(Sender: TObject);
var
section: string;
begin
FIniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini')) ;
section := 'FTPServer';
try
FHost := FIniFile.ReadString(section,'Host','');
FUsername := FIniFile.ReadString(section,'Username','');
FPassword := FIniFile.ReadString(section,'Password','');
FPort := FIniFile.ReadInteger(section,'Port',21);
FPassive := FIniFile.ReadBool(section,'Passive',false);
finally
FIniFile.Free;
end;
end;
procedure Tdm.WriteIniFile;
var
section: string;
begin
FIniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini')) ;
section := 'FTPServer';
try
FIniFile.WriteString(section,'Host',FHost);
FIniFile.WriteString(section,'Username',FUsername);
FIniFile.WriteString(section,'Password',FPassword);
FIniFile.WriteInteger(section,'Port',FPort);
FIniFile.WriteBool(section,'Passive',FPassive);
finally
FIniFile.Free;
end;
end;
function Tdm.FormatByteSize(const bytes: Longint): string;
const
B = 1; //byte
KB = 1024 * B; //kilobyte
MB = 1024 * KB; //megabyte
GB = 1024 * MB; //gigabyte
begin
// if bytes > GB then
// result := FormatFloat('#.## GB', bytes / GB)
// else
// if bytes > MB then
// result := FormatFloat('#.## MB', bytes / MB)
// else
// if bytes > KB then
// result := FormatFloat('# KB', bytes / KB)
// else
// //result := FormatFloat('#.## bytes', bytes);
result := FormatFloat('#,##0', bytes);
end;
//procedure Tdm.ftpWork(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Int64);
//begin
// if frmMain.sProgressBar1.Max > 0 then
// begin
// frmMain.sProgressBar1.Position := AWorkCount;
// frmMain.lblUploadProgress.Caption := IntToStr((frmMain.sProgressBar1.Position * 100) div frmMain.sProgressBar1.Max) + '%';
// end else
// frmMain.lblUploadProgress.Caption := IntToStr(AWorkCount) + ' bytes';
// frmMain.Update;
//end;
//
//procedure Tdm.ftpWorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64);
//begin
// if AWorkMode = wmWrite then
// frmMain.sProgressBar1.Max := AWorkCountMax
// else;
// frmMain.sProgressBar1.Max := FCurrentFileSize;
// frmMain.sProgressBar1.Position := 0;
//end;
//
//procedure Tdm.ftpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
//begin
// frmMain.sProgressBar1.Position := 0;
//end;
end.