//局域网客户连接事件 private void wifiServer_clientConnectEvent(object sender, ClientConnectEventArgs e) { //添加一个panel显示该用户的用户名 //每一次有用户连接则先清空面板,再刷新面板 connectedPanel.Controls.Clear(); //向主界面发送消息 this.Invoke((EventHandler)(delegate { foreach (string username in e.UserList) { UserPanel userPanel = new UserPanel(username, wifiServer); userPanel.Location = new System.Drawing.Point(0, ConnectedCount * 40); this.connectedPanel.Controls.Add(userPanel); } })); ConnectedCount++; }
//处理串口用户连接事件 private void comServer_clientConnectEvent(object sender, ClientConnectEventArgs e) { //向主界面发送消息 this.Invoke((EventHandler)(delegate { UserPanel userPanel = new UserPanel(e.UserName,bluetoothServer); userPanel.Location = new System.Drawing.Point(0, ConnectedCount * 40); this.connectedPanel.Controls.Add(userPanel); } )); }