GetPen() 공개 메소드

public GetPen ( GraphicsPath gp ) : Pen
gp System.Drawing.Drawing2D.GraphicsPath
리턴 System.Drawing.Pen
예제 #1
0
        public void TestCurrentColor()
        {
            elm.SetAttribute("stroke", "currentColor");
            elm.SetAttribute("color", "red");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");

            Pen pen = paint.GetPen(getGp());

            Assert.IsTrue(isSameColor(Color.Red, pen.Color));
        }
예제 #2
0
        public void TestColorStroke()
        {
            elm.SetAttribute("stroke", "green");
            elm.SetAttribute("stroke-width", "23px");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");

            Pen pen = paint.GetPen(getGp());

            Assert.IsTrue(isSameColor(Color.Green, pen.Color));
            Assert.AreEqual(23, pen.Width);
        }
예제 #3
0
        public void TestDashPattern()
        {
            elm.SetAttribute("stroke", "white");
            elm.SetAttribute("stroke-width", "2px");
            elm.SetAttribute("stroke-dasharray", "5,3,2");
            //elm.SetAttribute("stroke-dashoffset", "0.5");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");
            Pen pen = paint.GetPen(getGp());
            float[] correct = new float[]{2.5F, 1.5F, 1F, 2.5F, 1.5F, 1F};
            float[] actual = pen.DashPattern;

            Assert.AreEqual(6, actual.Length);
            Assert.AreEqual(2.5F, actual[0]);
            Assert.AreEqual(1.5F, actual[1]);
            Assert.AreEqual(1F, actual[2]);

            Assert.AreEqual(2.5F, actual[3]);
            Assert.AreEqual(1.5F, actual[4]);
            Assert.AreEqual(1F, actual[5]);
        }
예제 #4
0
        public void TestNone()
        {
            elm.SetAttribute("stroke", "none");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");
            Pen pen = paint.GetPen(getGp());

            Assert.IsNull(pen);
        }
예제 #5
0
        public void TestOpacityStroke()
        {
            elm.SetAttribute("stroke", "white");
            elm.SetAttribute("opacity", "0.5");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");

            Pen pen = paint.GetPen(getGp());
            Assert.AreEqual(128, pen.Color.A);
        }
예제 #6
0
 public void TestOpacityStrokeOpacityAndOpacity()
 {
     elm.SetAttribute("stroke", "white");
     elm.SetAttribute("opacity", "0.1");
     elm.SetAttribute("stroke-opacity", "0.5");
     GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");
     Pen pen = paint.GetPen(getGp());
     Assert.AreEqual(Convert.ToInt32(255*0.1*0.5), pen.Color.A);
 }
예제 #7
0
        public void TestNonExistingGradientRgbColor()
        {
            elm.SetAttribute("stroke", "url(#myGradient) blue");
            GdiSvgPaint paint = new GdiSvgPaint(elm, "stroke");

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

            Pen pen = paint.GetPen(getGp());
            Assert.IsTrue(isSameColor(Color.Blue, pen.Color));
        }
        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 Pen GetPen(GraphicsPath gp)
 {
     GdiSvgPaint paint = new GdiSvgPaint(element as SvgStyleableElement, "stroke");
     return paint.GetPen(gp);
 }
예제 #10
0
        private Pen GetPen(GraphicsPath gp)
        {
            GdiSvgPaint paint = new GdiSvgPaint(element as SvgStyleableElement, "stroke");

            return(paint.GetPen(gp));
        }
예제 #11
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);
                }
            }
        }