Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | Unit Addunit; |
2 | (************************************************************************ |
||
3 | Copyright (C) 2009, 2010 by Russell J. Peters, Roger Aelbrecht, |
||
4 | Eric W. Engler and Chris Vleghert. |
||
5 | |||
6 | This file is part of TZipMaster Version 1.9. |
||
7 | |||
8 | TZipMaster is free software: you can redistribute it and/or modify |
||
9 | it under the terms of the GNU Lesser General Public License as published by |
||
10 | the Free Software Foundation, either version 3 of the License, or |
||
11 | (at your option) any later version. |
||
12 | |||
13 | TZipMaster is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | GNU Lesser General Public License for more details. |
||
17 | |||
18 | You should have received a copy of the GNU Lesser General Public License |
||
19 | along with TZipMaster. If not, see <http://www.gnu.org/licenses/>. |
||
20 | |||
21 | contact: problems@delphizip.org (include ZipMaster in the subject). |
||
22 | updates: http://www.delphizip.org |
||
23 | DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip |
||
24 | ************************************************************************) |
||
25 | |||
26 | {$INCLUDE '..\..\ZipVers19.inc'} |
||
27 | {$IFDEF VERD6up} |
||
28 | {$WARN UNIT_PLATFORM OFF} |
||
29 | {$WARN SYMBOL_PLATFORM OFF} |
||
30 | {$ENDIF} |
||
31 | |||
32 | Interface |
||
33 | |||
34 | Uses |
||
35 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
||
36 | StdCtrls, FileCtrl, ExtCtrls, Menus, ShlObj; |
||
37 | |||
38 | Type |
||
39 | TAddForm = Class(TForm) |
||
40 | Panel1: TPanel; |
||
41 | Panel2: TPanel; |
||
42 | Panel3: TPanel; |
||
43 | Panel4: TPanel; |
||
44 | Panel5: TPanel; |
||
45 | Panel6: TPanel; |
||
46 | Panel7: TPanel; |
||
47 | Panel8: TPanel; |
||
48 | DriveComboBox1: TDriveComboBox; |
||
49 | FileListBox1: TFileListBox; |
||
50 | DirectoryListBox1: TDirectoryListBox; |
||
51 | OKBut: TButton; |
||
52 | AddBtn: TButton; |
||
53 | SortBut: TButton; |
||
54 | RemoveBut: TButton; |
||
55 | CancelBut: TButton; |
||
56 | AddDirBut: TButton; |
||
57 | VolSizeBut: TButton; |
||
58 | AddFileBut: TButton; |
||
59 | FreeDisk1But: TButton; |
||
60 | SelectAllBut: TButton; |
||
61 | SelectedList: TListBox; |
||
62 | Label1: TLabel; |
||
63 | Label2: TLabel; |
||
64 | DirNameCB: TCheckBox; |
||
65 | RecurseCB: TCheckBox; |
||
66 | EncryptCB: TCheckBox; |
||
67 | DiskSpanCB: TCheckBox; |
||
68 | Bevel1: TBevel; |
||
69 | PopupMenu1: TPopupMenu; |
||
70 | Add1: TMenuItem; |
||
71 | Update1: TMenuItem; |
||
72 | Freshen1: TMenuItem; |
||
73 | Move1: TMenuItem; |
||
74 | AtribOnlyCB: TCheckBox; |
||
75 | AtribResetCB: TCheckBox; |
||
76 | FreeDiskAllBut: TButton; |
||
77 | |||
78 | Procedure OKButClick(Sender: TObject); |
||
79 | Procedure CancelButClick(Sender: TObject); |
||
80 | Procedure AddFileButClick(Sender: TObject); |
||
81 | Procedure SortButClick(Sender: TObject); |
||
82 | Procedure RemoveButClick(Sender: TObject); |
||
83 | Procedure SelectAllButClick(Sender: TObject); |
||
84 | Procedure FormCreate(Sender: TObject); |
||
85 | Procedure AddDirButClick(Sender: TObject); |
||
86 | Procedure AddBtnClick(Sender: TObject); |
||
87 | Procedure Add1Click(Sender: TObject); |
||
88 | Procedure VolSizeButClick(Sender: TObject); |
||
89 | Procedure FreeDiskAllButClick(Sender: TObject); |
||
90 | Procedure DiskSpanCBClick(Sender: TObject); |
||
91 | |||
92 | PUBLIC |
||
93 | { Public declarations } |
||
94 | ZipAction: Integer; |
||
95 | End; |
||
96 | |||
97 | Var |
||
98 | AddForm: TAddForm; |
||
99 | InMouseClick: Boolean; |
||
100 | |||
101 | Implementation |
||
102 | |||
103 | Uses mainunit; |
||
104 | {$R *.DFM} |
||
105 | |||
106 | Procedure TAddForm.OKButClick(Sender: TObject); |
||
107 | Begin |
||
108 | mainunit.Canceled := False; |
||
109 | Close; |
||
110 | End; |
||
111 | |||
112 | Procedure TAddForm.CancelButClick(Sender: TObject); |
||
113 | Begin |
||
114 | mainunit.Canceled := True; |
||
115 | Close; |
||
116 | End; |
||
117 | |||
118 | Procedure TAddForm.SortButClick(Sender: TObject); |
||
119 | Begin |
||
120 | SelectedList.Sorted := True; |
||
121 | SortBut.Enabled := False; { list will remain sorted } |
||
122 | End; |
||
123 | |||
124 | Procedure TAddForm.RemoveButClick(Sender: TObject); |
||
125 | Var |
||
126 | i: Integer; |
||
127 | Begin |
||
128 | For i := SelectedList.Items.Count - 1 Downto 0 Do |
||
129 | Begin |
||
130 | If SelectedList.Selected[i] Then |
||
131 | SelectedList.Items.Delete(i); |
||
132 | End; |
||
133 | End; |
||
134 | |||
135 | Procedure TAddForm.SelectAllButClick(Sender: TObject); |
||
136 | Var |
||
137 | i: Integer; |
||
138 | Begin |
||
139 | For i := 0 To FileListBox1.Items.Count - 1 Do |
||
140 | FileListBox1.Selected[i] := True; |
||
141 | End; |
||
142 | |||
143 | Procedure TAddForm.FormCreate(Sender: TObject); |
||
144 | Var |
||
145 | SpecFolder: String; |
||
146 | Begin |
||
147 | SpecFolder := ''; |
||
148 | |||
149 | MainForm.GetSpecialFolder(CSIDL_DESKTOPDIRECTORY, SpecFolder); |
||
150 | DriveComboBox1.Drive := ExtractFileDrive(SpecFolder)[1]; |
||
151 | DirectoryListBox1.Directory := ExtractFilePath(SpecFolder); |
||
152 | InMouseClick := False; |
||
153 | End; |
||
154 | |||
155 | Procedure TAddForm.AddDirButClick(Sender: TObject); |
||
156 | Var |
||
157 | i: Integer; |
||
158 | FullName: String; |
||
159 | Begin |
||
160 | mainunit.Canceled := True; // default |
||
161 | For i := 0 To DirectoryListBox1.Items.Count - 1 Do |
||
162 | Begin |
||
163 | If DirectoryListBox1.Selected[i] Then |
||
164 | Begin |
||
165 | // Add this file if it isn't already in listbox |
||
166 | FullName := MainForm.ZipMaster1.AppendSlash(DirectoryListBox1.Directory) |
||
167 | + '*.*'; |
||
168 | |||
169 | If SelectedList.Items.IndexOf(FullName) < 0 Then |
||
170 | SelectedList.Items.Add(FullName); |
||
171 | { Never de-select dirnames from the DirectoryList! } |
||
172 | { DirectoryListBox1.Selected[i]:=False; } |
||
173 | End; |
||
174 | End; |
||
175 | { Position the "SelectedList" listbox at the bottom } |
||
176 | With SelectedList Do |
||
177 | Begin |
||
178 | Selected[Items.Count - 1] := True; |
||
179 | Selected[Items.Count - 1] := False; |
||
180 | End; |
||
181 | End; |
||
182 | |||
183 | Procedure TAddForm.AddFileButClick(Sender: TObject); |
||
184 | Var |
||
185 | i: Integer; |
||
186 | FullName: String; |
||
187 | Begin |
||
188 | mainunit.Canceled := True; // default |
||
189 | For i := 0 To FileListBox1.Items.Count - 1 Do |
||
190 | Begin |
||
191 | If FileListBox1.Selected[i] Then |
||
192 | Begin |
||
193 | // Add this file if it isn't already in listbox |
||
194 | FullName := MainForm.ZipMaster1.AppendSlash(DirectoryListBox1.Directory) |
||
195 | + FileListBox1.Items[i]; |
||
196 | If SelectedList.Items.IndexOf(FullName) < 0 Then |
||
197 | SelectedList.Items.Add(FullName); |
||
198 | FileListBox1.Selected[i] := False; |
||
199 | End; |
||
200 | End; |
||
201 | { Position the "SelectedList" listbox at the bottom } |
||
202 | With SelectedList Do |
||
203 | Begin |
||
204 | Selected[Items.Count - 1] := True; |
||
205 | Selected[Items.Count - 1] := False; |
||
206 | End; |
||
207 | End; |
||
208 | |||
209 | Procedure TAddForm.AddBtnClick(Sender: TObject); |
||
210 | Var |
||
211 | pt: TPoint; |
||
212 | Begin |
||
213 | pt.x := 4; |
||
214 | pt.y := 4; |
||
215 | pt := AddBtn.ClientToScreen(pt); |
||
216 | PopupMenu1.Popup(pt.x, pt.y); |
||
217 | End; |
||
218 | |||
219 | Procedure TAddForm.Add1Click(Sender: TObject); |
||
220 | Begin |
||
221 | ZipAction := TMenuItem(Sender).Tag; |
||
222 | TMenuItem(Sender).Checked := True; |
||
223 | TMenuItem(Sender).Default := True; |
||
224 | AddBtn.Caption := 'Action: ' + TMenuItem(Sender).Caption; |
||
225 | End; |
||
226 | |||
227 | Procedure TAddForm.VolSizeButClick(Sender: TObject); |
||
228 | Begin |
||
229 | MainForm.ZipMaster1.MaxVolumeSize := StrToIntDef(InputBox('Max Vol size', |
||
230 | 'Maximum size of an archive part', IntToStr |
||
231 | (MainForm.ZipMaster1.MaxVolumeSize)), 0); |
||
232 | End; |
||
233 | |||
234 | Procedure TAddForm.FreeDiskAllButClick(Sender: TObject); |
||
235 | Begin |
||
236 | MainForm.ZipMaster1.KeepFreeOnAllDisks := StrToIntDef |
||
237 | (InputBox('Keep free on All Disks', 'Unused bytes on all disks', IntToStr |
||
238 | (MainForm.ZipMaster1.KeepFreeOnAllDisks)), 0); |
||
239 | End; |
||
240 | |||
241 | Procedure TAddForm.DiskSpanCBClick(Sender: TObject); |
||
242 | Begin |
||
243 | VolSizeBut.Enabled := DiskSpanCB.Checked; |
||
244 | FreeDisk1But.Enabled := DiskSpanCB.Checked; |
||
245 | End; |
||
246 | |||
247 | End. |