Wraps a GraphicsContainer because it is sealed. This is a helper for GraphicsWrapper so that it can save multiple container states. It holds the containers for both the idMapGraphics and the main graphics being rendered in the GraphicsWrapper.
 public void EndContainer(GraphicsContainerWrapper container)
 {
     if (_idMapGraphics != null)
     {
         _idMapGraphics.EndContainer(container.idmapGraphicsContainer);
     }
     _graphics.EndContainer(container.mainGraphicsContainer);
 }
        public GraphicsContainerWrapper BeginContainer()
        {
            GraphicsContainerWrapper container = new GraphicsContainerWrapper();

            if (_idMapGraphics != null)
            {
                container.idmapGraphicsContainer = _idMapGraphics.BeginContainer();
            }
            container.mainGraphicsContainer = _graphics.BeginContainer();
            return(container);
        }
예제 #3
0
        public override void BeforeRender(ISvgRenderer renderer)
        {
            if (_uniqueColor.IsEmpty)
            _uniqueColor = ((GdiRenderer)renderer)._getNextColor(this);

              GraphicsWrapper graphics = ((GdiRenderer) renderer).GraphicsWrapper;

              graphicsContainer = graphics.BeginContainer();
              SetQuality(graphics);
              Transform(graphics);
              Clip(graphics);
        }
예제 #4
0
        public override void BeforeRender(ISvgRenderer renderer)
        {
            if (_uniqueColor.IsEmpty)
            {
                _uniqueColor = ((GdiRenderer)renderer)._getNextColor(this);
            }

            GraphicsWrapper graphics = ((GdiRenderer)renderer).GraphicsWrapper;

            graphicsContainer = graphics.BeginContainer();
            SetQuality(graphics);
            Transform(graphics);
            Clip(graphics);
        }
        public void PaintMarker(GdiRenderer renderer, GraphicsWrapper gr, SvgMarkerPosition markerPos, SvgStyleableElement refElement)
        {
            ISharpMarkerHost markerHostElm = (ISharpMarkerHost)refElement;
            SvgMarkerElement markerElm     = (SvgMarkerElement)element;

            PointF[] vertexPositions = markerHostElm.MarkerPositions;
            int      start;
            int      len;

            // Choose which part of the position array to use
            switch (markerPos)
            {
            case SvgMarkerPosition.Start:
                start = 0;
                len   = 1;
                break;

            case SvgMarkerPosition.Mid:
                start = 1;
                len   = vertexPositions.Length - 2;
                break;

            default:
                // == MarkerPosition.End
                start = vertexPositions.Length - 1;
                len   = 1;
                break;
            }

            for (int i = start; i < start + len; i++)
            {
                PointF point = vertexPositions[i];

                GraphicsContainerWrapper gc = gr.BeginContainer();

                gr.TranslateTransform(point.X, point.Y);

                if (markerElm.OrientType.AnimVal.Equals(SvgMarkerOrient.Angle))
                {
                    gr.RotateTransform((float)markerElm.OrientAngle.AnimVal.Value);
                }
                else
                {
                    float angle;

                    switch (markerPos)
                    {
                    case SvgMarkerPosition.Start:
                        angle = markerHostElm.GetStartAngle(i + 1);
                        break;

                    case SvgMarkerPosition.Mid:
                        //angle = (markerHostElm.GetEndAngle(i) + markerHostElm.GetStartAngle(i + 1)) / 2;
                        angle = SvgNumber.CalcAngleBisection(markerHostElm.GetEndAngle(i), markerHostElm.GetStartAngle(i + 1));
                        break;

                    default:
                        angle = markerHostElm.GetEndAngle(i);
                        break;
                    }
                    gr.RotateTransform(angle);
                }

                if (markerElm.MarkerUnits.AnimVal.Equals(SvgMarkerUnit.StrokeWidth))
                {
                    SvgLength strokeWidthLength = new SvgLength(refElement, "stroke-width", SvgLengthSource.Css, SvgLengthDirection.Viewport, "1");
                    float     strokeWidth       = (float)strokeWidthLength.Value;
                    gr.ScaleTransform(strokeWidth, strokeWidth);
                }

                SvgPreserveAspectRatio spar = (SvgPreserveAspectRatio)markerElm.PreserveAspectRatio.AnimVal;
                float[] translateAndScale   = spar.FitToViewBox(
                    (SvgRect)markerElm.ViewBox.AnimVal,
                    new SvgRect(
                        0,
                        0,
                        (float)markerElm.MarkerWidth.AnimVal.Value,
                        (float)markerElm.MarkerHeight.AnimVal.Value)
                    );


                gr.TranslateTransform(
                    -(float)markerElm.RefX.AnimVal.Value * translateAndScale[2],
                    -(float)markerElm.RefY.AnimVal.Value * translateAndScale[3]
                    );

                gr.ScaleTransform(translateAndScale[2], translateAndScale[3]);

                Clip(gr);

                markerElm.RenderChildren(renderer);

                gr.EndContainer(gc);
            }
        }
예제 #6
0
 public void EndContainer(GraphicsContainerWrapper container)
 {
     if(_idMapGraphics != null) _idMapGraphics.EndContainer(container.idmapGraphicsContainer);
     _graphics.EndContainer(container.mainGraphicsContainer);
 }
예제 #7
0
 public GraphicsContainerWrapper BeginContainer()
 {
     GraphicsContainerWrapper container = new GraphicsContainerWrapper();
     if(_idMapGraphics != null) container.idmapGraphicsContainer = _idMapGraphics.BeginContainer();
     container.mainGraphicsContainer = _graphics.BeginContainer();
       return container;
 }
예제 #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);
                }
            }
        }