/// <summary> /// Handles the Click event of the ConnectBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void ConnectBtn_Click(object sender, EventArgs e) { var msg = ru ? "Соединиться" : "Connect"; if (Client.IsConnected) { Client.Disconnect(); LedConnect.ImageIndex = 0; ConnectBtn.Invk(t => t.Text = msg); return; } IPaddress = SrvName.Text; try { Port = decimal.ToInt32(PortNum.Value); } catch (Exception ex) { Port = Globals.Port; } Client.Connect(IPaddress, Port); if (Client.IsConnected) { LedConnect.ImageIndex = 1; ConnectBtn.Invk(t => t.Text = ru ? "Отсоединиться" : "Disconnect"); Client.SendInfo("I'm test client for MainC"); Client.AskServerState(); msg += ru ? " - соединение успешно" : " is connected"; Console.WriteLine(msg); } else { msg += " не доступен"; Console.WriteLine(msg); MessageBox.Show(msg, ru ? "Предупреждение" : "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }