Пример #1
0
        private void tsmi发送消息_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
                return;
            if (treeView1.SelectedNode.Tag == null)
                return;
            Jid j = new Jid(treeView1.SelectedNode.Tag.ToString(), XmppCon.Server, null);
            if (!Util.ChatForms.ContainsKey(j.ToString()))
            {
                friendListView.UpdateFriendFlicker(j.User);
                ChatForm chat = new ChatForm(j, XmppCon, j.User);

                Friend friend = friendListView.Rosters[j.User];

                if (friend!=null)
                {
                    chat.UpdateFriendOnline(friendListView.Rosters[j.User].IsOnline);
                }

                if (msgBox.ContainsKey(j.Bare.ToString()))
                {
                    chat.FristMessage(msgBox[j.Bare.ToString()]);
                    msgBox.Remove(j.Bare.ToString());
                }
                try
                {
                    chat.Show();
                }
                catch (Exception)
                {

                }

            }
        }
Пример #2
0
        /// <summary>
        /// 聊天窗口打开事件
        /// </summary>
        /// <param name="sender"></param>
        public void friendListView_OpenChatEvent(Friend sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new QQListViewEx.delegate_openChat(friendListView_OpenChatEvent), new object[] { sender });
                return;
            }

            if (!Util.ChatForms.ContainsKey(sender.Ritem.Jid.ToString()))
            {
                try
                {

                    ChatForm chat = new ChatForm(sender.Ritem.Jid, XmppCon, sender.NikeName);
                    chat.UpdateFriendOnline(sender.IsOnline);//设置好友在线状态

                    ChatMessageBox.GetInstance(this).RemoveFriend(sender.Ritem.Jid);
                    if (msgBox.ContainsKey(sender.Ritem.Jid.ToString()))
                    {
                        chat.FristMessage(msgBox[sender.Ritem.Jid.ToString()]);
                        msgBox.Remove(sender.Ritem.Jid.ToString());
                    }
                    chat.Show();

                    if (ChatMessageBox.GetInstance(this).FrienMessageCount() > 0)
                        Debug.WriteLine("?");
                    else
                    {
                        notifyIcon1.Icon = CSS.IM.UI.Properties.Resources.Iico;
                        timer_notifyIco.Enabled = false;
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
            else
            {
                try
                {
                    ChatForm chatform = Util.ChatForms[sender.Ritem.Jid.ToString()] as ChatForm;
                    chatform.WindowState = FormWindowState.Normal;
                    chatform.Activate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 通过消息盒子打开消息窗体
        /// </summary>
        /// <param name="friend"></param>
        /// <param name="sender"></param>
        /// <param name="CName"></param>
        void QQMainForm_OpenChatEvent(Friend friend, Jid sender, string CName)
        {
            RosterItem ritem = new RosterItem(sender);
            friend.Ritem = ritem;
            //throw new NotImplementedException();
            //friendListView_OpenChatEvent(friend);
            if (!Util.ChatForms.ContainsKey(friend.Ritem.Jid.Bare.ToString()))
            {
                friendListView.UpdateFriendFlicker(friend.NikeName);
                ChatForm chat = new ChatForm(friend.Ritem.Jid, XmppCon, friend.NikeName);

                Friend flfriend = friendListView.Rosters[friend.NikeName];
                if (flfriend!=null)
                {
                    chat.UpdateFriendOnline(flfriend.IsOnline);
                }

                if (msgBox.ContainsKey(friend.Ritem.Jid.Bare.ToString()))
                {
                    chat.FristMessage(msgBox[friend.Ritem.Jid.Bare.ToString()]);
                    msgBox.Remove(friend.Ritem.Jid.Bare.ToString());
                }
                chat.Show();
            }
            else
            {
                try
                {
                    ChatForm chatform = Util.ChatForms[friend.Ritem.Jid.ToString()] as ChatForm;
                    chatform.WindowState = FormWindowState.Normal;
                    chatform.Activate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            if (ChatMessageBox.GetInstance(this).FrienMessageCount() > 0)
                Debug.WriteLine("?");
            else
            {
                notifyIcon1.Icon = CSS.IM.UI.Properties.Resources.Iico;
                timer_notifyIco.Enabled = false;
            }
        }