Ignore:
Timestamp:
Dec 23, 2006, 1:03:50 AM (18 years ago)
Author:
alloc
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Tool_Preview.pas

    r43 r45  
    11unit Tool_Preview;
    2 
    32interface
    4 
    53uses
    64  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;
    97
    108type
    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;
    1511    panel_buttons: TPanel;
    1612    btn_dec: TButton;
    1713    btn_startstop: TButton;
    1814    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);
    3619
    3720    procedure PreviewImage;
     
    3922    procedure btn_incClick(Sender: TObject);
    4023    procedure btn_decClick(Sender: TObject);
    41     procedure FormResize(Sender: TObject);
    4224    procedure btn_startstopClick(Sender: TObject);
     25    procedure timerTimer(Sender: TObject);
    4326    procedure panel_buttonsResize(Sender: TObject);
    44     procedure timerTimer(Sender: TObject);
    45     procedure FormCreate(Sender: TObject);
    46     procedure FormClose(Sender: TObject; var Action: TCloseAction);
    4727
    4828    procedure DrawImage(index: Integer);
    4929    procedure SetBitmapCount(Count: Integer);
    5030    procedure LoadImage(fileid, index: Integer);
    51     procedure listMouseDown(Sender: TObject; Button: TMouseButton;
    52       Shift: TShiftState; X, Y: Integer);
    5331  private
    5432    bitmaps:   array of TBitmap;
     
    6240
    6341implementation
    64 
    6542{$R *.dfm}
    6643
    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
     45procedure TForm_Preview.FormCreate(Sender: TObject);
     46begin
     47  inherited;
     48  Self.OnNewFileSelected := NewFile;
     49end;
     50
     51
     52procedure TForm_Preview.NewFile(fileinfo: TFileInfo);
     53var
     54  ext: String;
     55begin
     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;
     71end;
    11472
    11573
     
    13492
    13593
    136 
    137 
    138 procedure TForm_Preview.combo_extensionClick(Sender: TObject);
    139 begin
    140   LoadFileNames;
    141 end;
    142 
    143 
    144 
    14594procedure TForm_Preview.DrawImage(index: Integer);
    14695begin
     
    153102
    154103
    155 
    156 
    157104procedure TForm_Preview.SetBitmapCount(Count: Integer);
    158105var
     
    175122
    176123
    177 
    178 
    179 procedure TForm_Preview.check_zerobyteClick(Sender: TObject);
    180 begin
    181   LoadFileNames;
    182 end;
    183 
    184 
    185 
    186 
    187 procedure TForm_Preview.check_filternameClick(Sender: TObject);
    188 begin
    189   edit_filtername.Enabled := not check_filtername.Checked;
    190   LoadFileNames;
    191 end;
    192 
    193 
    194 
    195 
    196 procedure TForm_Preview.listClick(Sender: TObject);
    197 var
    198   ext: String;
    199 begin
    200   _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') then
    207     PreviewImage
    208   else if ext = 'TXAN' then
    209     PreviewTXAN
    210   else
    211   begin
    212     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 var
    223   pt: TPoint;
    224 begin
    225   pt.X := x;
    226   pt.Y := y;
    227   list.ItemIndex := list.ItemAtPos(pt, true);
    228   if list.ItemIndex > -1 then
    229     Self.listClick(Self);
    230 end;
    231 
    232124procedure TForm_Preview.PreviewImage;
    233125begin
     
    236128  DrawImage(0);
    237129end;
    238 
    239 
    240130
    241131
     
    266156
    267157
    268 
    269 
    270158procedure TForm_Preview.timerTimer(Sender: TObject);
    271159begin
    272160  btn_incClick(Self);
    273161end;
    274 
    275 
    276162
    277163
     
    288174
    289175
    290 
    291 
    292176procedure TForm_Preview.btn_decClick(Sender: TObject);
    293177begin
     
    302186
    303187
    304 
    305 
    306188procedure TForm_Preview.btn_incClick(Sender: TObject);
    307189begin
     
    316198
    317199
    318 
    319 
    320200procedure TForm_Preview.panel_buttonsResize(Sender: TObject);
    321201begin
     
    325205
    326206
    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 
     207begin
     208  AddToolListEntry('preview', 'Preview-Window', '');
    364209end.
Note: See TracChangeset for help on using the changeset viewer.