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
        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();
        }