unit MauryAnimate;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, graphics;
type
TMauryAnimate = class(TImage)
private
FImmagine : TImageList;
FTimer : TTimer;
num : integer;
function get_att: boolean;
procedure set_att(const Value: boolean);
procedure anima;
procedure timer(Sender : Tobject);
function get_vel: integer;
procedure sset_vel(const Value: integer);
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(AOwner : TComponent); override;
{ Public declarations }
published
property Immagine : TImageList read FImmagine write FImmagine;
property Attivo : boolean read get_att write set_att default true;
property Velocita : integer read get_vel write sset_vel default 125;
property Immage_Number : Integer read num write num;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MauryTecnologies', [TMauryAnimate]);
end;
{ TMauryAnimate }
procedure TMauryAnimate.anima;
var bit : TBitmap;
begin
bit := TBitmap.Create;
bit.Height := FImmagine.Height;
bit.Width := FImmagine.Width;
FImmagine.Draw(bit.Canvas,0,0,num);
Height := FImmagine.Height;
Width := FImmagine.Width;
Picture.Graphic := bit;
end;
constructor TMauryAnimate.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FTimer := TTimer.Create( self );
FTimer.Name := 'Timer';
FTimer.OnTimer := timer;
FTimer.SetSubComponent(false);
FImmagine := TImageList.Create( self );
num := 0;
end;
function TMauryAnimate.get_att: boolean;
begin
Result := FTimer.Enabled;
end;
function TMauryAnimate.get_vel: integer;
begin
Result := FTimer.Interval;
end;
procedure TMauryAnimate.set_att(const Value: boolean);
begin
FTimer.Enabled := Value;
end;
procedure TMauryAnimate.sset_vel(const Value: integer);
begin
FTimer.Interval := Value;
end;
procedure TMauryAnimate.timer(Sender: Tobject);
begin
if Immagine <> nil then
begin
try
if num >= Immagine.Count then
num := 0;
anima;
Inc( num );
if num = Immagine.Count then
num := 0;
except
Attivo := False;
raise;
end;
end;
end;
end.