Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  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;
  38.  
  39. type
  40.   TAddForm = 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.     Label1:            TLabel;
  50.     OKBut:             TButton;
  51.     SortBut:           TButton;
  52.     AddDirBut:         TButton;
  53.     RemoveBut:         TButton;
  54.     CancelBut:         TButton;
  55.     AddFileBut:        TButton;
  56.     SelectedList:      TListBox;
  57.     SelectAllBut:      TButton;
  58.     FileListBox1:      TFileListBox;
  59.     DriveComboBox1:    TDriveComboBox;
  60.     DirectoryListBox1: TDirectoryListBox;
  61.  
  62.     procedure OKButClick( Sender: TObject );
  63.     procedure CancelButClick( Sender: TObject );
  64.     procedure AddFileButClick( Sender: TObject );
  65.     procedure SortButClick( Sender: TObject );
  66.     procedure RemoveButClick( Sender: TObject );
  67.     procedure SelectAllButClick( Sender: TObject );
  68.     procedure FormCreate( Sender: TObject );
  69.     procedure AddDirButClick( Sender: TObject );
  70.     function  AppendSlash( const sDir : String ): String;
  71.   private
  72.     { Private declarations }
  73.   public
  74.     { Public declarations }
  75.   end;
  76.  
  77. var
  78.   AddForm: TAddForm;
  79.   InMouseClick: Boolean;
  80.  
  81. implementation
  82.  
  83. uses mainunit;
  84.  
  85. {$R *.DFM}
  86.  
  87. procedure TAddForm.OKButClick( Sender: TObject );
  88. begin
  89.    MainUnit.Cancelled := False;
  90.    Close;
  91. end;
  92.  
  93. procedure TAddForm.CancelButClick( Sender: TObject );
  94. begin
  95.   MainUnit.Cancelled := True;
  96.   Close;
  97. end;
  98.  
  99. procedure TAddForm.SortButClick( Sender: TObject );
  100. begin
  101.   SelectedList.Sorted := True;
  102.   SortBut.Enabled     := False;  { list will remain sorted }
  103. end;
  104.  
  105. procedure TAddForm.RemoveButClick( Sender: TObject );
  106. var
  107.    i: Integer;
  108. begin
  109.    for i := SelectedList.Items.Count - 1 downto 0 do
  110.    begin
  111.       if SelectedList.Selected[i] then
  112.          SelectedList.Items.Delete( i );
  113.    end;
  114. end;
  115.  
  116. procedure TAddForm.SelectAllButClick( Sender: TObject );
  117. var
  118.    i: Integer;
  119. begin
  120.    for i := 0 to FileListBox1.Items.Count - 1 do
  121.       FileListBox1.Selected[i] := True;
  122. end;
  123.  
  124. function TAddForm.AppendSlash( const sDir: String ): String;
  125. begin
  126.   Result := sDir;
  127.   if (Length( sDir ) > 0) and (sDir[Length( sDir )] <> '\') then
  128.      Result := Result + '\';
  129. end;
  130.  
  131. procedure TAddForm.FormCreate( Sender: TObject );
  132. begin
  133.    InMouseClick := False;
  134. end;
  135.  
  136. procedure TAddForm.AddDirButClick( Sender: TObject );
  137. var
  138.    i:        Integer;
  139.    FullName: String;
  140. begin
  141.    MainUnit.Cancelled := True;  // default
  142.    for i := 0 to DirectoryListBox1.Items.Count - 1 do
  143.    begin
  144.       if DirectoryListBox1.Selected[i] then
  145.       begin
  146.          // Add this file if it isn't already in listbox
  147.          FullName := AppendSlash( DirectoryListBox1.Directory ) + '*.*';
  148.  
  149.          if SelectedList.Items.IndexOf( FullName ) < 0 then
  150.             SelectedList.Items.Add( FullName );
  151.       { Never de-select dirnames from the DirectoryList! }
  152.       {  DirectoryListBox1.Selected[i]:=False; }
  153.       end;
  154.    end;
  155.    { Position the "SelectedList" listbox at the bottom }
  156.    with SelectedList do
  157.    begin
  158.       Selected[Items.Count - 1] := True;
  159.       Selected[Items.Count - 1] := False;
  160.    end;
  161. end;
  162.  
  163. procedure TAddForm.AddFileButClick( Sender: TObject );
  164. var
  165.    i:        Integer;
  166.    FullName: String;
  167. begin
  168.    MainUnit.Cancelled := True;  // default
  169.    for i := 0 to FileListBox1.Items.Count - 1 do
  170.    begin
  171.       if FileListBox1.Selected[i] then
  172.       begin
  173.          // Add this file if it isn't already in listbox
  174.          FullName := AppendSlash( DirectoryListBox1.Directory ) + FileListBox1.Items[i];
  175.          if SelectedList.Items.IndexOf( FullName ) < 0 then
  176.             SelectedList.Items.Add( FullName );
  177.          FileListBox1.Selected[i] := False;
  178.       end;
  179.    end;
  180.    { Position the "SelectedList" listbox at the bottom }
  181.    with SelectedList do
  182.    begin
  183.       Selected[Items.Count - 1] := True;
  184.       Selected[Items.Count - 1] := False;
  185.    end;
  186. end;
  187.  
  188. end.
  189.