• 大小: 143KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-19
  • 语言: 其他
  • 标签: 模仿qq  

资源简介

模仿qq,实现聊天功能

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
// 添加额外命名空间
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Client
{
    public partial class ChatFormcs : Form
    {
        private string selfUserName;
        private string peerUserName;
        private IPEndPoint peerUserIPEndPoint;
        private UdpClient sendUdpClient;

        public ChatFormcs()
        {
            InitializeComponent();
        }

        public void SetUserInfo(string selfName string peerName IPEndPoint peerIPEndPoint)
        {
            selfUserName = selfName;
            peerUserName = peerName;
            peerUserIPEndPoint = peerIPEndPoint;
        }

        private void btnSend_Click(object sender EventArgs e)
        {
            // 匿名发送
            sendUdpClient = new UdpClient();
            // 启动发送线程
            Thread sendThread = new Thread(SendMessage);
            sendThread.Start(string.Format(“talk{0}{1}{2}“ DateTime.Now.ToLongTimeString() selfUserName txbSend.Text));
            richtxbTalkinfo.AppendText(selfUserName + “    “ + DateTime.Now.ToLongTimeString() + Environment.NewLine + txbSend.Text);
            richtxbTalkinfo.AppendText(Environment.NewLine);
            // 将控件内容滚动到当前插入符的位置
            richtxbTalkinfo.ScrollToCaret();
            txbSend.Text = ““;
            txbSend.Focus();

        }
        private void SendMessage(object obj)
        {
            string message = (string)obj;
            byte[] sendbytes = Encoding.Unicode.GetBytes(message);
            sendUdpClient.Send(sendbytessendbytes.LengthpeerUserIPEndPoint);
            sendUdpClient.Close();
        }

        public void ShowTalkInfo(string peerName string time string content)
        {
            richtxbTalkinfo.AppendText(peerName + “    “ + time + Environment.NewLine + content);
            richtxbTalkinfo.AppendText(Environment.NewLine);
            richtxbTalkinfo.ScrollToCaret();
        }
        private void btnClose_Click(object sender EventArgs e)
        {
            this.Close();
        }

        private void ChatFormcs_Load(object sender EventArgs e)
        {

        }

        private void richtxbTalkinfo_TextChanged(object sender EventArgs e)
        {

        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        167  2012-12-18 22:06  模仿qq\Client\Client\App.config

     文件      18432  2015-09-23 17:59  模仿qq\Client\Client\bin\Debug\Client.exe

     文件        167  2012-12-18 22:06  模仿qq\Client\Client\bin\Debug\Client.exe.config

     文件      34304  2015-09-23 17:59  模仿qq\Client\Client\bin\Debug\Client.pdb

     文件      24216  2015-09-23 17:54  模仿qq\Client\Client\bin\Debug\Client.vshost.exe

     文件        167  2012-12-18 22:06  模仿qq\Client\Client\bin\Debug\Client.vshost.exe.config

     文件        490  2015-07-10 19:01  模仿qq\Client\Client\bin\Debug\Client.vshost.exe.manifest

     文件       2580  2015-09-23 17:42  模仿qq\Client\Client\ChatFormcs.cs

     文件       4812  2015-09-23 17:42  模仿qq\Client\Client\ChatFormcs.Designer.cs

     文件       5817  2015-09-23 17:42  模仿qq\Client\Client\ChatFormcs.resx

     文件       4209  2012-12-18 22:06  模仿qq\Client\Client\Client.csproj

     文件       9920  2015-09-23 17:59  模仿qq\Client\Client\LoginForm.cs

     文件      10472  2015-09-23 17:59  模仿qq\Client\Client\LoginForm.Designer.cs

     文件       5817  2015-09-23 17:59  模仿qq\Client\Client\LoginForm.resx

     文件        180  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.ChatFormcs.resources

     文件       2646  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.csproj.FileListAbsolute.txt

     文件       1044  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.csproj.GenerateResource.Cache

     文件      18432  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.exe

     文件        180  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.LoginForm.resources

     文件      34304  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.pdb

     文件        180  2015-09-23 17:59  模仿qq\Client\Client\obj\Debug\Client.Properties.Resources.resources

     文件        865  2015-09-23 11:43  模仿qq\Client\Client\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6998  2015-09-23 11:41  模仿qq\Client\Client\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2012-09-16 16:04  模仿qq\Client\Client\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2012-09-16 16:04  模仿qq\Client\Client\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2012-09-16 16:04  模仿qq\Client\Client\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       4608  2012-12-18 22:06  模仿qq\Client\Client\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件        526  2015-09-23 17:26  模仿qq\Client\Client\Program.cs

     文件       1350  2012-09-16 16:04  模仿qq\Client\Client\Properties\AssemblyInfo.cs

     文件       2852  2012-12-18 22:06  模仿qq\Client\Client\Properties\Resources.Designer.cs

............此处省略63个文件信息

评论

共有 条评论