Ejemplo n.º 1
0
        protected virtual void DrawItemBackground(TabItemPaintEventArgs e)
        {
            var   rect        = e.Bounds;
            Color borderColor = Color.Empty;

            if (e.Selected)
            {
                // 把BaseLineSize加回去
                switch (e.Bar.Alignment)
                {
                case TabAlignment.Left:
                    rect.Width += e.Bar.BaseLineSize;
                    break;

                case TabAlignment.Top:
                    rect.Height += e.Bar.BaseLineSize;
                    break;

                case TabAlignment.Right:
                    rect.X     -= e.Bar.BaseLineSize;
                    rect.Width += e.Bar.BaseLineSize;
                    break;

                case TabAlignment.Bottom:
                    rect.Y      -= e.Bar.BaseLineSize;
                    rect.Height += e.Bar.BaseLineSize;
                    break;
                }

                Color backColor = e.Item.BackColor ?? e.Bar.SelectedItemBackColor;
                if (!backColor.IsEmpty)
                {
                    //LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, PaintHelper.GetLightColor(backColor), backColor, 90.0f);
                    var backBrush = new SolidBrush(backColor);
                    e.Graphics.FillRectangle(backBrush, rect);
                }

                borderColor = e.Bar.BaseLineColor;
            }
            else
            {
                Color backColor = e.Item.BackColor ?? e.Bar.ItemBackColor;
                switch (e.Status)
                {
                case UIControlStatus.Hover:
                    backColor = e.Bar.HoverItemBackColor;
                    break;
                }

                if (!backColor.IsEmpty)
                {
                    var backBrush = new SolidBrush(backColor);
                    e.Graphics.FillRectangle(backBrush, e.Item.Bounds);

                    borderColor = PaintHelper.AdjustColorS(PaintHelper.GetDarkColor(backColor, 0.15), 10, 20);
                }
            }

            if (!borderColor.IsEmpty)
            {
                DrawItemBorder(e, rect, borderColor);
            }
        }