Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtNickname.Text == "")
     {
         MessageBox.Show("Nick name is empty");
     }
     else
     {
         ClientChat client = new ClientChat(txtNickname.Text);
         client.FormClosed += Client_FormClosed;
         this.Hide();
         client.Show();
     }
 }
Beispiel #2
0
        public void Client_Received(ClientChat client, string receivedMsg)
        {
            var cmd = receivedMsg.Split('|');

            switch (cmd[0])
            {
            case "Users":
                this.Invoke(() =>
                {
                    userList.Items.Clear();
                    for (int i = 1; i < cmd.Length; i++)
                    {
                        if (cmd[i] != "Connected" | cmd[i] != "RefreshChat")
                        {
                            userList.Items.Add(cmd[i]);
                        }
                    }
                }
                            );
                break;

            case "Message":
                this.Invoke(() => { txtReceivedMsg.Text += cmd[1] + "\r\n"; });
                break;

            case "RefreshChat":
                this.Invoke(() => { txtReceivedMsg.Text = cmd[1]; });
                break;

            case "Chat":
                this.Invoke(() =>
                {
                    pChat.Text = pChat.Text.Replace("user", main.txtUsername.Text);
                    pChat.Show();
                });
                break;

            case "pMessage":
                this.Invoke(() => { pChat.txtReceivedMsg.Text += "Server: " + cmd[1] + "\r\n"; });
                break;

            case "Disconnect":
                Application.Exit();
                break;
            }
        }
Beispiel #3
0
 public MainForm()
 {
     client = new ClientChat();
     InitializeComponent();
 }
Beispiel #4
0
 private static void Client_Disconnected(ClientChat clientChat)
 {
 }