FromGraphics() публичный статический Метод

Creates a new SvgRenderer from the specified Graphics.
public static FromGraphics ( Graphics graphics ) : SvgRenderer
graphics System.Drawing.Graphics The to create the renderer from.
Результат SvgRenderer
Пример #1
0
        /// <summary>
        /// Initializes the <see cref="SvgText"/> class.
        /// </summary>
        static SvgText()
        {
            Bitmap bitmap   = new Bitmap(1, 1);
            var    graphics = Graphics.FromImage(bitmap);

            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            _stringMeasure             = SvgRenderer.FromGraphics(graphics);
        }
Пример #2
0
        /// <summary>
        /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
        public void Draw(Graphics graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            this.Render(SvgRenderer.FromGraphics(graphics));
        }
Пример #3
0
        /// <summary>
        /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
        public void Draw(Graphics graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var renderer = SvgRenderer.FromGraphics(graphics);

            renderer.SetBoundable(this);
            this.Render(renderer);
        }
Пример #4
0
        /// <summary>
        /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
        /// <param name="size">The <see cref="SizeF"/> to render the document. If <c>null</c> document is rendered at the default document size.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
        public void Draw(Graphics graphics, SizeF?size)
        {
            if (graphics is null)
            {
                throw new ArgumentNullException("graphics");
            }

            using (var renderer = SvgRenderer.FromGraphics(graphics))
            {
                var boundable = size.HasValue ? (ISvgBoundable) new GenericBoundable(0, 0, size.Value.Width, size.Value.Height) : this;
                this.Draw(renderer, boundable);
            }
        }
Пример #5
0
        /// <summary>
        /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
        /// <param name="size">The <see cref="SizeF"/> to render the document. If <c>null</c> document is rendered at the default document size.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
        public void Draw(Graphics graphics, SizeF?size)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            var renderer = SvgRenderer.FromGraphics(graphics);

            if (size.HasValue)
            {
                renderer.SetBoundable(new GenericBoundable(0, 0, size.Value.Width, size.Value.Height));
            }
            else
            {
                renderer.SetBoundable(this);
            }
            this.Render(renderer);
        }