Example #1
0
        /// <summary>
        /// Creates text as drawing object.
        /// </summary>
        /// <param name="graphics"><see cref="IGraphics"/> object.</param>
        /// <param name="text">Text that will be drawn.</param>
        /// <param name="font">Font that will be used to draw the text.</param>
        /// <param name="foregroundColor">Color of the brush that will be used to paint the text.</param>
        /// <param name="backgroundColor">Color of the brush that will be used to paint the text's background.</param>
        /// <param name="left">Left position of the text.</param>
        /// <param name="top">Top position of the text.</param>
        /// <param name="width">Virtual text box width. If value is less than 0, it will be automatically computed.</param>
        /// <param name="height">Virtual text box height. If value is less than 0, it will be automatically computed.</param>
        /// <param name="horizontalAlignment">Text horizontal alignment.</param>
        /// <param name="verticalAlignment">Text vertical alignment.</param>
        /// <param name="wrapping">Text wrapping.</param>
        /// <param name="rotation">Text clockwise rotation in radians.</param>
        /// <returns>Text as drawing object.</returns>
        public static IText CreateText(this IGraphics graphics, string text, IFont font, Color foregroundColor, Color backgroundColor, double left = 0, double top = 0, double width = -1, double height = -1, TextHorizontalAlignment horizontalAlignment = TextHorizontalAlignment.Left, TextVerticalAlignment verticalAlignment = TextVerticalAlignment.Top, TextWrapping wrapping = TextWrapping.Wrap, double rotation = 0)
        {
            IBrush foreground = graphics.CreateSolidColorBrush(foregroundColor);
            IBrush background = graphics.CreateSolidColorBrush(backgroundColor);

            return(graphics.CreateText(text, font, foreground, background, left, top, width, height, horizontalAlignment, verticalAlignment, wrapping, rotation));
        }
Example #2
0
        /// <summary>
        /// Creates circle as drawing object.
        /// </summary>
        /// <param name="graphics"><see cref="IGraphics"/> object.</param>
        /// <param name="penColor">Pen color.</param>
        /// <param name="centerX">Circle center X coordinate.</param>
        /// <param name="centerY">Circle center Y coordinate.</param>
        /// <param name="radius">Circle radius.</param>
        /// <param name="fillBrushColor">Color of the brush used to fill the content.</param>
        /// <param name="penThickness">Pen thickness.</param>
        /// <returns>Circle as drawing object.</returns>
        public static ICircle CreateCircle(this IGraphics graphics, Color penColor, double centerX, double centerY, double radius, Color fillBrushColor, double penThickness = 1)
        {
            IPen   pen   = CreatePen(graphics, penColor, penThickness);
            IBrush brush = graphics.CreateSolidColorBrush(fillBrushColor);

            return(graphics.CreateCircle(pen, centerX, centerY, radius, brush));
        }
Example #3
0
        /// <summary>
        /// Creates ellipse as drawing object.
        /// </summary>
        /// <param name="graphics"><see cref="IGraphics"/> object.</param>
        /// <param name="penColor">Pen color.</param>
        /// <param name="left">Left coordinate of top left corner.</param>
        /// <param name="top">Top coordinate of top left corner.</param>
        /// <param name="width">Ellipse rectangle width.</param>
        /// <param name="height">Ellipse rectangle height.</param>
        /// <param name="rotation">Ellipse clockwise rotation in radians.</param>
        /// <param name="fillBrushColor">Color of the brush used to fill the content.</param>
        /// <param name="penThickness">Pen thickness.</param>
        /// <returns>Ellipse as drawing object.</returns>
        public static IEllipse CreateEllipse(this IGraphics graphics, Color penColor, double left, double top, double width, double height, double rotation, Color fillBrushColor, double penThickness = 1)
        {
            IPen   pen   = CreatePen(graphics, penColor, penThickness);
            IBrush brush = graphics.CreateSolidColorBrush(fillBrushColor);

            return(graphics.CreateEllipse(pen, left, top, width, height, rotation, brush));
        }
Example #4
0
        /// <summary>
        /// Creates pen object.
        /// </summary>
        /// <param name="graphics"><see cref="IGraphics"/> object.</param>
        /// <param name="color">Pen color.</param>
        /// <param name="thickness">Pen thickness.</param>
        /// <returns>Pen object.</returns>
        public static IPen CreatePen(this IGraphics graphics, Color color, double thickness = 1)
        {
            IBrush brush = graphics.CreateSolidColorBrush(color);

            return(graphics.CreatePen(brush, thickness));
        }