Exemplo n.º 1
0
            protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);
                var button = e.Item as ToolStripButton;

                var shadow = new Rectangle(
                    e.TextRectangle.X + 1,
                    e.TextRectangle.Y + 1,
                    e.TextRectangle.Width,
                    e.TextRectangle.Height);

                uint shadowColor = UColor.Blend(0xdd, UColor.White);
                uint textColor = e.TextColor.ToUInt();

                if (e.Item.Selected || e.Item.Pressed || (button != null && button.Checked))
                {
                    shadowColor = UColor.Blend(0x7a, UColor.Black);
                    textColor = UColor.White;
                }

                var format = new StringFormat();
                format.LineAlignment = StringAlignment.Center;
                format.Alignment = StringAlignment.Near;

                helper.Text(e.Text, e.TextFont, shadowColor, shadow, format);
                helper.Text(e.Text, e.TextFont, textColor, e.TextRectangle, format);
            }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var helper = new GraphicsHelper(e.Graphics);
            var bounds = new Rectangle(0, 0, Width, Height);

            var shadowWidth = 20;

            switch (orientation)
            {
                case SideBarOrientation.Left:
                    helper.Line(UColor.Blend(0x50, UColor.Black), Width - 1, 0, Width - 1, Height);

                    helper.Gradient(UColor.Blend(0x20, UColor.Black), UColor.Transparent,
                        new Rectangle(Width - shadowWidth, 0, shadowWidth, Height), 180);

                    break;
                case SideBarOrientation.Right:
                    helper.Line(UColor.Blend(0x50, UColor.Black), 0, 0, 0, Height);

                    helper.Gradient(UColor.Blend(0x20, UColor.Black), UColor.Transparent,
                        new Rectangle(0, 0, shadowWidth, Height), 0);

                    break;
            }
        }
Exemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var helper = new GraphicsHelper(e.Graphics);

            helper.Gradient(UColor.Blend(0x30, UColor.Black), UColor.Transparent, new Rectangle(0, 0, Width, Height/2),
                90);
            helper.Line(UColor.Blend(0x60, UColor.Black), 0, 0, Width, 0);
        }
Exemplo n.º 4
0
            protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);

                if (RenderBackground)
                {
                    helper.Line(UColor.Blend(0x7a, UColor.Black), 0, e.AffectedBounds.Width, e.AffectedBounds.Height - 1);
                    helper.Line(UColor.Blend(0xdd, UColor.White), 0, e.AffectedBounds.Width, e.AffectedBounds.Height - 2);
                }
            }
Exemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var helper = new GraphicsHelper(e.Graphics);
            var bounds = new Rectangle(0, 0, Width - 1, Height - 1);
            var inner = new Rectangle(1, 1, Width - 3, Height - 3);
            var gradient = new Rectangle(1, 1, Width - 3, (Height - 1)/2);
            var textShadow = new Rectangle(1, 1, Width - 2, Height - 1);

            helper.RoundedFill(UColor.White, bounds, 4);
            if (!Hover && !Pressed)
            {
                helper.RoundedGradient(UColor.Blend(0x05, UColor.Black), UColor.Blend(0x20, UColor.Black), bounds, 90, 4);
                helper.RoundedGradient(UColor.Blend(0xdd, UColor.White), UColor.White, gradient, 90, 4);

                helper.RoundedOutline(UColor.Blend(0x80, UColor.White), inner, 4);
                helper.RoundedOutline(UColor.Blend(0x70, UColor.Black), bounds, 4);

                helper.Text(Caption, Font, UColor.White, textShadow);
                helper.Text(Caption, Font, UColor.Blend(0xdd, UColor.Black), bounds);
            }
            if (Hover && !Pressed)
            {
                helper.RoundedFill(UColor.Blend(0x25, UColor.CornflowerBlue), bounds, 4);

                helper.RoundedGradient(UColor.Blend(0x15, UColor.Black), UColor.Blend(0x20, UColor.Black), bounds, 90, 4);
                helper.RoundedGradient(UColor.Blend(0x66, UColor.White), UColor.Blend(0x66, UColor.White), gradient, 90,
                    4);

                helper.RoundedOutline(UColor.Blend(0x60, UColor.White), inner, 4);
                helper.RoundedOutline(UColor.Blend(0x80, UColor.Black), bounds, 4);

                helper.Text(Caption, Font, UColor.Blend(0xaa, UColor.White), textShadow);
                helper.Text(Caption, Font, UColor.Blend(0xee, UColor.Black), bounds);
            }
            if (Pressed)
            {
                helper.RoundedFill(UColor.Blend(0x25, UColor.CornflowerBlue), bounds, 4);

                helper.RoundedGradient(UColor.Blend(0x30, UColor.Black), UColor.Blend(0x05, UColor.Black), bounds, 90, 4);

                helper.RoundedOutline(UColor.Blend(0x60, UColor.White), inner, 4);
                helper.RoundedOutline(UColor.Blend(0x80, UColor.Black), bounds, 4);

                helper.Text(Caption, Font, UColor.Blend(0xaa, UColor.White), textShadow);
                helper.Text(Caption, Font, UColor.Blend(0xee, UColor.Black), bounds);
            }
            if (!Enabled)
            {
                helper.Text(Caption, Font, UColor.Blend(0x30, UColor.White), bounds);
            }
            if (Image != null)
            {
                e.Graphics.DrawImage(Image, new Point(Width/2 - Image.Width/2, Height/2 - Image.Height/2));
            }
        }
Exemplo n.º 6
0
            protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);

                if (RenderBackground)
                {
                    helper.Clear(UColor.White);
                    helper.Gradient(UColor.Blend(0x05, UColor.Black), UColor.Blend(0x30, UColor.Black),
                        e.AffectedBounds.Inflated(-1), 90);
                }
            }
Exemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var helper = new GraphicsHelper(e.Graphics);
            var orientation = SideBarOrientation.Left;

            if (SideBar != null)
            {
                orientation = SideBar.Orientation;
            }
            for (var i = 0; i < Tabs.Count; i++)
            {
                SideBarTab tab = Tabs[i];

                Point currentPosition = Point.Empty;

                Rectangle tabRect = Rectangle.Empty,
                    textRect = Rectangle.Empty;

                switch (orientation)
                {
                    case SideBarOrientation.Left:
                        currentPosition = new Point(TabMarginLeft, i*(TabHeight + TabSpacing) + TabMarginTop);
                        tabRect = new Rectangle(currentPosition.X, currentPosition.Y, Width, TabHeight);
                        break;
                    case SideBarOrientation.Right:
                        currentPosition = new Point(TabMarginLeft, i*(TabHeight + TabSpacing) + TabMarginTop);
                        tabRect = new Rectangle(currentPosition.X - TabMarginLeft*2, currentPosition.Y, Width, TabHeight);
                        break;
                }

                var leftFormat = new StringFormat();
                leftFormat.LineAlignment = StringAlignment.Center;
                leftFormat.Alignment = StringAlignment.Near;

                if (i == SelectedIndex || i == hoverIndex)
                {
                    var gradient = new Rectangle(tabRect.X + 1, tabRect.Y + 1, tabRect.Width - 3, (tabRect.Height - 1)/2);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedFill(UColor.White, tabRect, 4);
                    }
                    if (i == hoverIndex)
                    {
                        helper.RoundedFill(UColor.Blend(0x50, UColor.White), tabRect, 4);
                    }
                    helper.RoundedGradient(UColor.Blend(0x05, UColor.Black), UColor.Blend(0x20, UColor.Black), tabRect,
                        90, 4);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedGradient(UColor.Blend(0xdd, UColor.White), UColor.White, gradient, 90, 4);
                    }

                    helper.RoundedOutline(UColor.Blend(0x60, UColor.White), tabRect.Inflated(1), 4);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedOutline(UColor.Blend(0x90, UColor.Black), tabRect, 4);
                    }
                    else if (i == hoverIndex)
                    {
                        helper.RoundedOutline(UColor.Blend(0x50, UColor.Black), tabRect, 4);
                    }
                }

                if (tab.Changed)
                {
                    helper.RoundedFill(UColor.Blend(0x30, UColor.White), tabRect, 4);
                    helper.RoundedFill(UColor.Blend(0x20, UColor.Red), tabRect, 4);
                }
                if (tab.HasIcon)
                {
                    e.Graphics.DrawImage(tab.Icon,
                        new Point(currentPosition.X + TabMarginLeft, currentPosition.Y + TabHeight/2 - tab.Icon.Height/2));
                    currentPosition.Offset(TabMarginLeft + 2 + tab.Icon.Width, 0);
                }

                textRect = new Rectangle(currentPosition.X, currentPosition.Y, Width, TabHeight);
                if (i == SelectedIndex)
                {
                    helper.Text(tab.Caption, Font, UColor.Blend(0xff, UColor.White), textRect.ShrinkedY(-2), leftFormat);
                    helper.Text(tab.Caption, Font, UColor.Blend(0xdd, UColor.Black), textRect, leftFormat);
                }
                else
                {
                    helper.Text(tab.Caption, Font, UColor.Blend(0xee, UColor.Black), textRect.ShrinkedY(-2), leftFormat);
                    helper.Text(tab.Caption, Font, UColor.Blend(0xff, UColor.White), textRect, leftFormat);
                }
            }
        }
Exemplo n.º 8
0
            protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);
                var itemBounds = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                var button = e.Item as ToolStripButton;

                if (e.Item.Selected && !e.Item.Pressed || (button != null && button.Checked))
                {
                    helper.RoundedFill(UColor.White, itemBounds, 4);
                    helper.RoundedGradient(
                        UColor.Blend(0x80, UColor.Black),
                        UColor.Blend(0x60, UColor.Black),
                        itemBounds,
                        90, 4);
                }
                if (e.Item.Pressed)
                {
                    helper.RoundedFill(UColor.White, itemBounds, 4);
                    helper.RoundedGradient(
                        UColor.Blend(0xa0, UColor.Black),
                        UColor.Blend(0x60, UColor.Black),
                        itemBounds,
                        90, 4);
                }
                if (e.Item.Selected || e.Item.Pressed || (button != null && button.Checked))
                {
                    for (int i = innerShadow; i >= 0; i--)
                    {
                        helper.RoundedOutline(UColor.Blend((byte) ((5 + innerShadow*10) - i*10), UColor.Black),
                            itemBounds.Inflated(i + 2), i + 1);
                    }
                    helper.RoundedOutline(UColor.Blend(0x60, UColor.Black), itemBounds.Inflated(1), 4);
                    helper.RoundedOutline(UColor.Blend(0xff, UColor.White), itemBounds, 4);
                }
            }
Exemplo n.º 9
0
 protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
 {
     var helper = new GraphicsHelper(e.Graphics);
     switch (e.Vertical)
     {
         case true:
             helper.Line(UColor.Blend(0x50, UColor.White), e.Item.Width/2 - 1, 0, e.Item.Width/2 - 1,
                 e.Item.Height);
             helper.Line(UColor.Blend(0x60, UColor.Black), e.Item.Width/2, 0, e.Item.Width/2, e.Item.Height);
             helper.Line(UColor.Blend(0x50, UColor.White), e.Item.Width/2 + 1, 0, e.Item.Width/2 + 1,
                 e.Item.Height);
             break;
         case false:
             helper.Line(UColor.Blend(0x50, UColor.Black), 0, e.Item.Height/2, e.Item.Width, e.Item.Height/2);
             helper.Line(UColor.Blend(0x80, UColor.White), 0, e.Item.Height/2 + 1, e.Item.Width,
                 e.Item.Height/2 + 1);
             break;
     }
 }