protected static void PaintMarkers(GdiGraphicsRenderer renderer, SvgStyleableElement styleElm, GdiGraphicsWrapper gr) { // OPTIMIZE if (styleElm is ISharpMarkerHost) { string markerStartUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-start", "marker")); string markerMiddleUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-mid", "marker")); string markerEndUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-end", "marker")); if (markerStartUrl.Length > 0) { GdiMarkerRendering grNode = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerStartUrl) as GdiMarkerRendering; if (grNode != null) { grNode.PaintMarker(renderer, gr, SvgMarkerPosition.Start, styleElm); } } if (markerMiddleUrl.Length > 0) { // TODO markerMiddleUrl != markerStartUrl GdiMarkerRendering grNode = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerMiddleUrl) as GdiMarkerRendering; if (grNode != null) { grNode.PaintMarker(renderer, gr, SvgMarkerPosition.Mid, styleElm); } } if (markerEndUrl.Length > 0) { // TODO: markerEndUrl != markerMiddleUrl GdiMarkerRendering grNode = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerEndUrl) as GdiMarkerRendering; if (grNode != null) { grNode.PaintMarker(renderer, gr, SvgMarkerPosition.End, styleElm); } } } }
protected static void RenderMarkers(WpfDrawingRenderer renderer, SvgStyleableElement styleElm, WpfDrawingContext gr) { // OPTIMIZE if (styleElm is ISharpMarkerHost) { string markerStartUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-start", "marker")); string markerMiddleUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-mid", "marker")); string markerEndUrl = ExtractMarkerUrl(styleElm.GetPropertyValue("marker-end", "marker")); if (markerStartUrl.Length > 0) { WpfMarkerRendering markerRenderer = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerStartUrl) as WpfMarkerRendering; if (markerRenderer != null) { markerRenderer.RenderMarker(renderer, gr, SvgMarkerPosition.Start, styleElm); } } if (markerMiddleUrl.Length > 0) { // TODO markerMiddleUrl != markerStartUrl WpfMarkerRendering markerRenderer = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerMiddleUrl) as WpfMarkerRendering; if (markerRenderer != null) { markerRenderer.RenderMarker(renderer, gr, SvgMarkerPosition.Mid, styleElm); } } if (markerEndUrl.Length > 0) { // TODO: markerEndUrl != markerMiddleUrl WpfMarkerRendering markerRenderer = CreateByUri(styleElm.OwnerDocument, styleElm.BaseURI, markerEndUrl) as WpfMarkerRendering; if (markerRenderer != null) { markerRenderer.RenderMarker(renderer, gr, SvgMarkerPosition.End, styleElm); } } } }
public void RenderMarker0(WpfDrawingRenderer renderer, WpfDrawingContext gr, SvgMarkerPosition markerPos, SvgStyleableElement refElement) { //PathGeometry g; //g.GetPointAtFractionLength( ISharpMarkerHost markerHostElm = (ISharpMarkerHost)refElement; SvgMarkerElement markerElm = (SvgMarkerElement)_svgElement; SvgPointF[] 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++) { SvgPointF point = vertexPositions[i]; Matrix m = GetTransformMatrix(_svgElement); //GraphicsContainer gc = gr.BeginContainer(); this.BeforeRender(renderer); //gr.TranslateTransform(point.X, point.Y); //PAUL: //m.Translate(point.X, point.Y); if (markerElm.OrientType.AnimVal.Equals(SvgMarkerOrient.Angle)) { m.Rotate(markerElm.OrientAngle.AnimVal.Value); //gr.RotateTransform((double)markerElm.OrientAngle.AnimVal.Value); } else { double 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); m.Rotate(angle); } if (markerElm.MarkerUnits.AnimVal.Equals(SvgMarkerUnit.StrokeWidth)) { string propValue = refElement.GetPropertyValue("stroke-width"); if (propValue.Length == 0) propValue = "1"; SvgLength strokeWidthLength = new SvgLength("stroke-width", propValue, refElement, SvgLengthDirection.Viewport); double strokeWidth = strokeWidthLength.Value; //gr.ScaleTransform(strokeWidth, strokeWidth); m.Scale(strokeWidth, strokeWidth); } SvgPreserveAspectRatio spar = (SvgPreserveAspectRatio)markerElm.PreserveAspectRatio.AnimVal; double[] translateAndScale = spar.FitToViewBox( (SvgRect)markerElm.ViewBox.AnimVal, new SvgRect(0, 0, markerElm.MarkerWidth.AnimVal.Value, markerElm.MarkerHeight.AnimVal.Value)); //PAUL: //m.Translate(-(double)markerElm.RefX.AnimVal.Value * translateAndScale[2], -(double)markerElm.RefY.AnimVal.Value * translateAndScale[3]); //PAUL: m.Scale(translateAndScale[2], translateAndScale[3]); m.Translate(point.X, point.Y); //Matrix oldTransform = TransformMatrix; //TransformMatrix = m; //try //{ //newTransform.Append(m); //TransformGroup tg = new TransformGroup(); //renderer.Canvas.re //gr.TranslateTransform( // -(double)markerElm.RefX.AnimVal.Value * translateAndScale[2], // -(double)markerElm.RefY.AnimVal.Value * translateAndScale[3] // ); //gr.ScaleTransform(translateAndScale[2], translateAndScale[3]); renderer.RenderChildren(markerElm); // markerElm.RenderChildren(renderer); //} //finally //{ // TransformMatrix = oldTransform; //} // //gr.EndContainer(gc); _matrix = m; this.Render(renderer); //gr.EndContainer(gc); this.AfterRender(renderer); } }
private void PaintMarkers(GdiRenderer renderer, SvgStyleableElement styleElm, GraphicsWrapper gr) { // OPTIMIZE if ( styleElm is ISharpMarkerHost ) { string markerStartUrl = extractMarkerUrl(styleElm.GetPropertyValue("marker-start", "marker")); string markerMiddleUrl = extractMarkerUrl(styleElm.GetPropertyValue("marker-mid", "marker")); string markerEndUrl = extractMarkerUrl(styleElm.GetPropertyValue("marker-end", "marker")); RenderingNode grNode; if ( markerStartUrl.Length > 0 ) { grNode = renderer.GetGraphicsNodeByUri(styleElm.BaseURI, markerStartUrl); if (grNode is SvgMarkerGraphicsNode) { ((SvgMarkerGraphicsNode) grNode).PaintMarker(renderer, gr, SvgMarkerPosition.Start, styleElm); } } if ( markerMiddleUrl.Length > 0 ) { // TODO markerMiddleUrl != markerStartUrl grNode = renderer.GetGraphicsNodeByUri(styleElm.BaseURI, markerMiddleUrl); if ( grNode is SvgMarkerGraphicsNode ) { ((SvgMarkerGraphicsNode) grNode).PaintMarker(renderer, gr, SvgMarkerPosition.Mid, styleElm); } } if ( markerEndUrl.Length > 0 ) { // TODO: markerEndUrl != markerMiddleUrl grNode = renderer.GetGraphicsNodeByUri(styleElm.BaseURI, markerEndUrl); if(grNode is SvgMarkerGraphicsNode) { ((SvgMarkerGraphicsNode) grNode).PaintMarker(renderer, gr, SvgMarkerPosition.End, styleElm); } } } }