Changeset 45 for oup/current/Tool_Preview.pas
- Timestamp:
- Dec 23, 2006, 1:03:50 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Tool_Preview.pas
r43 r45 1 1 unit Tool_Preview; 2 3 2 interface 4 5 3 uses 6 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 Dialogs, Math, ExtCtrls, StdCtrls, StrUtils, Menus,8 Code_ Functions, Data, Code_Exporters, Code_OniImgClass, Code_OniDataClass;5 Dialogs, StdCtrls, Tool_Template, ExtCtrls, Math, StrUtils, 6 Code_OniDataClass, Code_OniImgClass, Data, Menus; 9 7 10 8 type 11 TForm_Preview = class(TForm) 12 timer: TTimer; 13 panel_preview: TPanel; 14 img: TImage; 9 TForm_Preview = class(TForm_ToolTemplate) 10 lbl_notpossible: TLabel; 15 11 panel_buttons: TPanel; 16 12 btn_dec: TButton; 17 13 btn_startstop: TButton; 18 14 btn_inc: TButton; 19 Splitter1: TSplitter; 20 lbl_notpossible: TLabel; 21 panel_files: TPanel; 22 list: TListBox; 23 panel_extension: TPanel; 24 lbl_filter: TLabel; 25 combo_extension: TComboBox; 26 check_zerobyte: TCheckBox; 27 edit_filtername: TEdit; 28 check_filtername: TCheckBox; 29 procedure LoadFileNames; 30 procedure check_filternameClick(Sender: TObject); 31 procedure check_zerobyteClick(Sender: TObject); 32 procedure combo_extensionClick(Sender: TObject); 33 procedure panel_extensionResize(Sender: TObject); 34 procedure listClick(Sender: TObject); 35 procedure Recreatelist; 15 img: TImage; 16 timer: TTimer; 17 procedure FormCreate(Sender: TObject); 18 procedure NewFile(fileinfo: TFileInfo); 36 19 37 20 procedure PreviewImage; … … 39 22 procedure btn_incClick(Sender: TObject); 40 23 procedure btn_decClick(Sender: TObject); 41 procedure FormResize(Sender: TObject);42 24 procedure btn_startstopClick(Sender: TObject); 25 procedure timerTimer(Sender: TObject); 43 26 procedure panel_buttonsResize(Sender: TObject); 44 procedure timerTimer(Sender: TObject);45 procedure FormCreate(Sender: TObject);46 procedure FormClose(Sender: TObject; var Action: TCloseAction);47 27 48 28 procedure DrawImage(index: Integer); 49 29 procedure SetBitmapCount(Count: Integer); 50 30 procedure LoadImage(fileid, index: Integer); 51 procedure listMouseDown(Sender: TObject; Button: TMouseButton;52 Shift: TShiftState; X, Y: Integer);53 31 private 54 32 bitmaps: array of TBitmap; … … 62 40 63 41 implementation 64 65 42 {$R *.dfm} 66 43 67 uses Main; 68 69 70 71 72 procedure TForm_Preview.Recreatelist; 73 var 74 i: LongWord; 75 exts: TStringArray; 76 begin 77 combo_extension.Items.Clear; 78 combo_extension.Items.Add('_All files_ (' + 79 IntToStr(OniDataConnection.GetFilesCount) + ')'); 80 exts := OniDataConnection.GetExtensionsList; 81 for i := 0 to High(exts) do 82 combo_extension.Items.Add(exts[i]); 83 combo_extension.ItemIndex := 0; 84 combo_extensionClick(Self); 85 end; 86 87 88 89 90 procedure TForm_Preview.LoadFileNames; 91 var 92 Extension: String[4]; 93 no_zero_bytes: Boolean; 94 pattern: String; 95 files: TStringArray; 96 i: LongWord; 97 begin 98 Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4); 99 no_zero_bytes := not check_zerobyte.Checked; 100 pattern := ''; 101 if check_filtername.Checked then 102 pattern := edit_filtername.Text; 103 if Extension = '_All' then 104 Extension := ''; 105 106 files := OniDataConnection.GetFilesList(extension, pattern, no_zero_bytes); 107 list.Items.Clear; 108 if Length(files) > 0 then 109 for i := 0 to High(files) do 110 list.Items.Add(files[i]); 111 end; 112 113 44 45 procedure TForm_Preview.FormCreate(Sender: TObject); 46 begin 47 inherited; 48 Self.OnNewFileSelected := NewFile; 49 end; 50 51 52 procedure TForm_Preview.NewFile(fileinfo: TFileInfo); 53 var 54 ext: String; 55 begin 56 _fileid := fileinfo.ID; 57 lbl_notpossible.Visible := False; 58 Self.img.Visible := True; 59 Self.timer.Enabled := False; 60 Self.panel_buttons.Visible := False; 61 ext := fileinfo.Extension; 62 if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then 63 PreviewImage 64 else if ext = 'TXAN' then 65 PreviewTXAN 66 else 67 begin 68 Self.lbl_notpossible.Visible := True; 69 Self.img.Visible := False; 70 end; 71 end; 114 72 115 73 … … 134 92 135 93 136 137 138 procedure TForm_Preview.combo_extensionClick(Sender: TObject);139 begin140 LoadFileNames;141 end;142 143 144 145 94 procedure TForm_Preview.DrawImage(index: Integer); 146 95 begin … … 153 102 154 103 155 156 157 104 procedure TForm_Preview.SetBitmapCount(Count: Integer); 158 105 var … … 175 122 176 123 177 178 179 procedure TForm_Preview.check_zerobyteClick(Sender: TObject);180 begin181 LoadFileNames;182 end;183 184 185 186 187 procedure TForm_Preview.check_filternameClick(Sender: TObject);188 begin189 edit_filtername.Enabled := not check_filtername.Checked;190 LoadFileNames;191 end;192 193 194 195 196 procedure TForm_Preview.listClick(Sender: TObject);197 var198 ext: String;199 begin200 _fileid := OniDataConnection.ExtractFileID(list.Items.Strings[list.ItemIndex]);201 lbl_notpossible.Visible := False;202 Self.img.Visible := True;203 Self.timer.Enabled := False;204 Self.panel_buttons.Visible := False;205 ext := RightStr(list.Items.Strings[list.ItemIndex], 4);206 if (ext = 'PSpc') or (ext = 'TXMB') or (ext = 'TXMP') then207 PreviewImage208 else if ext = 'TXAN' then209 PreviewTXAN210 else211 begin212 Self.lbl_notpossible.Visible := True;213 Self.img.Visible := False;214 end;215 end;216 217 218 219 220 procedure TForm_Preview.listMouseDown(Sender: TObject; Button: TMouseButton;221 Shift: TShiftState; X, Y: Integer);222 var223 pt: TPoint;224 begin225 pt.X := x;226 pt.Y := y;227 list.ItemIndex := list.ItemAtPos(pt, true);228 if list.ItemIndex > -1 then229 Self.listClick(Self);230 end;231 232 124 procedure TForm_Preview.PreviewImage; 233 125 begin … … 236 128 DrawImage(0); 237 129 end; 238 239 240 130 241 131 … … 266 156 267 157 268 269 270 158 procedure TForm_Preview.timerTimer(Sender: TObject); 271 159 begin 272 160 btn_incClick(Self); 273 161 end; 274 275 276 162 277 163 … … 288 174 289 175 290 291 292 176 procedure TForm_Preview.btn_decClick(Sender: TObject); 293 177 begin … … 302 186 303 187 304 305 306 188 procedure TForm_Preview.btn_incClick(Sender: TObject); 307 189 begin … … 316 198 317 199 318 319 320 200 procedure TForm_Preview.panel_buttonsResize(Sender: TObject); 321 201 begin … … 325 205 326 206 327 328 329 procedure TForm_Preview.panel_extensionResize(Sender: TObject); 330 begin 331 combo_extension.Width := panel_extension.Width - 5; 332 edit_filtername.Width := panel_extension.Width - 5; 333 end; 334 335 336 337 338 procedure TForm_Preview.FormResize(Sender: TObject); 339 begin 340 if Self.Width < 300 then 341 Self.Width := 300; 342 if Self.Height < 200 then 343 Self.Height := 200; 344 end; 345 346 347 348 349 procedure TForm_Preview.FormCreate(Sender: TObject); 350 begin 351 SetLength(bitmaps, 0); 352 Self.Width := 260; 353 Self.Height := 300; 354 end; 355 356 357 358 359 procedure TForm_Preview.FormClose(Sender: TObject; var Action: TCloseAction); 360 begin 361 Action := caFree; 362 end; 363 207 begin 208 AddToolListEntry('preview', 'Preview-Window', ''); 364 209 end.
Note:
See TracChangeset
for help on using the changeset viewer.