| 1 |
unit Unit1; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, |
| 7 |
System.Classes, Vcl.Graphics, |
| 8 |
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, |
| 9 |
Vcl.Imaging.pngimage, System.Actions, Vcl.ActnList, Vcl.Touch.GestureMgr, |
| 10 |
Vcl.FileCtrl, Vcl.Buttons, System.UITypes, System.IniFiles, System.IOUtils, |
| 11 |
Vcl.ExtDlgs, System.Zip; |
| 12 |
|
| 13 |
type |
| 14 |
TForm1 = class(TForm) |
| 15 |
AppBar: TPanel; |
| 16 |
CloseButton: TImage; |
| 17 |
ActionList1: TActionList; |
| 18 |
Action1: TAction; |
| 19 |
GestureManager1: TGestureManager; |
| 20 |
DirectoryListBox1: TDirectoryListBox; |
| 21 |
Edit1: TEdit; |
| 22 |
BitBtn1: TBitBtn; |
| 23 |
Button1: TButton; |
| 24 |
ListBox1: TListBox; |
| 25 |
Button2: TButton; |
| 26 |
ComboBox1: TComboBox; |
| 27 |
Label1: TLabel; |
| 28 |
Button3: TButton; |
| 29 |
Label2: TLabel; |
| 30 |
Label3: TLabel; |
| 31 |
Label4: TLabel; |
| 32 |
Label5: TLabel; |
| 33 |
Button4: TButton; |
| 34 |
OpenTextFileDialog1: TOpenTextFileDialog; |
| 35 |
CheckBox1: TCheckBox; |
| 36 |
DriveComboBox1: TDriveComboBox; |
| 37 |
Panel1: TPanel; |
| 38 |
procedure CloseButtonClick(Sender: TObject); |
| 39 |
procedure Action1Execute(Sender: TObject); |
| 40 |
procedure FormResize(Sender: TObject); |
| 41 |
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
| 42 |
procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo; |
| 43 |
var Handled: Boolean); |
| 44 |
procedure FormCreate(Sender: TObject); |
| 45 |
procedure BitBtn1Click(Sender: TObject); |
| 46 |
procedure Button1Click(Sender: TObject); |
| 47 |
procedure Label1Click(Sender: TObject); |
| 48 |
procedure Button3Click(Sender: TObject); |
| 49 |
procedure DirectoryListBox1Click(Sender: TObject); |
| 50 |
procedure Edit1Change(Sender: TObject); |
| 51 |
procedure FormDestroy(Sender: TObject); |
| 52 |
procedure Label3Click(Sender: TObject); |
| 53 |
procedure Button4Click(Sender: TObject); |
| 54 |
private |
| 55 |
{ private ���� } |
| 56 |
procedure AppBarResize; |
| 57 |
procedure AppBarShow(mode: integer); |
| 58 |
public |
| 59 |
{ public ���� } |
| 60 |
List: TStringList; |
| 61 |
procedure Preview(const fileName: string); |
| 62 |
end; |
| 63 |
|
| 64 |
var |
| 65 |
Form1: TForm1; |
| 66 |
|
| 67 |
implementation |
| 68 |
|
| 69 |
{$R *.dfm} |
| 70 |
|
| 71 |
const |
| 72 |
AppBarHeight = 75; |
| 73 |
|
| 74 |
procedure TForm1.AppBarResize; |
| 75 |
begin |
| 76 |
AppBar.SetBounds(0, AppBar.Parent.Height - AppBarHeight, AppBar.Parent.Width, |
| 77 |
AppBarHeight); |
| 78 |
end; |
| 79 |
|
| 80 |
procedure TForm1.AppBarShow(mode: integer); |
| 81 |
begin |
| 82 |
if mode = -1 then // �������� |
| 83 |
mode := integer(not AppBar.Visible); |
| 84 |
|
| 85 |
if mode = 0 then |
| 86 |
AppBar.Visible := False |
| 87 |
else |
| 88 |
begin |
| 89 |
AppBar.Visible := True; |
| 90 |
AppBar.BringToFront; |
| 91 |
end; |
| 92 |
end; |
| 93 |
|
| 94 |
procedure TForm1.BitBtn1Click(Sender: TObject); |
| 95 |
begin |
| 96 |
if System.SysUtils.DirectoryExists(Edit1.Text) = True then |
| 97 |
begin |
| 98 |
DirectoryListBox1.Directory := Edit1.Text; |
| 99 |
DirectoryListBox1Click(Sender); |
| 100 |
end; |
| 101 |
end; |
| 102 |
|
| 103 |
procedure TForm1.Button1Click(Sender: TObject); |
| 104 |
var |
| 105 |
s1, s2, s3: string; |
| 106 |
z: TZipFile; |
| 107 |
x: Boolean; |
| 108 |
begin |
| 109 |
s3 := ''; |
| 110 |
x := Copy(Label1.Caption,1,10) <> 'Click here'; |
| 111 |
if (Sender = Button1)or(x = true) then |
| 112 |
Preview(Edit1.Text + '\' + ComboBox1.Text); |
| 113 |
if (Sender = Button2)and(x = true) then |
| 114 |
begin |
| 115 |
z := TZipFile.Create; |
| 116 |
try |
| 117 |
for s1 in List do |
| 118 |
begin |
| 119 |
if s3 = '' then |
| 120 |
begin |
| 121 |
s3 := Label1.Caption + '\' + ChangeFileExt(ExtractFileName(s1), ''); |
| 122 |
if CheckBox1.Checked = True then |
| 123 |
begin |
| 124 |
if FileExists(s3 + '.zip') = True then |
| 125 |
DeleteFile(s3 + '.zip'); |
| 126 |
z.Open(s3 + '.zip', TZipMode.zmWrite); |
| 127 |
end |
| 128 |
else if System.SysUtils.DirectoryExists(s3) = False then |
| 129 |
MkDir(s3); |
| 130 |
end; |
| 131 |
s2 := s3 + '\' + ExtractFileName(s1); |
| 132 |
if CheckBox1.Checked = True then |
| 133 |
z.Add(s1) |
| 134 |
else |
| 135 |
CopyFile(System.PWideChar(s1), System.PWideChar(s2), False); |
| 136 |
end; |
| 137 |
finally |
| 138 |
z.Free; |
| 139 |
end; |
| 140 |
end; |
| 141 |
end; |
| 142 |
|
| 143 |
procedure TForm1.Button3Click(Sender: TObject); |
| 144 |
begin |
| 145 |
Close; |
| 146 |
end; |
| 147 |
|
| 148 |
procedure TForm1.Button4Click(Sender: TObject); |
| 149 |
begin |
| 150 |
if System.SysUtils.DirectoryExists(Label1.Caption) = True then |
| 151 |
begin |
| 152 |
OpenTextFileDialog1.InitialDir := Label1.Caption; |
| 153 |
OpenTextFileDialog1.Execute; |
| 154 |
end; |
| 155 |
end; |
| 156 |
|
| 157 |
procedure TForm1.Action1Execute(Sender: TObject); |
| 158 |
begin |
| 159 |
AppBarShow(-1); |
| 160 |
end; |
| 161 |
|
| 162 |
procedure TForm1.CloseButtonClick(Sender: TObject); |
| 163 |
begin |
| 164 |
Application.Terminate; |
| 165 |
end; |
| 166 |
|
| 167 |
procedure TForm1.DirectoryListBox1Click(Sender: TObject); |
| 168 |
var |
| 169 |
s: TSearchRec; |
| 170 |
i: integer; |
| 171 |
t: string; |
| 172 |
begin |
| 173 |
t := ''; |
| 174 |
for i := 0 to DirectoryListBox1.ItemIndex do |
| 175 |
begin |
| 176 |
if i < 2 then |
| 177 |
begin |
| 178 |
t := t + DirectoryListBox1.Items[i]; |
| 179 |
end |
| 180 |
else |
| 181 |
begin |
| 182 |
t := t + '\' + DirectoryListBox1.Items[i]; |
| 183 |
end; |
| 184 |
if (t = DirectoryListBox1.Directory) and (i < DirectoryListBox1.ItemIndex) |
| 185 |
then |
| 186 |
begin |
| 187 |
if i < 1 then |
| 188 |
begin |
| 189 |
t := t + DirectoryListBox1.Items[DirectoryListBox1.ItemIndex]; |
| 190 |
end |
| 191 |
else |
| 192 |
begin |
| 193 |
t := t + '\' + DirectoryListBox1.Items[DirectoryListBox1.ItemIndex]; |
| 194 |
end; |
| 195 |
break; |
| 196 |
end; |
| 197 |
end; |
| 198 |
Edit1.Text := t; |
| 199 |
if ListBox1.Items.Count > 0 then |
| 200 |
ListBox1.Items.Clear; |
| 201 |
if ComboBox1.Items.Count > 0 then |
| 202 |
ComboBox1.Items.Clear; |
| 203 |
i := FindFirst(Edit1.Text + '\*.dpr', faAnyFile, s); |
| 204 |
try |
| 205 |
while i = 0 do |
| 206 |
begin |
| 207 |
if CompareText(ExtractFileExt(s.Name), '.dpr') = 0 then |
| 208 |
ComboBox1.Items.Add(s.Name); |
| 209 |
i := FindNext(s); |
| 210 |
end; |
| 211 |
finally |
| 212 |
FindClose(s); |
| 213 |
end; |
| 214 |
if ComboBox1.Items.Count = 0 then |
| 215 |
begin |
| 216 |
ComboBox1.Text := ''; |
| 217 |
end |
| 218 |
else |
| 219 |
begin |
| 220 |
ComboBox1.Text := ComboBox1.Items[0]; |
| 221 |
end; |
| 222 |
end; |
| 223 |
|
| 224 |
procedure TForm1.Edit1Change(Sender: TObject); |
| 225 |
begin |
| 226 |
Edit1.Hint := Edit1.Text; |
| 227 |
end; |
| 228 |
|
| 229 |
procedure TForm1.FormCreate(Sender: TObject); |
| 230 |
var |
| 231 |
s: TIniFile; |
| 232 |
begin |
| 233 |
s := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini')); |
| 234 |
try |
| 235 |
Edit1.Text := s.ReadString('Directory', 'Current', |
| 236 |
DirectoryListBox1.Directory); |
| 237 |
Label1.Caption := s.ReadString('Directory', 'Save', Label1.Caption); |
| 238 |
finally |
| 239 |
s.Free; |
| 240 |
end; |
| 241 |
BitBtn1Click(Sender); |
| 242 |
Label3.Caption := Edit1.Text; |
| 243 |
List := TStringList.Create; |
| 244 |
end; |
| 245 |
|
| 246 |
procedure TForm1.FormDestroy(Sender: TObject); |
| 247 |
var |
| 248 |
s: TIniFile; |
| 249 |
begin |
| 250 |
List.Free; |
| 251 |
s := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini')); |
| 252 |
try |
| 253 |
s.WriteString('Directory', 'Current', Label3.Caption); |
| 254 |
if System.SysUtils.DirectoryExists(Label1.Caption) = True then |
| 255 |
s.WriteString('Directory', 'Save', Label1.Caption); |
| 256 |
finally |
| 257 |
s.Free; |
| 258 |
end; |
| 259 |
end; |
| 260 |
|
| 261 |
procedure TForm1.FormGesture(Sender: TObject; |
| 262 |
const EventInfo: TGestureEventInfo; var Handled: Boolean); |
| 263 |
begin |
| 264 |
AppBarShow(0); |
| 265 |
end; |
| 266 |
|
| 267 |
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; |
| 268 |
Shift: TShiftState); |
| 269 |
begin |
| 270 |
if Key = VK_ESCAPE then |
| 271 |
AppBarShow(-1) |
| 272 |
else |
| 273 |
AppBarShow(0); |
| 274 |
end; |
| 275 |
|
| 276 |
procedure TForm1.FormResize(Sender: TObject); |
| 277 |
begin |
| 278 |
AppBarResize; |
| 279 |
end; |
| 280 |
|
| 281 |
procedure TForm1.Label1Click(Sender: TObject); |
| 282 |
begin |
| 283 |
if System.SysUtils.DirectoryExists(Edit1.Text) = false then |
| 284 |
MkDir(Edit1.Text); |
| 285 |
if MessageDlg('Change Save-Dir?', mtInformation, [mbOK, mbCancel], 0) = mrOK then |
| 286 |
Label1.Caption := Edit1.Text; |
| 287 |
end; |
| 288 |
|
| 289 |
procedure TForm1.Label3Click(Sender: TObject); |
| 290 |
begin |
| 291 |
if (System.SysUtils.DirectoryExists(Edit1.Text) = True) and |
| 292 |
(MessageDlg('Change Current-Dir?', mtInformation, [mbOK, mbCancel], 0) |
| 293 |
= mrOK) then |
| 294 |
Label3.Caption := Edit1.Text; |
| 295 |
end; |
| 296 |
|
| 297 |
procedure TForm1.Preview(const fileName: string); |
| 298 |
var |
| 299 |
s: TStringList; |
| 300 |
str1, str2: string; |
| 301 |
i: integer; |
| 302 |
j: integer; |
| 303 |
begin |
| 304 |
ListBox1.Items.Clear; |
| 305 |
List.Clear; |
| 306 |
if FileExists(ChangeFileExt(fileName, '.dproj')) = True then |
| 307 |
begin |
| 308 |
str1 := ChangeFileExt(fileName, '.dproj'); |
| 309 |
List.Add(str1); |
| 310 |
ListBox1.Items.Add(ExtractFileName(str1)); |
| 311 |
end; |
| 312 |
if FileExists(fileName) = True then |
| 313 |
begin |
| 314 |
List.Add(fileName); |
| 315 |
ListBox1.Items.Add(ExtractFileName(fileName)); |
| 316 |
end; |
| 317 |
if FileExists(ChangeFileExt(fileName, '.res')) = True then |
| 318 |
begin |
| 319 |
str1 := ChangeFileExt(fileName, '.res'); |
| 320 |
List.Add(str1); |
| 321 |
ListBox1.Items.Add(ExtractFileName(str1)); |
| 322 |
end; |
| 323 |
s := TStringList.Create; |
| 324 |
try |
| 325 |
if FileExists(fileName) = True then |
| 326 |
s.LoadFromFile(fileName); |
| 327 |
for i := 0 to s.Count - 1 do |
| 328 |
begin |
| 329 |
str1 := s[i]; |
| 330 |
j := Pos(' in ', str1); |
| 331 |
if j > 0 then |
| 332 |
begin |
| 333 |
Delete(str1, 1, j + 3); |
| 334 |
Delete(str1, 1, Pos('''', str1)); |
| 335 |
str1 := Copy(str1, 1, Pos('''', str1) - 1); |
| 336 |
if List.Count > 0 then |
| 337 |
str2 := ExtractFilePath(List[0]); |
| 338 |
j := List.Add(TPath.Combine(str2, str1)); |
| 339 |
ListBox1.Items.Add(ExtractFileName(str1)); |
| 340 |
str1 := List[j]; |
| 341 |
if CompareText(ExtractFileExt(str1), '.pas') = 0 then |
| 342 |
begin |
| 343 |
str1 := ChangeFileExt(str1, '.dfm'); |
| 344 |
if FileExists(str1) = True then |
| 345 |
begin |
| 346 |
List.Add(str1); |
| 347 |
ListBox1.Items.Add(ExtractFileName(str1)); |
| 348 |
end; |
| 349 |
str1 := ChangeFileExt(str1, '.fmx'); |
| 350 |
if FileExists(str1) = True then |
| 351 |
begin |
| 352 |
List.Add(str1); |
| 353 |
ListBox1.Items.Add(ExtractFileName(str1)); |
| 354 |
end; |
| 355 |
end; |
| 356 |
continue; |
| 357 |
end; |
| 358 |
str1 := Copy(TrimLeft(s[i]), 1, 5); |
| 359 |
if CompareText(str1, 'begin') = 0 then |
| 360 |
break; |
| 361 |
end; |
| 362 |
finally |
| 363 |
s.Free; |
| 364 |
end; |
| 365 |
end; |
| 366 |
|
| 367 |
end. |