VILLOG

Top  Previous  Next

unit Villog;

 

interface

 

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,

Forms, Dialogs, ExtCtrls;

 

type

 

TVillog = class(TPanel)

private

  FActive : boolean;         {Villog vagy nem}

  FActiveColor: TColor;      {Egyik szín}

  FInActiveColor: TColor;    {Másik szín}

  FBaseColor: TColor;        {Alap szín amikor nem villog}

  FTimer  : TTimer;

  ido     : longint;

  FInterval: integer;        {Időzítő intervalluma 1/1000 sec}

  procedure SetInterval(Value:integer);

  procedure SetActive(Value:boolean);

  procedure SetBaseColor(Value:TColor);

protected

public

  constructor Create(AOwner:TComponent);override;

  destructor Destroy;override;

  procedure Timer(Sender : TObject);

published

  property Active: boolean read FActive write SetActive;

  property Interval: integer read FInterval write SetInterval default 200;

  property ActiveColor: TColor read FActiveColor write FActiveColor;

  property InActiveColor: TColor read FInActiveColor write FInActiveColor;

  property BaseColor: TColor read FBaseColor write SetBaseColor;

end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

RegisterComponents('MIKI', [TVillog]);

end;

 

constructor TVillog.Create(AOwner:TComponent);

begin

   inherited Create(AOwner);

   ido := 0;

   Active := True;

   FActiveColor   := clRed;

   FInActiveColor := clLime;

   FBaseColor     := clSilver;

   Color := clGreen;

   Caption := '';

   FTimer:=TTimer.Create(Self);

   FTimer.OnTimer := Timer;

   Ftimer.Interval:=200;

end;

 

destructor TVillog.Destroy;

begin

   FTimer.Free;

   inherited Destroy;

end;

 

procedure TVillog.Timer;

begin

If Active then begin

Inc(ido);

Case (ido mod 2) of

0: Color:=InActiveColor;

1: Color:=ActiveColor;

end;

end;

end;

 

procedure TVillog.SetInterval(Value:integer);

begin

 FInterval:=Value;

 Ftimer.Interval:=Value;

end;

 

procedure TVillog.SetActive(Value:boolean);

begin

 FActive:=Value;

 If not Value then Color := BaseColor;

 invalidate;

end;

 

procedure TVillog.SetBaseColor(Value:TColor);

begin

 FBaseColor := Value;

 If not Active then Color := BaseColor;

end;

 

end.