GetBrush() публичный Метод

public GetBrush ( GraphicsPath gp ) : Brush
gp System.Drawing.Drawing2D.GraphicsPath
Результат System.Drawing.Brush
Пример #1
0
        public void TestColorFill()
        {
            elm.SetAttribute("fill", "red");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "fill");

            Brush brush = paint.GetBrush(getGp());

            Assert.AreEqual(typeof(SolidBrush), brush.GetType());
            Assert.IsTrue(isSameColor(Color.Red, ((SolidBrush)brush).Color));
        }
Пример #2
0
        public void TestNonExistingGradientCurrentColor()
        {
            elm.SetAttribute("color", "red");
            elm.SetAttribute("fill", "url(#myGradient) currentColor");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "fill");

            Assert.AreEqual(SvgPaintType.UriCurrentColor, paint.PaintType);

            Brush brush = paint.GetBrush(getGp());
            Assert.IsTrue(isSameColor(Color.Red, ((SolidBrush)brush).Color));
        }
Пример #3
0
 public void TestOpacityFill()
 {
     elm.SetAttribute("opacity", "0.5");
     GdiSvgPaint paint = new GdiSvgPaint(elm, "fill");
     Brush brush = paint.GetBrush(getGp());
     Assert.AreEqual(128, ((SolidBrush)brush).Color.A);
 }
Пример #4
0
        public void TestNonExistingGradient()
        {
            elm.SetAttribute("fill", "url(#myGradient)");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "fill");

            Assert.AreEqual(SvgPaintType.Uri, paint.PaintType);

            Brush brush = paint.GetBrush(getGp());
            Assert.IsNull(brush);
        }
        public override void Render(ISvgRenderer renderer)
        {
            GdiRenderer gdiRenderer = renderer as GdiRenderer;
            GraphicsWrapper graphics = gdiRenderer.GraphicsWrapper;

            if ( !(element is SvgClipPathElement) && !(element.ParentNode is SvgClipPathElement) )
            {
                SvgStyleableElement styleElm = element as SvgStyleableElement;
                if ( styleElm != null )
                {
                    string sVisibility = styleElm.GetPropertyValue("visibility");
                    string sDisplay = styleElm.GetPropertyValue("display");

                    if (element is ISharpGDIPath && sVisibility != "hidden" && sDisplay != "none")
                    {
                        GraphicsPath gp = ((ISharpGDIPath)element).GetGraphicsPath();

                        if ( gp != null )
                        {
                            Clip(graphics);

                            GdiSvgPaint fillPaint = new GdiSvgPaint(styleElm, "fill");
                            Brush brush = fillPaint.GetBrush(gp);

                            GdiSvgPaint strokePaint = new GdiSvgPaint(styleElm, "stroke");
                            Pen pen = strokePaint.GetPen(gp);

                            if ( brush != null )
                            {
                                if ( brush is PathGradientBrush )
                                {
                                    GradientPaintServer gps = fillPaint.PaintServer as GradientPaintServer;
                                    //GraphicsContainer container = graphics.BeginContainer();

                                    graphics.SetClip(gps.GetRadialGradientRegion(gp.GetBounds()), CombineMode.Exclude);

                                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)brush).InterpolationColors.Colors[0]);
                                    graphics.FillPath(this, tempBrush,gp);
                                    tempBrush.Dispose();
                                    graphics.ResetClip();

                                    //graphics.EndContainer(container);
                                }

                                graphics.FillPath(this, brush, gp);
                                brush.Dispose();
                            }

                            if ( pen != null )
                            {
                                if ( pen.Brush is PathGradientBrush )
                                {
                                    GradientPaintServer gps = strokePaint.PaintServer as GradientPaintServer;
                                    GraphicsContainerWrapper container = graphics.BeginContainer();

                                    graphics.SetClip(gps.GetRadialGradientRegion(gp.GetBounds()), CombineMode.Exclude);

                                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)pen.Brush).InterpolationColors.Colors[0]);
                                    Pen tempPen = new Pen(tempBrush, pen.Width);
                                    graphics.DrawPath(this, tempPen,gp);
                                    tempPen.Dispose();
                                    tempBrush.Dispose();

                                    graphics.EndContainer(container);
                                }

                                graphics.DrawPath(this, pen, gp);
                                pen.Dispose();
                            }
                        }
                    }
                    PaintMarkers(gdiRenderer, styleElm, graphics);
                }
            }
        }
 private Brush GetBrush(GraphicsPath gp)
 {
     GdiSvgPaint paint = new GdiSvgPaint(element as SvgStyleableElement, "fill");
     return paint.GetBrush(gp);
 }
Пример #7
0
        private Brush GetBrush(GraphicsPath gp)
        {
            GdiSvgPaint paint = new GdiSvgPaint(element as SvgStyleableElement, "fill");

            return(paint.GetBrush(gp));
        }
Пример #8
0
        public override void Render(ISvgRenderer renderer)
        {
            GdiRenderer     gdiRenderer = renderer as GdiRenderer;
            GraphicsWrapper graphics    = gdiRenderer.GraphicsWrapper;

            if (!(element is SvgClipPathElement) && !(element.ParentNode is SvgClipPathElement))
            {
                SvgStyleableElement styleElm = element as SvgStyleableElement;
                if (styleElm != null)
                {
                    string sVisibility = styleElm.GetPropertyValue("visibility");
                    string sDisplay    = styleElm.GetPropertyValue("display");

                    if (element is ISharpGDIPath && sVisibility != "hidden" && sDisplay != "none")
                    {
                        GraphicsPath gp = ((ISharpGDIPath)element).GetGraphicsPath();

                        if (gp != null)
                        {
                            Clip(graphics);

                            GdiSvgPaint fillPaint = new GdiSvgPaint(styleElm, "fill");
                            Brush       brush     = fillPaint.GetBrush(gp);

                            GdiSvgPaint strokePaint = new GdiSvgPaint(styleElm, "stroke");
                            Pen         pen         = strokePaint.GetPen(gp);

                            if (brush != null)
                            {
                                if (brush is PathGradientBrush)
                                {
                                    GradientPaintServer gps = fillPaint.PaintServer as GradientPaintServer;
                                    //GraphicsContainer container = graphics.BeginContainer();

                                    graphics.SetClip(gps.GetRadialGradientRegion(gp.GetBounds()), CombineMode.Exclude);

                                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)brush).InterpolationColors.Colors[0]);
                                    graphics.FillPath(this, tempBrush, gp);
                                    tempBrush.Dispose();
                                    graphics.ResetClip();

                                    //graphics.EndContainer(container);
                                }

                                graphics.FillPath(this, brush, gp);
                                brush.Dispose();
                            }

                            if (pen != null)
                            {
                                if (pen.Brush is PathGradientBrush)
                                {
                                    GradientPaintServer      gps       = strokePaint.PaintServer as GradientPaintServer;
                                    GraphicsContainerWrapper container = graphics.BeginContainer();

                                    graphics.SetClip(gps.GetRadialGradientRegion(gp.GetBounds()), CombineMode.Exclude);

                                    SolidBrush tempBrush = new SolidBrush(((PathGradientBrush)pen.Brush).InterpolationColors.Colors[0]);
                                    Pen        tempPen   = new Pen(tempBrush, pen.Width);
                                    graphics.DrawPath(this, tempPen, gp);
                                    tempPen.Dispose();
                                    tempBrush.Dispose();

                                    graphics.EndContainer(container);
                                }

                                graphics.DrawPath(this, pen, gp);
                                pen.Dispose();
                            }
                        }
                    }
                    PaintMarkers(gdiRenderer, styleElm, graphics);
                }
            }
        }