unit UFormServer;

{$mode delphi}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Spin, UServerList;

type

  { TFormServer }

  TFormServer = class(TForm)
    ButtonCancel: TButton;
    ButtonOk: TButton;
    EditName: TEdit;
    EditAddress: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    SpinEdit1: TSpinEdit;
    procedure ButtonOkClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    FServerInfo: TServerInfo;
    procedure SetServerInfo(AValue: TServerInfo);
    procedure Load(Server: TServerInfo);
    procedure Save(Server: TServerInfo);
  public
    property ServerInfo: TServerInfo read FServerInfo write SetServerInfo;
  end;

var
  FormServer: TFormServer;

implementation

{$R *.lfm}

uses
  UCore;

{ TFormServer }

procedure TFormServer.FormShow(Sender: TObject);
begin
  Core.ThemeManager1.UseTheme(Self);
end;

procedure TFormServer.ButtonOkClick(Sender: TObject);
begin
  Save(FServerInfo);
end;

procedure TFormServer.SetServerInfo(AValue: TServerInfo);
begin
  if FServerInfo = AValue then Exit;
  FServerInfo := AValue;
  if Assigned(FServerInfo) then Load(FServerInfo);
end;

procedure TFormServer.Load(Server: TServerInfo);
begin
  EditName.Text := Server.Name;
  EditAddress.Text := Server.Address;
  SpinEdit1.Value := Server.Port;
end;

procedure TFormServer.Save(Server: TServerInfo);
begin
  Server.Name := EditName.Text;
  Server.Address := EditAddress.Text;
  Server.Port := SpinEdit1.Value;
end;

end.

