BSOne.SFC/EM.Lib/ImageEn_SRC/Demos/Display/MviewFlow/umain.pas

221 lines
6.0 KiB
Plaintext

unit umain;
interface
{$IfNDef VER130}
{$WARN UNIT_PLATFORM OFF}
{$EndIf}
uses
Windows, Messages, SysUtils, {$IfNDef VER130} Variants, {$EndIf} Classes, Graphics, Controls, Forms,
Dialogs, ieview, iemview, StdCtrls, ComCtrls, FileCtrl, Buttons, ExtCtrls, ieanimation, hyieutils, iexBitmaps,
hyiedefs, iesettings, iexLayers, iexRulers, jpeg;
type
TMainForm = class(TForm)
Panel1: TPanel;
SpeedButtonAdvanced: TSpeedButton;
Label9: TLabel;
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
ComboBox1: TComboBox;
PageControl1: TPageControl;
TabSheet3: TTabSheet;
Label6: TLabel;
Label2: TLabel;
Label8: TLabel;
EditAnimDuration: TEdit;
UpDownAnimDuration: TUpDown;
EditDepth: TEdit;
UpDownDepth: TUpDown;
EditShadowAlphaMin: TEdit;
UpDownShadowAlphaMin: TUpDown;
EditShadowAlphaMax: TEdit;
UpDownShadowAlphaMax: TUpDown;
CheckBoxShowBorder: TCheckBox;
CheckBoxShowFilename: TCheckBox;
CheckBoxShowScrollbar: TCheckBox;
TabSheet1: TTabSheet;
Label1: TLabel;
Label5: TLabel;
Label3: TLabel;
Label4: TLabel;
EditHorizDistance: TEdit;
UpDownHorizDistance: TUpDown;
EditRotateAngle: TEdit;
UpDownRotateAngle: TUpDown;
EditImagesHorizPer: TEdit;
UpDownImagesHorizPer: TUpDown;
EditImagesVertPer: TEdit;
UpDownImagesVertPer: TUpDown;
EditImagesZoom: TEdit;
UpDownImagesZoom: TUpDown;
EditCurrentImageZoom: TEdit;
UpDownCurrentImageZoom: TUpDown;
TabSheet2: TTabSheet;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit1: TEdit;
UpDown1: TUpDown;
Edit2: TEdit;
UpDown2: TUpDown;
Edit3: TEdit;
UpDown3: TUpDown;
Edit4: TEdit;
UpDown4: TUpDown;
Edit5: TEdit;
UpDown5: TUpDown;
ImageEnMView1: TImageEnMView;
Label7: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
dlgColor: TColorDialog;
lblColor: TLabel;
pnlColor: TPanel;
procedure DirectoryListBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButtonAdvancedClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure OnCtrlChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure pnlColorClick(Sender: TObject);
private
{ Private declarations }
procedure SetAnimationProperties();
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
{$R WindowsTheme.res}
procedure TMainForm.FormCreate(Sender: TObject);
begin
ComboBox1.ItemIndex := 0;
DirectoryListBox1.Directory := ExtractFilePath(Application.Exename) + 'slides';
end;
procedure TMainForm.DirectoryListBox1Change(Sender: TObject);
begin
ImageEnMView1.Clear();
ImageEnMView1.FillFromDirectory(DirectoryListBox1.Directory);
ImageEnMView1.SelectedImage := 0;
SetAnimationProperties();
end;
// update animation object with the content of form controls
procedure TMainForm.SetAnimationProperties();
var
Animation: TIEAnimation;
begin
Animation := ImageEnMView1.Animation;
if assigned(Animation) then
begin
// common properties
Animation.Depth := UpDownDepth.Position;
Animation.AnimDuration := UpDownAnimDuration.Position;
Animation.ShowBorder := CheckboxShowBorder.Checked;
Animation.ShadowAlphaMin := UpDownShadowAlphaMin.Position;
Animation.ShadowAlphaMax := UpDownShadowAlphaMax.Position;
Animation.ShowScrollbar := CheckboxShowScrollbar.Checked;
Animation.ShowText := CheckboxShowFilename.Checked;
Animation.Font.Color := pnlColor.Color;
// specific TIEHorizontalFlow properties
if Animation is TIEHorizontalFlow then
with 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 Animation is TIECircularFlow then
with Animation as TIECircularFlow do
begin
ImagesSizePercentage := UpDown1.Position;
ImagesZoom := UpDown2.Position / 100;
CurrentImageZoom := UpDown3.Position / 100;
VisibleImages := UpDown4.Position;
EllipseAngle := UpDown5.Position;
end;
end;
end;
// Advanced button
procedure TMainForm.SpeedButtonAdvancedClick(Sender: TObject);
begin
PageControl1.Visible := not PageControl1.Visible;
end;
// changes animation type
procedure TMainForm.ComboBox1Change(Sender: TObject);
begin
case ComboBox1.ItemIndex of
0: ImageEnMView1.Animation := nil;
1: ImageEnMView1.Animation := TIEHorizontalFlow.Create();
2: ImageEnMView1.Animation := TIECircularFlow.Create();
end;
SetAnimationProperties();
end;
// Controls change
procedure TMainForm.OnCtrlChange(Sender: TObject);
begin
SetAnimationProperties();
end;
// Delete image
procedure TMainForm.Button1Click(Sender: TObject);
begin
ImageEnMView1.DeleteImage(imageenmview1.selectedimage);
end;
// Append image
procedure TMainForm.Button2Click(Sender: TObject);
begin
ImageEnMView1.AppendImage(ExtractFilePath(ParamStr(0))+'\new.jpg');
end;
// Insert image
procedure TMainForm.Button3Click(Sender: TObject);
begin
ImageEnMView1.InsertImage(ImageEnMView1.SelectedImage);
ImageEnMView1.SetImageFromFile(ImageEnMView1.SelectedImage, ExtractFilePath(ParamStr(0))+'\new.jpg');
end;
procedure TMainForm.pnlColorClick(Sender: TObject);
begin
dlgColor.Color := pnlColor.Color;
if dlgColor.Execute then
begin
pnlColor.Color := dlgColor.Color;
SetAnimationProperties();
ImageEnMView1.Update;
end;
end;
end.