Пример #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (base.Panel1Collapsed || base.Panel2Collapsed)
            {
                return;
            }

            Rectangle rect        = base.SplitterRectangle;
            bool      bHorizontal = base.Orientation == Orientation.Horizontal;

            System.Drawing.Drawing2D.LinearGradientMode gradientMode = bHorizontal ?
                                                                       System.Drawing.Drawing2D.LinearGradientMode.Vertical : System.Drawing.Drawing2D.LinearGradientMode.Horizontal;

            using (LinearGradientBrush brush = new LinearGradientBrush(
                       rect, gradientColor1, gradientColor2, gradientMode))
            {
                Blend blend = new Blend();
                blend.Positions = new float[] { 0f, .5f, 1f };
                blend.Factors   = new float[] { .5F, 1F, .5F };

                brush.Blend = blend;
                e.Graphics.FillRectangle(brush, rect);
            }

            if (_collapsePanel == CollapsePanel.None)
            {
                return;
            }

            Rectangle arrowRect;
            Rectangle topLeftRect;
            Rectangle bottomRightRect;

            CalculateRect(
                CollapseRect,
                out arrowRect,
                out topLeftRect,
                out bottomRightRect);

            ArrowDirection direction = ArrowDirection.Left;

            switch (_collapsePanel)
            {
            case CollapsePanel.Panel1:
                if (bHorizontal)
                {
                    direction =
                        _spliterPanelState == SpliterPanelState.Collapsed ?
                        ArrowDirection.Down : ArrowDirection.Up;
                }
                else
                {
                    direction =
                        _spliterPanelState == SpliterPanelState.Collapsed ?
                        ArrowDirection.Right : ArrowDirection.Left;
                }
                break;

            case CollapsePanel.Panel2:
                if (bHorizontal)
                {
                    direction =
                        _spliterPanelState == SpliterPanelState.Collapsed ?
                        ArrowDirection.Up : ArrowDirection.Down;
                }
                else
                {
                    direction =
                        _spliterPanelState == SpliterPanelState.Collapsed ?
                        ArrowDirection.Left : ArrowDirection.Right;
                }
                break;
            }

            Color foreColor = _mouseState == ControlState.Hover ?
                              Color.FromArgb(21, 66, 139) : Color.FromArgb(80, 136, 228);

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(e.Graphics))
            {
                RenderHelper.RenderGrid(e.Graphics, topLeftRect, new Size(3, 3), foreColor);
                RenderHelper.RenderGrid(e.Graphics, bottomRightRect, new Size(3, 3), foreColor);

                using (Brush brush = new SolidBrush(foreColor))
                {
                    RenderHelper.RenderArrowInternal(
                        e.Graphics,
                        arrowRect,
                        direction,
                        brush);
                }
            }
        }
Пример #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (base.Panel1Collapsed || base.Panel2Collapsed)
            {
                return;
            }

            Graphics g = e.Graphics;
            Rectangle rect = base.SplitterRectangle;
            bool bHorizontal = base.Orientation == Orientation.Horizontal;

            System.Drawing.Drawing2D.LinearGradientMode gradientMode = bHorizontal ?
                System.Drawing.Drawing2D.LinearGradientMode.Vertical : System.Drawing.Drawing2D.LinearGradientMode.Horizontal;

            using (LinearGradientBrush brush = new LinearGradientBrush(
                rect, gradientColor1,gradientColor2, gradientMode))
            {
                Blend blend = new Blend();
                blend.Positions = new float[] { 0f, .5f, 1f };
                blend.Factors = new float[] { .5F, 1F, .5F };

                brush.Blend = blend;
                g.FillRectangle(brush, rect);
            }

            if (_collapsePanel == CollapsePanel.None)
            {
                return;
            }

            Rectangle arrowRect;
            Rectangle topLeftRect;
            Rectangle bottomRightRect;

            CalculateRect(
                CollapseRect,
                out arrowRect,
                out topLeftRect,
                out bottomRightRect);

            ArrowDirection direction = ArrowDirection.Left;

            switch (_collapsePanel)
            {
                case CollapsePanel.Panel1:
                    if (bHorizontal)
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Down : ArrowDirection.Up;
                    }
                    else
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Right : ArrowDirection.Left;
                    }
                    break;
                case CollapsePanel.Panel2:
                    if (bHorizontal)
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Up : ArrowDirection.Down;
                    }
                    else
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Left : ArrowDirection.Right;
                    }
                    break;
            }

            Color foreColor = _mouseState == ControlState.Hover ?
                Color.FromArgb(21, 66, 139) : Color.FromArgb(80, 136, 228);
            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                RenderHelper.RenderGrid(g, topLeftRect, new Size(3, 3), foreColor);
                RenderHelper.RenderGrid(g, bottomRightRect, new Size(3, 3), foreColor);

                using (Brush brush = new SolidBrush(foreColor))
                {
                    RenderHelper.RenderArrowInternal(
                        g,
                        arrowRect,
                        direction,
                        brush);
                }
            }
        }