Пример #1
0
        public static DrawObject CreateDrawObject(SVGUnit svge)
        {
            DrawObject o = null;

            switch (svge.getElementType())
            {
            case SVGUnit.SVGUnitType.typeLine:
                o = DrawLineObject.Create((SVGLine)svge);
                break;

            case SVGUnit.SVGUnitType.typeRect:
                o = DrawRectangleObject.Create((SVGRect)svge);
                break;

            case SVGUnit.SVGUnitType.typeEllipse:
                o = DrawEllipseObject.Create((SVGEllipse)svge);
                break;

            case SVGUnit.SVGUnitType.typePolyline:
                o = DrawPolygonObject.Create((SVGPolyline)svge);
                break;

            case SVGUnit.SVGUnitType.typeImage:
                o = DrawImageObject.Create((SVGImage)svge);
                break;

            case SVGUnit.SVGUnitType.typeText:
                o = DrawTextObject.Create((SVGText)svge);
                break;

            case SVGUnit.SVGUnitType.typePath:
                o = DrawPathObject.Create((SVGPath)svge);
                break;

            case SVGUnit.SVGUnitType.typeCircle:
                o = DrawCircleObject.Create((SVGCircle)svge);
                break;

            default:
                break;
            }
            return(o);
        }
Пример #2
0
        /// <summary>
        /// 根据读取的xml生成项目
        /// </summary>
        /// <param name="svg"></param>
        public static void CreateProjectFromXML(SVGUnit svg, DrawObjectList list)
        {
            while (svg != null)
            {
                switch (svg.getElementType())
                {
                case SVGUnit.SVGUnitType.def:    //将所有symbol读取
                    SVGUnit defchild = svg.getChild();
                    while (defchild != null)
                    {
                        if (defchild.getElementType() == SVGUnit.SVGUnitType.symbol)
                        {
                            CreateSysmbolUnit(defchild as SVGSymbol);
                        }

                        defchild = defchild.getNext();
                    }
                    break;

                case SVGUnit.SVGUnitType.typeGroup:
                    if (svg.Id == SVGDefine.ConnectLineClass)
                    {
                        SVGGroup          group             = svg.getChild() as SVGGroup;
                        DrawConnectObject drawConnectObject = DrawConnectObject.Create(group.getChild() as SVGPath);
                        SVGCN_Ref         svgcnRef          = group.getChild().getNext().getChild() as SVGCN_Ref;
                        var linkDnd = svgcnRef.LinkObjecttlDnd.Split('@');

                        drawConnectObject.SetConnectDeviceFromXml(linkDnd[0], 1, int.Parse(linkDnd[1]), list.GetDeviceList());
                        linkDnd = svgcnRef.LinkObjectIDznd.Split('@');
                        drawConnectObject.SetConnectDeviceFromXml(linkDnd[0], 2, int.Parse(linkDnd[1]), list.GetDeviceList());

                        drawConnectObject.Id = int.Parse(group.Id);
                        list.Add(drawConnectObject);
                        group = group.getNext() as SVGGroup;
                    }
                    else if (svg.Id == SVGDefine.AnimationClass)
                    {
                    }
                    else
                    {
                        SVGGroup group = svg.getChild() as SVGGroup;
                        while (group != null)
                        {
                            var gchild = group.getChild();
                            switch (gchild.getElementType())
                            {
                            case SVGUnit.SVGUnitType.use:
                                SVGUse use     = gchild as SVGUse;
                                var    gDevice = CreateDeviceDrawObjectBase(use, group.Id);     //TODO 后期添加到工作组中
                                list.Add(gDevice);
                                break;

                            default:
                                //TODO 未编排为设备的图素集合,暂时用临时分组表示
                                var o = SVGDrawFactory.CreateDrawObject(svg);
                                list.Add(o);
                                //vBase = new DeviceDrawObjectBase(0f, 0f, 0f, 0f, group.Id, drawObjects, null, "");
                                break;
                            }
                            group = group.getNext() as SVGGroup;    //获取下一个
                        }
                    }


                    break;

                default: break;
                }

                svg = svg.getNext();
            }
        }