Beispiel #1
0
        /// <summary>
        /// 手动
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="id"></param>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public static DeviceDrawObjectBase CreateDeviceDrawObjectBase(float x, float y, float w, float h, string id, string entityId)
        {
            //获取每一个实例化的设备
            DeviceDrawObjectBase        vBase = null;
            List <DeviceDrawObjectBase> deviceDrawObjectBases = null;
            List <DrawObject>           drawObjects           = new List <DrawObject>();


            var symbol = id;//设备定义引用 指明使用的哪一种设备类型

            SymbolUnit._Dic.TryGetValue(symbol, out SymbolUnit value);
            if (value != null)
            {
                foreach (var unit in value._symbolChildSvgs)
                {
                    if (unit.getElementType() == SVGUnit.SVGUnitType.use)
                    {
                        var childSvgUse = unit as SVGUse;


                        var entityLInk = CreateDeviceDrawObjectBase(childSvgUse, entityId);
                        if (deviceDrawObjectBases == null)
                        {
                            deviceDrawObjectBases = new List <DeviceDrawObjectBase>();
                        }
                        {
                            deviceDrawObjectBases.Add(entityLInk);
                        }
                    }
                    else
                    {
                        var o = SVGDrawFactory.CreateDrawObject(unit);
                        if (o != null)
                        {
                            if (o is DrawRectangleObject rectangleObject)
                            {
                                rectangleObject.Proportion = new PointF(rectangleObject.Width / w,
                                                                        rectangleObject.Height / h);
                            }
                            drawObjects.Add(o);
                        }
                    }
                }
                if (value.SymbolId.Contains("负荷开关@1"))
                {
                    vBase = new SingleDisConnectorDevice(x, y, w, h, entityId, drawObjects, deviceDrawObjectBases, value.SymbolId);
                }
                else
                {
                    vBase = new DeviceDrawObjectBase(x, y, w, h, entityId, drawObjects, deviceDrawObjectBases,
                                                     value.SymbolId);
                }
                vBase.SetViewBox(value.W, value.H);
            }



            return(vBase);
        }
Beispiel #2
0
        public static DeviceDrawObjectBase CreateDeviceDrawObjectBase(SVGUse use, string entityId)
        {
            //获取每一个实例化的设备
            DeviceDrawObjectBase        vBase = null;
            List <DeviceDrawObjectBase> deviceDrawObjectBases = null;
            List <DrawObject>           drawObjects           = new List <DrawObject>();

            if (use != null)
            {
                string id     = use.HRef;//获取实体Id
                var    x      = string.IsNullOrEmpty(use.X)?0f:float.Parse(use.X);
                var    y      = string.IsNullOrEmpty(use.Y) ? 0f : float.Parse(use.Y);
                var    w      = string.IsNullOrEmpty(use.Width) ? 0f : float.Parse(use.Width);
                var    h      = string.IsNullOrEmpty(use.Height) ? 0f : float.Parse(use.Height);
                var    symbol = use.HRef.Substring(1);//设备定义引用 指明使用的哪一种设备类型

                SymbolUnit._Dic.TryGetValue(symbol, out SymbolUnit value);
                if (value != null)
                {
                    foreach (var unit in value._symbolChildSvgs)
                    {
                        if (unit.getElementType() == SVGUnit.SVGUnitType.use)
                        {
                            var childSvgUse = unit as SVGUse;
                            var entityLInk  = CreateDeviceDrawObjectBase(unit as SVGUse, entityId);
                            if (deviceDrawObjectBases == null)
                            {
                                deviceDrawObjectBases = new List <DeviceDrawObjectBase>();
                            }
                            deviceDrawObjectBases.Add(entityLInk);
                        }
                        else
                        {
                            var o = SVGDrawFactory.CreateDrawObject(unit);
                            if (o != null)
                            {
                                drawObjects.Add(o);
                            }
                        }
                    }
                    vBase = new DeviceDrawObjectBase(x, y, w, h, entityId, drawObjects, deviceDrawObjectBases, value.SymbolId);
                    vBase.SetViewBox(value.W, value.H);
                }
            }

            return(vBase);
        }
Beispiel #3
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();
            }
        }