Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Maury Animate (Componente) - MauryAnimate.pas

MauryAnimate.pas

Caricato da: Maury91
Scarica il programma completo

  1. unit MauryAnimate;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Classes, Controls, ExtCtrls, graphics;
  7.  
  8. type
  9.   TMauryAnimate = class(TImage)
  10.   private
  11.     FImmagine : TImageList;
  12.     FTimer : TTimer;
  13.     num : integer;
  14.     function get_att: boolean;
  15.     procedure set_att(const Value: boolean);
  16.     procedure anima;
  17.     procedure timer(Sender : Tobject);
  18.     function get_vel: integer;
  19.     procedure sset_vel(const Value: integer);
  20.     { Private declarations }
  21.   protected
  22.     { Protected declarations }
  23.   public
  24.   constructor Create(AOwner : TComponent); override;
  25.     { Public declarations }
  26.   published
  27.   property Immagine : TImageList read FImmagine write FImmagine;
  28.   property Attivo : boolean read get_att write set_att default true;
  29.   property Velocita : integer read get_vel write sset_vel default 125;
  30.   property Immage_Number : Integer read num write num;
  31.     { Published declarations }
  32.   end;
  33.  
  34. procedure Register;
  35.  
  36. implementation
  37.  
  38. procedure Register;
  39. begin
  40.   RegisterComponents('MauryTecnologies', [TMauryAnimate]);
  41. end;
  42.  
  43. { TMauryAnimate }
  44.  
  45. procedure TMauryAnimate.anima;
  46. var bit : TBitmap;
  47. begin
  48. bit := TBitmap.Create;
  49. bit.Height := FImmagine.Height;
  50. bit.Width := FImmagine.Width;
  51. FImmagine.Draw(bit.Canvas,0,0,num);
  52. Height := FImmagine.Height;
  53. Width := FImmagine.Width;
  54. Picture.Graphic := bit;
  55. end;
  56.  
  57. constructor TMauryAnimate.Create(AOwner: TComponent);
  58. begin
  59.   inherited Create(AOwner);
  60.   FTimer := TTimer.Create( self );
  61.   FTimer.Name := 'Timer';
  62.   FTimer.OnTimer := timer;
  63.   FTimer.SetSubComponent(false);
  64.   FImmagine := TImageList.Create( self );
  65.   num := 0;
  66. end;    
  67.  
  68. function TMauryAnimate.get_att: boolean;
  69. begin
  70. Result := FTimer.Enabled;
  71. end;
  72.  
  73. function TMauryAnimate.get_vel: integer;
  74. begin
  75. Result := FTimer.Interval;
  76. end;
  77.  
  78. procedure TMauryAnimate.set_att(const Value: boolean);
  79. begin
  80. FTimer.Enabled := Value;
  81. end;
  82.  
  83. procedure TMauryAnimate.sset_vel(const Value: integer);
  84. begin
  85. FTimer.Interval := Value;
  86. end;
  87.  
  88. procedure TMauryAnimate.timer(Sender: Tobject);
  89. begin
  90.   if Immagine <> nil then
  91.   begin
  92.     try
  93.       if num >= Immagine.Count then
  94.         num := 0;
  95.  
  96.       anima;
  97.  
  98.       Inc( num );
  99.       if num = Immagine.Count then
  100.         num := 0;
  101.     except
  102.       Attivo := False;
  103.       raise;
  104.     end;
  105.   end;
  106. end;
  107.  
  108. end.