/// <summary>Draws a background with a linear gradient still border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background linear gradient.</param>
        /// <param name="border">The border type.</param>
        /// <param name="mouseState">The control mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, LinearGradientBrush background, Border border, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            FillBackground(graphics, backgroundPath, background);
            VisualBorderRenderer.DrawBorderStyle(graphics, border, backgroundPath, mouseState);
        }
        /// <summary>Draws a background with a linear gradient still border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background linear gradient.</param>
        /// <param name="border">The border type.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, LinearGradientBrush background, Border border, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            FillBackground(graphics, backgroundPath, background);
            VisualBorderRenderer.DrawBorder(graphics, backgroundPath, border.Color, border.Thickness);
        }
        /// <summary>Draws an arrow button.</summary>
        /// <param name="graphics">The <see cref="Graphics" /> used to paint.</param>
        /// <param name="arrowUp">true for an up arrow, false otherwise.</param>
        /// <param name="border">The border.</param>
        /// <param name="color">The color.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="orientation">The <see cref="Orientation" />.</param>
        /// <param name="rectangle">The rectangle in which to paint.</param>
        /// <param name="state">The <see cref="MouseStates" /> of the arrow button.</param>
        public static void DrawArrowButton(Graphics graphics, bool arrowUp, Border border, ControlColorState color, bool enabled, Orientation orientation, Rectangle rectangle, MouseStates state)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (rectangle.IsEmpty || graphics.IsVisibleClipEmpty || !graphics.VisibleClipBounds.IntersectsWith(rectangle))
            {
                return;
            }

            Color _thumbBackColor = ControlColorState.BackColorState(color, enabled, state);

            VisualBackgroundRenderer.DrawBackground(graphics, _thumbBackColor, state, rectangle, border);

            GraphicsPath _buttonGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _buttonGraphicsPath, state);

            Image _arrowImage = RetrieveButtonArrowImage(enabled);

            _arrowImage = RotateImageByOrientation(_arrowImage, orientation, arrowUp);
            graphics.DrawImage(_arrowImage, rectangle);
        }
示例#4
0
        /// <summary>Draws the badge.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="rectangle">The rectangle.</param>
        /// <param name="backColor">The back color.</param>
        /// <param name="text">The text.</param>
        /// <param name="font">The font.</param>
        /// <param name="foreColor">The fore color.</param>
        /// <param name="shape">The shape type.</param>
        /// <param name="textLocation">The _text Location.</param>
        public static void DrawBadge(Graphics graphics, Rectangle rectangle, Color backColor, string text, Font font, Color foreColor, Shape shape, Point textLocation)
        {
            GraphicsPath _badgePath = VisualBorderRenderer.CreateBorderTypePath(rectangle, shape.Rounding, shape.Thickness, shape.Type);

            graphics.FillPath(new SolidBrush(backColor), _badgePath);
            VisualBorderRenderer.DrawBorder(graphics, _badgePath, shape.Color, shape.Thickness);
            graphics.DrawString(text, font, new SolidBrush(foreColor), textLocation);
        }
示例#5
0
        /// <summary>Draws a button control.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="backColor">The BackColor of the button.</param>
        /// <param name="backgroundImage">The background image for the button.</param>
        /// <param name="border">The border.</param>
        /// <param name="mouseState">The mouse State.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="font">The font to use in the string.</param>
        /// <param name="foreColor">The color of the string.</param>
        /// <param name="image">The image to draw.</param>
        /// <param name="imageSize">The image Size.</param>
        /// <param name="textImageRelation">The text image relation.</param>
        public static void DrawButton(Graphics graphics, Rectangle rectangle, Color backColor, Image backgroundImage, Border border, MouseStates mouseState, string text, Font font, Color foreColor, Image image, Size imageSize, TextImageRelation textImageRelation)
        {
            GraphicsPath _controlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            VisualBackgroundRenderer.DrawBackground(graphics, backColor, backgroundImage, mouseState, rectangle, border);
            DrawContent(graphics, rectangle, text, font, foreColor, image, imageSize, textImageRelation);
            VisualBorderRenderer.DrawBorderStyle(graphics, border, _controlGraphicsPath, mouseState);
        }
        /// <summary>Fills the background graphics path.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background color.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="border">The border type.</param>
        /// <returns>The <see cref="GraphicsPath" />.</returns>
        private static GraphicsPath FillBackgroundPath(Graphics graphics, Color background, Rectangle rectangle, Shape border)
        {
            GraphicsPath backgroundPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            graphics.SetClip(backgroundPath);
            graphics.FillRectangle(new SolidBrush(background), rectangle);
            graphics.ResetClip();
            return(backgroundPath);
        }
        /// <summary>Draws a background with a still border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background color.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="shape">The shape.</param>
        public static void DrawBackground(Graphics graphics, Color background, Rectangle rectangle, Shape shape)
        {
            GraphicsPath backgroundPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, shape);

            graphics.SetClip(backgroundPath);
            graphics.FillRectangle(new SolidBrush(background), rectangle);
            graphics.ResetClip();
            VisualBorderRenderer.DrawBorder(graphics, backgroundPath, shape.Color, thickness: shape.Thickness);
        }
示例#8
0
        /// <summary>Draws a check box control in the specified state and location.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="border">The border type.</param>
        /// <param name="checkStyle">The check mark type.</param>
        /// <param name="rectangle">The rectangle that represents the dimensions of the check box.</param>
        /// <param name="checkState">The check State.</param>
        /// <param name="enabled">The state to draw the check mark in.</param>
        /// <param name="color">The background color.</param>
        /// <param name="backgroundImage">The background Image.</param>
        /// <param name="mouseStates">The mouse States.</param>
        public static void DrawCheckBox(Graphics graphics, Border border, CheckStyle checkStyle, Rectangle rectangle, bool checkState, bool enabled, Color color, Image backgroundImage, MouseStates mouseStates)
        {
            GraphicsPath _boxGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            graphics.SetClip(_boxGraphicsPath);
            VisualBackgroundRenderer.DrawBackground(graphics, color, backgroundImage, mouseStates, rectangle, border);

            if (checkState)
            {
                DrawCheckMark(graphics, checkStyle, rectangle, enabled);
            }

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _boxGraphicsPath, mouseStates);
            graphics.ResetClip();
        }
示例#9
0
        /// <summary>Draws the control background, with a BackColor and the specified BackgroundImage.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="image">The background image to use for the background.</param>
        /// <param name="border">The shape settings.</param>
        /// <param name="color">The color.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawElement(Graphics graphics, Image image, Border border, ControlColorState color, bool enabled, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath _elementGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            graphics.SetClip(_elementGraphicsPath);
            Color _colorState = ControlColorState.BackColorState(color, enabled, mouseState);

            graphics.FillRectangle(new SolidBrush(_colorState), rectangle);
            graphics.ResetClip();

            if (image != null)
            {
                graphics.SetClip(_elementGraphicsPath);
                graphics.DrawImage(image, rectangle);
                graphics.ResetClip();
            }

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _elementGraphicsPath, mouseState);
        }
示例#10
0
        /// <summary>
        ///     Draws a check mark control in the specified state, on the specified graphics surface, and within the specified
        ///     bounds.
        /// </summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="checkStyle">The check mark type.</param>
        /// <param name="rectangle">The rectangle that represents the dimensions of the check box.</param>
        /// <param name="enabled">The state to draw the check mark in.</param>
        public static void DrawCheckMark(Graphics graphics, CheckStyle checkStyle, Rectangle rectangle, bool enabled)
        {
            Size _characterSize = StringUtil.MeasureText(checkStyle.Character.ToString(), checkStyle.Font, graphics);

            int _styleCount       = checkStyle.Style.Count();
            var _defaultLocations = new Point[_styleCount];

            _defaultLocations[0] = new Point((rectangle.X + (rectangle.Width / 2)) - (_characterSize.Width / 2), (rectangle.Y + (rectangle.Height / 2)) - (_characterSize.Height / 2));
            _defaultLocations[1] = new Point((rectangle.X + (rectangle.Width / 2)) - (checkStyle.Bounds.Width / 2), (rectangle.Y + (rectangle.Height / 2)) - (checkStyle.Bounds.Height / 2));
            _defaultLocations[2] = new Point((rectangle.X + (rectangle.Width / 2)) - (checkStyle.Bounds.Width / 2), (rectangle.Y + (rectangle.Height / 2)) - (checkStyle.Bounds.Height / 2));
            _defaultLocations[3] = new Point((rectangle.X + (rectangle.Width / 2)) - (checkStyle.Bounds.Width / 2), (rectangle.Y + (rectangle.Height / 2)) - (checkStyle.Bounds.Height / 2));

            Point _tempLocation;

            if (checkStyle.AutoSize)
            {
                int styleIndex;

                switch (checkStyle.Style)
                {
                case CheckStyle.CheckType.Character:
                {
                    styleIndex = 0;
                    break;
                }

                case CheckStyle.CheckType.Image:
                {
                    styleIndex = 1;
                    break;
                }

                case CheckStyle.CheckType.Shape:
                {
                    styleIndex = 2;
                    break;
                }

                case CheckStyle.CheckType.Checkmark:
                {
                    styleIndex = 3;
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException();
                }
                }

                _tempLocation = _defaultLocations[styleIndex];
            }
            else
            {
                _tempLocation = checkStyle.Bounds.Location;
            }

            switch (checkStyle.Style)
            {
            case CheckStyle.CheckType.Character:
            {
                graphics.DrawString(checkStyle.Character.ToString(), checkStyle.Font, new SolidBrush(checkStyle.CheckColor), _tempLocation);
                break;
            }

            case CheckStyle.CheckType.Image:
            {
                Rectangle _imageRectangle = new Rectangle(_tempLocation, checkStyle.Bounds.Size);
                graphics.DrawImage(checkStyle.Image, _imageRectangle);
                break;
            }

            case CheckStyle.CheckType.Shape:
            {
                Rectangle    shapeRectangle = new Rectangle(_tempLocation, checkStyle.Bounds.Size);
                GraphicsPath shapePath      = VisualBorderRenderer.CreateBorderTypePath(shapeRectangle, checkStyle.ShapeRounding, checkStyle.ShapeRounding, checkStyle.ShapeType);
                graphics.FillPath(new SolidBrush(checkStyle.CheckColor), shapePath);
                break;
            }

            case CheckStyle.CheckType.Checkmark:
            {
                DrawCheckmark(graphics, checkStyle.CheckColor, rectangle, checkStyle.Thickness);
            }

            break;

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }
        }
        /// <summary>Draws a background with a still border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="border">The border type.</param>
        /// <param name="background">The background color.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, Border border, Color background, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = FillBackgroundPath(graphics, background, rectangle, border);

            VisualBorderRenderer.DrawBorder(graphics, backgroundPath, border.Color, thickness: border.Thickness);
        }
        /// <summary>Draws a background with a border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background color.</param>
        /// <param name="border">The border type.</param>
        /// <param name="mouseState">The control mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, Color background, Border border, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = FillBackgroundPath(graphics, background, rectangle, border);

            VisualBorderRenderer.DrawBorderStyle(graphics, border, backgroundPath, mouseState);
        }
        /// <summary>Draws the control background, with a BackColor and the specified BackgroundImage.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="backColor">The color to use for the background.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="shape">The shape settings.</param>
        public static void DrawBackground(Graphics graphics, Color backColor, MouseStates mouseState, Rectangle rectangle, Border shape)
        {
            GraphicsPath _controlGraphicsPath = FillBackgroundPath(graphics, backColor, rectangle, shape);

            VisualBorderRenderer.DrawBorderStyle(graphics, shape, _controlGraphicsPath, mouseState);
        }