unit umain; interface {$IfNDef VER130} {$WARN UNIT_PLATFORM OFF} {$EndIf} uses Windows, Messages, SysUtils, {$IfNDef VER130} Variants, {$EndIf} Classes, Graphics, Controls, Forms, Dialogs, ieview, imageenview, ExtCtrls, StdCtrls, FileCtrl, hyieutils, imageenproc, iexBitmaps, ComCtrls, Buttons, ieanimation; type TMainForm = class(TForm) Panel1: TPanel; ImageEnView1: TImageEnView; DriveComboBox1: TDriveComboBox; DirectoryListBox1: TDirectoryListBox; Timer1: TTimer; SpeedButtonAdvanced: TSpeedButton; Label7: TLabel; Label9: TLabel; ComboBox1: TComboBox; PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; Label1: TLabel; EditHorizDistance: TEdit; UpDownHorizDistance: TUpDown; Label5: TLabel; EditRotateAngle: TEdit; UpDownRotateAngle: TUpDown; Label3: TLabel; EditImagesHorizPer: TEdit; UpDownImagesHorizPer: TUpDown; EditImagesVertPer: TEdit; UpDownImagesVertPer: TUpDown; Label4: TLabel; EditImagesZoom: TEdit; UpDownImagesZoom: TUpDown; EditCurrentImageZoom: TEdit; UpDownCurrentImageZoom: TUpDown; TabSheet3: TTabSheet; Label6: TLabel; EditAnimDuration: TEdit; UpDownAnimDuration: TUpDown; Label2: TLabel; EditDepth: TEdit; UpDownDepth: TUpDown; Label8: TLabel; EditShadowAlphaMin: TEdit; UpDownShadowAlphaMin: TUpDown; EditShadowAlphaMax: TEdit; UpDownShadowAlphaMax: TUpDown; CheckBoxShowBorder: TCheckBox; CheckBoxShowFilename: TCheckBox; CheckBoxShowScrollbar: TCheckBox; Label10: TLabel; Edit1: TEdit; UpDown1: TUpDown; Label11: TLabel; Edit2: TEdit; UpDown2: TUpDown; Edit3: TEdit; UpDown3: TUpDown; Label12: TLabel; Edit4: TEdit; UpDown4: TUpDown; Label13: TLabel; Edit5: TEdit; UpDown5: TUpDown; lblColor: TLabel; pnlColor: TPanel; dlgColor: TColorDialog; procedure DirectoryListBox1Change(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure ImageEnView1VirtualKey(Sender: TObject; VirtualKey, KeyData: Cardinal; KeyDown: Boolean); procedure FormResize(Sender: TObject); procedure CtrlsChanged(Sender: TObject); procedure ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure ImageEnView1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure SpeedButtonAdvancedClick(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure pnlColorClick(Sender: TObject); private { Private declarations } procedure cf_getimage(Sender:TObject; imageIndex:integer; var image:TIEBitmap; var filename:WideString); procedure setProperties(); procedure createAnimator(); public { Public declarations } m_images:TIEImageList; m_animation:TIEAnimation; m_draggingSlider:boolean; end; var MainForm: TMainForm; implementation {$R *.DFM} {$R WindowsTheme.res} procedure TMainForm.FormCreate(Sender: TObject); begin ComboBox1.ItemIndex := 0; m_images := TIEImageList.Create(); m_animation := nil; createAnimator(); m_draggingSlider := false; DirectoryListBox1.Directory := ExtractFilePath(Application.Exename) + 'slides'; end; procedure TMainForm.createAnimator(); begin case ComboBox1.ItemIndex of 0: m_animation := TIEHorizontalFlow.Create(); 1: m_animation := TIECircularFlow.Create(); end; m_animation.SetupEvents(cf_getimage); end; procedure TMainForm.FormDestroy(Sender: TObject); begin m_animation.Free(); m_images.Free(); end; // directory changed, reload all images in TIEImageList (m_images) procedure TMainForm.DirectoryListBox1Change(Sender: TObject); begin m_images.Clear(); m_images.FillFromDirectory(DirectoryListBox1.Directory, 50); // LOAD UP TO 50 IMAGES!! m_animation.ImageCount := m_images.ImageCount; SetProperties(); end; // called by TIEAnimation (m_animation) when the bitmap needs to be displayed procedure TMainForm.cf_getimage(Sender:TObject; imageIndex:integer; var image:TIEBitmap; var filename:WideString); begin image := m_images[imageIndex]; filename := IEExtractFileNameW( m_images.Filename[imageIndex] ); end; var lastTick:dword = 0; // repaint frame (if necessary) procedure TMainForm.Timer1Timer(Sender: TObject); begin if m_animation.NeedRefresh then begin ImageEnView1.IEBitmap.Fill(clBlack); m_animation.Display(ImageEnView1.IEBitmap); ImageEnView1.Update(); Label7.Caption := Format('%d fps', [ round(1000/(GetTickCount()-lastTick+0.00001)) ]); lastTick := GetTickCount(); end; end; // handles left-top and right-bottom cursor keys procedure TMainForm.ImageEnView1VirtualKey(Sender: TObject; VirtualKey, KeyData: Cardinal; KeyDown: Boolean); begin if (VirtualKey = 39) or (VirtualKey = 40) then // right or bottom arrows m_animation.CurrentImage := m_animation.CurrentImage + 1; if (VirtualKey = 37) or (VirtualKey = 38) then // left or up arrows m_animation.CurrentImage := m_animation.CurrentImage - 1; end; // form resizing procedure TMainForm.FormResize(Sender: TObject); begin ImageEnView1.Proc.ImageResize( ImageEnView1.ClientWidth, ImageEnView1.ClientHeight ); SetProperties(); end; // update animation with the content of form controls procedure TMainForm.SetProperties(); begin // common properties m_animation.ViewWidth := ImageEnView1.IEBitmap.Width; m_animation.ViewHeight := ImageEnView1.IEBitmap.Height; m_animation.Depth := UpDownDepth.Position; m_animation.AnimDuration := UpDownAnimDuration.Position; m_animation.ShowBorder := CheckboxShowBorder.Checked; m_animation.ShadowAlphaMin := UpDownShadowAlphaMin.Position; m_animation.ShadowAlphaMax := UpDownShadowAlphaMax.Position; m_animation.ShowScrollbar := CheckboxShowScrollbar.Checked; m_animation.ShowText := CheckboxShowFilename.Checked; m_animation.Font.Color := pnlColor.Color; // specific TIEHorizontalFlow properties if m_animation is TIEHorizontalFlow then with m_animation as TIEHorizontalFlow do begin HorizontalDistance := UpDownHorizDistance.Position; ImagesHorizontalPercentage := UpDownImagesHorizPer.Position; ImagesVerticalPercentage := UpDownImagesVertPer.Position; RotateAngle := UpDownRotateAngle.Position; ImagesZoom := UpDownImagesZoom.Position / 100; CurrentImageZoom := UpDownCurrentImageZoom.Position / 100; end; if m_animation is TIECircularFlow then with m_animation as TIECircularFlow do begin ImagesSizePercentage := UpDown1.Position; ImagesZoom := UpDown2.Position / 100; CurrentImageZoom := UpDown3.Position / 100; VisibleImages := UpDown4.Position; EllipseAngle := UpDown5.Position; end; end; // handle all form controls changes procedure TMainForm.CtrlsChanged(Sender: TObject); begin SetProperties(); end; // mouse down, make an image current procedure TMainForm.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var selim: integer; begin // show an image clicking on it selim := m_animation.FindImageAt(X, Y); if selim > -1 then m_animation.CurrentImage := selim; // start scrollbar slider dragging if m_animation.ShowScrollbar then begin if m_animation.IsInsideScrollbarSlider(X, Y) then m_draggingSlider := true // directly move to the clicked scrollbar position else if m_animation.IsInsideScrollbar(X, Y) then m_animation.MoveScrollbarSliderTo(X); end; end; procedure TMainForm.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if m_animation.ShowScrollbar then begin // change mouse cursor (hand when inside the scrollbar slider, default otherwise) if m_animation.IsInsideScrollbarSlider(X, Y) then ImageEnView1.Cursor := crHandPoint else ImageEnView1.Cursor := crDefault; // dragging scrollbar slider if m_draggingSlider then m_animation.MoveScrollbarSliderTo(X); end; end; procedure TMainForm.ImageEnView1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin // eventually ends dragging m_draggingSlider := false; end; // advanced button procedure TMainForm.SpeedButtonAdvancedClick(Sender: TObject); begin PageControl1.Visible := not PageControl1.Visible; end; // changes animation type procedure TMainForm.ComboBox1Change(Sender: TObject); begin m_animation.Free(); createAnimator(); m_animation.ImageCount := m_images.ImageCount; SetProperties(); end; procedure TMainForm.pnlColorClick(Sender: TObject); begin dlgColor.Color := pnlColor.Color; if dlgColor.Execute then begin pnlColor.Color := dlgColor.Color; SetProperties(); m_animation.NeedRefresh := True; end; end; end.