コード例 #1
0
        /// <summary>
        /// 绘制列表子项
        /// </summary>
        /// <param name="g">绘图表面</param>
        /// <param name="subItem">要绘制的子项</param>
        /// <param name="rectSubItem">该子项的区域</param>
        /// <param name="sb">画刷</param>
        protected virtual void DrawSubItem(Graphics g, ChatListSubItem subItem, ref Rectangle rectSubItem, SolidBrush sb)
        {
            if (subItem.Equals(selectSubItem))
            {                                                     //判断改子项是否被选中
                rectSubItem.Height = (int)ChatListItemIcon.Large; //如果选中则绘制成大图标
                sb.Color           = this.subItemSelectColor;
                g.FillRectangle(sb, rectSubItem);
                DrawHeadImage(g, subItem, rectSubItem);         //绘制头像
                DrawLargeSubItem(g, subItem, rectSubItem);      //绘制大图标 显示的个人信息
                subItem.Bounds = new Rectangle(rectSubItem.Location, rectSubItem.Size);
                return;
            }
            else if (subItem.Equals(m_mouseOnSubItem))
            {
                sb.Color = this.subItemMouseOnColor;
            }
            else
            {
                sb.Color = this.subItemColor;
            }
            g.FillRectangle(sb, rectSubItem);
            DrawHeadImage(g, subItem, rectSubItem);

            if (iconSizeMode == ChatListItemIcon.Large)         //没有选中则根据 图标模式绘制
            {
                DrawLargeSubItem(g, subItem, rectSubItem);
            }
            else
            {
                DrawSmallSubItem(g, subItem, rectSubItem);
            }

            subItem.Bounds = new Rectangle(rectSubItem.Location, rectSubItem.Size);
        }
コード例 #2
0
        /// <summary>
        /// 绘制列表子项的头像
        /// </summary>
        /// <param name="g">绘图表面</param>
        /// <param name="subItem">要绘制头像的子项</param>
        /// <param name="rectSubItem">该子项的区域</param>
        protected virtual void DrawHeadImage(Graphics g, ChatListSubItem subItem, Rectangle rectSubItem)
        {
            if (subItem.IsTwinkle)
            {                              //判断改头像是否闪动
                if (subItem.IsTwinkleHide) //同理该值 在线程中 取反赋值
                {
                    return;
                }
            }

            int imageHeight = rectSubItem.Height - 10;      //根据子项的大小计算头像的区域

            subItem.HeadRect = new Rectangle(5, rectSubItem.Top + 5, imageHeight, imageHeight);

            if (subItem.HeadImage == null)                 //如果头像位空 用默认资源给定的头像
            {
                subItem.HeadImage = global::CuStomControls.Resources._null;
            }
            if (subItem.Status == ChatListSubItem.UserStatus.OffLine)
            {
                g.DrawImage(subItem.GetDarkImage(), subItem.HeadRect);
            }
            else
            {
                g.DrawImage(subItem.HeadImage, subItem.HeadRect);       //如果在线根据在想状态绘制小图标
                if (subItem.Status == ChatListSubItem.UserStatus.QMe)
                {
                    g.DrawImage(global::CuStomControls.Resources.QMe1, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                }
                if (subItem.Status == ChatListSubItem.UserStatus.Away)
                {
                    g.DrawImage(global::CuStomControls.Resources.Away1, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                }
                if (subItem.Status == ChatListSubItem.UserStatus.Busy)
                {
                    g.DrawImage(global::CuStomControls.Resources.Busy1, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                }
                if (subItem.Status == ChatListSubItem.UserStatus.DontDisturb)
                {
                    g.DrawImage(global::CuStomControls.Resources.Dont_Disturb, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                }
            }

            if (subItem.Equals(selectSubItem))              //根据是否选中头像绘制头像的外边框
            {
                g.DrawRectangle(Pens.Cyan, subItem.HeadRect);
            }
            else
            {
                g.DrawRectangle(Pens.Gray, subItem.HeadRect);
            }
        }