public CssBoxSvgRoot CreateSvgBox(CssBox parentBox, HtmlElement elementNode, LayoutFarm.Css.BoxSpec spec) { //TODO: review here // //create blank svg document VgDocument svgdoc = new VgDocument(); svgdoc.CssActiveSheet = new LayoutFarm.WebDom.CssActiveSheet(); _currentDoc = svgdoc; _svgDocBuilder.ResultDocument = svgdoc; // _svgDocBuilder.OnBegin(); CreateBoxContent(elementNode); _svgDocBuilder.OnEnd(); //----------------------------------------- SvgRootEventPortal svgRootController = new SvgRootEventPortal(elementNode); CssBoxSvgRoot svgRoot = new CssBoxSvgRoot( elementNode.Spec, svgdoc); svgRoot.SetController(svgRootController); svgRootController.SvgRoot = svgRoot; parentBox.AppendChild(svgRoot); return(svgRoot); }
public VgVisualDoc CreateVgVisualDoc(VgDocument svgdoc, VgVisualDocHost docHost) { // //reset some value _containerWidth = 500; _containerHeight = 500; _emHeight = 17; _waitingList.Clear(); // _svgdoc = svgdoc; _activeSheet1 = svgdoc.CssActiveSheet; _vgVisualDoc = new VgVisualDoc(docHost); _defsList = _vgVisualDoc._defsList; _styleList = _vgVisualDoc._styleList; _registeredElemsById = _vgVisualDoc._registeredElemsById; //--------------------------- //create visual tree for svg nodes SvgElement rootElem = svgdoc.Root; VgVisualElement vgVisualRootElem = new VgVisualElement(WellknownSvgElementName.RootSvg, null, _vgVisualDoc); _vgVisualDoc.VgRootElem = vgVisualRootElem;//** int childCount = rootElem.ChildCount; for (int i = 0; i < childCount; ++i) { CreateSvgVisualElement(vgVisualRootElem, rootElem.GetChild(i)); } //resolve int j = _waitingList.Count; BuildDefinitionNodes(); for (int i = 0; i < j; ++i) { //resolve VgUseVisualElement useNodeVisElem = (VgUseVisualElement)_waitingList[i]; if (useNodeVisElem.HRefSvgRenderElement == null) { //resolve SvgUseSpec useSpec = (SvgUseSpec)useNodeVisElem._visualSpec; if (_registeredElemsById.TryGetValue(useSpec.Href.Value, out VgVisualElement result)) { useNodeVisElem.HRefSvgRenderElement = result; } else { } } } return(_vgVisualDoc); }