コード例 #1
0
        // 双击打开与某个用户聊天的子窗口
        private void lstviewOnlineUser_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string peerName = lstviewOnlineUser.SelectedItems[0].SubItems[1].Text;

            if (peerName == txtusername.Text)
            {
                return;
            }
            lstviewOnlineUser.SelectedItems[0].SubItems[0].Text = "";//清空未读消息提示

            string ipEndPoint = lstviewOnlineUser.SelectedItems[0].SubItems[2].Text;

            //MessageBox.Show("ipEndPoint : " + ipEndPoint);
            string[]   splitString    = ipEndPoint.Split(':');
            IPAddress  peerIP         = IPAddress.Parse(splitString[0]);
            IPEndPoint peerIPEndPoint = new IPEndPoint(peerIP, int.Parse(splitString[1]));
            ChatFormcs dialogChat     = new ChatFormcs();

            dialogChat.SetUserInfo(txtusername.Text, peerName, peerIPEndPoint);
            dialogChat.Text = peerName;
            chatFormList.Add(dialogChat);

            if (unReadMsg.ContainsKey(peerName))
            {
                foreach (Dictionary <string, string> msgItem in unReadMsg[peerName])
                {
                    dialogChat.ShowTalkInfo(peerName, msgItem["time"], msgItem["content"]);
                }
                unReadMsg[peerName].Clear();
            }
            dialogChat.FormClosing += closeDialogChat;
            dialogChat.Show();
        }
コード例 #2
0
        private void closeDialogChat(object sender, FormClosingEventArgs e)
        {
            ChatFormcs chatFormcs = (ChatFormcs)sender;
            string     peerName   = chatFormcs.peerUserName;

            foreach (ChatFormcs item in this.chatFormList)
            {
                if (item.peerUserName == peerName)
                {
                    this.chatFormList.Remove(item);
                    break;
                }
            }
        }
コード例 #3
0
        private void showDialogChatToReceiveFile(ListViewItem electedItem)
        {
            string peerName = electedItem.SubItems[1].Text;

            electedItem.SubItems[0].Text = "";//清空未读消息de提示
            string ipEndPoint = electedItem.SubItems[2].Text;

            //MessageBox.Show("ipEndPoint : " + ipEndPoint);
            string[]   splitString    = ipEndPoint.Split(':');
            IPAddress  peerIP         = IPAddress.Parse(splitString[0]);
            IPEndPoint peerIPEndPoint = new IPEndPoint(peerIP, int.Parse(splitString[1]));
            ChatFormcs dialogChat     = new ChatFormcs();

            dialogChat.SetUserInfo(txtusername.Text, peerName, peerIPEndPoint);
            dialogChat.Text = peerName;
            chatFormList.Add(dialogChat);

            dialogChat.ShowTalkInfo(peerName, DateTime.Now.ToLongTimeString(), "向你发送了文件");
            dialogChat.FormClosing += closeDialogChat;
            dialogChat.Show();
        }
コード例 #4
0
        // 双击打开与某个用户聊天的子窗口
        private void lstviewOnlineUser_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string peerName = lstviewOnlineUser.SelectedItems[0].SubItems[1].Text;

            if (peerName == txtusername.Text)
            {
                return;
            }

            string ipEndPoint = lstviewOnlineUser.SelectedItems[0].SubItems[2].Text;

            string[]   splitString    = ipEndPoint.Split(':');
            IPAddress  peerIP         = IPAddress.Parse(splitString[0]);
            IPEndPoint peerIPEndPoint = new IPEndPoint(peerIP, int.Parse(splitString[1]));
            ChatFormcs dialogChat     = new ChatFormcs();

            dialogChat.SetUserInfo(txtusername.Text, peerName, peerIPEndPoint);
            dialogChat.Text = peerName;
            chatFormList.Add(dialogChat);
            dialogChat.Show();
        }
コード例 #5
0
        // 双击打开与某个用户聊天的子窗口
        private void lstviewOnlineUser_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string peerName = lstviewOnlineUser.SelectedItems[0].SubItems[1].Text;
            if (peerName == txtusername.Text)
            {
                return;
            }

            string ipEndPoint = lstviewOnlineUser.SelectedItems[0].SubItems[2].Text;
            string[] splitString = ipEndPoint.Split(':');
            IPAddress peerIP = IPAddress.Parse(splitString[0]);
            IPEndPoint peerIPEndPoint = new IPEndPoint(peerIP,int.Parse(splitString[1]));
            ChatFormcs dialogChat = new ChatFormcs();
            dialogChat.SetUserInfo(txtusername.Text, peerName, peerIPEndPoint);
            dialogChat.Text = peerName;
            chatFormList.Add(dialogChat);
            dialogChat.Show();
        }