Example #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)));
        }
Example #2
0
 protected Brush GetForeBrush(DrawItemEventArgs e)
 {
     if (GetFocused(e))
     {
         return(new SolidBrush(ProtoListControlHelp.DefaultForeColorOnFocus));
     }
     return(new SolidBrush(ProtoListControlHelp.CheckEnabled(ForeColor, Enabled)));
 }
Example #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));
 }
Example #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)));
        }
Example #5
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)));
        }
Example #6
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;
                }
            }
        }
Example #7
0
 protected Color CheckEnabled(Color c)
 {
     return(ProtoListControlHelp.CheckEnabled(c, Enabled));
 }