unit uServerMainForm;

interface

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

type
  TfServerForm = class(TForm)
    PopupMenu1: TPopupMenu;
    ActionList: TActionList;
    actCerrar: TAction;
    Cerrar1: TMenuItem;
    actRestart: TAction;
    actOpciones: TAction;
    actConexiones: TAction;
    Opciones1: TMenuItem;
    Refrescarconexin1: TMenuItem;
    N2: TMenuItem;
    XPManifest1: TXPManifest;
    Panel1: TPanel;
    Image1: TImage;
    JvGradient1: TJvGradient;
    actAcerca: TAction;
    Acercade1: TMenuItem;
    N1: TMenuItem;
    JvAppInstances1: TJvAppInstances;
    TrayIcon1: TTrayIcon;
    JvProgressDialog1: TJvProgressDialog;
    procedure actCerrarExecute(Sender: TObject);
    procedure actRestartExecute(Sender: TObject);
    procedure actOpcionesExecute(Sender: TObject);
    procedure actAcercaExecute(Sender: TObject);
    procedure JvAppInstances1CmdLineReceived(Sender: TObject;
      CmdLine: TStrings);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fServerForm : TfServerForm;

implementation

uses
  uROComboService, uDataModuleServer, uConfiguracion, uAcercaDe, uServerAppUtils;

{$R *.dfm}

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

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

procedure TfServerForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if not ROIsService then
    with JvProgressDialog1 do
    begin
      InitValues(0, 100, 10, 0, 'Cerrar FactuGES Server', 'Espere mientras FactuGES Server se cierra...');
      Show;
      while Assigned(dmServer) do
      begin
        if (Position + Interval > Max) then
          Position := Min
        else
          Position := Position + Interval;
        Refresh;
        FreeAndNIL(dmServer);
        Sleep(500);
        TrayIcon1.Visible := False;
      end;
      Hide;
    end;
  CanClose := True;
end;

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

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

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

end.
