Exemplo n.º 1
0
        protected override void DrawItemBackground(TabItemPaintEventArgs e)
        {
            //base.DrawItemBackground(e);

            TaskBar taskBar   = e.GetBar <TaskBar>();
            Color   backColor = e.Bar.ItemBackColor;

            switch (e.Status)
            {
            case UIControlStatus.Selected:
            case UIControlStatus.Focused:
                if (taskBar.IsActive)
                {
                    backColor = taskBar.SelectedItemBackColor;
                }
                else
                {
                    backColor = taskBar.InactiveSelectedItemBackColor;
                }
                break;

            case UIControlStatus.Hover:
                backColor = taskBar.HoverItemBackColor;
                break;
            }

            if (!backColor.IsEmpty)
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(e.Bounds, taskBar.TabRounded, taskBar.TabRounded, 0, 0);
                //if (e.Status == UIControlStatus.Hover)
                //{
                //    LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, backColor, backColor, 90.0f);
                //    ColorBlend cb = new ColorBlend(3);
                //    cb.Colors = new Color[] { PaintHelper.GetLightColor(backColor), backColor, backColor };
                //    cb.Positions = new float[] { 0.0f, 0.5f, 1.0f };
                //    backBrush.InterpolationColors = cb;
                //    e.Graphics.FillPath(backBrush, path);
                //}
                //else
                //{
                SolidBrush backBrush = new SolidBrush(backColor);
                e.Graphics.FillPath(backBrush, path);
                //}

                //
                if ((e.Status == UIControlStatus.Normal || e.Status == UIControlStatus.Hover) &&
                    e.Bounds.Height > 10)
                {
                    Rectangle rectShadow = e.Bounds;
                    rectShadow.Y      = rectShadow.Bottom - 6;
                    rectShadow.Height = 5;
                    var brush = new LinearGradientBrush(rectShadow, Color.Transparent,
                                                        PaintHelper.AdjustColorSLess(PaintHelper.GetDarkColor(backColor), 20), 90.0f);
                    rectShadow.Y++;//规避一个Gdi+错误, 会导致第一行有一个很深的线
                    //e.Graphics.FillRectangle(Brushes.Red, rectShadow);
                    e.Graphics.FillRectangle(brush, rectShadow);
                }
            }
        }