Beispiel #1
0
        private void MessagePanel1_CreateMsgAfter(object sender, IMLibrary3.Protocol.Message msg)
        {
            if (User.UserID == myUserID)
            {
                IMLibrary3.Global.MsgShow("不能给自己发送消息");
                return;
            }

            msg.MessageType = IMLibrary3.Enmu.MessageType.User;

            if (SendMsgToUser != null)
            {
                SendMsgToUser(msg, User);
            }
            this.MsgToRichTextBox(msg, true);

            #region 发送截图
            List <IMLibrary3.MyPicture> pictures = MessagePanel1.GetSendPicture();
            if (pictures != null) //如果文件是截图
            {
                foreach (IMLibrary3.MyPicture pic in pictures)
                {
                    if (pic.MD5.Length == 32)
                    {
                        string          fileName = myUserID + "\\sendImage\\" + pic.MD5 + ".gif";
                        ImageFileClient tcpFile  = new ImageFileClient(Global.ImageServerEP, fileName);//发送图片文件到服务器
                        tcpFile.fileTransmitted += delegate(object sender1, fileTransmitEvnetArgs e)
                        {
                            if (SendMsgToUser != null)
                            {
                                IMLibrary3.Protocol.ImageFileMsg fileMsg = new IMLibrary3.Protocol.ImageFileMsg();
                                fileMsg.MessageType = IMLibrary3.Enmu.MessageType.User;
                                fileMsg.Name        = "";
                                fileMsg.MD5         = e.fileInfo.MD5;
                                fileMsg.Extension   = e.fileInfo.Extension;
                                fileMsg.Length      = e.fileInfo.Length;
                                SendMsgToUser(fileMsg, User);
                            }
                            (sender1 as ImageFileClient).Dispose();
                            sender1 = null;
                        };
                    }
                }
            }
            #endregion

            this.MessagePanel1.ClearMsgTextBox();
        }
Beispiel #2
0
        void ft_fileTransmitted(object sender)
        {
            OurMsg.Controls.FileTransmit ft = sender as OurMsg.Controls.FileTransmit;
            if (ft.isSend)
            {
                MessagePanel1.addRemarkTextToRecord(" 文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”已经传输结束!");
            }
            else
            {
                MessagePanel1.addRemarkTextToRecord(" 文件“<file:\\\\" + ft.P2PFileTransmit.TFileInfo.fullName + ">”已经传输结束!");
            }

            flowLayoutPanel1.Controls.Remove(ft);
            ft.Dispose();
            ft = null;
        }
Beispiel #3
0
        private void MessagePanel1_CreateMsgAfter(object sender, IMLibrary3.Protocol.Message Message)
        {
            Message.MessageType = IMLibrary3.Enmu.MessageType.Group; //消息类型为组对话
            Message.from        = myUserID;
            Message.to          = Room.RoomID;                       //将群组编号存入Tag
            if (SendMsgToGroup != null)
            {
                SendMsgToGroup(Message, Room);
            }
            this.MsgToRichTextBox(Message, true);

            #region 发送截图
            List <IMLibrary3.MyPicture> pictures = MessagePanel1.GetSendPicture();
            if (pictures != null)//如果文件是截图
            {
                foreach (IMLibrary3.MyPicture pic in pictures)
                {
                    if (pic.MD5.Length == 32)
                    {
                        string          fileName = myUserID + "\\sendImage\\" + pic.MD5 + ".gif";
                        ImageFileClient tcpFile  = new ImageFileClient(Global.ImageServerEP, fileName);//发送图片文件到服务器
                        tcpFile.fileTransmitted += delegate(object sender1, fileTransmitEvnetArgs e)
                        {
                            if (SendMsgToGroup != null)
                            {
                                IMLibrary3.Protocol.ImageFileMsg fileMsg = new IMLibrary3.Protocol.ImageFileMsg();
                                fileMsg.from        = myUserID;
                                fileMsg.to          = Room.RoomID;
                                fileMsg.MessageType = IMLibrary3.Enmu.MessageType.Group;
                                fileMsg.Name        = "";
                                fileMsg.MD5         = e.fileInfo.MD5;
                                fileMsg.Extension   = e.fileInfo.Extension;
                                fileMsg.Length      = e.fileInfo.Length;
                                SendMsgToGroup(fileMsg, Room);
                            }
                            (sender1 as ImageFileClient).Dispose();
                            sender1 = null;
                        };
                    }
                }
            }
            #endregion

            this.MessagePanel1.ClearMsgTextBox();
        }
Beispiel #4
0
        void ft_fileTransmitCancel(object sender)
        {
            OurMsg.Controls.FileTransmit ft = sender as OurMsg.Controls.FileTransmit;

            IMLibrary3.Protocol.P2PFileMsg pfile = new IMLibrary3.Protocol.P2PFileMsg(); //文件传输协商协议
            pfile.type = IMLibrary3.Protocol.type.cancel;                                //标记取消文件传输
            pfile.MD5  = ft.P2PFileTransmit.TFileInfo.MD5;

            if (SendMsgToUser != null)//触发消息发送事件
            {
                SendMsgToUser(pfile, User);
            }

            MessagePanel1.addRemarkTextToRecord(" 您取消了文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”的传输!");

            flowLayoutPanel1.Controls.Remove(ft);
            ft.Dispose();
            ft = null;
        }
Beispiel #5
0
        /// <summary>
        /// 取消文件传输
        /// </summary>
        /// <param name="pfile"></param>
        public void CancelFile(IMLibrary3.Protocol.P2PFileMsg pfile)
        {
            if (pfile.MD5 == "")
            {
                flowLayoutPanel1.Controls.Clear();
                MessagePanel1.addRemarkTextToRecord(" 对方取消了所有文件的传输!");
                return;
            }

            foreach (Control c in flowLayoutPanel1.Controls)
            {
                OurMsg.Controls.FileTransmit ft = c as OurMsg.Controls.FileTransmit;
                if (ft != null && (ft.P2PFileTransmit.TFileInfo.MD5 == pfile.MD5))
                {
                    ft.CancelTransmit();
                    MessagePanel1.addRemarkTextToRecord(" 对方取消了文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”的传输!");
                    flowLayoutPanel1.Controls.Remove(ft);
                    ft.Dispose();
                    ft = null;
                }
            }
        }