示例#1
0
        protected Brush GetBackBrush(DrawListViewSubItemEventArgs e)
        {
            int   index = e.ItemIndex % ProtoListControlHelp.DefaultFocusColors.Count;
            Color c     = ProtoListControlHelp.DefaultBackColors[index];

            return(new SolidBrush(ProtoListControlHelp.CheckEnabled(c, Enabled)));
        }
示例#2
0
 protected Brush GetForeBrush(DrawItemEventArgs e)
 {
     if (GetFocused(e))
     {
         return(new SolidBrush(ProtoListControlHelp.DefaultForeColorOnFocus));
     }
     return(new SolidBrush(ProtoListControlHelp.CheckEnabled(ForeColor, Enabled)));
 }
示例#3
0
 protected virtual Brush GetBrush()
 {
     if (ForeBrush != null)
     {
         return(ForeBrush);
     }
     if (DataColor != default(Color))
     {
         return(new SolidBrush(ProtoListControlHelp.CheckEnabled(DataColor, Enabled)));
     }
     return(new SolidBrush(Color.Gray));
 }
示例#4
0
        protected Brush GetForeBrush(DrawListViewItemEventArgs e)
        {
            Color c;

            if (GetFocused(e))
            {
                c = ProtoListControlHelp.DefaultForeColorOnFocus;
            }
            else
            {
                c = ForeColor;
            }
            return(new SolidBrush(ProtoListControlHelp.CheckEnabled(c, Enabled)));
        }
示例#5
0
 private void ProtoSelectable_Paint(object sender, PaintEventArgs e)
 {
     if (this.Focused)
     {
         Brush back = ProtoListControlHelp.GetFocusBrush(e.ClipRectangle, BackColor);
         e.Graphics.FillRectangle(back, e.ClipRectangle);
         ProtoFrameControlHelp.DrawFocusRectangle(e.Graphics, e.ClipRectangle);
         e.Graphics.DrawString(Text, Font, new SolidBrush(Color.White), e.ClipRectangle, Format);
     }
     else
     {
         e.Graphics.FillRectangle(new SolidBrush(Color.White), e.ClipRectangle);
         e.Graphics.DrawString(Text, Font, new SolidBrush(this.ForeColor), e.ClipRectangle, Format);
     }
 }
示例#6
0
        protected Brush GetBackBrush(DrawItemEventArgs e)
        {
            if (!(this.DroppedDown || Focused))
            {
                return(new SolidBrush(this.BackColor));
            }
            if (GetFocused(e))
            {
                return(ProtoListControlHelp.GetFocusBrush(e.Bounds, BackColor));
            }
            int   index = e.Index % ProtoListControlHelp.DefaultFocusColors.Count;
            Color c     = ProtoListControlHelp.DefaultBackColors[index];

            return(new SolidBrush(ProtoListControlHelp.CheckEnabled(c, Enabled)));
        }
示例#7
0
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     if (e.Index < 0 || e.Index >= Items.Count)
     {
         return;
     }
     if (Items.Count == 0 && Focused)
     {
         ProtoListControlHelp.DrawFocusRectangle(e.Graphics, e.Bounds);
         return;
     }
     // 描绘背景颜色
     e.Graphics.FillRectangle(GetBackBrush(e), e.Bounds);
     if (GetFocused(e))
     {
         ProtoListControlHelp.DrawFocusRectangle(e.Graphics, e.Bounds);
     }
     // 描绘文字
     e.Graphics.DrawString(Items[e.Index].ToString(), Font, GetForeBrush(e), e.Bounds);
 }
示例#8
0
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            if (e.ItemIndex < 0 || e.ItemIndex >= Items.Count)
            {
                return;
            }
            if (Items.Count == 0 && Focused)
            {
                ProtoListControlHelp.DrawFocusRectangle(e.Graphics, e.Bounds);
                return;
            }
            Rectangle Bounds = new Rectangle(e.Bounds.X, e.Bounds.Y, this.ClientSize.Width, e.Bounds.Height);

            // TODO:修正焦点条被截断的问题。
            // 描绘背景图形
            e.Graphics.FillRectangle(GetBackBrush(e), Bounds);
            if (GetFocused(e))
            {
                e.Graphics.FillRectangle(ProtoListControlHelp.GetFocusBrush(e.Bounds, BackColor), e.Bounds);
                ProtoListControlHelp.DrawFocusRectangle(e.Graphics, e.Bounds);
            }
            // 子类描绘调用
            foreach (ListViewItem.ListViewSubItem item in e.Item.SubItems)
            {
                OnDrawSubItem(new DrawListViewSubItemEventArgs(
                                  e.Graphics, item.Bounds, e.Item, item, e.ItemIndex, 0, null, e.State));
            }
            // 补齐剩余部分
            if (e.ItemIndex == Items.Count - 1)
            {
                int cy = e.Bounds.Y + e.Bounds.Height, count = e.ItemIndex % ProtoListControlHelp.DefaultBackColors.Count;
                while (cy <= this.ClientRectangle.Height)
                {
                    count = (count + 1) % ProtoListControlHelp.DefaultBackColors.Count;
                    SolidBrush ExtraBackBrush = new SolidBrush(ProtoListControlHelp.
                                                               CheckEnabled(ProtoListControlHelp.DefaultBackColors[count], Enabled));
                    e.Graphics.FillRectangle(ExtraBackBrush, new Rectangle(e.Bounds.X, cy, this.ClientSize.Width, e.Bounds.Height));
                    cy += e.Bounds.Height;
                }
            }
        }
示例#9
0
 protected Color CheckEnabled(Color c)
 {
     return(ProtoListControlHelp.CheckEnabled(c, Enabled));
 }
示例#10
0
 protected void DrawFocusRectangle(Graphics graphics, Rectangle rect)
 {
     ProtoListControlHelp.DrawFocusRectangle(graphics, rect);
 }
示例#11
0
 protected Brush GetFocusBrush(Rectangle?rect = null)
 {
     return(ProtoListControlHelp.GetFocusBrush(rect, BackColor));
 }