private void btn_upload_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { OpenFileDialog Dlg = new OpenFileDialog(); FileInfo FI; Dlg.Filter = "所有文件(*.*)|*.*"; Dlg.CheckFileExists = true; if (Dlg.ShowDialog() == DialogResult.OK) { FI = new FileInfo(Dlg.FileName); if (FI.Length == 0) { MessageBox.Show("不可上传空文件"); } else { string info = string.Join(SEPARATOR + "", new string[] { MessageType.FileMessage + "", COMPUTER_NAME, IP_ADDRESS, Dlg.FileName, FI.Length + "" }); UdpSendMessage.SendToAll(info); } } else { MessageBox.Show("取消上传"); } }
public static void IntervalBroadcast() { IntPtr charRoom = Win32API.FindWindow(null, "Чат групи LAN"); string info = string.Join(ChatRoom.SEPARATOR + "", new string[] { MessageType.Broadcast + "", ChatRoom.COMPUTER_NAME, ChatRoom.IP_ADDRESS }); while (true) { Win32API.SendMessage(charRoom, (int)MessageType.ClearUsers, 0, 0); UdpSendMessage.SendToAll(info); Thread.Sleep(BROADCAST_INTERVAL); } }
private void btn_send_Click(object sender, EventArgs e) { string data = message_chat.Text.Trim(); if (data == String.Empty) { MessageBox.Show("发送不能为空!"); } else { string info = string.Join(SEPARATOR + "", new string[] { MessageType.ChatMessage + "", COMPUTER_NAME, IP_ADDRESS, data }); UdpSendMessage.SendToAll(info); } message_chat.Clear(); }