public SvgElementInstance(XmlNode refNode, SvgUseElement useElement, SvgElementInstance parent) { correspondingUseElement = (ISvgUseElement)useElement; parentNode = (SvgElementInstance)parent; correspondingElement = (ISvgElement)refNode; eventTarget = new EventTarget(this); }
/// <summary> /// Generates a new <see cref="RenderingNode">RenderingNode</see> that /// corresponds to the given Uri. /// </summary> /// <param name="baseUri"> /// The base Uri. /// </param> /// <param name="url"> /// The url. /// </param> /// <returns> /// The generated <see cref="RenderingNode">RenderingNode</see> that /// corresponds to the given Uri. /// </returns> public RenderingNode GetGraphicsNodeByUri( string baseUri, string url) { if (url.StartsWith("#")) { // do nothing } else if (baseUri != "") { Uri absoluteUri = new Uri(new Uri(baseUri), url); url = absoluteUri.AbsoluteUri; } else { // TODO: Handle xml:base here? // Right now just skip this... it can't be resolved, must assume it is absolute } ISvgElement elm = ((SvgDocument)Window.Document).GetNodeByUri(url) as ISvgElement; if (elm != null) { return(GetRenderingNode(elm)); } else { return(null); } }
public static bool TryGetTransform(ISvgTransformable element, out Transform transform) { transform = null; if (element == null) { return(false); } ISvgTransformList svgTList = element.Transform.AnimVal; ISvgMatrix svgMatrix = ((SvgTransformList)element.Transform.AnimVal).TotalMatrix; ISvgElement nVE = element.NearestViewportElement; if (nVE != null) { SvgTransformableElement par = (element as SvgElement).ParentNode as SvgTransformableElement; while (par != null && par != nVE) { svgTList = par.Transform.AnimVal; svgMatrix = svgTList.Consolidate().Matrix.Multiply(svgMatrix); par = par.ParentNode as SvgTransformableElement; } } if (svgMatrix.IsIdentity) { transform = Transform.Identity; return(false); } transform = new MatrixTransform(ToWpfMatrix(svgMatrix)); return(true); }
private static void AddToElement <TElem, TAttrib>(ISvgElement <TElem, TAttrib> svgElement, object attributeToAdd) where TElem : class, TAttrib where TAttrib : class { if (attributeToAdd == null) { return; } if (attributeToAdd is ITransformationAttribute) { svgElement.TransformationAttribute = (ITransformationAttribute)attributeToAdd; } else if (attributeToAdd is IdAttribute) { svgElement.IdAttribute = (IdAttribute)attributeToAdd; } else if (attributeToAdd is ISvgAttribute <TAttrib> ) { svgElement.GenericAttributes.Add((ISvgAttribute <TAttrib>)attributeToAdd); } else if (attributeToAdd is ISvgAttribute <TElem> ) { svgElement.ElementAttributes.Add((ISvgAttribute <TElem>)attributeToAdd); } }
public MoveEventArgs(ISvgElement element,PointF before,PointF after) { svgelement = element; beforeMove = before; afterMove = after; Cancel = false; }
// Methods public CollectionChangedEventArgs(ISvgElement element) { ISvgElement[] elementArray1 = new ISvgElement[1] { element }; this.ChangeElements = elementArray1; }
public void Render(ISvgElement node) { //throw new NotImplementedException(); //SvgRectF updatedRect; //if (invalidRect != SvgRectF.Empty) // updatedRect = new SvgRectF(invalidRect.X, invalidRect.Y, // invalidRect.Width, invalidRect.Height); //else // updatedRect = SvgRectF.Empty; //RendererBeforeRender(); //if (graphics != null && graphics.Graphics != null) //{ // _svgRenderer.Render(node); //} //RendererAfterRender(); //if (onRender != null) // OnRender(updatedRect); _renderingContext = new WpfDrawingContext(true, _renderingSettings); _renderingContext.Initialize(null, _fontFamilyVisitor, _imageVisitor); _renderingContext.BeginDrawing(); _svgRenderer.Render(node); _renderingContext.EndDrawing(); }
public void Render(ISvgElement node) { if (node is Dom.IElementVisitorTarget evt) { RenderElement(evt); } }
private void RenderElement(ISvgElement svgElement) { bool isNotRenderable = !svgElement.IsRenderable || string.Equals(svgElement.LocalName, "a"); if (isNotRenderable) { return; } GdiRenderingBase renderingNode = GdiRendering.Create(svgElement); if (renderingNode == null) { return; } if (!renderingNode.NeedRender(_renderer)) { renderingNode.Dispose(); renderingNode = null; return; } bool shouldRender = true; SvgStyleableElement stylable = svgElement as SvgStyleableElement; if (stylable != null) { string sVisibility = stylable.GetPropertyValue("visibility"); string sDisplay = stylable.GetPropertyValue("display"); if (string.Equals(sVisibility, "hidden") || string.Equals(sDisplay, "none")) { shouldRender = false; } } if (shouldRender) { //_rendererMap[svgElement] = renderingNode; _rendererMap.Push(renderingNode); renderingNode.BeforeRender(_renderer); renderingNode.Render(_renderer); if (!renderingNode.IsRecursive && svgElement.HasChildNodes) { RenderChildren(svgElement); } //renderingNode = _rendererMap[svgElement]; renderingNode = _rendererMap.Pop(); Debug.Assert(renderingNode.Element == svgElement); renderingNode.AfterRender(_renderer); //_rendererMap.Remove(svgElement); } renderingNode.Dispose(); renderingNode = null; }
private void RenderUseElement(ISvgElement svgElement) { SvgUseElement useElement = (SvgUseElement)svgElement; int hashCode = useElement.OuterXml.GetHashCode(); if (!this.BeginUseElement(hashCode)) { return; } SvgDocument document = useElement.OwnerDocument; XmlElement refEl = useElement.ReferencedElement; if (refEl == null) { this.EndUseElement(hashCode); return; } // For the external node, the documents are different, and we may not be // able to insert this node, so we first import it... if (useElement.OwnerDocument != refEl.OwnerDocument) { XmlElement importedNode = useElement.OwnerDocument.ImportNode(refEl, true) as XmlElement; if (importedNode != null) { SvgElement importedSvgElement = importedNode as SvgElement; if (importedSvgElement != null) { importedSvgElement.Imported = true; importedSvgElement.ImportNode = refEl as SvgElement; importedSvgElement.ImportDocument = refEl.OwnerDocument as SvgDocument; } refEl = importedNode; } } else { // For elements/nodes within the same document, clone it. refEl = (XmlElement)refEl.CloneNode(true); } // Reset any ID on the cloned/copied element to avoid duplication of IDs. // refEl.SetAttribute("id", ""); useElement.OwnerDocument.Static = true; useElement.CopyToReferencedElement(refEl); useElement.AppendChild(refEl); // Now, render the use element... this.RenderElement(svgElement); useElement.RemoveChild(refEl); useElement.RestoreReferencedElement(refEl); this.EndUseElement(hashCode); }
public int Add(ISvgElement value) { if (value == null) { return(-1); } int num1 = -1; num1 = base.List.IndexOf(value); if (!(num1 >= 0 && num1 <= List.Count - 1)) { if (value is ItopVector.Core.Figure.ConnectLine) { num1 = 0; this.List.Insert(0, value); } else { num1 = base.List.Add(value); } } if ((this.OnCollectionChangedEvent != null) && this.NotifyEvent) { this.OnCollectionChangedEvent(this, new CollectionChangedEventArgs(value)); } return(num1); }
/// <summary> /// Renders the <see cref="SvgElement">SvgElement</see>. /// </summary> /// <param name="node"> /// The <see cref="SvgElement">SvgElement</see> node to be /// rendered /// </param> /// <returns> /// The bitmap on which the rendering was performed. /// </returns> public void Render(ISvgElement node) { SvgRectF updatedRect; if (invalidRect != SvgRectF.Empty) { updatedRect = new SvgRectF(invalidRect.X, invalidRect.Y, invalidRect.Width, invalidRect.Height); } else { updatedRect = SvgRectF.Empty; } RendererBeforeRender(); if (graphics != null && graphics.Graphics != null) { _svgRenderer.Render(node); } RendererAfterRender(); if (onRender != null) { OnRender(updatedRect); } }
public static GraphicsPath CreatePath(ISvgElement element) { if (element == null || element.RenderingHint != SvgRenderingHint.Shape) { return(null); } string localName = element.LocalName; switch (localName) { case "ellipse": return(CreatePath((SvgEllipseElement)element)); case "rect": return(CreatePath((SvgRectElement)element)); case "line": return(CreatePath((SvgLineElement)element)); case "path": return(CreatePath((SvgPathElement)element)); case "circle": return(CreatePath((SvgCircleElement)element)); case "polyline": return(CreatePath((SvgPolylineElement)element)); case "polygon": return(CreatePath((SvgPolygonElement)element)); } return(null); }
public SvgElementInstance(XmlNode refNode, SvgUseElement useElement, SvgElementInstance parent) { _correspondingUseElement = useElement; _parentNode = parent; _correspondingElement = refNode as ISvgElement; _eventTarget = new EventTarget(this); }
/// <summary> /// Generates a new <see cref="RenderingNode">RenderingNode</see> that /// corresponds to the given Uri. /// </summary> /// <param name="baseUri"> /// The base Uri. /// </param> /// <param name="url"> /// The url. /// </param> /// <returns> /// The generated <see cref="RenderingNode">RenderingNode</see> that /// corresponds to the given Uri. /// </returns> public static GdiRendering CreateByUri(SvgDocument document, string baseUri, string url) { if (url.StartsWith("#")) { // do nothing } else if (baseUri != "") { Uri absoluteUri = new Uri(new Uri(baseUri), url); url = absoluteUri.AbsoluteUri; } else { // TODO: Handle xml:base here? // Right now just skip this... it can't be resolved, must assume it is absolute } ISvgElement elm = document.GetNodeByUri(url) as ISvgElement; if (elm != null) { return(GdiRendering.Create(elm)); } else { return(null); } }
public int Add(ISvgElement value) { if (value == null) { return -1; } int num1 =-1; num1 = base.List.IndexOf(value); if(!(num1>=0 && num1<=List.Count -1)) { if (value is ItopVector.Core.Figure.ConnectLine) { num1=0; this.List.Insert(0,value); } else { num1 =base.List.Add(value); } } if ((this.OnCollectionChangedEvent != null) && this.NotifyEvent) { this.OnCollectionChangedEvent(this, new CollectionChangedEventArgs(value)); } return num1; }
public ISvgMatrix GetTransformToElement(ISvgElement element) { ISvgLocatable loc = element as ISvgLocatable; ISvgMatrix ctm = loc.GetCTM(); ISvgMatrix vctm; XmlNode node = element.ParentNode; while (node != null && node != OwnerDocument) { if (string.Equals(node.Name, "svg", StringComparison.Ordinal)) { vctm = ((SvgSvgElement)node).ViewBoxTransform; ctm = vctm.Multiply(ctm); } else { loc = node as ISvgLocatable; ctm = loc.GetCTM().Multiply(ctm); } node = node.ParentNode; } return(ctm); }
public ISvgMatrix GetTransformToElement(ISvgElement element) { ISvgLocatable loc = element as ISvgLocatable; ISvgMatrix ctm = loc.GetCTM(); ISvgMatrix vctm; XmlNode node = element.ParentNode; while (node != null && node != OwnerDocument) { if (node.Name == "svg") { vctm = (node as SvgSvgElement).ViewBoxTransform; ctm = vctm.Multiply(ctm); } else { loc = node as ISvgLocatable; ctm = loc.GetCTM().Multiply(ctm); } node = node.ParentNode; } return(ctm); }
private void setFillColor(ISvgElement rootNode, Color fillColor, string property) { if (rootNode == null) { return; } if (rootNode.RenderingHint == SvgRenderingHint.Text || rootNode.RenderingHint == SvgRenderingHint.Shape) { setNodeFillColor(rootNode, fillColor, property); } foreach (XmlNode node in rootNode.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } ISvgElement element = node as ISvgElement; if (element != null) { setFillColor(element, fillColor, property); } } }
/// <summary> /// Generates a new <see cref="WpfRendering">RenderingNode</see> that /// corresponds to the given Uri. /// </summary> /// <param name="baseUri"> /// The base Uri. /// </param> /// <param name="url"> /// The url. /// </param> /// <returns> /// The generated <see cref="WpfRendering">RenderingNode</see> that /// corresponds to the given Uri. /// </returns> public static WpfRendering CreateByUri(SvgDocument document, string baseUri, string url) { url = url.Trim().Trim(new char[] { '\"', '\'' }); if (url.StartsWith("#", StringComparison.OrdinalIgnoreCase)) { // do nothing } else if (baseUri != "") { Uri absoluteUri = new Uri(new Uri(baseUri), url); url = absoluteUri.AbsoluteUri; } else { // TODO: Handle xml:base here? // Right now just skip this... it can't be resolved, must assume it is absolute } ISvgElement elm = document.GetNodeByUri(url) as ISvgElement; if (elm != null) { return(WpfRendering.Create(elm)); } return(null); }
private Color?GetColor(ISvgElement rootNode, string property) { if (rootNode.RenderingHint == SvgRenderingHint.Text || rootNode.RenderingHint == SvgRenderingHint.Shape) { Color?fillColor = GetNodeColor(rootNode, property); if (fillColor != null) { return(fillColor); } } foreach (XmlNode node in rootNode.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } ISvgElement element = node as ISvgElement; if (element != null) { Color?fillColor = GetColor(element, property); if (fillColor != null) { return(fillColor); } } } return(null); }
public MoveEventArgs(ISvgElement element, PointF before, PointF after) { svgelement = element; beforeMove = before; afterMove = after; Cancel = false; }
public void Insert(int index, ISvgElement value) { base.List.Insert(index, value); if ((this.OnCollectionChangedEvent != null) && this.NotifyEvent) { this.OnCollectionChangedEvent(this, new CollectionChangedEventArgs(value)); } }
public void Render(ISvgElement node) { Dom.IElementVisitorTarget evt = node as Dom.IElementVisitorTarget; if (evt != null) { RenderElement(evt); } }
public static WpfRendering Create(ISvgElement element) { if (element == null) { return(null); } SvgElement svgElement = (SvgElement)element; SvgRenderingHint hint = element.RenderingHint; // For the shapes and text contents... if (hint == SvgRenderingHint.Shape) { return(new WpfPathRendering(svgElement)); } if (hint == SvgRenderingHint.Text) { return(new WpfTextRendering(svgElement)); } string localName = element.LocalName; if (string.IsNullOrWhiteSpace(localName)) { return(new WpfRendering(svgElement)); } switch (localName) { case "svg": return(new WpfSvgRendering(svgElement)); case "g": return(new WpfGroupRendering(svgElement)); case "a": return(new WpfARendering(svgElement)); case "use": return(new WpfUseRendering(svgElement)); case "symbol": return(new WpfSymbolRendering(svgElement)); case "switch": return(new WpfSwitchRendering(svgElement)); case "image": return(new WpfImageRendering(svgElement)); case "marker": return(new WpfMarkerRendering(svgElement)); } return(new WpfRendering(svgElement)); }
private void RenderUseElement(ISvgElement svgElement) { SvgUseElement useElement = (SvgUseElement)svgElement; SvgDocument document = useElement.OwnerDocument; XmlElement refEl = useElement.ReferencedElement; if (refEl == null) { return; } bool isImported = false; // For the external node, the documents are different, and we may not be // able to insert this node, so we first import it... if (useElement.OwnerDocument != refEl.OwnerDocument) { XmlElement importedNode = useElement.OwnerDocument.ImportNode(refEl, true) as XmlElement; if (importedNode != null) { SvgElement importedSvgElement = importedNode as SvgElement; if (importedSvgElement != null) { importedSvgElement.Imported = true; importedSvgElement.ImportNode = refEl as SvgElement; importedSvgElement.ImportDocument = refEl.OwnerDocument as SvgDocument; } refEl = importedNode; isImported = true; } } XmlElement refElParent = (XmlElement)refEl.ParentNode; useElement.OwnerDocument.Static = true; useElement.CopyToReferencedElement(refEl); if (!isImported) // if imported, we do not need to remove it... { refElParent.RemoveChild(refEl); } useElement.AppendChild(refEl); // Now, render the use element... this.RenderElement(svgElement); useElement.RemoveChild(refEl); useElement.RestoreReferencedElement(refEl); if (!isImported) { refElParent.AppendChild(refEl); } useElement.OwnerDocument.Static = false; }
public void InvalidateElement(ISvgElement element) { if (element is IGraph) { GraphicsPath path1 = (GraphicsPath)((IGraph)element).GPath.Clone(); path1.Transform(((IGraph)element).GraphTransform.Matrix); RectangleF ef1 = path1.GetBounds(); base.Invalidate(new Rectangle(((int)ef1.X) - 30, ((int)ef1.Y) - 30, ((int)ef1.Width) + 60, ((int)ef1.Height) + 60)); } }
private Path WrapGeometry(Geometry geometry, ISvgElement element) { System.Windows.Shapes.Path path = new System.Windows.Shapes.Path(); if (TryGetTransform(element as ISvgTransformable, out Transform transform)) { geometry.Transform = transform; } path.Data = geometry; return(path); }
private Color?GetNodeColor(ISvgElement targetNode, string property) { //StyleColor fillColor = new StyleColor(); //fillColor.FillType = ColorFillType.Solid; string szRGB = null; string szOpacity = null; string szNodeopacity = null; if (targetNode.RenderingHint == SvgRenderingHint.Text || targetNode.RenderingHint == SvgRenderingHint.Shape) { szRGB = (targetNode as SvgElement).GetComputedStyle("").GetPropertyValue(property); szOpacity = (targetNode as SvgElement).GetComputedStyle("").GetPropertyValue(property + @"-opacity"); szNodeopacity = (targetNode as SvgElement).GetComputedStyle("").GetPropertyValue("opacity"); if (string.IsNullOrEmpty(szRGB)) { return(null); } } //Get RGB Color SvgPaint paint = new SvgPaint(szRGB); if (paint.RgbColor == null) { return(null); } Color?solidColor = WpfConvert.ToColor(paint.RgbColor); if (solidColor == null) { return(null); } //Get Aplha Color result = solidColor.Value; if (szNodeopacity != null || szOpacity != null) { double opacityValue = 1; if (szNodeopacity != null && szNodeopacity.Length > 0) { opacityValue *= SvgNumber.ParseNumber(szNodeopacity); } else if (szOpacity != null && szOpacity.Length > 0) { opacityValue *= SvgNumber.ParseNumber(szOpacity); } opacityValue = Math.Min(opacityValue, 1); opacityValue = Math.Max(opacityValue, 0); result.A = Convert.ToByte(opacityValue * 255); } return(result); }
public void Remove(ISvgElement value) { if (!this.Contains(value)) { return; } base.List.Remove(value); if (this.OnCollectionChangedEvent != null) { this.OnCollectionChangedEvent(this, new CollectionChangedEventArgs(value)); } }
private void RenderElement(ISvgElement svgElement) { bool isNotRenderable = !svgElement.IsRenderable; if (string.Equals(svgElement.LocalName, "a")) { } if (isNotRenderable) { return; } WpfRenderingBase renderingNode = WpfRendering.Create(svgElement); if (renderingNode == null) { return; } if (!renderingNode.NeedRender(_renderer)) { //renderingNode.Dispose(); //renderingNode = null; return; } SvgElement currentElement = (SvgElement)svgElement; if (_rendererMap.ContainsKey(currentElement.UniqueId)) { // Might be circular rendering... // System.Diagnostics.Debug.WriteLine("Circular Object: " + currentElement.LocalName); return; } _rendererMap[currentElement.UniqueId] = renderingNode; renderingNode.BeforeRender(_renderer); renderingNode.Render(_renderer); if (!renderingNode.IsRecursive && svgElement.HasChildNodes) { RenderChildren(svgElement); } renderingNode = _rendererMap[currentElement.UniqueId]; renderingNode.AfterRender(_renderer); _rendererMap.Remove(currentElement.UniqueId); //renderingNode.Dispose(); //renderingNode = null; }
private Path WrapGeometry(Geometry geometry, ISvgElement element) { Path path = new Path(); Transform transform; if (TryGetTransform(element as ISvgTransformable, out transform)) { geometry.Transform = transform; } path.Data = geometry; return(path); }
public void RenderChildren(ISvgElement svgElement) { if (svgElement == null) { return; } string elementName = svgElement.LocalName; if (String.Equals(elementName, "switch")) { RenderSwitchChildren(svgElement); } else { RenderElementChildren(svgElement); } }
public void Render(ISvgElement svgElement) { if (svgElement == null) { return; } string elementName = svgElement.LocalName; if (String.Equals(elementName, "use")) { RenderUseElement(svgElement); } else { RenderElement(svgElement); } }
public static GdiRendering Create(ISvgElement element) { if (element == null) { return null; } SvgRenderingHint hint = element.RenderingHint; // For the shapes and text contents... if (hint == SvgRenderingHint.Shape) { return new GdiPathRendering((SvgElement)element); } if (hint == SvgRenderingHint.Text) { return new GdiTextRendering((SvgElement)element); } string localName = element.LocalName; if (String.IsNullOrEmpty(localName)) { return new GdiRendering((SvgElement)element); } switch (localName) { case "svg": return new GdiRootRendering((SvgElement)element); case "image": return new GdiImageRendering((SvgElement)element); case "marker": return new GdiMarkerRendering((SvgElement)element); } return new GdiRendering((SvgElement)element); }
public static GraphicsPath CreatePath(ISvgElement element) { if (element == null || element.RenderingHint != SvgRenderingHint.Shape) { return null; } string localName = element.LocalName; switch (localName) { case "ellipse": return CreatePath((SvgEllipseElement)element); case "rect": return CreatePath((SvgRectElement)element); case "line": return CreatePath((SvgLineElement)element); case "path": return CreatePath((SvgPathElement)element); case "circle": return CreatePath((SvgCircleElement)element); case "polyline": return CreatePath((SvgPolylineElement)element); case "polygon": return CreatePath((SvgPolygonElement)element); } return null; }
public void Remove(ISvgElement value) { if(!this.Contains(value))return; base.List.Remove(value); if (this.OnCollectionChangedEvent != null) { this.OnCollectionChangedEvent(this, new CollectionChangedEventArgs(value)); } }
public SvgElementCollection(ISvgElement[] value) { this.NotifyEvent = false; this.AddRange(value); }
public static void CreateAnimateValues(ISvgElement svgelement, int time, int maxbegin) { if (svgelement is SvgElement) { SvgElement element1 = (SvgElement) svgelement; element1.AnimateNameValues.Clear(); Hashtable hashtable1 = new Hashtable(0x10); int num1 = 0; int num2 = 0; int num3 = 0; SvgElementCollection.ISvgElementEnumerator enumerator1 = element1.AnimateList.GetEnumerator(); while (enumerator1.MoveNext()) { ItopVector.Core.Animate.Animate animate1 = (ItopVector.Core.Animate.Animate) enumerator1.Current; if (animate1.Begin < maxbegin) { string text1 = animate1.GetAttribute("additive").Trim(); if (((text1 == null) || (text1 == string.Empty)) && (animate1 is MotionAnimate)) { text1 = "sum"; } bool flag1 = text1 == "sum"; string text2 = animate1.AttributeName; int num4 = animate1.Begin; DomType type1 = DomTypeFunc.GetTypeOfAttributeName(text2); object obj1 = animate1.GetAnimateResult((float) time, type1); if ((obj1 != null) && (obj1.ToString() != string.Empty)) { if (element1.AnimateNameValues.ContainsKey(text2)) { AnimateInfo info1 = (AnimateInfo) element1.AnimateNameValues[text2]; info1.Add(obj1, num4, flag1); } else { AnimateInfo info2 = new AnimateInfo(); info2.Add(obj1, num4, flag1); element1.AnimateNameValues.Add(text2, info2); } } if (num1 == 0) { num2 = num4; num3 = num4 + animate1.Duration; continue; } num2 = Math.Min(animate1.Begin, num2); num3 = Math.Max((int) (num4 + animate1.Duration), num3); } } foreach (string text3 in element1.AnimateNameValues.Keys) { DomType type2 = DomTypeFunc.GetTypeOfAttributeName(text3); if (element1.SvgAttributes.ContainsKey(text3)) { object obj2 = element1.SvgAttributes[text3]; object obj3 = AnimFunc.GetAnimateValue(element1, text3, type2, obj2); if (element1.SvgAnimAttributes.ContainsKey(text3)) { element1.SvgAnimAttributes[text3] = obj3; } else { element1.SvgAnimAttributes.Add(text3, obj3); } continue; } object obj4 = null; object obj5 = AnimFunc.GetAnimateValue(element1, text3, type2, obj4); if (element1.SvgAnimAttributes.ContainsKey(text3)) { element1.SvgAnimAttributes[text3] = obj5; continue; } element1.SvgAnimAttributes.Add(text3, obj5); } } }
public ISvgMatrix GetTransformToElement(ISvgElement element) { ISvgLocatable loc = element as ISvgLocatable; ISvgMatrix ctm = loc.GetCTM(); ISvgMatrix vctm; XmlNode node = element.ParentNode; while (node != null && node != OwnerDocument) { if (node.Name == "svg") { vctm = (node as SvgSvgElement).ViewBoxTransform; ctm = vctm.Multiply(ctm); } else { loc = node as ISvgLocatable; ctm = loc.GetCTM().Multiply(ctm); } node = node.ParentNode; } return ctm; }
// Methods public CollectionChangedEventArgs(ISvgElement element) { ISvgElement[] elementArray1 = new ISvgElement[1] { element } ; this.ChangeElements = elementArray1; }
public SvgElementSelectedEventArgs(ISvgElement element) { Elements =new ISvgElement[1]{element}; }
public SvgElement AddElement(ISvgElement mypath) { // AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer); XmlNode node1 = OwnerDocument.RootElement; XmlNode newNode =null; Matrix matrix1 = new Matrix(); // if (node1 is IGraph) // { // matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone(); // Matrix matrix2 = this.coordTransform.Clone(); // matrix2.Invert(); // matrix1.Multiply(matrix2, MatrixOrder.Append); // } // matrix1.Invert(); // matrix1 = TransformFunc.RoundMatrix(matrix1, 2); bool flag1 = OwnerDocument.AcceptChanges; // OwnerDocument.AcceptChanges = false; OwnerDocument.AcceptChanges = true; if (mypath is IGraphPath) { ISvgBrush brush1 = ((IGraphPath) mypath).GraphBrush; if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null)) { bool flag2 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = true; OwnerDocument.NumberOfUndoOperations++; XmlNode node2 = OwnerDocument.AddDefsElement((SvgElement) brush1); OwnerDocument.AcceptChanges = false; if (node2 is ITransformBrush) { string text1 = ((SvgElement) node2).ID; AttributeFunc.SetAttributeValue((SvgElement) mypath, "fill", "url(#" + text1 + ")"); } OwnerDocument.AcceptChanges = flag2; } brush1 = ((IGraphPath) mypath).GraphStroke.Brush; if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null)) { bool flag3 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = true; OwnerDocument.NumberOfUndoOperations++; XmlNode node3 = OwnerDocument.AddDefsElement((SvgElement) brush1); OwnerDocument.AcceptChanges = false; if (node3 is ITransformBrush) { string text2 = ((SvgElement) node3).ID; AttributeFunc.SetAttributeValue((SvgElement) mypath, "stroke", "url(#" + text2 + ")"); } OwnerDocument.AcceptChanges = flag3; } } if (!matrix1.IsIdentity && (mypath is IGraph)) { bool flag4 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = false; Matrix matrix3 = ((IGraph) mypath).Transform.Matrix.Clone(); matrix1.Multiply(matrix3); Transf transf1 = new Transf(); transf1.setMatrix(matrix1); AttributeFunc.SetAttributeValue((SvgElement) mypath, "transform", transf1.ToString()); OwnerDocument.AcceptChanges = flag4; } if (((SvgElement) mypath).ParentNode != node1) { if (((ContainerElement) node1).IsValidChild((SvgElement) mypath)) { // node1.AppendChild((SvgElement) mypath); SvgElement element1 =(SvgElement) mypath;//(SvgElement)OwnerDocument.ImportNode((SvgElement) mypath,true); newNode = node1.AppendChild(element1); OwnerDocument.Render(element1); } } OwnerDocument.AcceptChanges = flag1; return newNode!=null?newNode as SvgElement:null; }
public SvgElementSelectedEventArgs(ISvgElement[] list) { this.Elements = list; }
public void RenderMask(ISvgElement node, WpfDrawingContext context) { if (context == null) { _renderingContext = new WpfDrawingContext(true, _renderingSettings); _renderingContext.Initialize(null, _fontFamilyVisitor, _imageVisitor); } else { _renderingContext = context; } _renderingContext.BeginDrawing(); _svgRenderer.RenderMask(node); _renderingContext.EndDrawing(); }
public void RenderChildren(ISvgElement node) { _svgRenderer.RenderChildren(node); }
public void Render(ISvgElement node, WpfDrawingContext context) { //throw new NotImplementedException(); //SvgRectF updatedRect; //if (invalidRect != SvgRectF.Empty) // updatedRect = new SvgRectF(invalidRect.X, invalidRect.Y, // invalidRect.Width, invalidRect.Height); //else // updatedRect = SvgRectF.Empty; //RendererBeforeRender(); //if (graphics != null && graphics.Graphics != null) //{ // _svgRenderer.Render(node); //} //RendererAfterRender(); //if (onRender != null) // OnRender(updatedRect); if (context == null) { _renderingContext = new WpfDrawingContext(true, _renderingSettings); _renderingContext.Initialize(null, _fontFamilyVisitor, _imageVisitor); } else { _renderingContext = context; } _renderingContext.BeginDrawing(); _svgRenderer.Render(node); _renderingContext.EndDrawing(); }
public ISvgRect GetRenderedBounds(ISvgElement element, float margin) { return SvgRect.Empty; }
/// <summary> /// Returns true if the rendered content of the given element is entirely contained within /// the supplied rectangle, honoring the 'pointer-events' property value on each candidate /// graphics element. /// </summary> /// <param name="element">The element on which to perform the given test</param> /// <param name="rect">The test rectangle. The values are in the initial coordinate system /// for the current 'svg' element.</param> /// <returns>True or false, depending on whether the given element is enclosed by the /// supplied rectangle.</returns> public bool CheckEnclosure(ISvgElement element, ISvgRect rect) { throw new NotImplementedException(); }
protected RenderingNode(ISvgElement element) { this.element = element; }
public CollectionChangedEventArgs(ISvgElement[] list) { this.ChangeElements = list; }
public static Geometry CreateGeometry(ISvgElement element, bool optimizePath) { if (element == null || element.RenderingHint != SvgRenderingHint.Shape) { return null; } string localName = element.LocalName; switch (localName) { case "ellipse": return CreateGeometry((SvgEllipseElement)element); case "rect": return CreateGeometry((SvgRectElement)element); case "line": return CreateGeometry((SvgLineElement)element); case "path": if (optimizePath) { return CreateGeometryEx((SvgPathElement)element); } else { return CreateGeometry((SvgPathElement)element); } case "circle": return CreateGeometry((SvgCircleElement)element); case "polyline": return CreateGeometry((SvgPolylineElement)element); case "polygon": return CreateGeometry((SvgPolygonElement)element); } return null; }
/// <summary> /// Returns the list of graphics elements whose rendered content intersects the supplied /// rectangle, honoring the 'pointer-events' property value on each candidate graphics /// element. /// </summary> /// <param name="rect">The test rectangle. The values are in the initial coordinate /// system for the current 'svg' element.</param> /// <param name="referenceElement">If not null, then only return elements whose drawing /// order has them below the given reference element.</param> /// <returns>A list of Elements whose content intersects the supplied rectangle.</returns> public XmlNodeList GetIntersectionList(ISvgRect rect, ISvgElement referenceElement) { throw new NotImplementedException(); }
public void InvalidateElement(ISvgElement element) { if (element is IGraph) { GraphicsPath path1 = (GraphicsPath) ((IGraph) element).GPath.Clone(); path1.Transform(((IGraph) element).GraphTransform.Matrix); RectangleF ef1 = path1.GetBounds(); base.Invalidate(new Rectangle(((int) ef1.X) - 30, ((int) ef1.Y) - 30, ((int) ef1.Width) + 60, ((int) ef1.Height) + 60)); } }
/// <summary> /// Returns true if the rendered content of the given element intersects the supplied /// rectangle, honoring the 'pointer-events' property value on each candidate graphics /// element. /// </summary> /// <param name="element">The element on which to perform the given test.</param> /// <param name="rect">The test rectangle. The values are in the initial coordinate system /// for the current 'svg' element.</param> /// <returns>True or false, depending on whether the given element intersects the supplied /// rectangle.</returns> public bool CheckIntersection(ISvgElement element, ISvgRect rect) { throw new NotImplementedException(); }
// Methods public SvgElementChangedEventArgs(ISvgElement newelement,ISvgElement oldelement ) { newElement = newelement; oldElement = oldelement; }
public AddSvgElementEventArgs(ISvgElement element) { svgelement=element; Cancel=false; }
public static WpfRendering Create(ISvgElement element) { if (element == null) { return null; } SvgRenderingHint hint = element.RenderingHint; // For the shapes and text contents... if (hint == SvgRenderingHint.Shape) { return new WpfPathRendering((SvgElement)element); } if (hint == SvgRenderingHint.Text) { return new WpfTextRendering((SvgElement)element); } string localName = element.LocalName; if (String.IsNullOrEmpty(localName)) { return new WpfRendering((SvgElement)element); } switch (localName) { case "svg": return new WpfSvgRendering((SvgElement)element); case "g": return new WpfGroupRendering((SvgElement)element); case "a": return new WpfARendering((SvgElement)element); case "use": return new WpfUseRendering((SvgElement)element); case "switch": return new WpfSwitchRendering((SvgElement)element); case "image": return new WpfImageRendering((SvgElement)element); case "marker": return new WpfMarkerRendering((SvgElement)element); } return new WpfRendering((SvgElement)element); }