unit U_PEGetBox;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, RzPanel, StdCtrls,
  U_Main, U_BaseCommon, U_SCSComponent, RzButton, Menus, siComp, siLngLnk;
type
  TF_PEGetBox = class(TForm)
    RzPanel1: TRzPanel;
    RzPanel2: TRzPanel;
    RzPanel3: TRzPanel;
    Label1: TLabel;
    bOk: TRzBitBtn;
    bCancel: TRzBitBtn;
    pmForTree: TPopupMenu;
    lng_Forms: TsiLangLinked;
    procedure FormCreate(Sender: TObject);
    procedure bOkClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }

    FNormBase: TForm;
    procedure InitPopupMenuForTree;
    procedure FreePopupMenuForTree;
  public
    { Public declarations }
    GetCompon: TSCSComponent;
    procedure SetNBToForm;
    Function GetSCSCompon: TSCSComponent;
 //   function Execute: Boolean;
  end;

var
  F_PEGetBox: TF_PEGetBox;


implementation

{$R *.dfm}


procedure TF_PEGetBox.SetNBToForm;
var
  CompTypeSysNames: TStringList;
begin
  try
    GGDBMode := bkNormBase;
    CompTypeSysNames := TStringList.Create;
    CompTypeSysNames.Add(ctsnTerminalBox);

    FNormBase := TF_Main.Create(Self, bkNormBase, fmConnections);

   // FSavedNBTreeCatalogChange := TF_Main(FNormBase).Tree_Catalog.OnChange;

    TF_Main(FNormBase).FNormBase := F_NormBase;
    TF_Main(FNormBase).FProjectMan := F_ProjMan;


    TF_Main(FNormBase).Visible := false;
    TF_Main(FNormBase).Constraints.MinWidth := 0;
    TF_Main(FNormBase).ToolBar_Tree.Visible := false;
    TF_Main(FNormBase).HideTemplateControls;
    TF_Main(FNormBase).Panel_Addition.Visible := false;
    TF_Main(FNormBase).Panel_OKCancel.Visible := false;
    TF_Main(FNormBase).Parent := RzPanel1;
    TF_Main(FNormBase).Align := alClient;
    TF_Main(FNormBase).EnableDisableEdit(false);
    InitPopupMenuForTree;
    TF_Main(FNormBase).Tree_Catalog.PopupMenu := pmForTree;
   // TF_Main(FNormBase).Tree_Catalog.OnChange := NBTree_CatalogChange;

    FreeAndNil(TF_Main(FNormBase).PopupMenu_Catalog);

    TF_Main(FNormBase).SetFilterBlockForCompType(CompTypeSysNames);
    TF_Main(FNormBase).Visible := true;

    FreeAndNil(CompTypeSysNames);
  except
    on E: Exception do AddExceptionToLogEx('TF_PEGetBox.SetNBToForm ', E.Message);
  end;
end;

procedure TF_PEGetBox.FormCreate(Sender: TObject);
begin
  GetCompon := Nil;
end;

procedure TF_PEGetBox.bOkClick(Sender: TObject);
begin
  GetCompon := GetSCSCompon;
end;



procedure TF_PEGetBox.InitPopupMenuForTree;
var
  Item: TMenuItem;
begin
  Item := TMenuItem.Create(Self);
  Item.Action := TF_MAIN(FNormBase).Act_MinimizeDir;
  Item.Caption := TF_MAIN(FNormBase).Act_MinimizeDir.Caption;
  //Item.Visible := True;

  pmForTree.Items.Add(Item);
  Item := TMenuItem.Create(Self);
  Item.Action := TF_MAIN(FNormBase).Act_MaximizeDir;
  pmForTree.Items.Add(Item);
end;

procedure TF_PEGetBox.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  pmForTree.Items.Clear;
  TF_MAIN(FNormBase).Free;
end;

procedure TF_PEGetBox.FreePopupMenuForTree;
begin
  //
end;

function TF_PEGetBox.GetSCSCompon: TSCSComponent;
begin
  if Assigned(TF_MAIN(FNormBase).GSCSBase.SCSComponent) then
  begin
    Result := TSCSComponent.Create(F_NormBase);
    Result.Assign(TF_MAIN(FNormBase).GSCSBase.SCSComponent, false, true);
  end;
end;    

end.
