Ejemplo n.º 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);

                //对color进行变换
                for (int i = rectSubItem.Height; i > 0; i--)
                {
                    if (sb.Color.R - i * 3 >= 0//先保证RGB值在合理范围内
                        && sb.Color.G - i * 3 >= 0)
                    {
                        g.DrawLine(new Pen(Color.FromArgb(100, sb.Color.R - i * 3, sb.Color.G - i * 3, sb.Color.B)),
                            rectSubItem.Left, rectSubItem.Top + i,
                            rectSubItem.Right, rectSubItem.Top + i);
                    }
                }

                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);//

            //对color进行变换
            for (int i = rectSubItem.Height; i > 0; i--) {
                if (sb.Color.R - i * 3 >= 0
                    && sb.Color.R - i * 3 >= 0)
                {
                    g.DrawLine(new Pen(Color.FromArgb(100, sb.Color.R - i * 3, sb.Color.G - i * 3, sb.Color.B)),
                        rectSubItem.Left, rectSubItem.Top+i,
                        rectSubItem.Right, rectSubItem.Top+i);
                }
            }

            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);
        }
Ejemplo n.º 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::_CUSTOM_CONTROLS.Properties.Resources._null;
            if (subItem.Status == ChatListSubItem.UserStatus.OffLine)
                g.DrawImage(subItem.GetDarkImage(), subItem.HeadRect);
            else {
                pairs_image image = new pairs_image();
                g.DrawImage(image.get_image_from_name(subItem.DisplayName), subItem.HeadRect);//绘制小图标

                /*
                if (subItem.Status == ChatListSubItem.UserStatus.QMe)
                    g.DrawImage(global::_CUSTOM_CONTROLS.Properties.Resources.QMe, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                if (subItem.Status == ChatListSubItem.UserStatus.Away)
                    g.DrawImage(global::_CUSTOM_CONTROLS.Properties.Resources.Away, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                if (subItem.Status == ChatListSubItem.UserStatus.Busy)
                    g.DrawImage(global::_CUSTOM_CONTROLS.Properties.Resources.Busy, new Rectangle(subItem.HeadRect.Right - 10, subItem.HeadRect.Bottom - 10, 11, 11));
                if (subItem.Status == ChatListSubItem.UserStatus.DontDisturb)
                    g.DrawImage(global::_CUSTOM_CONTROLS.Properties.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);
        }