unit Connect;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Main ;

type
  TfrmConnect = class(TForm)
    editAddress: TEdit;
    Label1: TLabel;
    editPort: TEdit;
    Label2: TLabel;
    editName: TEdit;
    Label3: TLabel;
    editPassword: TEdit;
    Label4: TLabel;
    editCatalog: TEdit;
    Label5: TLabel;
    checkCatalog: TCheckBox;
    btnConnect: TButton;
    btnCancel: TButton;
    btnBrowse: TButton;
    OpenDialog1: TOpenDialog;
    procedure checkCatalogClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure btnBrowseClick(Sender: TObject);
    procedure btnConnectClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmConnect: TfrmConnect;

implementation

{$R *.dfm}

procedure TfrmConnect.checkCatalogClick(Sender: TObject);
begin
  if( checkCatalog.State = cbChecked ) then
    begin
      editCatalog.Enabled := TRUE ;
      editCatalog.ReadOnly := FALSE ;
      editCatalog.Color := clWindow ;
      btnBrowse.Enabled := TRUE ;
    end
  else
    begin
      editCatalog.Enabled := FALSE ;
      editCatalog.ReadOnly := TRUE ;
      editCatalog.Color := clBtnFace ;
      btnBrowse.Enabled := FALSE ;
    end ;
end;

procedure TfrmConnect.btnCancelClick(Sender: TObject);
begin
  frmConnect.Close ;
end;

procedure TfrmConnect.btnBrowseClick(Sender: TObject);
begin
  OpenDialog1.Execute ;
  editCatalog.Text := OpenDialog1.FileName ;
end;

procedure TfrmConnect.btnConnectClick(Sender: TObject);
begin
  NISession.Connect( editAddress.Text,
                     StrToInt( editPort.Text ),
                     editName.Text,
                     editPassword.Text,
                     editCatalog.Text ) ;
  frmConnect.Close ;
end ;

procedure TfrmConnect.FormShow(Sender: TObject);
begin
  if( NISession.fConnected = TRUE ) then
    btnConnect.Enabled := FALSE
  else
    btnConnect.Enabled := TRUE ;
end;

end.
