Пример #1
0
        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);
        }
Пример #2
0
 public VgVisualDoc(VgVisualDocHost vgVisualDocHost = null)
 {
     _vgVisualDocHost = vgVisualDocHost;
 }