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 | |||
27 | {$INCLUDE '..\..\ZipVers19.inc'} |
||
28 | {$IFDEF VERD6up} |
||
29 | {$WARN UNIT_PLATFORM OFF} |
||
30 | {$WARN SYMBOL_PLATFORM OFF} |
||
31 | {$ENDIF} |
||
32 | |||
33 | interface |
||
34 | |||
35 | uses |
||
36 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
||
37 | StdCtrls, FileCtrl, ExtCtrls, Menus, ShlObj; |
||
38 | |||
39 | type |
||
40 | TAddFile = class( TForm ) |
||
41 | Panel1: TPanel; |
||
42 | Panel2: TPanel; |
||
43 | Panel3: TPanel; |
||
44 | Panel4: TPanel; |
||
45 | Panel5: TPanel; |
||
46 | Panel6: TPanel; |
||
47 | Panel7: TPanel; |
||
48 | Panel8: TPanel; |
||
49 | Panel9: TPanel; |
||
50 | Bevel1: TBevel; |
||
51 | Label1: TLabel; |
||
52 | Label2: TLabel; |
||
53 | Label3: TLabel; |
||
54 | AddFileBut: TButton; |
||
55 | RemoveBut: TButton; |
||
56 | OKBut: TButton; |
||
57 | CancelBut: TButton; |
||
58 | SelectAllBut: TButton; |
||
59 | SortBut: TButton; |
||
60 | AddDirBut: TButton; |
||
61 | AddWildBttn: TButton; |
||
62 | AddWildPathBttn: TButton; |
||
63 | DirNameCB: TCheckBox; |
||
64 | RecurseCB: TCheckBox; |
||
65 | EncryptCB: TCheckBox; |
||
66 | SelectedList: TListBox; |
||
67 | WildEdit: TEdit; |
||
68 | DriveComboBox1: TDriveComboBox; |
||
69 | FileListBox1: TFileListBox; |
||
70 | DirectoryListBox1: TDirectoryListBox; |
||
71 | |||
72 | procedure OKButClick( Sender: TObject ); |
||
73 | procedure CancelButClick( Sender: TObject ); |
||
74 | procedure AddFileButClick( Sender: TObject ); |
||
75 | procedure SortButClick( Sender: TObject ); |
||
76 | procedure RemoveButClick( Sender: TObject ); |
||
77 | procedure SelectAllButClick( Sender: TObject ); |
||
78 | procedure FormCreate( Sender: TObject ); |
||
79 | procedure AddDirButClick( Sender: TObject ); |
||
80 | procedure AddWildBttnClick( Sender: TObject ); |
||
81 | procedure AddWildPathBttnClick( Sender: TObject ); |
||
82 | |||
83 | public |
||
84 | { Public declarations } |
||
85 | end; |
||
86 | |||
87 | var |
||
88 | AddFile: TAddFile; |
||
89 | InMouseClick: Boolean; |
||
90 | |||
91 | implementation |
||
92 | |||
93 | uses main; |
||
94 | |||
95 | {$R *.DFM} |
||
96 | |||
97 | procedure TAddFile.OKButClick( Sender: TObject ); |
||
98 | begin |
||
99 | Main.Canceled := False; |
||
100 | Close; |
||
101 | end; |
||
102 | |||
103 | procedure TAddFile.CancelButClick( Sender: TObject ); |
||
104 | begin |
||
105 | Main.Canceled := True; |
||
106 | Close; |
||
107 | end; |
||
108 | |||
109 | procedure TAddFile.SortButClick( Sender: TObject ); |
||
110 | begin |
||
111 | SelectedList.Sorted := True; |
||
112 | SortBut.Enabled := False; { list will remain sorted } |
||
113 | end; |
||
114 | |||
115 | procedure TAddFile.RemoveButClick( Sender: TObject ); |
||
116 | var |
||
117 | i: Integer; |
||
118 | begin |
||
119 | for i := SelectedList.Items.Count - 1 downto 0 do |
||
120 | begin |
||
121 | if SelectedList.Selected[i] then |
||
122 | SelectedList.Items.Delete(i); |
||
123 | end; |
||
124 | end; |
||
125 | |||
126 | procedure TAddFile.SelectAllButClick( Sender: TObject ); |
||
127 | var |
||
128 | i: Integer; |
||
129 | begin |
||
130 | for i := 0 to FileListBox1.Items.Count - 1 do |
||
131 | FileListBox1.Selected[i] := True; |
||
132 | end; |
||
133 | |||
134 | procedure TAddFile.FormCreate( Sender: TObject ); |
||
135 | var |
||
136 | SpecFolder: String; |
||
137 | begin |
||
138 | SpecFolder := ''; |
||
139 | |||
140 | MainForm.GetSpecialFolder( CSIDL_DESKTOPDIRECTORY, SpecFolder ); |
||
141 | DriveComboBox1.Drive := ExtractFileDrive( SpecFolder )[1]; |
||
142 | DirectoryListBox1.Directory := ExtractFilePath( SpecFolder ); |
||
143 | InMouseClick := False; |
||
144 | end; |
||
145 | |||
146 | procedure TAddFile.AddDirButClick( Sender: TObject ); |
||
147 | var |
||
148 | i: Integer; |
||
149 | FullName: String; |
||
150 | begin |
||
151 | Main.Canceled := True; // default |
||
152 | for i := 0 to DirectoryListBox1.Items.Count - 1 do |
||
153 | begin |
||
154 | if DirectoryListBox1.Selected[i] then |
||
155 | begin |
||
156 | // Add this file if it isn't already in listbox |
||
157 | FullName := Mainform.ZipMaster1.AppendSlash( DirectoryListBox1.Directory ) + '*.*'; |
||
158 | |||
159 | if SelectedList.Items.IndexOf( FullName ) < 0 then |
||
160 | SelectedList.Items.Add( FullName ); |
||
161 | { Never de-select dirnames from the DirectoryList! } |
||
162 | { DirectoryListBox1.Selected[i]:=False; } |
||
163 | end; |
||
164 | end; |
||
165 | { Position the "SelectedList" listbox at the bottom } |
||
166 | with SelectedList do |
||
167 | begin |
||
168 | Selected[Items.Count - 1] := True; |
||
169 | Selected[Items.Count - 1] := False; |
||
170 | end; |
||
171 | end; |
||
172 | |||
173 | procedure TAddFile.AddFileButClick( Sender: TObject ); |
||
174 | var |
||
175 | i: Integer; |
||
176 | FullName: String; |
||
177 | begin |
||
178 | Main.Canceled := True; // default |
||
179 | for i := 0 to FileListBox1.Items.Count - 1 do |
||
180 | begin |
||
181 | if FileListBox1.Selected[i] then |
||
182 | begin |
||
183 | // Add this file if it isn't already in listbox |
||
184 | FullName := Mainform.ZipMaster1.AppendSlash( DirectoryListBox1.Directory ) + FileListBox1.Items[i]; |
||
185 | if SelectedList.Items.IndexOf( FullName ) < 0 then |
||
186 | SelectedList.Items.Add( FullName ); |
||
187 | FileListBox1.Selected[i] := False; |
||
188 | end; |
||
189 | end; |
||
190 | { Position the "SelectedList" listbox at the bottom } |
||
191 | with SelectedList do |
||
192 | begin |
||
193 | Selected[Items.Count - 1] := True; |
||
194 | Selected[Items.Count - 1] := False; |
||
195 | end; |
||
196 | end; |
||
197 | |||
198 | procedure TAddFile.AddWildBttnClick( Sender: TObject ); |
||
199 | begin |
||
200 | with SelectedList, SelectedList.Items do |
||
201 | begin |
||
202 | if (Length( WildEdit.Text ) > 0) and (IndexOf( WildEdit.Text ) < 0) then |
||
203 | begin |
||
204 | Add( WildEdit.Text ); |
||
205 | // Position the "SelectedList" listbox at the bottom. |
||
206 | Selected[Count - 1] := True; |
||
207 | Selected[Count - 1] := False; |
||
208 | end; |
||
209 | end; |
||
210 | end; |
||
211 | |||
212 | procedure TAddFile.AddWildPathBttnClick( Sender: TObject ); |
||
213 | var |
||
214 | FullName: String; |
||
215 | begin |
||
216 | if Length( WildEdit.Text ) > 0 then |
||
217 | begin |
||
218 | FullName := MainForm.ZipMaster1.AppendSlash( DirectoryListBox1.Directory ) + WildEdit.Text; |
||
219 | |||
220 | with SelectedList, SelectedList.Items do |
||
221 | begin |
||
222 | if IndexOf( FullName ) < 0 then |
||
223 | begin |
||
224 | Add( FullName ); |
||
225 | // Position the "SelectedList" listbox at the bottom. |
||
226 | Selected[Count - 1] := True; |
||
227 | Selected[Count - 1] := False; |
||
228 | end; |
||
229 | end; |
||
230 | end; |
||
231 | end; |
||
232 | |||
233 | end. |