private void UserList_MouseDoubleClick(object sender, MouseEventArgs e) { var item = UserList.SelectedItem as User; if (item != null) { PrivateChat chatPanel; if (OpenedChats.TryGetValue(item.Identity, out chatPanel)) { chatPanel.Show(); } else { chatPanel = new PrivateChat(socket, item); chatPanel.FormClosed += ChatPanelClosed; OpenedChats.Add(item.Identity, chatPanel); chatPanel.Show(); } } }
private void HandleMessage(BinaryReader buffer) { var message = (PrivateMessage)serializer.Deserialize(buffer.ReadBytes(BUFFERSIZE)); this.InvokeOnUI(() => { PrivateChat chatPanel; if (OpenedChats.TryGetValue(message.To.Identity, out chatPanel)) { this.InvokeOnUI(chatPanel.Activate); chatPanel.PrintMessage(message.Message, message.To.Name); } else { chatPanel = new PrivateChat(socket, message.To); chatPanel.FormClosed += ChatPanelClosed; chatPanel.PrintMessage(message.Message, message.To.Name); OpenedChats.Add(message.To.Identity, chatPanel); chatPanel.Show(); } }); }