summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 09:10:06 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 09:10:06 +0000
commit194923c172167eb3fc33807ec8009b255f86337e (patch)
tree1effc97a1bd872cc3a5eac7a361250cf283e0efd /plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas
parentb2943645fed61d0c0cfee1225654e5ff44fd96f8 (diff)
Plugin is not adapted until someone can compile it and tell others how to do the same
git-svn-id: http://svn.miranda-ng.org/main/trunk@1809 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas')
-rw-r--r--plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas113
1 files changed, 113 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas b/plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas
new file mode 100644
index 0000000000..b5c12fef1e
--- /dev/null
+++ b/plugins/!NotAdopted/Chess4Net/ConnectionUnit.pas
@@ -0,0 +1,113 @@
+////////////////////////////////////////////////////////////////////////////////
+// All code below is exclusively owned by author of Chess4Net - Pavel Perminov
+// (packpaul@mail.ru, packpaul1@gmail.com).
+// Any changes, modifications, borrowing and adaptation are a subject for
+// explicit permition from the owner.
+
+unit ConnectionUnit;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
+ Dialogs, StdCtrls, ExtCtrls, Mask;
+
+type
+ TConnectionForm = class(TForm)
+ NickLabel: TLabel;
+ NickEdit: TEdit;
+ ConnectionRadioGroup: TRadioGroup;
+ ServerRadioButton: TRadioButton;
+ ClientRadioButton: TRadioButton;
+ OKButton: TButton;
+ CancelButton: TButton;
+ IPEdit: TEdit;
+ IPLabel: TLabel;
+ PortLabel: TLabel;
+ PortEdit: TMaskEdit;
+ procedure FormShow(Sender: TObject);
+ procedure ServerRadioButtonClick(Sender: TObject);
+ procedure ClientRadioButtonClick(Sender: TObject);
+ procedure NickEditExit(Sender: TObject);
+ procedure FormKeyPress(Sender: TObject; var Key: Char);
+ procedure IPEditChange(Sender: TObject);
+ procedure PortEditExit(Sender: TObject);
+ public
+ function GetPort: word;
+ constructor Create(Owner: TComponent); reintroduce;
+ end;
+
+implementation
+
+{$R *.dfm}
+
+uses
+ GlobalsLocalUnit;
+
+procedure TConnectionForm.ServerRadioButtonClick(Sender: TObject);
+begin
+ IPEdit.Enabled := FALSE;
+ OKButton.Enabled := TRUE;
+end;
+
+procedure TConnectionForm.FormShow(Sender: TObject);
+var
+ frmOwner: TForm;
+begin
+ frmOwner := (Owner as TForm);
+ Left:= frmOwner.Left + (frmOwner.Width - Width) div 2;
+ Top:= frmOwner.Top + (frmOwner.Height - Height) div 2;
+end;
+
+procedure TConnectionForm.ClientRadioButtonClick(Sender: TObject);
+begin
+ IPEdit.Enabled:= TRUE;
+ if IPEdit.Text <> '' then OKButton.Enabled:= TRUE
+ else OKButton.Enabled:= FALSE;
+end;
+
+procedure TConnectionForm.PortEditExit(Sender: TObject);
+begin
+ PortEdit.Text := IntToStr(GetPort);
+end;
+
+procedure TConnectionForm.NickEditExit(Sender: TObject);
+begin
+ if NickEdit.Text = '' then NickEdit.Text:= 'NN';
+end;
+
+procedure TConnectionForm.FormKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key = #13 then ModalResult:= mrOk;
+end;
+
+procedure TConnectionForm.IPEditChange(Sender: TObject);
+begin
+ if IPEdit.Text <> '' then OKButton.Enabled:= TRUE
+ else OKButton.Enabled:= FALSE;
+end;
+
+constructor TConnectionForm.Create(Owner: TComponent);
+begin
+ FormStyle := (Owner as TForm).FormStyle;
+ inherited;
+ PortEdit.Text := IntToStr(DEFAULT_PORT);
+end;
+
+function TConnectionForm.GetPort: word;
+var
+ port: integer;
+begin
+ try
+ port := StrToInt(Trim(PortEdit.Text));
+ if (port > 0) and (port <= $FFFF) then
+ Result := port
+ else
+ Result := DEFAULT_PORT
+ except
+ on EConvertError do
+ Result := DEFAULT_PORT;
+ end;
+end;
+
+end.