| 1 | 
   | 
 unit Preview; | 
 
 
 
 
 
 
 
 
 | 2 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 3 | 
   | 
 interface | 
 
 
 
 
 
 
 
 
 | 4 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 | 
   | 
 uses | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 | 
   | 
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | 
 
 
 
 
 
 
 
 
 
 
 
 | 7 | 
 < | 
   Dialogs, StdCtrls, Template, ExtCtrls, Math, StrUtils, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 | 
 < | 
   ConnectionManager, {OniImgClass,} Data, TypeDefs, Menus, Buttons; | 
 
 
 
 
 
 
 
 
 
 | 7 | 
 > | 
   Dialogs, _TemplateFileList, Menus, StdCtrls, ExtCtrls, Buttons, | 
 
 
 
 
 
 | 8 | 
 > | 
   TypeDefs, OniImgClass; | 
 
 
 
 
 
 
 
 
 
 
 
 | 9 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 | 
   | 
 type | 
 
 
 
 
 
 
 
 
 
 
 
 | 11 | 
 < | 
   TForm_Preview = class(TForm_ToolTemplate) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 | 
 < | 
     lbl_notpossible: TLabel; | 
 
 
 
 
 
 
 
 
 
 | 11 | 
 > | 
   TForm_Preview = class(TForm_TemplateFileList) | 
 
 
 
 
 
 | 12 | 
 > | 
     img: TImage; | 
 
 
 
 
 
 
 
 
 
 
 
 | 13 | 
   | 
     panel_buttons: TPanel; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 | 
   | 
     btn_dec: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 | 
   | 
     btn_startstop: TButton; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 | 
   | 
     btn_inc: TButton; | 
 
 
 
 
 
 
 
 
 
 | 15 | 
 – | 
     img: TImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 | 
   | 
     timer: TTimer; | 
 
 
 
 
 
 
 
 
 | 18 | 
 + | 
     lbl_notpossible: TLabel; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 | 
   | 
     procedure FormCreate(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | 
   | 
     procedure NewFile(fileinfo: TFileInfo); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | 
   | 
     procedure DrawImage(index: Integer); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
     procedure SetBitmapCount(Count: Integer); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | 
   | 
     procedure LoadImage(fileid, index: Integer); | 
 
 
 
 
 
 
 
 
 | 33 | 
 + | 
     procedure Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | 
   | 
   private | 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | 
 < | 
     bitmaps:   array of TBitmap; | 
 
 
 
 
 
 
 
 
 
 | 35 | 
 > | 
     bitmaps:   array of TOniImage; | 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | 
   | 
     actualimg: Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 | 
   | 
     _fileid:   Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 | 
   | 
   public | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 39 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 | 38 | 
 – | 
 var | 
 
 
 
 
 
 
 
 
 
 | 39 | 
 – | 
   Form_Preview: TForm_Preview; | 
 
 
 
 
 
 
 
 
 
 | 40 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 41 | 
   | 
 implementation | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 | 
   | 
 {$R *.dfm} | 
 
 
 
 
 
 
 
 
 | 43 | 
 + | 
 uses | 
 
 
 
 
 
 
 
 
 | 44 | 
 + | 
   ConnectionManager, Math, _TemplateFile; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | 
   | 
 procedure TForm_Preview.FormCreate(Sender: TObject); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | 
   | 
   inherited; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | 
   | 
   Self.OnNewFileSelected := NewFile; | 
 
 
 
 
 
 
 
 
 | 51 | 
 + | 
   SetBitmapCount(0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | 
   | 
   ext: String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | 
   | 
   _fileid := fileinfo.ID; | 
 
 
 
 
 
 
 
 
 | 60 | 
 + | 
   SetBitmapCount(0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | 
   | 
   if _fileid >= 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | 
   | 
     lbl_notpossible.Visible := False; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 | 
   | 
 procedure TForm_Preview.LoadImage(fileid, index: Integer); | 
 
 
 
 
 
 
 
 
 
 | 85 | 
 – | 
 var | 
 
 
 
 
 
 
 
 
 
 | 86 | 
 – | 
   Data:      Tdata; | 
 
 
 
 
 
 
 
 
 
 | 87 | 
 – | 
   memstream: TMemoryStream; | 
 
 
 
 
 
 
 
 
 
 | 88 | 
 – | 
   OniImage:  TOniImage; | 
 
 
 
 
 
 
 
 
 
 | 89 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 | 90 | 
 < | 
   OniImage := TOniImage.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | 
 < | 
   OniImage.Load(Connection, fileid); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | 
 < | 
   Data := OniImage.GetAsBMP; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | 
 < | 
   OniImage.Free; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | 
 < | 
   memstream := TMemoryStream.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | 
 < | 
   memstream.Write(Data[0], Length(Data)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 | 
 < | 
   memstream.Seek(0, soFromBeginning); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 | 
 < | 
   bitmaps[index].LoadFromStream(memstream); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 | 
 < | 
   memstream.Free; | 
 
 
 
 
 
 
 
 
 
 | 90 | 
 > | 
   bitmaps[index].Load(ConnectionID, fileid); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | 
   | 
 procedure TForm_Preview.DrawImage(index: Integer); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | 
 < | 
   BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 107 | 
 < | 
     bitmaps[index].Canvas.Handle, 0, 0, WHITENESS); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 108 | 
 < | 
   BitBlt(img.Canvas.Handle, 0, 0, bitmaps[index].Width, bitmaps[index].Height, | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 | 
 < | 
     bitmaps[index].Canvas.Handle, 0, 0, SRCCOPY); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 | 
 < | 
   img.Invalidate; | 
 
 
 
 
 
 
 
 
 
 | 96 | 
 > | 
   bitmaps[index].DrawOnCanvas(img.Canvas, 1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | 
   | 
     i := Length(bitmaps); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 | 
   | 
     SetLength(bitmaps, Count); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 114 | 
   | 
     for i := i to High(bitmaps) do | 
 
 
 
 
 
 
 
 
 
 
 
 | 115 | 
 < | 
       bitmaps[i] := TBitmap.Create; | 
 
 
 
 
 
 
 
 
 
 | 115 | 
 > | 
       bitmaps[i] := TOniImage.Create; | 
 
 
 
 
 
 
 
 
 
 
 
 | 116 | 
   | 
   end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 117 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 118 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 119 | 
   | 
  | 
 
 
 
 
 
 
 
 
 | 120 | 
 + | 
 procedure TForm_Preview.Splitter1Moved(Sender: TObject); | 
 
 
 
 
 
 
 
 
 | 121 | 
 + | 
 begin | 
 
 
 
 
 
 
 
 
 | 122 | 
 + | 
   inherited; | 
 
 
 
 
 
 
 
 
 | 123 | 
 + | 
   img.Picture.Assign(nil); | 
 
 
 
 
 
 
 
 
 | 124 | 
 + | 
   if Length(bitmaps) > 0 then | 
 
 
 
 
 
 
 
 
 | 125 | 
 + | 
     DrawImage(0); | 
 
 
 
 
 
 
 
 
 | 126 | 
 + | 
 end; | 
 
 
 
 
 
 
 
 
 | 127 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 128 | 
   | 
 procedure TForm_Preview.PreviewImage; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 129 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 130 | 
   | 
   SetBitmapCount(1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 136 | 
   | 
 procedure TForm_Preview.PreviewTXAN; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 137 | 
   | 
 var | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 138 | 
   | 
   loop_speed: Word; | 
 
 
 
 
 
 
 
 
 
 
 
 | 139 | 
 < | 
   linkcount: LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 140 | 
 < | 
   link: LongWord; | 
 
 
 
 
 
 
 
 
 
 | 139 | 
 > | 
   linkcount: Integer; | 
 
 
 
 
 
 | 140 | 
 > | 
   link: Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 | 141 | 
   | 
   i:    Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 142 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 | 143 | 
 < | 
   Connection.LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 144 | 
 < | 
   Connection.LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount); | 
 
 
 
 
 
 
 
 
 
 | 143 | 
 > | 
   ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed); | 
 
 
 
 
 
 | 144 | 
 > | 
   ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount); | 
 
 
 
 
 
 
 
 
 
 
 
 | 145 | 
   | 
   SetBitmapCount(linkcount); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 146 | 
   | 
   for i := 0 to linkcount - 1 do | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 147 | 
   | 
   begin | 
 
 
 
 
 
 
 
 
 
 
 
 | 148 | 
 < | 
     Connection.LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link); | 
 
 
 
 
 
 
 
 
 
 | 148 | 
 > | 
     ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link); | 
 
 
 
 
 
 
 
 
 
 
 
 | 149 | 
   | 
     link := link div 256; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
     if link = 0 then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
   | 
       link := _fileid - 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 170 | 
   | 
   Self.timer.Enabled   := not Self.timer.Enabled; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 | 
   | 
   Self.btn_dec.Enabled := not Self.timer.Enabled; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
   | 
   Self.btn_inc.Enabled := not Self.timer.Enabled; | 
 
 
 
 
 
 
 
 
 | 173 | 
 + | 
   if self.timer.Enabled then | 
 
 
 
 
 
 
 
 
 | 174 | 
 + | 
     timerTimer(Self); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 175 | 
   | 
   if Self.timer.Enabled then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 176 | 
   | 
     Self.btn_startstop.Caption := 'Stop automatic' | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 177 | 
   | 
   else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 185 | 
   | 
     Dec(actualimg) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | 
   | 
   else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 187 | 
   | 
     actualimg := High(bitmaps); | 
 
 
 
 
 
 
 
 
 
 
 
 | 188 | 
 < | 
   Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName + | 
 
 
 
 
 
 
 
 
 
 | 188 | 
 > | 
   Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + | 
 
 
 
 
 
 
 
 
 
 
 
 | 189 | 
   | 
     ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 190 | 
   | 
   DrawImage(actualimg); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 191 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 197 | 
   | 
     Inc(actualimg) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 198 | 
   | 
   else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 199 | 
   | 
     actualimg := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 | 200 | 
 < | 
   Self.Caption := 'Preview ' + Connection.GetFileInfo(_fileid).FileName + | 
 
 
 
 
 
 
 
 
 
 | 200 | 
 > | 
   Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + | 
 
 
 
 
 
 
 
 
 
 
 
 | 201 | 
   | 
     ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 202 | 
   | 
   DrawImage(actualimg); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 203 | 
   | 
 end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 212 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 213 | 
   | 
 begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 214 | 
   | 
   AddToolListEntry('preview', 'Preview-Window', ''); | 
 
 
 
 
 
 
 
 
 
 
 
 | 215 | 
 < | 
 end. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 215 | 
 > | 
 end. | 
 
 
 
 
 
 | 216 | 
 > | 
  |