Example #1
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  g      = e.Graphics;
            Rectangle bounds = this.ClientRectangle;

            /* Translate e.Graphics to render different scroll-button styles. */

            switch (this.Style)
            {
            case NuGenScrollButtonStyle.Left:
            {
                bounds = new Rectangle(bounds.Top, bounds.Left, bounds.Height, bounds.Width);
                NuGenControlPaint.Make90CWGraphics(g, bounds);
                break;
            }

            case NuGenScrollButtonStyle.Right:
            {
                NuGenControlPaint.Make90CCWGraphics(g, bounds);
                bounds = new Rectangle(bounds.Top, bounds.Left, bounds.Height, bounds.Width);
                break;
            }

            case NuGenScrollButtonStyle.Up:
            {
                NuGenControlPaint.Make180CCWGraphics(g, bounds);
                break;
            }
            }

            if (
                bounds.Width > 0 &&
                bounds.Height > 0
                )
            {
                NuGenPaintParams paintParams = new NuGenPaintParams(g);
                paintParams.Bounds = bounds;
                paintParams.State  = this.ButtonStateTracker.GetControlState();

                if (this.DoubleArrow)
                {
                    this.Renderer.DrawDoubleScrollButton(paintParams);
                }
                else
                {
                    this.Renderer.DrawScrollButton(paintParams);
                }
            }
        }
Example #2
0
        private void DrawHeader(Graphics g, Rectangle bounds)
        {
            Debug.Assert(g != null, "g != null");

            int headerHeight        = this.LayoutManager.GetHeaderHeight();
            int collapseButtonWidth = this.LayoutManager.GetCollapseButtonWidth();

            Rectangle headerBounds = new Rectangle(
                bounds.Left
                , bounds.Top + headerHeight
                , bounds.Width
                , headerHeight
                );

            Rectangle headerBodyBounds = headerBounds;

            headerBodyBounds.Width -= collapseButtonWidth;

            if (this.RightToLeft == RightToLeft.Yes)
            {
                headerBodyBounds.X += collapseButtonWidth;
            }

            NuGenControlState    headerState       = this.HeaderStateTracker.GetControlState();
            NuGenItemPaintParams headerPaintParams = new NuGenItemPaintParams(g);

            headerPaintParams.Bounds       = NuGenControlPaint.BorderRectangle(headerBounds);
            headerPaintParams.ContentAlign =
                this.RightToLeft == RightToLeft.Yes
                                        ? ContentAlignment.MiddleRight
                                        : ContentAlignment.MiddleLeft
            ;
            headerPaintParams.Font      = this.Font;
            headerPaintParams.ForeColor = this.ForeColor;
            headerPaintParams.Image     = this.Image;
            headerPaintParams.State     = headerState;
            headerPaintParams.Text      = this.Text;

            this.Renderer.DrawBackground(headerPaintParams);
            this.Renderer.DrawBorder(headerPaintParams);

            headerPaintParams.Bounds = headerBodyBounds;
            this.Renderer.DrawHeader(headerPaintParams);

            Rectangle collapseButtonBounds = new Rectangle(headerBounds.Left, headerBounds.Top, collapseButtonWidth, headerBounds.Height);

            if (this.RightToLeft == RightToLeft.Yes)
            {
                if (!_collapsed)
                {
                    NuGenControlPaint.Make180CCWGraphics(headerPaintParams.Graphics, collapseButtonBounds);
                }
            }
            else
            {
                if (!_collapsed)
                {
                    headerPaintParams.Graphics.RotateTransform(180);
                    headerPaintParams.Graphics.TranslateTransform(
                        -(headerBounds.Width + headerBodyBounds.Width) + 1
                        , -headerHeight + 1
                        );
                }

                collapseButtonBounds.X += headerBodyBounds.Right;
            }

            headerPaintParams.Bounds = collapseButtonBounds;
            this.Renderer.DrawCollapseButton(headerPaintParams);
        }