SharpVectors.Dom.Svg.SvgUseElement.CopyToReferencedElement C# (CSharp) Method

CopyToReferencedElement() public method

public CopyToReferencedElement ( XmlElement refEl ) : void
refEl System.Xml.XmlElement
return void
        public void CopyToReferencedElement(XmlElement refEl)
        {
            // X and Y become a translate portion of any transform, width and height may get passed on
              if (X.AnimVal.Value != 0 || Y.AnimVal.Value != 0)
              {
            saveTransform = this.GetAttribute("transform");
            this.SetAttribute("transform", saveTransform + " translate(" + X.AnimVal.Value + "," + Y.AnimVal.Value + ")");
              }
              if (refEl is SvgSymbolElement)
              {
            refEl.SetAttribute("width", (HasAttribute("width")) ? GetAttribute("width") : "100%");
            refEl.SetAttribute("height", (HasAttribute("height")) ? GetAttribute("height") : "100%");
              }
              if (refEl is SvgSymbolElement)
              {
            saveWidth = refEl.GetAttribute("width");
            saveHeight = refEl.GetAttribute("height");
            if (HasAttribute("width"))
              refEl.SetAttribute("width",  GetAttribute("width"));
            if (HasAttribute("height"))
              refEl.SetAttribute("height", GetAttribute("height"));
              }
        }

Usage Example

コード例 #1
0
        public RectangleF GetBRect(float margin)
        {
            if (this is ISharpGDIPath)
            {
                ISharpGDIPath gdiPathElm = (ISharpGDIPath)this;
                GraphicsPath  gp         = gdiPathElm.GetGraphicsPath();
                SvgMatrix     svgMatrix  = (SvgMatrix)this.GetScreenCTM();
                RectangleF    bounds     = gp.GetBounds(svgMatrix.ToMatrix());
                bounds = RectangleF.Inflate(bounds, margin, margin);
                return(bounds);
            }
            else if (this is ISvgUseElement)
            {
                SvgUseElement           use   = (SvgUseElement)this;
                SvgTransformableElement refEl = use.ReferencedElement as SvgTransformableElement;
                if (refEl == null)
                {
                    return(RectangleF.Empty);
                }
                XmlElement refElParent = (XmlElement)refEl.ParentNode;
                OwnerDocument.Static = true;
                use.CopyToReferencedElement(refEl);
                this.AppendChild(refEl);
                RectangleF bbox = refEl.GetBRect(margin);
                this.RemoveChild(refEl);
                use.RestoreReferencedElement(refEl);
                refElParent.AppendChild(refEl);
                OwnerDocument.Static = false;
                return(bbox);
            }
            else
            {
                RectangleF union = RectangleF.Empty;
                SvgTransformableElement transformChild;
                foreach (XmlNode childNode in ChildNodes)
                {
                    if (childNode is SvgDefsElement)
                    {
                        continue;
                    }
                    if (childNode is ISvgTransformable)
                    {
                        transformChild = (SvgTransformableElement)childNode;
                        RectangleF bbox = transformChild.GetBRect(margin);
                        if (bbox != RectangleF.Empty)
                        {
                            if (union == RectangleF.Empty)
                            {
                                union = bbox;
                            }
                            else
                            {
                                union = RectangleF.Union(union, bbox);
                            }
                        }
                    }
                }

                return(union);
            }
        }