unit uServerMainForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
  uROClient, uROPoweredByRemObjectsButton, uROClientIntf, uROServer,
  uROBinMessage, uROIndyHTTPServer, uROIndyTCPServer, frxClass, frxPreview,
  JvComponent, JvTrayIcon, ActnList, Menus, XPMan, JvExControls,
  JvGradient, JvGIF, ExtCtrls, JvComponentBase, JvAppInst;

type
  TfServerForm = class(TForm)
    Memo1: TMemo;
    PopupMenu1: TPopupMenu;
    ActionList: TActionList;
    actCerrar: TAction;
    Cerrar1: TMenuItem;
    actRestart: TAction;
    actOpciones: TAction;
    actConexiones: TAction;
    Opciones1: TMenuItem;
    Refrescarconexin1: TMenuItem;
    N2: TMenuItem;
    XPManifest1: TXPManifest;
    JvTrayIcon: TJvTrayIcon;
    Panel1: TPanel;
    Image1: TImage;
    JvGradient1: TJvGradient;
    Button1: TButton;
    actAcerca: TAction;
    Acercade1: TMenuItem;
    N1: TMenuItem;
    JvAppInstances1: TJvAppInstances;
    procedure actCerrarExecute(Sender: TObject);
    procedure actRestartExecute(Sender: TObject);
    procedure actOpcionesExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure actAcercaExecute(Sender: TObject);
    procedure actConexionesExecute(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure JvAppInstances1CmdLineReceived(Sender: TObject;
      CmdLine: TStrings);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fServerForm : TfServerForm;

implementation

uses
  uDataModuleServer, uConfiguracion, uAcercaDe;

{$R *.dfm}

procedure TfServerForm.actCerrarExecute(Sender: TObject);
begin
  Close;
end;

procedure TfServerForm.actConexionesExecute(Sender: TObject);
var
  i: Integer;
begin
  JvTrayIcon.ShowApplication;
  with Memo1.Lines do
  begin
    Clear;
    for i := 0 to dmServer.ConnectionManager.Connections.Count - 1 do
      Memo1.Lines.Add(dmServer.ConnectionManager.Connections[i].Name + ' -> ' + dmServer.ConnectionManager.Connections[i].ConnectionString);
  end;
//  JvTrayIcon.HideApplication;
end;

procedure TfServerForm.actRestartExecute(Sender: TObject);
begin
  dmServer.RefrescarConexion;
end;

procedure TfServerForm.Button1Click(Sender: TObject);
begin
  JvTrayIcon.HideApplication;
end;

procedure TfServerForm.actOpcionesExecute(Sender: TObject);
var
  AForm : TForm;
begin
  AForm := TfConfiguracion.Create(NIL);
  try
    AForm.ShowModal;
  finally
    AForm.Free;
    actRestart.Execute;
  end;
end;

procedure TfServerForm.FormCreate(Sender: TObject);
begin
  JvTrayIcon.HideApplication;
  JvTrayIcon.Active := True;
end;

procedure TfServerForm.JvAppInstances1CmdLineReceived(Sender: TObject;
  CmdLine: TStrings);
begin
  dmServer.RefrescarConexion;
end;

procedure TfServerForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  JvTrayIcon.Active := False;
end;

procedure TfServerForm.actAcercaExecute(Sender: TObject);
begin
  with TfAcercaDe.Create(NIL) do
    try
      ShowModal;
    finally
      Free;
    end;
end;

end.
