private void button_send_Click(object sender, EventArgs e) { try { if (TextBox_send.Text == "") { MessageBox.Show("发送内容不能为空", "操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string text = TextBox_send.Text; while (is_sending) { } ; is_sending = true; TextBox_chat.SelectionAlignment = HorizontalAlignment.Right; string whole = Aliases[0] + "(" + members[0] + ")" + " " + DateTime.Now.ToString() + "\n" + text + "\n"; TextBox_chat.AppendText(whole); whole = text + "\n"; is_sending = false; TextBox_send.Clear(); foreach (Socket sc in all_sockets) { AsynSend(sc, whole); } } catch (Exception) { MessageBox.Show("连接失效", "网络错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
// 清空输入栏 private void button_clear_Click(object sender, EventArgs e) { TextBox_send.Clear(); }