//返回消息时回调的方法
        private void diaplayUser(Exception ee, byte[] response, object tag)
        {
            searchList.Items.Clear();
            //反序列化返回的消息生成list
            ObjSerial<List<string>> se = new ObjSerial<List<string>>();
            List<string> list=se.deserializeBytes(response);

            ChatListItem gp = new ChatListItem();//新建一个组
            gp.Text = "查询结果";
            gp.IsOpen = true;
            ChatListSubItemExtend user = new ChatListSubItemExtend();
            //获取在线用户的ID
            foreach (string srtings in list)
            {
                //string的形式:
                //ID卍昵称卍性别卍生日卍地址卍注册时间
                string[] userInfo = Regex.Split(srtings, Constant.SPLIT, RegexOptions.IgnoreCase);
                user.ID = Convert.ToUInt32(userInfo[0]);
                user.NicName = "";
                user.DisplayName = userInfo[1];
                if(userInfo[2]=="1")
                {
                    user.Sex = ChatListSubItemExtend.UserSex.Man;
                }
                else if(userInfo[2]=="0")
                {
                    user.Sex = ChatListSubItemExtend.UserSex.Women;
                }
                user.Birth = userInfo[3];
                user.Address = userInfo[4];
                user.RegistrationDate = userInfo[5];
                gp.SubItems.Add(user);
            }
            this.searchList.Items.Add(gp);
        }
 public ClassStartUdpThread(ChatListBox chat)
 {
     this.Chat = chat;
     ListItem = new ChatListItem("我的好友");
     MyNameItem = new ChatListItem("自己");
     HNameItem = new ChatListItem("黑名单");
     Chat.Items.Add(ListItem);
     Chat.Items.Add(MyNameItem);
     Chat.Items.Add(HNameItem);
 }
Example #3
0
        /// <summary>
        /// 绘制列表项
        /// </summary>
        /// <param name="g">绘图表面</param>
        /// <param name="item">要绘制的列表项</param>
        /// <param name="rectItem">该列表项的区域</param>
        /// <param name="sb">画刷</param>
        protected virtual void DrawItem(Graphics g, ChatListItem item, Rectangle rectItem, SolidBrush sb)
        {
            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;
            sf.SetTabStops(0.0F, new float[] { 20.0F });
            if (item.Equals(m_mouseOnItem))           //根据列表项现在的状态绘制相应的背景色
            {
                sb.Color = this.itemMouseOnColor;
            }
            else
            {
                sb.Color = this.itemColor;
            }
            g.FillRectangle(sb, rectItem);
            if (item.IsOpen)                        //如果展开的画绘制 展开的三角形
            {
                sb.Color = this.arrowColor;
                g.FillPolygon(sb, new Point[] {
                    new Point(2, rectItem.Top + 11),
                    new Point(12, rectItem.Top + 11),
                    new Point(7, rectItem.Top + 16)
                });
            }
            else                                        //如果没有展开判断该列表项下面的子项闪动的个数
            {
                if (item.TwinkleSubItemNumber > 0)      //如果列表项下面有子项闪动 那么判断闪动状态 是否绘制或者不绘制
                {
                    if (item.IsTwinkleHide)             //该布尔值 在线程中不停 取反赋值
                    {
                        return;
                    }
                }
                sb.Color = this.arrowColor;
                g.FillPolygon(sb, new Point[] {
                    new Point(5, rectItem.Top + 8),
                    new Point(5, rectItem.Top + 18),
                    new Point(10, rectItem.Top + 13)
                });
            }
            string strItem = "\t" + item.Text;

            sb.Color     = this.ForeColor;
            sf.Alignment = StringAlignment.Near;
            g.DrawString(strItem, this.Font, sb, rectItem, sf);
            sf.Alignment = StringAlignment.Far;
            g.DrawString("[" + item.SubItems.GetOnLineNumber() + "/" + item.SubItems.Count + "]", this.Font, sb,
                         new Rectangle(rectItem.X, rectItem.Y, rectItem.Width - 15, rectItem.Height), sf);
        }
Example #4
0
        private void mnuGroupPhoto_Click(object sender, EventArgs e)
        {
            if (lstChats.SelectedItem != null)
            {
                ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                using (frmViewGroup frm = new frmViewGroup(itm.Network))
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        SaveProfile();
                    }
                }
            }
        }
Example #5
0
        private ChatListItem AddChatView(MeshNetwork network)
        {
            ChatListItem itm = new ChatListItem(network);

            itm.ChatPanel.SettingsModified += chatPanel_SettingsModified;
            itm.ChatPanel.ForwardTo        += chatPanel_ForwardTo;

            network.MessageReceived += network_MessageReceived;

            mainContainer.Panel2.Controls.Add(itm.ChatPanel);

            lstChats.AddItem(itm);

            return(itm);
        }
 public void Add(ChatListItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("Item cannot be null");
     }
     this.EnsureSpace(1);
     if (-1 != this.IndexOf(item))
     {
         return;
     }
     item.OwnerChatListBox        = this.owner;
     this.m_arrItem[this.count++] = item;
     this.owner.Invalidate();
 }
Example #7
0
        private ChatListItem AddChatView(BitChat chat)
        {
            ChatListItem itm = new ChatListItem(chat);

            itm.ChatPanel.SettingsModified    += chatPanel_SettingsModified;
            itm.ChatPanel.MessageNotification += chatPanel_MessageNotification;
            itm.ChatPanel.SwitchToPrivateChat += chatPanel_SwitchToPrivateChat;
            itm.ChatPanel.ShareFile           += chatPanel_ShareFile;

            mainContainer.Panel2.Controls.Add(itm.ChatPanel);

            lstChats.AddItem(itm);

            return(itm);
        }
Example #8
0
        private void RemoveSelectedChatView()
        {
            if (lstChats.SelectedItem != null)
            {
                ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                lstChats.RemoveItem(itm);
                mainContainer.Panel2.Controls.Remove(itm.ChatPanel);

                itm.ChatPanel.SettingsModified    -= chatPanel_SettingsModified;
                itm.ChatPanel.MessageNotification -= chatPanel_MessageNotification;
                itm.ChatPanel.SwitchToPrivateChat -= chatPanel_SwitchToPrivateChat;

                itm.BitChat.LeaveChat();
            }
        }
Example #9
0
        /// <summary>
        /// 获取我的好友
        /// </summary>
        public void GetAllMyFriend()
        {
            //获取之前先清空用户字典
            Common.AllUserDic.Clear();
            if (Common.AllUserDic.Count == 0)
            {
                //向服务器端发送信息并获取结果
                UserListContract userListContract = Common.TcpConn
                                                    .SendReceiveObject <UserListContract>("GetFriends", "ResGetFriends", 50000, Common.CurrentUser.ID);

                //遍历加载好友
                IEnumerable <IGrouping <string, IMUserInfo> > groupUserList = userListContract.UserList.GroupBy(p => p.IMGroupName);

                foreach (var group in groupUserList)
                {
                    ChatListItem chatListItem = new ChatListItem();
                    chatListItem.Text = group.Key;
                    chatListBox.Items.Add(chatListItem);
                    foreach (var user in group)
                    {
                        ChatListSubItem subItem = new ChatListSubItem(user.DisplayName, user.Name, user.DisplaySignature, ChatListSubItem.UserStatus.Online);
                        subItem.Tag = user;
                        if (user.IsOnline)
                        {
                            subItem.Status = ChatListSubItem.UserStatus.Online;
                        }
                        else
                        {
                            subItem.Status = ChatListSubItem.UserStatus.OffLine;
                        }
                        if (user.Sex == "女")
                        {
                            subItem.HeadImage = Resource1.big45;
                        }
                        else
                        {
                            subItem.HeadImage = Resource1.big28;
                        }

                        Common.AddFriend(user.ID, user);
                        // Image.FromFile("Resources/q1.jpg");
                        userItem.Add(user.ID, subItem);
                        chatListItem.SubItems.Add(subItem);
                    }
                }
            }
        }
Example #10
0
        //加载工程
        public void LoadProject()
        {
            //清空工程列表
            ProjectList.Items.Clear();
            ProjectNum = 0;
            //一些没用的东西
            ChatListItem item = new ChatListItem("My Project");

            //工程数据
            DirectoryInfo[] di = new DirectoryInfo(ProjectPath).GetDirectories();
            for (int i = 0; i < di.Length; i++)
            {
                ProjectConfig = di[i].FullName + "/init.config";
                //判断文件是否存在
                if (File.Exists(ProjectConfig))
                {
                    ChatListSubItem sub = new ChatListSubItem();
                    //判断工程配置文件是否读取错误
                    if (GetConfig("Name") == "Project Config File Error")
                    {
                        //配置文件损坏 工程名称标红
                        sub.IsVip = true;
                    }
                    //判断图标文件是否存在
                    if (File.Exists(di[i].FullName + "/icon.png"))
                    {
                        //存在 使用工程图标
                        sub.HeadImage = new Bitmap(di[i].FullName + "/icon.png");
                    }
                    else
                    {
                        //不存在 使用默认图标
                        sub.HeadImage = Properties.Resources.icon;
                    }
                    sub.NicName     = GetConfig("Var");
                    sub.DisplayName = GetConfig("Name");
                    sub.PersonalMsg = di[i].FullName;
                    item.SubItems.Add(sub);
                    ProjectList.Items.Add(item);
                    ProjectNum += 1;
                }
            }
            //展开工程
            ProjectList.ExpandAll();
            //设置统计
            label1.Text = "My project (" + ProjectNum + ")";
        }
 private void EnsureSpace(int elements)
 {
     if (this.m_arrItem == null)
     {
         this.m_arrItem = new ChatListItem[Math.Max(elements, 4)];
     }
     else
     {
         if (this.count + elements <= this.m_arrItem.Length)
         {
             return;
         }
         ChatListItem[] chatListItemArray = new ChatListItem[Math.Max(this.count + elements, this.m_arrItem.Length * 2)];
         this.m_arrItem.CopyTo((Array)chatListItemArray, 0);
         this.m_arrItem = chatListItemArray;
     }
 }
Example #12
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (GlobalResourceManager.CurrentUser == null)
            {
                MessageBoxEx.Show("请先登录");
                new LoginForm().ShowDialog();
                return;
            }

            // 启动心跳线程
            ThreadPool.QueueUserWorkItem(HeartbeatThread, null);

            ProtocolDecoder.Singleton.OnGetFriendsResponse += OnGetFriendsResponse;
            ProtocolDecoder.Singleton.OnChangeStatusNotice += OnChangeStatusNotice;
            ProtocolDecoder.Singleton.OnFriendChatNotice   += OnFriendChatNotice;

            ChatListItem itemFriend = new ChatListItem("我的好友");

            chatListBox1.Items.Add(itemFriend);
            itemFriend.IsOpen = true;

            User user = new User();

            user.UserID    = "SystemGroupChat";
            user.NickName  = "群聊";
            user.Signature = "一起来聊天吧!";
            AppendUserToList(user);

            labelName.Text      = GlobalResourceManager.CurrentUser.NickName;
            labelSignature.Text = GlobalResourceManager.CurrentUser.Signature;
            // 下载头像
            String headFile = Path.Combine(GlobalResourceManager.AppPath, GlobalResourceManager.CurrentUser.UserID, "res", "head.jpg");

            Utils.DownFile(GlobalResourceManager.CurrentUser.HeadImageUrl, headFile);
            if (File.Exists(headFile))
            {
                skinButton_headImage.Image = Image.FromFile(headFile);
            }
            AppendUserToList(GlobalResourceManager.CurrentUser);

            GetFriendsRequest getFriendsRequest = new GetFriendsRequest();

            getFriendsRequest.UserID = GlobalResourceManager.CurrentUser.UserID;
            TCPClient.Singleton.SendProtoMessage(CMD.GetFriendsRequestCMD, getFriendsRequest);
        }
Example #13
0
        /// <summary>
        /// 处理添加朋友的界面显示.
        /// </summary>
        /// <param name="obj"></param>
        private void AddFriend(Friend obj)
        {
            try
            {
                //找到FatherQQ,再添加一个朋友.
                foreach (ChatListItem item in FriendList.Items)
                {
                    if (item.Value == obj.FatherNumber)
                    {
                        ChatListSubItem sitem = new ChatListSubItem(obj.NikeName);
                        //sitem.ID = int.Parse(obj.QQNumber);
                        sitem.DisplayName = obj.QQNumber;

                        sitem.Info = obj;
                        item.SubItems.Add(sitem);
                        return;
                    }
                }

                //没有找到FatherQQ帐号,意味着没有该项,先添加FatherQQ.再添加一个朋友.
                ChatListItem citem = new ChatListItem(obj.FatherNumber);
                citem.Text  = obj.FatherNumber;
                citem.Value = obj.FatherNumber;

                ChatListSubItem subitem = new ChatListSubItem(obj.NikeName);
                subitem.DisplayName = obj.QQNumber;
                subitem.Info        = obj;
                citem.SubItems.Add(subitem);
                FriendList.Items.Add(citem);

                //更新 重点qq对象.
                if (_Settings.MajorFriendMap.ContainsKey(obj.FatherNumber))
                {
                    FriendCollection coll = _Settings.MajorFriendMap[obj.FatherNumber];
                    foreach (var item in coll)
                    {
                        AddMajorFriend(item);
                    }
                }
            }
            catch (Exception ex)
            {
                Loger.WriteLog(ex);
            }
        }
Example #14
0
        public void UserStatusChanged(GGUser user)
        {
            ChatListSubItem[] items = this.chatListBox.GetSubItemsById(user.ID);
            if (items == null || items.Length == 0)
            {
                return;
            }

            items[0].HeadImage = this.resourceGetter.GetHeadImage(user);
            items[0].Status    = this.ConvertUserStatus(user.UserStatus);
            ChatListItem item = this.GetCatelogChatListItem(user);

            if (item != null)
            {
                item.SubItems.Sort();
            }
            this.chatListBox.Invalidate();
        }
Example #15
0
        private void lstChats_ItemMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                mnuMuteNotifications.Enabled = true;
                mnuMuteNotifications.Checked = itm.BitChat.Mute;
                mnuGoOffline.Enabled         = true;
                mnuGoOffline.Checked         = (itm.BitChat.NetworkStatus == BitChatCore.Network.BitChatNetworkStatus.Offline);
                mnuLeaveChat.Enabled         = true;
                mnuViewPeerProfile.Visible   = (itm.BitChat.NetworkType == BitChatCore.Network.BitChatNetworkType.PrivateChat);
                mnuViewPeerProfile.Enabled   = (itm.Peer != null);
                mnuGroupPhoto.Visible        = (itm.BitChat.NetworkType == BitChatCore.Network.BitChatNetworkType.GroupChat);
                mnuProperties.Enabled        = true;
                mnuChat.Show(sender as Control, e.Location);
            }
        }
Example #16
0
        private void mnuGoOffline_Click(object sender, EventArgs e)
        {
            if (lstChats.SelectedItem != null)
            {
                ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                mnuGoOffline.Checked = !mnuGoOffline.Checked;

                if (mnuGoOffline.Checked)
                {
                    itm.GoOffline();
                }
                else
                {
                    itm.GoOnline();
                }
            }
        }
Example #17
0
File: Form1.cs Project: tvrjcf/Demo
        private void Form1_Load(object sender, EventArgs e)
        {
            ChatListItem    item = new ChatListItem("我的好友");
            ChatListSubItem sub  = new ChatListSubItem();

            sub.NicName     = "乔克斯";
            sub.DisplayName = "小乔";
            sub.Status      = ChatListSubItem.UserStatus.QMe;
            item.SubItems.Add(sub);
            this.chatListBox1.Items.Add(item);
            ChatListItem    item2 = new ChatListItem("亲人");
            ChatListSubItem sub2  = new ChatListSubItem();

            sub2.NicName     = "乔克斯1";
            sub2.DisplayName = "小乔1";
            sub2.Status      = ChatListSubItem.UserStatus.QMe;
            item2.SubItems.Add(sub2);
            this.chatListBox1.Items.Add(item2);
        }
Example #18
0
        private void mnuDeleteChat_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to delete chat?\r\n\r\nWarning! You will lose all stored messages in this chat. If you wish to join back the same chat again, you will need to remember the Group Name/UserId and password.", "Delete Chat?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                if (lstChats.SelectedItem != null)
                {
                    ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                    lstChats.RemoveItem(itm);
                    mainContainer.Panel2.Controls.Remove(itm.ChatPanel);

                    itm.ChatPanel.SettingsModified -= chatPanel_SettingsModified;

                    itm.Network.DeleteNetwork();

                    SaveProfile();
                }
            }
        }
Example #19
0
        public void ChangeCatelogName(string oldName, string newName)
        {
            if (this.currentUser.UserStatus == UserStatus.OffLine)
            {
                return;
            }

            this.catelogManager.Remove(oldName);
            ChatListItem existedItem = null;

            foreach (ChatListItem item in this.chatListBox.Items)
            {
                if (item.Text == newName)
                {
                    existedItem = item;
                    break;
                }
            }
            if (existedItem != null)
            {
                foreach (ChatListSubItem sub in this.chatListBox.SelectItem.SubItems)
                {
                    sub.OwnerListItem = existedItem;
                    existedItem.SubItems.Add(sub);
                }
                existedItem.SubItems.Sort();
                this.chatListBox.Items.Remove(this.chatListBox.SelectItem);
                existedItem.IsOpen = true;
                if (this.CatalogNameChanged != null)
                {
                    this.CatalogNameChanged(oldName, newName, true);
                }
                return;
            }

            this.catelogManager.Add(newName, this.chatListBox.SelectItem);
            this.chatListBox.SelectItem.Text = newName;
            if (this.CatalogNameChanged != null)
            {
                this.CatalogNameChanged(oldName, newName, false);
            }
        }
Example #20
0
 /// <summary>
 /// 根据索引位置插入一个列表项
 /// </summary>
 /// <param name="index">索引位置</param>
 /// <param name="item">要插入的列表项</param>
 public void Insert(int index, ChatListItem item)
 {
     if (index < 0 || index >= this.count)
     {
         throw new IndexOutOfRangeException("Index was outside the bounds of the array");
     }
     if (item == null)
     {
         throw new ArgumentNullException("Item cannot be null");
     }
     this.EnsureSpace(1);
     for (int i = this.count; i > index; i--)
     {
         m_arrItem[i] = m_arrItem[i - 1];
     }
     item.OwnerChatListBox = this.owner;
     m_arrItem[index]      = item;
     this.count++;
     this.owner.Invalidate();
 }
Example #21
0
        private void ShowContactList()
        {
            ChatListItem item = new ChatListItem("联系人");

            foreach (var contact in InitHelper.BatchGetContact.MemberList)
            {
                ChatListSubItem sitem = new ChatListSubItem()
                {
                    NicName     = contact.UserName,
                    DisplayName = contact.NickName,
                    PersonalMsg = contact.Signature
                };
                InitHelper.SetImageAsync(sitem, contact.HeadImgUrl);
                item.SubItems.Add(sitem);
            }
            chatListBox1.BeginInvoke(new Action(() =>
            {
                chatListBox1.Items.Add(item);
            }));
        }
Example #22
0
        public void InitMain(IRapidPassiveEngine rapidPassiveEngine)
        {
            if (this.myInfo == null)
            {
                this.myInfo = new ChatListSubItem();
            }
            this.rapidPassiveEngine = rapidPassiveEngine;
            this.myInfo.ID          = Convert.ToUInt32(rapidPassiveEngine.CurrentUserID);

            //加载分组
            ChatListItem gp = new ChatListItem();//new一个分组

            gp.Text = "TestList";
            ChatListSubItem people = new ChatListSubItem();

            if (myInfo.ID == 10010)
            {
                lbl_userName.Text  = "联通";
                people.ID          = 10086; //ID
                people.NicName     = "移动";  //昵称
                people.DisplayName = "X";   //备注名
                people.PersonalMsg = "买买买买买";
            }
            else if (myInfo.ID == 10086)
            {
                lbl_userName.Text  = "移动";
                people.ID          = 10010; //ID
                people.NicName     = "联通";  //昵称
                people.DisplayName = "X";   //备注名
                people.PersonalMsg = "买买买买买";
            }
            gp.SubItems.Add(people);
            //chatListBox_contacts.GetSubItemsById();//按照ID查找listbox中的用户

            chatListBox_contacts.Items.Add(gp);//添加到listBox中

            //预订接收到广播消息的处理事件
            this.rapidPassiveEngine.GroupOutter.BroadcastReceived += new CbGeneric <string, string, int, byte[]>(GroupOutter_BroadcastReceived);
            //预订断线事件
            this.rapidPassiveEngine.ConnectionInterrupted += new CbGeneric(rapidPassiveEngine_ConnectionInterrupted);
        }
Example #23
0
        private void GroupListForm_Load(object sender, EventArgs e)
        {
            groupListBox.IconSizeMode = ChatListItemIcon.Large;
            Random rnd = new Random();

            listItem = new ChatListItem("我的群组");
            IList <Chatroom> chatRoommemberBll = chatRoomMemberBll.getChatRoomDetail(user.UId);

            foreach (Chatroom chatroomdetail in chatRoommemberBll)
            {
                ChatListSubItem subItem = new ChatListSubItem();
                subItem.DisplayName  = chatroomdetail.Name;
                subItem.ID           = chatroomdetail.CId;
                subItem.ChatRoomPort = chatroomdetail.ChatRoomPort;
                Size   size  = new Size(84, 79);
                Bitmap image = new Bitmap(Image.FromFile("Head/1 (" + rnd.Next(0, 45) + ").png"), size);
                subItem.HeadImage = image;
                listItem.SubItems.Add(subItem);
            }
            groupListBox.Items.Add(listItem);
        }
Example #24
0
        public startNewGroup()
        {
            InitializeComponent();
            List <user>  onlineUserList = publicClass.onlineUserList; //在线用户
            ChatListItem onlineUser     = new ChatListItem("请选择在线用户");

            foreach (user i in onlineUserList)  //绘制在线列表
            {
                if (i.id != publicClass.mainUser.id)
                {
                    ChatListSubItem sub = new ChatListSubItem();
                    sub.NicName     = "未选择";
                    sub.Status      = ChatListSubItem.UserStatus.OffLine;
                    sub.ID          = (uint)i.id;
                    sub.HeadImage   = System.Drawing.Image.FromFile("../..//src/img/avatar" + i.avatar + ".png");
                    sub.DisplayName = i.userName;
                    sub.PersonalMsg = i.IPAddress;
                    onlineUser.SubItems.Add(sub);
                }
            }
            this.selectUserBox.Items.Add(onlineUser);
        }
Example #25
0
        private void mnuProperties_Click(object sender, EventArgs e)
        {
            if (lstChats.SelectedItem != null)
            {
                ChatListItem itm = lstChats.SelectedItem as ChatListItem;

                using (frmChatProperties frm = new frmChatProperties(itm.BitChat, _profile))
                {
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            itm.BitChat.SharedSecret = frm.SharedSecret;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Example #26
0
        void QQMangers_AddFatherQQ(string fatherQQ, string nickName)
        {
            FriendList.QueueInvoke(() =>
            {
                //当获取到QQ昵称时,在朋友列表添加 一个QQ帐号.
                ChatListItem citem = new ChatListItem(fatherQQ);
                citem.Text         = string.Format("{0}({1})", fatherQQ, nickName);
                citem.Value        = fatherQQ;
                FriendList.Items.Add(citem);

                //更新 重点qq对象.
                if (_Settings.MajorFriendMap.ContainsKey(fatherQQ))
                {
                    FriendCollection coll = _Settings.MajorFriendMap[fatherQQ];
                    foreach (var item in coll)
                    {
                        AddMajorFriend(item);
                    }
                }
            }
                                   );
        }
Example #27
0
        private void ShowSessionList()
        {
            ChatListItem item = new ChatListItem("会话列表");

            item.IsOpen = true;

            foreach (var contact in InitHelper.WebWeixinInit.ContactList)
            {
                ChatListSubItem sitem = new ChatListSubItem()
                {
                    NicName     = contact.UserName,
                    DisplayName = contact.NickName,
                    PersonalMsg = contact.Signature
                };
                InitHelper.SetImageAsync(sitem, contact.HeadImgUrl);
                item.SubItems.Add(sitem);
            }
            chatListBox1.BeginInvoke(new Action(() =>
            {
                chatListBox1.Items.Add(item);
            }));
        }
Example #28
0
        private void AddChatView(BitChat chat)
        {
            string title;

            if (chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat)
            {
                if (chat.NetworkName == null)
                {
                    title = chat.PeerEmailAddress.Address;
                }
                else
                {
                    title = chat.NetworkName;
                }
            }
            else
            {
                title = chat.NetworkName;
            }

            ChatListItem itm = new ChatListItem(title);

            BitChatPanel chatPanel = new BitChatPanel(chat, itm);

            chatPanel.Dock                 = DockStyle.Fill;
            chatPanel.SettingsModified    += chatPanel_SettingsModified;
            chatPanel.MessageNotification += chatPanel_MessageNotification;

            mainContainer.Panel2.Controls.Add(chatPanel);
            itm.Tag = chatPanel;

            lstChats.AddItem(itm);

            if (lstChats.Controls.Count == 1)
            {
                ShowSelectedChatView();
            }
        }
Example #29
0
 private void OnVcardResult(object sender, IQ iq, object data)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new IqCB(OnVcardResult), new[] { sender, iq, data });
         return;
     }
     if (iq.Type == IqType.result && iq.HasTag(typeof(Vcard)))
     {
         Vcard vcard = iq.Vcard;
         if (vcard != null)
         {
             if (iq.Id == _packetId)
             {
                 pictureHead.Image     = vcard.Photo.Image;
                 labelControlName.Text = vcard.Nickname;
             }
             else
             {
                 ChatListItem item =
                     chatListBoxFriend.Items.Cast <ChatListItem>().FirstOrDefault(c => c.Text == data.ToString());
                 if (item != null)
                 {
                     ChatListSubItem subItem =
                         item.SubItems.Cast <ChatListSubItem>().FirstOrDefault(sub => sub.JidUser == iq.From.Bare);
                     if (subItem != null)
                     {
                         subItem.HeadImage   = vcard.Photo.Image;
                         subItem.NicName     = vcard.Name.Given;
                         subItem.DisplayName = vcard.Nickname;
                         subItem.PersonalMsg = null;
                     }
                 }
             }
         }
     }
 }
Example #30
0
        private void ShowFriendList(ClassMsg msg)
        {
            LoginMsg loginmsg = (LoginMsg) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
            int      i        = 0;

            foreach (var item in loginmsg.FriendList.Group)
            {
                ChatListItem chatlist1 = new ChatListItem();
                chatlist1.Bounds               = new System.Drawing.Rectangle(0, 53, 363, 25);
                chatlist1.IsTwinkleHide        = false;
                chatlist1.OwnerChatListBox     = this.chatListBox1;
                chatlist1.Text                 = item.GroupName;
                chatlist1.TwinkleSubItemNumber = 0;
                chatListBox1.Items.AddRange(new ChatListItem[] { chatlist1 });
                foreach (var item1 in loginmsg.FriendList.Group[i].Friend)
                {
                    ChatListSubItem chatListSubItem1 = new ChatListSubItem();
                    chatListSubItem1.Bounds        = new System.Drawing.Rectangle(0, 0, 0, 0);
                    chatListSubItem1.DisplayName   = item1.AlternateName;
                    chatListSubItem1.HeadImage     = null;
                    chatListSubItem1.HeadRect      = new System.Drawing.Rectangle(0, 0, 0, 0);
                    chatListSubItem1.ID            = Convert.ToInt32(item1.UserID);
                    chatListSubItem1.IpAddress     = null;
                    chatListSubItem1.IsTwinkle     = false;
                    chatListSubItem1.IsTwinkleHide = false;
                    chatListSubItem1.NicName       = item1.NickName;
                    chatListSubItem1.OwnerListItem = chatlist1;
                    chatListSubItem1.PersonalMsg   = item1.UserPersonalMessage;
                    chatListSubItem1.Status        = ChatListSubItem.UserStatus.Online;
                    chatListSubItem1.Tag           = null;
                    chatListSubItem1.TcpPort       = 0;
                    chatListSubItem1.UpdPort       = 0;
                    chatlist1.SubItems.AddRange(new ChatListSubItem[] { chatListSubItem1 });
                }
                i++;
            }
        }
Example #31
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //int iActulaWidth = Screen.PrimaryScreen.Bounds.Width;
            //int iActulaHeight = Screen.PrimaryScreen.Bounds.Height;
            //当前的屏幕除任务栏外的工作域大小
            //int iActulaWidth = SystemInformation.WorkingArea.Width;
            //int iActulaHeight = SystemInformation.WorkingArea.Height;
            //this.Location = new Point(iActulaWidth - this.Width, iActulaHeight - this.Height);

            button1.Text = "闪动";
            button2.Text = "插入[离开]";
            button3.Text = "大/小图标";
            chatListBox1.Items.Clear();
            Random rnd = new Random();

            for (int i = 0; i < 1; i++)
            {
                ChatListItem item = new ChatListItem("默认分组");
                for (int j = 0; j < 10; j++)
                {
                    ChatListSubItem subItem = new ChatListSubItem("NicName", "DisplayName" + j, "Personal Message...!");
                    subItem.HeadImage = Image.FromFile("head/1 (" + rnd.Next(0, 45) + ").png");
                    subItem.Status    = (ChatListSubItem.UserStatus)(j % 6);
                    item.SubItems.AddAccordingToStatus(subItem);
                }
                item.SubItems.Sort();
                chatListBox1.Items.Add(item);
            }
            ChatListItem itema = new ChatListItem("TEST");

            for (int i = 0; i < 5; i++)
            {
                chatListBox1.Items.Add(itema);
            }
            chatListBox1.Items.Remove(itema);
        }
Example #32
0
        private ChatListItem BuildOrganizationItem(Organization org, int positionY)
        {
            var chatListItem = new ChatListItem();

            chatListItem.Bounds               = new System.Drawing.Rectangle(0, 1, positionY, 25);
            chatListItem.IsTwinkleHide        = false;
            chatListItem.OwnerChatListBox     = this.ColleagePanel;
            chatListItem.Text                 = org.name;
            chatListItem.TwinkleSubItemNumber = 0;

            foreach (var u in org.Members)
            {
                ChatListSubItem subItem      = new ChatListSubItem(u.Id, u.TrueName, u.Position, ChatListSubItem.UserStatus.Online);
                var             headFilePath = System.AppDomain.CurrentDomain.BaseDirectory + @"head\1.png";
                if (File.Exists(headFilePath))
                {
                    subItem.HeadImage = Image.FromFile(headFilePath);
                }
                subItem.Tag = u;
                chatListItem.SubItems.AddAccordingToStatus(subItem);
            }

            return(chatListItem);
        }
Example #33
0
 private void ShowFriendList(ClassMsg msg)
 {
     LoginMsg loginmsg = (LoginMsg)new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
     int i=0;
     foreach (var item in loginmsg.FriendList.Group)
     {
         ChatListItem chatlist1 = new ChatListItem();
         chatlist1.Bounds = new System.Drawing.Rectangle(0, 53, 363, 25);
         chatlist1.IsTwinkleHide = false;
         chatlist1.OwnerChatListBox = this.chatListBox1;
         chatlist1.Text = item.GroupName;
         chatlist1.TwinkleSubItemNumber = 0;
         chatListBox1.Items.AddRange(new ChatListItem[] { chatlist1 });
         foreach(var item1 in loginmsg.FriendList.Group[i].Friend)
         {
              ChatListSubItem chatListSubItem1 = new ChatListSubItem();
         chatListSubItem1.Bounds = new System.Drawing.Rectangle(0, 0, 0, 0);
         chatListSubItem1.DisplayName = item1.AlternateName;
         chatListSubItem1.HeadImage = null;
         chatListSubItem1.HeadRect = new System.Drawing.Rectangle(0, 0, 0, 0);
         chatListSubItem1.ID = Convert.ToInt32(item1.UserID);
         chatListSubItem1.IpAddress = null;
         chatListSubItem1.IsTwinkle = false;
         chatListSubItem1.IsTwinkleHide = false;
         chatListSubItem1.NicName = item1.NickName;
         chatListSubItem1.OwnerListItem = chatlist1;
         chatListSubItem1.PersonalMsg = item1.UserPersonalMessage;
         chatListSubItem1.Status = ChatListSubItem.UserStatus.Online;
         chatListSubItem1.Tag = null;
         chatListSubItem1.TcpPort = 0;
         chatListSubItem1.UpdPort = 0;
         chatlist1.SubItems.AddRange(new ChatListSubItem[] { chatListSubItem1 });
         }
         i++;
     }
 }
Example #34
0
        public void InitMain(IRapidPassiveEngine rapidPassiveEngine)
        {
            if (this.myInfo == null)
            {
                this.myInfo = new ChatListSubItem();
            }
            this.rapidPassiveEngine = rapidPassiveEngine;
            this.myInfo.ID = Convert.ToUInt32(rapidPassiveEngine.CurrentUserID);

            //加载分组
            ChatListItem gp = new ChatListItem();//new一个分组
            gp.Text = "TestList";
            ChatListSubItem people = new ChatListSubItem();

            if (myInfo.ID == 10010)
            {
                lbl_userName.Text = "联通";
                people.ID = 10086;//ID
                people.NicName = "移动";//昵称
                people.DisplayName = "X";//备注名
                people.PersonalMsg = "买买买买买";
            }
            else if (myInfo.ID == 10086)
            {
                lbl_userName.Text = "移动";
                people.ID = 10010;//ID
                people.NicName = "联通";//昵称
                people.DisplayName = "X";//备注名
                people.PersonalMsg = "买买买买买";
            }
            gp.SubItems.Add(people);
            //chatListBox_contacts.GetSubItemsById();//按照ID查找listbox中的用户

            chatListBox_contacts.Items.Add(gp);//添加到listBox中

            //预订接收到广播消息的处理事件
            this.rapidPassiveEngine.GroupOutter.BroadcastReceived += new CbGeneric<string, string, int, byte[]>(GroupOutter_BroadcastReceived);
            //预订断线事件
            this.rapidPassiveEngine.ConnectionInterrupted += new CbGeneric(rapidPassiveEngine_ConnectionInterrupted);
        }