Ejemplo n.º 1
0
 /// <summary>
 /// 聊天列表点击好友   开始聊天
 /// </summary>
 /// <param name="user"></param>
 private void wchatlist_StartChat(BaseContact user)
 {
     _chat2friend.Visible = true;
     _chat2friend.BringToFront();
     _chat2friend.MeUser     = RobotManager.Instance.Default.getMyAccount();
     _chat2friend.FriendUser = user;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 重绘每项
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Rectangle bound;

            for (int i = 0; i < Items.Count; ++i)
            {
                BaseContact user = Items[i] as BaseContact;
                bound = GetItemRectangle(i);

                if (user != null)  //好友项
                {
                    if (!ClientRectangle.IntersectsWith(bound))
                    {
                        continue;
                    }
                    if (_mouse_over == i)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 37, 37, 37)), bound);
                    }
                    if (SelectedIndex == i)
                    {
                        e.Graphics.FillRectangle(Brushes.LightGray, bound);
                    }
                    e.Graphics.DrawLine(new Pen(Color.FromArgb(50, Color.Black)), new Point(bound.X, bound.Y + 50), new Point(bound.X + Width, bound.Y + 50));
                    using (Font f = new System.Drawing.Font("微软雅黑", 11))
                    {
                        e.Graphics.DrawString(user.ShowName, f, Brushes.Black, new PointF(bound.X + 50, bound.Y + 16)); //昵称
                    }
                }
                else  //分类项
                {
                    if (!ClientRectangle.IntersectsWith(bound))
                    {
                        continue;
                    }

                    using (Font f = new Font("微软雅黑", 15))
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.Gray)), bound);
                        e.Graphics.DrawString(Items[i].ToString(), f, Brushes.Black, new PointF(bound.X + 10, bound.Y + 3));
                    }
                }
            }
        }
 public static void SetUrl(BaseContact contact, HyperLink link)
 {
     link.NavigateUrl = contact.Url;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 重绘
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Rectangle bound;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            for (int i = 0; i < Items.Count; ++i)
            {
                BaseContact user = Items[i] as BaseContact;
                if (user != null)
                {
                    bound = GetItemRectangle(i);
                    if (!ClientRectangle.IntersectsWith(bound))
                    {
                        continue;
                    }
                    if (_mouse_over == i)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 37, 37, 37)), bound);
                    }
                    if (SelectedIndex == i)
                    {
                        e.Graphics.FillRectangle(Brushes.LightGray, bound);
                    }
                    e.Graphics.DrawLine(new Pen(Color.FromArgb(50, Color.Black)), new Point(bound.X, bound.Y + 70), new Point(bound.X + Width, bound.Y + 70));
                    using (Font f = new System.Drawing.Font("微软雅黑", 11))
                    {
                        e.Graphics.DrawString(user.ShowName, f, Brushes.Black, new PointF(bound.X + 70, bound.Y + 8)); //昵称
                    }
                    List <WXMsg> list_unread = user.GetUnReadMsg();
                    WXMsg        latest      = user.GetLatestMsg();
                    if (list_unread != null)  //有未读消息
                    {
                        using (Font f2 = new Font("微软雅黑", 10))
                        {
                            string time_str  = list_unread[list_unread.Count - 1].Time.ToShortTimeString();
                            Size   time_size = TextRenderer.MeasureText(time_str, f2);
                            e.Graphics.DrawString(time_str, f2, new SolidBrush(Color.FromArgb(37, 37, 37)), new PointF(bound.X + Width - time_size.Width - 13, bound.Y + 8)); //最后一条未读消息时间

                            string latest_msg = list_unread[list_unread.Count - 1].Msg.ToString();                                                                            //最后一条未读消息
                            latest_msg = latest_msg.Length <= 10 ? latest_msg : latest_msg.Substring(0, 10) + "...";
                            latest_msg = "[" + list_unread.Count + "条] " + latest_msg;
                            Size latest_msg_size = TextRenderer.MeasureText(latest_msg, f2);
                            e.Graphics.DrawString(latest_msg, f2, new SolidBrush(Color.FromArgb(37, 37, 37)), new PointF(bound.X + 70, bound.Y + 40));
                        }
                        using (Font f3 = new Font("微软雅黑", 8))  //未读消息条数  小红圆点
                        {
                            e.Graphics.FillEllipse(Brushes.Red, new Rectangle(bound.X + 10 + 50 - 9, bound.Y + 10 - 9, 18, 18));
                            e.Graphics.DrawString((list_unread.Count < 10 ? list_unread.Count.ToString() : "*"), f3, Brushes.White, new PointF(bound.X + 10 + 50 - 5, bound.Y + 10 - 7));
                        }
                    }
                    else //否则 显示最新的一条消息
                    {
                        if (latest != null)
                        {
                            using (Font f2 = new Font("微软雅黑", 10))
                            {
                                string time_str  = latest.Time.ToShortTimeString();
                                Size   time_size = TextRenderer.MeasureText(time_str, f2);
                                e.Graphics.DrawString(time_str, f2, new SolidBrush(Color.FromArgb(37, 37, 37)), new PointF(bound.X + Width - time_size.Width - 13, bound.Y + 8)); //最后一条未读消息时间

                                string latest_msg = latest.Msg.ToString();                                                                                                        //最新一条消息
                                latest_msg = latest_msg.Length <= 10 ? latest_msg : latest_msg.Substring(0, 10) + "...";
                                Size latest_msg_size = TextRenderer.MeasureText(latest_msg, f2);
                                e.Graphics.DrawString(latest_msg, f2, new SolidBrush(Color.FromArgb(37, 37, 37)), new PointF(bound.X + 70, bound.Y + 40));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 通讯录中点击好友 查看好友信息
 /// </summary>
 /// <param name="user"></param>
 private void wfriendlist_FriendInfoView(BaseContact user)
 {
     _friendInfo.FriendUser = user;
     _friendInfo.Visible    = true;
     _friendInfo.BringToFront();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 聊天对话框中点击 好友信息
 /// </summary>
 /// <param name="user"></param>
 void _chat2friend_FriendInfoView(BaseContact user)
 {
     _friendInfo.FriendUser = user;
     _friendInfo.Visible    = true;
     _friendInfo.BringToFront();
 }