// DEPRECATED !!!

unit CtrlPanelZdvh;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DevCtrl, DatCtrl, ExtCtrls, StdCtrls, Buttons, VisZDVH, ZdvhCtrl;

type
  TCtrlPanelZdvhForm = class(TForm)
    Panel1: TPanel;
    Timer: TTimer;

    procedure FormActivate(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
  private
    frmDir: array of TZdvhCtrlFrame;
  public
    M: TVisZDVH;
  end;

var
  CtrlPanelZdvhForm: TCtrlPanelZdvhForm;

implementation
uses numbers, TagStorage;

{$R *.DFM}

procedure TCtrlPanelZdvhForm.FormCreate(Sender: TObject);
begin
  frmDir := nil;
end;

procedure TCtrlPanelZdvhForm.FormActivate(Sender: TObject);
var
  k,i,l: integer;
begin
  Timer.Enabled := false;
  // Создание объектов панели управления
  k:=0;

  l := length(frmDir);
  if length(frmDir) < M.DirCount then begin
    SetLength(frmDir, M.DirCount);
    for i:=l to M.DirCount-1 do frmDir[i] := nil;
  end else begin
    for i:=M.DirCount to l-1 do begin
      frmDir[i].Visible := false;
    end;
//    SetLength(frmDir, M.DirCount);

  end;

  for i:=0 to M.DirCount-1 do if frmDir[i] = nil then begin
    frmDir[i] := TZdvhCtrlFrame.Create(self);
    frmDir[i].Parent := self;
    frmDir[i].Name := 'frmDir' + IntToStr(i);
    frmDir[i].Left := 2;
    frmDir[i].Top :=  2 + k + i*frmDir[i].Height;
    frmDir[i].Visible := true;
  end else begin
    frmDir[i].Top :=  2 + k + i*frmDir[i].Height;
  end;


  // Заполнение данными
  for i:=0 to M.DirCount-1 do begin
    frmDir[i].M := M;
    frmDir[i].DirNum := i;
    frmDir[i].Init;
    frmDir[i].Visible := true;
  end;
  Timer.Enabled := true;

end;

procedure TCtrlPanelZdvhForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
  i: integer;
begin
  for i:=0 to length(frmDir)-1 do frmDir[i].Free;
  frmDir := nil;
  Timer.Enabled := false;
end;


procedure TCtrlPanelZdvhForm.TimerTimer(Sender: TObject);
var
  i: integer;
begin
  for i:=0 to M.DirCount-1 do frmDir[i].Process;
end;


end.
