Example #1
0
        public ChatForm(Jid jid, XmppClientConnection con, string nickname)
        {
            InitializeComponent();

            _emotion = new EmotionDropdown();
            AcceptInit = new AcceptInitDelegate(AcceptInitMethod);
            ReturnAcceptInit = new ReturnAcceptInitDelegate(ReturnAcceptMethod);
            AcceptOpen = new AcceptOpenDelegate(AcceptOpenMethod);
            FileSendRequestEvent = new FileSendRequestDelegate(onUserFileSendRequest);
            FileSendInitEvent = new FileSendInitDelegate(FileSendInit);

            to_Jid = jid;
            _connection = con;
            _nickname = jid.User;
            this.nikeName.Text = nickname;

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            packetId = viq.Id;
            _connection.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            Util.ChatForms.Add(to_Jid.Bare.ToLower(), this);
            nikeName.Text = _nickname;

            con.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);
            _emotion.EmotionContainer.ItemClick += new UI.Face.EmotionItemMouseEventHandler(EmotionContainer_ItemClick);

            friendHead.BackgroundImage = ResClass.GetImgRes("Padding4Normal");
            friendHead.Image = ResClass.GetHead("big194");

            rtfSend.AllowDrop = true;

            rtfSend.DragDrop += new DragEventHandler(rtfSend_DragDrop);
            rtfSend.DragEnter += new DragEventHandler(rtfSend_DragEnter);
        }
Example #2
0
        public ChatFromMsg(Jid jid, XmppClientConnection Conn,string nickName)
        {
            InitializeComponent();
            RemotBaseUDPIP = IPAddress.Parse("127.0.0.1");

            AccepVideotInit = new AcceptVideoInitDelegate(AcceptVideoInitMethod);
            ReturnAcceptVideoInit = new ReturnAcceptVideoInitDelegate(ReturnAcceptVideoInitMethod);
            AcceptVideoOpen = new AcceptVideoOpenDelegate(AcceptVideoOpenMethod);
            FileSendRequestEvent = new FileSendRequestDelegate(FileSendRequestMethod);
            FileSendInitEvent = new FileSendInitDelegate(FileSendInitMethod);
            GetFtpFileEvent = new GetFtpFileDelegate(GetFtpFileAMethod);
            Red5AccpetEvent = new Red5AccpetDelegate(Red5AccpetMethod);
            Red5RefuseEvent = new Red5RefuseDelegate(Red5RefuseMethod);

            TO_Jid = jid;
            XmppConn = Conn;
            this._NickName = nickName;
            this.Text = "正在与[" + (nikeName.Text != "" ? nikeName.Text : _NickName) + "]对话";

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            Util.ChatForms.Add(TO_Jid.Bare, this);
            nikeName.Text = _NickName;

            rtfSend.AllowDrop = true;
            rtfSend.DragDrop += new DragEventHandler(rtfSend_DragDrop);
            rtfSend.DragEnter += new DragEventHandler(rtfSend_DragEnter);

            XmppConn.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);

            //用于外部更新截图
            ScreenImageEvent += new ScreenImageDelegate(ChatFromMsg_ScreenImageEvent);
            Util.TO_Jid =TO_Jid;//公布对外的to_jid用于外部插入截图

            //初使化发送文件
            udpSendFile = new UdpSendFile(2);
            //sendFile.Log += new TraFransfersFileLogEventHandler(SendFileLog);
            udpSendFile.FileSendBuffer += new FileSendBufferEventHandler(FileSendBuffer);
            udpSendFile.FileSendAccept += new FileSendEventHandler(FileSendAccept);
            udpSendFile.FileSendRefuse += new FileSendEventHandler(FileSendRefuse);
            udpSendFile.FileSendCancel += new FileSendEventHandler(FileSendCancel);
            udpSendFile.FileSendComplete += new FileSendEventHandler(FileSendComplete);
            udpSendFile.Start();

            //初使化接收文件
            udpReceiveFile = new UdpReceiveFile(2);
            udpReceiveFile.RequestSendFile += new RequestSendFileEventHandler(RequestSendFile);
            udpReceiveFile.FileReceiveBuffer += new FileReceiveBufferEventHandler(FileReceiveBuffer);
            udpReceiveFile.FileReceiveComplete += new FileReceiveEventHandler(FileReceiveComplete);
            udpReceiveFile.FileReceiveCancel += new FileReceiveEventHandler(FileReceiveCancel);
            udpReceiveFile.Start();
        }