private ConnectWidget(Builder builder) : base(builder.GetObject(typeof(ConnectWidget).Name).Handle) { builder.Autoconnect(this); _cvAccept.Clicked += new EventHandler((o, e) => { try { string sHost = _cvEnterIP.Text, sPort = _cvEnterPort.Text, sName = _cvEnterName.Text; if (int.TryParse(sPort, out int port)) { IPAddress iPAddress; IPHostEntry iPHostEntry = Dns.GetHostEntry(sHost); if (!IPAddress.TryParse(sHost, out iPAddress)) { iPAddress = iPHostEntry.AddressList[0]; } IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, port); ClientManager clientManager = new ClientManager(new GameCore.Game()); Client <IServer, ClientManager> client = new Client <IServer, ClientManager>(clientManager, iPEndPoint); clientManager.SetServer(client.Server, sName); Connecting?.Invoke(this, new EventArgsConnecting(iPEndPoint, client, sName)); } else { throw new Exception($"Неверный порт: {sPort}"); } } catch (Exception ex) { ErrorValidating?.Invoke(this, new EventArgsValue <Exception>(ex)); } }); _cvCancel.Clicked += new EventHandler((o, e) => Cancel?.Invoke(this, EventArgs.Empty)); }
protected virtual void OnErrorValidating(EventArgs e) { ErrorValidating?.Invoke(this, e); }