home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / index / source / option.pas < prev    next >
Pascal/Delphi Source File  |  1996-05-03  |  5KB  |  198 lines

  1. unit Option;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, TabNotBk, StdCtrls, Buttons, ExtCtrls, FileCtrl, ComCtrls;
  8.  
  9. type
  10.   TOptionForm = class(TForm)
  11.     Onglet: TTabbedNotebook;
  12.     ListBox: TListBox;
  13.     FileList: TFileListBox;
  14.     DirectoryList: TDirectoryListBox;
  15.     DriveBox: TDriveComboBox;
  16.     AjouteBtn: TButton;
  17.     SupBtn: TButton;
  18.     OkBtn: TButton;
  19.     GroupBox1: TGroupBox;
  20.     GroupBox3: TGroupBox;
  21.     Ok2Btn: TButton;
  22.     AnnuleBtn: TButton;
  23.     RepEdit: TEdit;
  24.     ParcoursBtn: TButton;
  25.     TotalCheck: TCheckBox;
  26.     DifCheck: TCheckBox;
  27.     AnnexeCheck: TCheckBox;
  28.     Bevel1: TBevel;
  29.     Annule2Btn: TButton;
  30.     procedure DriveBoxChange(Sender: TObject);
  31.     procedure DirectoryListChange(Sender: TObject);
  32.     procedure AjouteBtnClick(Sender: TObject);
  33.     procedure SupBtnClick(Sender: TObject);
  34.     procedure OkBtnClick(Sender: TObject);
  35.     procedure Ok2BtnClick(Sender: TObject);
  36.     procedure AnnuleBtnClick(Sender: TObject);
  37.     procedure ParcoursBtnClick(Sender: TObject);
  38.     procedure Annule2BtnClick(Sender: TObject);
  39.     procedure FileListDblClick(Sender: TObject);
  40.     procedure ListBoxDblClick(Sender: TObject);
  41.   private
  42.     { Private declarations }
  43.   public
  44.     { Public declarations }
  45.   end;
  46.  
  47. var
  48.   OptionForm: TOptionForm;
  49.  
  50. implementation
  51.  
  52. {$R *.DFM}
  53.  
  54. uses main, directo ;
  55.  
  56.  
  57.  
  58. { Lorsque l'on ajoute un fichier dans la liste des fichiers annexes, il serait prΘfΘrable de ne 
  59.   pas mettre deux fois le mΩme fichier. Il faut tout prΘvoir avec des utilisateurs imprudents. }
  60. procedure ElimineDoublons ;
  61. var  i, j : integer ;
  62. begin
  63.      i := 0 ;
  64.      while i < OptionForm. ListBox. Items. Count do
  65.      begin
  66.           j := 0 ;
  67.           while j < OptionForm. ListBox. Items. Count do
  68.           begin
  69.                if (OptionForm. ListBox. Items[j] = OptionForm. ListBox. Items[i]) and
  70.                    (i<>j) then
  71.                   OptionForm. ListBox. Items. Delete(j) ;
  72.                inc(j) ;
  73.           end ;
  74.           inc(i) ;
  75.      end ;
  76. end ;
  77.  
  78.  
  79.  
  80. procedure ajouter ;
  81. var i : integer ;
  82. begin
  83.      for i := 0 to OptionForm.FileList. Items. Count - 1 do
  84.          if OptionForm.FileList. Selected[i] then
  85.             OptionForm.ListBox. Items. Add(OptionForm.DirectoryList. Directory+'\'+OptionForm.FileList. Items[i]) ;
  86.      ElimineDoublons ;
  87. end;
  88.  
  89.  
  90.  
  91. procedure supprimer ;
  92. var i : integer ;
  93. begin
  94.      i := OptionForm.ListBox. Items. Count - 1 ;
  95.      While i >= 0 do
  96.      begin
  97.            if OptionForm.ListBox. Selected[i] then
  98.               OptionForm.ListBox. Items. Delete(i) ;
  99.            Dec(i) ;
  100.      end ;
  101. end;
  102.  
  103.  
  104.  
  105. { Cette procΘdure transfert toutes les informations contenues dans la boεte de
  106.   dialogue vers la configuration courante. }
  107. procedure SauvegardeConfiguration ;
  108. var  i : Integer ;
  109. begin
  110.      with Configuration do
  111.      begin
  112.           RepertoireDefaut := OptionForm. RepEdit. Text;
  113.           IgnoreMAJmin := OptionForm. DifCheck. Checked;
  114.           ChargeTotal := OptionForm. TotalCheck. Checked;
  115.           AnnexeDAbord := OptionForm. AnnexeCheck. Checked;
  116.           Fichiers. Clear ;
  117.           for i := 0 to OptionForm. ListBox. Items. Count - 1 do
  118.               Fichiers. Add(OptionForm. ListBox. Items[i]) ;
  119.      end ;
  120. end ;
  121.  
  122.  
  123.  
  124. procedure TOptionForm.DriveBoxChange(Sender: TObject);
  125. begin
  126.      DirectoryList. Drive := DriveBox. Drive ;
  127. end;
  128.  
  129.  
  130.  
  131. procedure TOptionForm.DirectoryListChange(Sender: TObject);
  132. begin
  133.      FileList. Directory := DirectoryList. Directory ;
  134. end;
  135.  
  136.  
  137.  
  138. procedure TOptionForm.AjouteBtnClick(Sender: TObject);
  139. begin
  140.      ajouter ;
  141. end ;
  142.  
  143.  
  144. procedure TOptionForm.SupBtnClick(Sender: TObject);
  145. begin
  146.      supprimer ;
  147. end ;
  148.  
  149.  
  150. procedure TOptionForm.OkBtnClick(Sender: TObject);
  151. begin
  152.      SauvegardeConfiguration ;
  153.      Close ;
  154. end;
  155.  
  156.  
  157.  
  158. procedure TOptionForm.Ok2BtnClick(Sender: TObject);
  159. begin
  160.      SauvegardeConfiguration ;
  161.      Close ;
  162. end;
  163.  
  164.  
  165.  
  166. procedure TOptionForm.AnnuleBtnClick(Sender: TObject);
  167. begin
  168.      Close ;
  169. end;
  170.  
  171.  
  172.  
  173. procedure TOptionForm.ParcoursBtnClick(Sender: TObject);
  174. begin
  175.      RepForm. DirectoryBox. Directory := RepEdit. Text ;
  176.      RepForm. ShowModal ;
  177.      if RepForm. ModalResult = 1 then
  178.         RepEdit. Text := RepForm. DirectoryBox. Directory ;
  179. end;
  180.  
  181. procedure TOptionForm.Annule2BtnClick(Sender: TObject);
  182. begin
  183.      Close ;
  184. end;
  185.  
  186. procedure TOptionForm.FileListDblClick(Sender: TObject);
  187. begin
  188.      ajouter ;
  189. end;
  190.  
  191.  
  192. procedure TOptionForm.ListBoxDblClick(Sender: TObject);
  193. begin
  194.      Supprimer ;
  195. end;
  196.  
  197. end.
  198.