예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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();
                }
            });
        }