public override void AfterRender(WpfDrawingRenderer renderer) { if (_drawGroup != null) { WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); if (_drawGroup.Children.Count == 0) { DrawingGroup curGroup = _context.Peek(); if (curGroup != null) { curGroup.Children.Remove(_drawGroup); } } } base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } // Remove the added group from the stack... context.Pop(); // If the group is empty, we simply remove it... if (_drawGroup.Children.Count == 0 && _drawGroup.ClipGeometry == null && _drawGroup.Transform == null) { currentGroup = context.Peek(); if (currentGroup != null) { currentGroup.Children.Remove(_drawGroup); } } base.AfterRender(renderer); }
private void OnAfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); // Support for Tiny 1.2 viewport-fill property... if (_svgElement.HasAttribute("viewport-fill")) { var viewportFill = _svgElement.GetAttribute("viewport-fill"); if (!string.IsNullOrWhiteSpace(viewportFill)) { SvgSvgElement svgElm = (SvgSvgElement)_svgElement; var brush = WpfFill.CreateViewportBrush(svgElm); if (brush != null) { var bounds = new RectangleGeometry(_drawGroup.Bounds); var drawing = new GeometryDrawing(brush, null, bounds); _drawGroup.Children.Insert(0, drawing); } } } WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); if (_isRoot && !context.IsFragment) { this.AdjustViewbox(); } if (_isRoot || context.IsFragment) { return; } DrawingGroup drawGroup = CreateOuterGroup(); if (drawGroup == null) { return; } currentGroup = context.Peek(); if (currentGroup == null || currentGroup.Children.Remove(_drawGroup) == false) { return; } drawGroup.Children.Add(_drawGroup); currentGroup.Children.Add(drawGroup); }
public override void AfterRender(WpfDrawingRenderer renderer) { if (_isLayer) { WpfDrawingContext context = renderer.Context; context.Pop(); base.AfterRender(renderer); return; } if (_drawGroup != null) { WpfDrawingContext context = renderer.Context; if (context.IncludeRuntime) { // Add the element/object type... SvgObject.SetType(_drawGroup, SvgObjectType.Link); // Add title for tooltips, if any... SvgTitleElement titleElement = this.GetTitleElement(); if (titleElement != null) { string titleValue = titleElement.InnerText; if (!string.IsNullOrWhiteSpace(titleValue)) { SvgObject.SetTitle(_drawGroup, titleValue); } } } DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); // If not aggregated by a link visitor, we remove it from the links/animation and // add it to the main drawing stack... if (!_isAggregated) { if (context.Links.Children.Remove(_drawGroup)) { currentGroup = context.Peek(); currentGroup.Children.Add(_drawGroup); } } } base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { WpfDrawingContext context = renderer.Context; if (_drawGroup != null) { context.Pop(); } base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } ISvgAnimatedEnumeration markerUnits = _markerElement.MarkerUnits; if (markerUnits.AnimVal.Equals((ushort)SvgMarkerUnit.StrokeWidth)) { var comparer = StringComparison.OrdinalIgnoreCase; string overflowAttr = _markerElement.GetAttribute("overflow"); if (string.IsNullOrWhiteSpace(overflowAttr) || overflowAttr.Equals("scroll", comparer) || overflowAttr.Equals("hidden", comparer)) { Geometry markerClip = this.ClipGeometry; if (markerClip == null || markerClip.IsEmpty()) { SvgRect clipRect = (SvgRect)_markerElement.ViewBox.AnimVal; if (clipRect != null && !clipRect.IsEmpty) { _drawGroup.ClipGeometry = new RectangleGeometry( new Rect(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height)); } else if (_markerElement.IsSizeDefined) { _drawGroup.ClipGeometry = new RectangleGeometry(new Rect(0, 0, _markerElement.MarkerWidth.AnimVal.Value, _markerElement.MarkerHeight.AnimVal.Value)); } } } } context.Pop(); base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { base.AfterRender(renderer); Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); if (_isRoot && !context.IsFragment) { this.AdjustViewbox(); } if (_isRoot || context.IsFragment) { return; } DrawingGroup drawGroup = CreateOuterGroup(); if (drawGroup == null) { return; } currentGroup = context.Peek(); if (currentGroup == null || currentGroup.Children.Remove(_drawGroup) == false) { return; } drawGroup.Children.Add(_drawGroup); currentGroup.Children.Add(drawGroup); }
public override void AfterRender(WpfDrawingRenderer renderer) { WpfDrawingContext context = renderer.Context; if (_drawGroup != null) { context.Pop(); if (_drawGroup.Children.Count == 0) { DrawingGroup curGroup = _context.Peek(); if (curGroup != null) { curGroup.Children.Remove(_drawGroup); } } } base.AfterRender(renderer); }
public override void AfterRender(WpfDrawingRenderer renderer) { if (_horzRenderer != null) { _horzRenderer.Uninitialize(); _horzRenderer = null; } if (_vertRenderer != null) { _vertRenderer.Uninitialize(); _vertRenderer = null; } if (_pathRenderer != null) { _pathRenderer.Uninitialize(); _pathRenderer = null; } if (_drawContext != null) { _drawContext.Close(); _drawContext = null; } WpfDrawingContext context = renderer.Context; // TODO-PAUL: Testing this for validity... // Remove the GuidelineSet from the groups added by the FormattedText to reduced the // size of output XAML... if (_drawGroup != null) { ResetGuidelineSet(_drawGroup); } if (context.IncludeRuntime) { if (_drawGroup != null) { // Add the element/object type... SvgObject.SetType(_drawGroup, SvgObjectType.Text); // Add title for tooltips, if any... SvgTitleElement titleElement = _svgElement.SelectSingleNode("title") as SvgTitleElement; if (titleElement != null) { string titleValue = titleElement.InnerText; if (!string.IsNullOrWhiteSpace(titleValue)) { SvgObject.SetTitle(_drawGroup, titleValue); } } } } if (!_isGroupAdded) { if (_drawGroup != null) { if (_isTextPath || _drawGroup.Transform != null || _drawGroup.ClipGeometry != null) { DrawingGroup curGroup = _context.Peek(); Debug.Assert(curGroup != null); if (curGroup != null) { curGroup.Children.Add(_drawGroup); } } else if (_drawGroup.Children.Count != 0) { DrawingGroup firstGroup = _drawGroup.Children[0] as DrawingGroup; if (firstGroup != null && firstGroup.Children.Count != 0) { //Drawing firstDrawing = firstGroup.Children[0]; DrawingGroup curGroup = _context.Peek(); Debug.Assert(curGroup != null); if (curGroup != null) { curGroup.Children.Add(_drawGroup); } } } } } else { if (_drawGroup != null) { DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); } } _context = null; _drawGroup = null; base.AfterRender(renderer); }
private void OnAfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } context.Pop(); DrawingGroup drawGroup = CreateOuterGroup(); if (drawGroup == null) { return; } SvgSymbolElement symbolElement = (SvgSymbolElement)_svgElement; var transform = _drawGroup.Transform; Transform useTransform = null; XmlNode childNode = _svgElement.FirstChild; string childName = childNode.Name; try { // If none of the following attribute exists, an exception is thrown... double x = symbolElement.X.AnimVal.Value; double y = symbolElement.Y.AnimVal.Value; double width = symbolElement.Width.AnimVal.Value; double height = symbolElement.Height.AnimVal.Value; if (width > 0 && height > 0) { Rect elementBounds = new Rect(x, y, width, height); useTransform = this.UseFitToViewbox(symbolElement, elementBounds); } } catch (Exception ex) { Trace.TraceError(ex.ToString()); } if (useTransform != null) { if (transform == null) { transform = useTransform; } else // if (transform != null) { transform = Combine(useTransform, transform, true); } } _drawGroup.Transform = transform; currentGroup = context.Peek(); if (currentGroup == null || currentGroup.Children.Remove(_drawGroup) == false) { return; } drawGroup.Children.Add(_drawGroup); currentGroup.Children.Add(drawGroup); }
public override void AfterRender(WpfDrawingRenderer renderer) { Debug.Assert(_drawGroup != null); WpfDrawingContext context = renderer.Context; DrawingGroup currentGroup = context.Peek(); if (currentGroup == null || currentGroup != _drawGroup) { throw new InvalidOperationException("An existing group is expected."); } ISvgAnimatedEnumeration markerUnits = _markerElement.MarkerUnits; if (markerUnits.AnimVal.Equals((ushort)SvgMarkerUnit.StrokeWidth)) { var comparer = StringComparison.OrdinalIgnoreCase; string overflowAttr = _markerElement.GetAttribute("overflow"); if (string.IsNullOrWhiteSpace(overflowAttr) || overflowAttr.Equals("scroll", comparer) || overflowAttr.Equals("hidden", comparer)) { Geometry markerClip = this.ClipGeometry; if (markerClip == null || markerClip.IsEmpty()) { SvgRect clipRect = (SvgRect)_markerElement.ViewBox.AnimVal; if (clipRect != null && !clipRect.IsEmpty) { _drawGroup.ClipGeometry = new RectangleGeometry( new Rect(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height)); } else if (_markerElement.IsSizeDefined) { _drawGroup.ClipGeometry = new RectangleGeometry(new Rect(0, 0, _markerElement.MarkerWidth.AnimVal.Value, _markerElement.MarkerHeight.AnimVal.Value)); } else if (_hostElement != null) { // Special cases for zero-length 'path' and 'line' segments. var isLineSegment = false; if (_hostGeometry != null) { var bounds = _hostGeometry.Bounds; if (string.Equals(_hostElement.LocalName, "line", StringComparison.Ordinal)) { isLineSegment = true; } else if (string.Equals(_hostElement.LocalName, "rect", StringComparison.Ordinal)) { isLineSegment = bounds.Width.Equals(0) || bounds.Height.Equals(0); } else if (string.Equals(_hostElement.LocalName, "path", StringComparison.Ordinal)) { isLineSegment = bounds.Width.Equals(0) || bounds.Height.Equals(0); } } else { if (string.Equals(_hostElement.LocalName, "line", StringComparison.Ordinal)) { isLineSegment = true; } } if (isLineSegment) { bool isZeroWidthLine = false; if (_pathFigures != null) { if (_pathFigures.Count == 0) { isZeroWidthLine = true; } else { var pathWidth = 0.0d; foreach (PathFigure pathFigure in _pathFigures) { pathWidth += WpfConvert.GetPathFigureLength(pathFigure); } isZeroWidthLine = pathWidth.Equals(0.0d); } } if (isZeroWidthLine) { _drawGroup.ClipGeometry = new RectangleGeometry(new Rect(0, 0, _markerElement.MarkerWidth.AnimVal.Value, _markerElement.MarkerHeight.AnimVal.Value)); } } } } } } context.Pop(); base.AfterRender(renderer); }