| 1 | 
 unit _TemplateFileList; | 
 
 
 
 
 
 | 2 | 
  | 
 
 
 
 
 
 | 3 | 
 interface | 
 
 
 
 
 
 | 4 | 
  | 
 
 
 
 
 
 | 5 | 
 uses | 
 
 
 
 
 
 | 6 | 
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | 
 
 
 
 
 
 | 7 | 
   Dialogs, _TemplateFile, StdCtrls, ExtCtrls, Menus, Buttons, | 
 
 
 
 
 
 | 8 | 
   TypeDefs; | 
 
 
 
 
 
 | 9 | 
  | 
 
 
 
 
 
 | 10 | 
 type | 
 
 
 
 
 
 | 11 | 
   TForm_TemplateFileList = class(TForm_TemplateFile) | 
 
 
 
 
 
 | 12 | 
     panel_files: TPanel; | 
 
 
 
 
 
 | 13 | 
     filelist: TListBox; | 
 
 
 
 
 
 | 14 | 
     panel_extension: TPanel; | 
 
 
 
 
 
 | 15 | 
     label_sort2: TLabel; | 
 
 
 
 
 
 | 16 | 
     label_sort1: TLabel; | 
 
 
 
 
 
 | 17 | 
     label_extension: TLabel; | 
 
 
 
 
 
 | 18 | 
     btn_sort_id_asc: TSpeedButton; | 
 
 
 
 
 
 | 19 | 
     btn_sort_id_desc: TSpeedButton; | 
 
 
 
 
 
 | 20 | 
     btn_sort_name_asc: TSpeedButton; | 
 
 
 
 
 
 | 21 | 
     btn_sort_name_desc: TSpeedButton; | 
 
 
 
 
 
 | 22 | 
     btn_sort_ext_asc: TSpeedButton; | 
 
 
 
 
 
 | 23 | 
     btn_sort_ext_desc: TSpeedButton; | 
 
 
 
 
 
 | 24 | 
     combo_extension: TComboBox; | 
 
 
 
 
 
 | 25 | 
     check_zerobyte: TCheckBox; | 
 
 
 
 
 
 | 26 | 
     edit_filtername: TEdit; | 
 
 
 
 
 
 | 27 | 
     check_filtername: TCheckBox; | 
 
 
 
 
 
 | 28 | 
     bevel_filelist: TBevel; | 
 
 
 
 
 
 | 29 | 
     splitter_content: TSplitter; | 
 
 
 
 
 
 | 30 | 
     panel_content: TPanel; | 
 
 
 
 
 
 | 31 | 
     filepopup: TPopupMenu; | 
 
 
 
 
 
 | 32 | 
     popup_separator2: TMenuItem; | 
 
 
 
 
 
 | 33 | 
     popup_linkshere: TMenuItem; | 
 
 
 
 
 
 | 34 | 
     popup_separator: TMenuItem; | 
 
 
 
 
 
 | 35 | 
     popup_import: TMenuItem; | 
 
 
 
 
 
 | 36 | 
     popup_export: TMenuItem; | 
 
 
 
 
 
 | 37 | 
     importd: TOpenDialog; | 
 
 
 
 
 
 | 38 | 
     exportd: TSaveDialog; | 
 
 
 
 
 
 | 39 | 
     procedure NewCon(ID: Integer); | 
 
 
 
 
 
 | 40 | 
  | 
 
 
 
 
 
 | 41 | 
     procedure check_filternameClick(Sender: TObject); | 
 
 
 
 
 
 | 42 | 
     procedure check_zerobyteClick(Sender: TObject); | 
 
 
 
 
 
 | 43 | 
     procedure combo_extensionClick(Sender: TObject); | 
 
 
 
 
 
 | 44 | 
     procedure btn_sortClick(Sender: TObject); | 
 
 
 
 
 
 | 45 | 
     procedure listClick(Sender: TObject); | 
 
 
 
 
 
 | 46 | 
     procedure listMouseDown(Sender: TObject; Button: TMouseButton; | 
 
 
 
 
 
 | 47 | 
       Shift: TShiftState; X, Y: Integer); | 
 
 
 
 
 
 | 48 | 
  | 
 
 
 
 
 
 | 49 | 
     procedure popup_importClick(Sender: TObject); | 
 
 
 
 
 
 | 50 | 
     procedure popup_exportClick(Sender: TObject); | 
 
 
 
 
 
 | 51 | 
     procedure popup_opentool(Sender: TObject); | 
 
 
 
 
 
 | 52 | 
     procedure popup_linkshereClick(Sender: TObject); | 
 
 
 
 
 
 | 53 | 
     procedure filepopupPopup(Sender: TObject); | 
 
 
 
 
 
 | 54 | 
   private | 
 
 
 
 
 
 | 55 | 
     FSortBy: TSortType; | 
 
 
 
 
 
 | 56 | 
     FAllowedExts: String; | 
 
 
 
 
 
 | 57 | 
     FAllowMultiSelect: Boolean; | 
 
 
 
 
 
 | 58 | 
     procedure SetAllowedExts(exts: String); | 
 
 
 
 
 
 | 59 | 
     procedure SetMultiSelect(allow: Boolean); | 
 
 
 
 
 
 | 60 | 
   public | 
 
 
 
 
 
 | 61 | 
     constructor Create(AOwner: TComponent); override; | 
 
 
 
 
 
 | 62 | 
     procedure RecreateExtList; | 
 
 
 
 
 
 | 63 | 
     procedure LoadFileNames; | 
 
 
 
 
 
 | 64 | 
     procedure SetFileFilters(pattern, extension: String; zerobytes: Boolean); | 
 
 
 
 
 
 | 65 | 
     property AllowedExts: String read FAllowedExts write SetAllowedExts; | 
 
 
 
 
 
 | 66 | 
     property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect; | 
 
 
 
 
 
 | 67 | 
   end; | 
 
 
 
 
 
 | 68 | 
  | 
 
 
 
 
 
 | 69 | 
 implementation | 
 
 
 
 
 
 | 70 | 
 {$R *.dfm} | 
 
 
 
 
 
 | 71 | 
 uses ConnectionManager, Exporters, Functions, StrUtils, WhatLinksHere, Main, | 
 
 
 
 
 
 | 72 | 
   _BaseTemplate; | 
 
 
 
 
 
 | 73 | 
  | 
 
 
 
 
 
 | 74 | 
  | 
 
 
 
 
 
 | 75 | 
 procedure TForm_TemplateFileList.RecreateExtList; | 
 
 
 
 
 
 | 76 | 
 var | 
 
 
 
 
 
 | 77 | 
   i:    Integer; | 
 
 
 
 
 
 | 78 | 
   exts: TStrings; | 
 
 
 
 
 
 | 79 | 
 begin | 
 
 
 
 
 
 | 80 | 
   combo_extension.Items.Clear; | 
 
 
 
 
 
 | 81 | 
   if FConnectionID > -1 then | 
 
 
 
 
 
 | 82 | 
   begin | 
 
 
 
 
 
 | 83 | 
     combo_extension.Items.Add('_All files_ (' + | 
 
 
 
 
 
 | 84 | 
       IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')'); | 
 
 
 
 
 
 | 85 | 
     exts := nil; | 
 
 
 
 
 
 | 86 | 
     exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount); | 
 
 
 
 
 
 | 87 | 
     for i := 0 to exts.Count - 1 do | 
 
 
 
 
 
 | 88 | 
       if Length(FAllowedExts) > 0 then | 
 
 
 
 
 
 | 89 | 
       begin | 
 
 
 
 
 
 | 90 | 
         if Pos(MidStr(exts.Strings[i],1,4), FAllowedExts) > 0 then | 
 
 
 
 
 
 | 91 | 
           combo_extension.Items.Add(exts.Strings[i]); | 
 
 
 
 
 
 | 92 | 
       end | 
 
 
 
 
 
 | 93 | 
       else | 
 
 
 
 
 
 | 94 | 
         combo_extension.Items.Add(exts.Strings[i]); | 
 
 
 
 
 
 | 95 | 
     combo_extension.ItemIndex := 0; | 
 
 
 
 
 
 | 96 | 
     combo_extensionClick(Self); | 
 
 
 
 
 
 | 97 | 
     exts.Free; | 
 
 
 
 
 
 | 98 | 
   end; | 
 
 
 
 
 
 | 99 | 
 end; | 
 
 
 
 
 
 | 100 | 
  | 
 
 
 
 
 
 | 101 | 
 procedure TForm_TemplateFileList.LoadFileNames; | 
 
 
 
 
 
 | 102 | 
 var | 
 
 
 
 
 
 | 103 | 
   Extension: String; | 
 
 
 
 
 
 | 104 | 
   no_zero_bytes: Boolean; | 
 
 
 
 
 
 | 105 | 
   pattern: String; | 
 
 
 
 
 
 | 106 | 
   files: TStrings; | 
 
 
 
 
 
 | 107 | 
 begin | 
 
 
 
 
 
 | 108 | 
   if FConnectionID > -1 then | 
 
 
 
 
 
 | 109 | 
   begin | 
 
 
 
 
 
 | 110 | 
     Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4); | 
 
 
 
 
 
 | 111 | 
     no_zero_bytes := not check_zerobyte.Checked; | 
 
 
 
 
 
 | 112 | 
     pattern := ''; | 
 
 
 
 
 
 | 113 | 
     if check_filtername.Checked then | 
 
 
 
 
 
 | 114 | 
       pattern := edit_filtername.Text; | 
 
 
 
 
 
 | 115 | 
     if Extension = '_All' then | 
 
 
 
 
 
 | 116 | 
       if Length(FAllowedExts) > 0 then | 
 
 
 
 
 
 | 117 | 
         Extension := FAllowedExts | 
 
 
 
 
 
 | 118 | 
       else | 
 
 
 
 
 
 | 119 | 
         Extension := ''; | 
 
 
 
 
 
 | 120 | 
  | 
 
 
 
 
 
 | 121 | 
     files := nil; | 
 
 
 
 
 
 | 122 | 
     files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy); | 
 
 
 
 
 
 | 123 | 
  | 
 
 
 
 
 
 | 124 | 
     filelist.Visible := False; | 
 
 
 
 
 
 | 125 | 
     filelist.Items.Clear; | 
 
 
 
 
 
 | 126 | 
     if files.Count > 0 then | 
 
 
 
 
 
 | 127 | 
       filelist.Items.AddStrings(files); | 
 
 
 
 
 
 | 128 | 
     filelist.Visible := True; | 
 
 
 
 
 
 | 129 | 
   end; | 
 
 
 
 
 
 | 130 | 
 end; | 
 
 
 
 
 
 | 131 | 
  | 
 
 
 
 
 
 | 132 | 
  | 
 
 
 
 
 
 | 133 | 
 procedure TForm_TemplateFileList.NewCon(ID: Integer); | 
 
 
 
 
 
 | 134 | 
 begin | 
 
 
 
 
 
 | 135 | 
   RecreateExtList; | 
 
 
 
 
 
 | 136 | 
 end; | 
 
 
 
 
 
 | 137 | 
  | 
 
 
 
 
 
 | 138 | 
 procedure TForm_TemplateFileList.popup_exportClick(Sender: TObject); | 
 
 
 
 
 
 | 139 | 
 var | 
 
 
 
 
 
 | 140 | 
   id: Integer; | 
 
 
 
 
 
 | 141 | 
   ext: String; | 
 
 
 
 
 
 | 142 | 
 begin | 
 
 
 
 
 
 | 143 | 
   id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); | 
 
 
 
 
 
 | 144 | 
   ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4); | 
 
 
 
 
 
 | 145 | 
   exportd.Filter := 'Files of matching extension (*.' + ext + ')|*.' + ext + '|All files|*.*'; | 
 
 
 
 
 
 | 146 | 
   exportd.DefaultExt := ext; | 
 
 
 
 
 
 | 147 | 
   if exportd.Execute then | 
 
 
 
 
 
 | 148 | 
     ExportDatFile(FConnectionID, id, exportd.FileName); | 
 
 
 
 
 
 | 149 | 
 end; | 
 
 
 
 
 
 | 150 | 
  | 
 
 
 
 
 
 | 151 | 
 procedure TForm_TemplateFileList.popup_importClick(Sender: TObject); | 
 
 
 
 
 
 | 152 | 
 var | 
 
 
 
 
 
 | 153 | 
   id: Integer; | 
 
 
 
 
 
 | 154 | 
   finfo: TFileInfo; | 
 
 
 
 
 
 | 155 | 
   fs: TFileStream; | 
 
 
 
 
 
 | 156 | 
 begin | 
 
 
 
 
 
 | 157 | 
   if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then | 
 
 
 
 
 
 | 158 | 
   begin | 
 
 
 
 
 
 | 159 | 
     id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); | 
 
 
 
 
 
 | 160 | 
     finfo := ConManager.Connection[FConnectionID].GetFileInfo(id); | 
 
 
 
 
 
 | 161 | 
  | 
 
 
 
 
 
 | 162 | 
     importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + | 
 
 
 
 
 
 | 163 | 
           finfo.Extension + '|All files|*.*'; | 
 
 
 
 
 
 | 164 | 
     if importd.Execute then | 
 
 
 
 
 
 | 165 | 
     begin | 
 
 
 
 
 
 | 166 | 
       fs := TFileStream.Create(importd.FileName, fmOpenRead); | 
 
 
 
 
 
 | 167 | 
       if fs.Size <> finfo.Size then | 
 
 
 
 
 
 | 168 | 
       begin | 
 
 
 
 
 
 | 169 | 
         if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then | 
 
 
 
 
 
 | 170 | 
         begin | 
 
 
 
 
 
 | 171 | 
           ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + | 
 
 
 
 
 
 | 172 | 
             ', file has to have same size as file in .dat with this backend.' + CrLf + | 
 
 
 
 
 
 | 173 | 
             'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + | 
 
 
 
 
 
 | 174 | 
             'Size of chosen file: ' + FormatFileSize(fs.Size)); | 
 
 
 
 
 
 | 175 | 
           Exit; | 
 
 
 
 
 
 | 176 | 
         end else begin | 
 
 
 
 
 
 | 177 | 
           if MessageBox(Self.Handle, | 
 
 
 
 
 
 | 178 | 
               PChar('File has different size from the file in the .dat.' + CrLf + | 
 
 
 
 
 
 | 179 | 
                     'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + | 
 
 
 
 
 
 | 180 | 
                     'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf + | 
 
 
 
 
 
 | 181 | 
                     'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then | 
 
 
 
 
 
 | 182 | 
           begin | 
 
 
 
 
 
 | 183 | 
             Exit; | 
 
 
 
 
 
 | 184 | 
           end; | 
 
 
 
 
 
 | 185 | 
         end; | 
 
 
 
 
 
 | 186 | 
       end; | 
 
 
 
 
 
 | 187 | 
       ConManager.Connection[FConnectionID].UpdateDatFile(id, fs); | 
 
 
 
 
 
 | 188 | 
       Self.listClick(Self); | 
 
 
 
 
 
 | 189 | 
       fs.Free; | 
 
 
 
 
 
 | 190 | 
     end; | 
 
 
 
 
 
 | 191 | 
   end else begin | 
 
 
 
 
 
 | 192 | 
     ShowMessage('Editing .dat-contents not allowed with this backend.'); | 
 
 
 
 
 
 | 193 | 
   end; | 
 
 
 
 
 
 | 194 | 
 end; | 
 
 
 
 
 
 | 195 | 
  | 
 
 
 
 
 
 | 196 | 
  | 
 
 
 
 
 
 | 197 | 
 procedure TForm_TemplateFileList.popup_linkshereClick(Sender: TObject); | 
 
 
 
 
 
 | 198 | 
 begin | 
 
 
 
 
 
 | 199 | 
   Form_WhatLinksHere.ConID := FConnectionID; | 
 
 
 
 
 
 | 200 | 
   Form_WhatLinksHere.FileID := FSelectedFile.ID; | 
 
 
 
 
 
 | 201 | 
   Form_WhatLinksHere.SenderForm := Self; | 
 
 
 
 
 
 | 202 | 
   Form_WhatLinksHere.Show; | 
 
 
 
 
 
 | 203 | 
 end; | 
 
 
 
 
 
 | 204 | 
  | 
 
 
 
 
 
 | 205 | 
 procedure TForm_TemplateFileList.popup_opentool(Sender: TObject); | 
 
 
 
 
 
 | 206 | 
 var | 
 
 
 
 
 
 | 207 | 
   sender_name, context: String; | 
 
 
 
 
 
 | 208 | 
   id: Integer; | 
 
 
 
 
 
 | 209 | 
 begin | 
 
 
 
 
 
 | 210 | 
   sender_name := TComponent(Sender).Name; | 
 
 
 
 
 
 | 211 | 
   id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); | 
 
 
 
 
 
 | 212 | 
   context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name)); | 
 
 
 
 
 
 | 213 | 
   Form_Main.open_child(context, FConnectionID, id); | 
 
 
 
 
 
 | 214 | 
 end; | 
 
 
 
 
 
 | 215 | 
  | 
 
 
 
 
 
 | 216 | 
 procedure TForm_TemplateFileList.filepopupPopup(Sender: TObject); | 
 
 
 
 
 
 | 217 | 
 var | 
 
 
 
 
 
 | 218 | 
   ext: String; | 
 
 
 
 
 
 | 219 | 
   i: Integer; | 
 
 
 
 
 
 | 220 | 
 begin | 
 
 
 
 
 
 | 221 | 
   ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4); | 
 
 
 
 
 
 | 222 | 
   for i := 0 to High(ToolList) do | 
 
 
 
 
 
 | 223 | 
   begin | 
 
 
 
 
 
 | 224 | 
     filepopup.Items.Items[i].Enabled := True; | 
 
 
 
 
 
 | 225 | 
     if Length(ToolList[i].exts) > 0 then | 
 
 
 
 
 
 | 226 | 
       if Pos(ext, ToolList[i].exts) = 0 then | 
 
 
 
 
 
 | 227 | 
         filepopup.Items.Items[i].Enabled := False; | 
 
 
 
 
 
 | 228 | 
   end; | 
 
 
 
 
 
 | 229 | 
 end; | 
 
 
 
 
 
 | 230 | 
  | 
 
 
 
 
 
 | 231 | 
  | 
 
 
 
 
 
 | 232 | 
 procedure TForm_TemplateFileList.check_zerobyteClick(Sender: TObject); | 
 
 
 
 
 
 | 233 | 
 begin | 
 
 
 
 
 
 | 234 | 
   LoadFileNames; | 
 
 
 
 
 
 | 235 | 
 end; | 
 
 
 
 
 
 | 236 | 
  | 
 
 
 
 
 
 | 237 | 
 procedure TForm_TemplateFileList.btn_sortClick(Sender: TObject); | 
 
 
 
 
 
 | 238 | 
 begin | 
 
 
 
 
 
 | 239 | 
   if btn_sort_id_asc.Down then | 
 
 
 
 
 
 | 240 | 
     FSortBy := ST_IDAsc | 
 
 
 
 
 
 | 241 | 
   else if btn_sort_id_desc.Down then | 
 
 
 
 
 
 | 242 | 
     FSortBy := ST_IDDesc | 
 
 
 
 
 
 | 243 | 
   else if btn_sort_name_asc.Down then | 
 
 
 
 
 
 | 244 | 
     FSortBy := ST_NameAsc | 
 
 
 
 
 
 | 245 | 
   else if btn_sort_name_desc.Down then | 
 
 
 
 
 
 | 246 | 
     FSortBy := ST_NameDesc | 
 
 
 
 
 
 | 247 | 
   else if btn_sort_ext_asc.Down then | 
 
 
 
 
 
 | 248 | 
     FSortBy := ST_ExtAsc | 
 
 
 
 
 
 | 249 | 
   else if btn_sort_ext_desc.Down then | 
 
 
 
 
 
 | 250 | 
     FSortBy := ST_ExtDesc; | 
 
 
 
 
 
 | 251 | 
   LoadFileNames; | 
 
 
 
 
 
 | 252 | 
 end; | 
 
 
 
 
 
 | 253 | 
  | 
 
 
 
 
 
 | 254 | 
 procedure TForm_TemplateFileList.check_filternameClick(Sender: TObject); | 
 
 
 
 
 
 | 255 | 
 begin | 
 
 
 
 
 
 | 256 | 
   edit_filtername.Enabled := not check_filtername.Checked; | 
 
 
 
 
 
 | 257 | 
   LoadFileNames; | 
 
 
 
 
 
 | 258 | 
 end; | 
 
 
 
 
 
 | 259 | 
  | 
 
 
 
 
 
 | 260 | 
 procedure TForm_TemplateFileList.combo_extensionClick(Sender: TObject); | 
 
 
 
 
 
 | 261 | 
 begin | 
 
 
 
 
 
 | 262 | 
   LoadFileNames; | 
 
 
 
 
 
 | 263 | 
 end; | 
 
 
 
 
 
 | 264 | 
  | 
 
 
 
 
 
 | 265 | 
 procedure TForm_TemplateFileList.listClick(Sender: TObject); | 
 
 
 
 
 
 | 266 | 
 var | 
 
 
 
 
 
 | 267 | 
   fileid: Integer; | 
 
 
 
 
 
 | 268 | 
 begin | 
 
 
 
 
 
 | 269 | 
   if filelist.ItemIndex > -1 then | 
 
 
 
 
 
 | 270 | 
   begin | 
 
 
 
 
 
 | 271 | 
     fileid := ConManager.Connection[FConnectionID].ExtractFileIDOfName( | 
 
 
 
 
 
 | 272 | 
           filelist.Items.Strings[filelist.ItemIndex]); | 
 
 
 
 
 
 | 273 | 
     FSelectedFile := ConManager.Connection[FConnectionID].GetFileInfo(fileid); | 
 
 
 
 
 
 | 274 | 
     if Assigned(FOnNewFileSelected) then | 
 
 
 
 
 
 | 275 | 
       FOnNewFileSelected(FSelectedFile); | 
 
 
 
 
 
 | 276 | 
   end; | 
 
 
 
 
 
 | 277 | 
 end; | 
 
 
 
 
 
 | 278 | 
  | 
 
 
 
 
 
 | 279 | 
 procedure TForm_TemplateFileList.listMouseDown(Sender: TObject; Button: TMouseButton; | 
 
 
 
 
 
 | 280 | 
   Shift: TShiftState; X, Y: Integer); | 
 
 
 
 
 
 | 281 | 
 var | 
 
 
 
 
 
 | 282 | 
   pt: TPoint; | 
 
 
 
 
 
 | 283 | 
 begin | 
 
 
 
 
 
 | 284 | 
   pt.X := x; | 
 
 
 
 
 
 | 285 | 
   pt.Y := y; | 
 
 
 
 
 
 | 286 | 
   if Shift = [ssRight] then | 
 
 
 
 
 
 | 287 | 
   begin | 
 
 
 
 
 
 | 288 | 
     filelist.ItemIndex := filelist.ItemAtPos(pt, true); | 
 
 
 
 
 
 | 289 | 
     Self.listClick(Self); | 
 
 
 
 
 
 | 290 | 
   end; | 
 
 
 
 
 
 | 291 | 
 end; | 
 
 
 
 
 
 | 292 | 
  | 
 
 
 
 
 
 | 293 | 
  | 
 
 
 
 
 
 | 294 | 
  | 
 
 
 
 
 
 | 295 | 
 procedure TForm_TemplateFileList.SetAllowedExts(exts: String); | 
 
 
 
 
 
 | 296 | 
 begin | 
 
 
 
 
 
 | 297 | 
   FAllowedExts := exts; | 
 
 
 
 
 
 | 298 | 
   RecreateExtList; | 
 
 
 
 
 
 | 299 | 
 end; | 
 
 
 
 
 
 | 300 | 
  | 
 
 
 
 
 
 | 301 | 
 procedure TForm_TemplateFileList.SetFileFilters(pattern, extension: String; | 
 
 
 
 
 
 | 302 | 
   zerobytes: Boolean); | 
 
 
 
 
 
 | 303 | 
 var | 
 
 
 
 
 
 | 304 | 
   i: Integer; | 
 
 
 
 
 
 | 305 | 
 begin | 
 
 
 
 
 
 | 306 | 
   if Length(pattern) > 0 then | 
 
 
 
 
 
 | 307 | 
     Self.edit_filtername.Text := pattern; | 
 
 
 
 
 
 | 308 | 
   Self.check_filtername.Checked := Length(pattern) > 0; | 
 
 
 
 
 
 | 309 | 
   if Length(extension) > 0 then | 
 
 
 
 
 
 | 310 | 
   begin | 
 
 
 
 
 
 | 311 | 
     for i := 0 to Self.combo_extension.Items.Count - 1 do | 
 
 
 
 
 
 | 312 | 
       if Pos(extension, Self.combo_extension.Items.Strings[i]) > 0 then | 
 
 
 
 
 
 | 313 | 
         Break; | 
 
 
 
 
 
 | 314 | 
     if i < Self.combo_extension.Items.Count then | 
 
 
 
 
 
 | 315 | 
       Self.combo_extension.ItemIndex := i | 
 
 
 
 
 
 | 316 | 
     else | 
 
 
 
 
 
 | 317 | 
       Self.combo_extension.ItemIndex := -1; | 
 
 
 
 
 
 | 318 | 
   end; | 
 
 
 
 
 
 | 319 | 
   Self.check_zerobyte.Checked := zerobytes; | 
 
 
 
 
 
 | 320 | 
   Self.LoadFileNames; | 
 
 
 
 
 
 | 321 | 
 end; | 
 
 
 
 
 
 | 322 | 
  | 
 
 
 
 
 
 | 323 | 
 procedure TForm_TemplateFileList.SetMultiSelect(allow: Boolean); | 
 
 
 
 
 
 | 324 | 
 begin | 
 
 
 
 
 
 | 325 | 
   FAllowMultiSelect := allow; | 
 
 
 
 
 
 | 326 | 
   filelist.MultiSelect := allow; | 
 
 
 
 
 
 | 327 | 
 end; | 
 
 
 
 
 
 | 328 | 
  | 
 
 
 
 
 
 | 329 | 
  | 
 
 
 
 
 
 | 330 | 
  | 
 
 
 
 
 
 | 331 | 
 constructor TForm_TemplateFileList.Create(AOwner: TComponent); | 
 
 
 
 
 
 | 332 | 
 var | 
 
 
 
 
 
 | 333 | 
   i: Integer; | 
 
 
 
 
 
 | 334 | 
   item: TMenuItem; | 
 
 
 
 
 
 | 335 | 
 begin | 
 
 
 
 
 
 | 336 | 
   inherited; | 
 
 
 
 
 
 | 337 | 
   FAllowedExts := ''; | 
 
 
 
 
 
 | 338 | 
   FAllowMultiSelect := False; | 
 
 
 
 
 
 | 339 | 
   FOnNewConnection := NewCon; | 
 
 
 
 
 
 | 340 | 
   UpdateConList; | 
 
 
 
 
 
 | 341 | 
   if Length(ToolList) > 0 then | 
 
 
 
 
 
 | 342 | 
   begin | 
 
 
 
 
 
 | 343 | 
     for i := 0 to High(ToolList) do | 
 
 
 
 
 
 | 344 | 
     begin | 
 
 
 
 
 
 | 345 | 
       item := TMenuItem.Create(filepopup); | 
 
 
 
 
 
 | 346 | 
       item.Name := 'popup_' + ToolList[i].context; | 
 
 
 
 
 
 | 347 | 
       item.Caption := 'Open with ' + ToolList[i].name; | 
 
 
 
 
 
 | 348 | 
       item.OnClick := Self.popup_opentool; | 
 
 
 
 
 
 | 349 | 
       filepopup.Items.Insert(i, item); | 
 
 
 
 
 
 | 350 | 
     end; | 
 
 
 
 
 
 | 351 | 
   end; | 
 
 
 
 
 
 | 352 | 
 end; | 
 
 
 
 
 
 | 353 | 
  | 
 
 
 
 
 
 | 354 | 
  | 
 
 
 
 
 
 | 355 | 
 end. |