/// <summary>
        /// 获取完整的园区初始化xml
        /// </summary>
        /// <param name="floor"></param>
        /// <param name="parkName"></param>
        /// <returns></returns>
        public static TopoInfo CreateBuildingInitInfoByFloors(string buildingName, params TopoInfo[] floors)
        {
            TopoInfo building = new TopoInfo(buildingName, AreaTypes.大楼);

            //park.AddChild(building);

            if (floors.Length > 0)
            {
                TopoInfo firstFloor = null;
                foreach (var floor in floors)
                {
                    if (firstFloor == null)
                    {
                        firstFloor = floor;
                    }
                    building.AddChild(floor);
                }

                BoundInfo buildBound = firstFloor.BoundInfo.CloneByXml();
                buildBound.SetRectangle();                  //比例调整
                buildBound.Scale(1.05f);                    //比例调整
                building.BoundInfo            = buildBound; //大楼默认和楼层一致
                building.BoundInfo.IsRelative = false;
                //BoundInfo parkBound = building.BoundInfo.CloneByXml();
                //parkBound.SetRectangle();
                //parkBound.Scale(2);//园区默认是比大楼周围一圈
                //park.BoundInfo = parkBound;
            }


            return(building);
        }
Example #2
0
        private static InitInfo CreateInitInfo(TopoInfo floor, string parkName)
        {
            InitInfo initInfo = new InitInfo();
            TopoInfo root     = new TopoInfo("根节点", AreaTypes.区域);

            initInfo.TopoInfo = root;

            TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置

            root.AddChild(park);

            //TopoInfo group = new TopoInfo("分组1", AreaTypes.分组);
            //park.AddChild(group);

            TopoInfo building = new TopoInfo("大楼1", AreaTypes.大楼);

            park.AddChild(building);

            building.AddChild(floor);

            BoundInfo buildBound = floor.BoundInfo.CloneByXml();

            buildBound.SetRectangle();       //比例调整
            buildBound.Scale(1.05f);         //比例调整
            building.BoundInfo = buildBound; //大楼默认和楼层一致

            BoundInfo parkBound = building.BoundInfo.CloneByXml();

            parkBound.SetRectangle();
            parkBound.Scale(2);//园区默认是比大楼周围一圈
            park.BoundInfo = parkBound;

            return(initInfo);
        }
        /// <summary>
        /// 获取完整的园区初始化xml
        /// </summary>
        /// <param name="floor"></param>
        /// <param name="parkName"></param>
        /// <returns></returns>
        public static InitInfo CreateParkInitInfoByFloors(string parkName, string buildingName, params TopoInfo[] floors)
        {
            InitInfo initInfo = new InitInfo();
            TopoInfo root     = new TopoInfo("根节点", AreaTypes.区域);

            initInfo.TopoInfo = root;

            TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置

            root.AddChild(park);

            TopoInfo group = new TopoInfo("生产区域", AreaTypes.分组);//todo:可以扩展成园区、大楼手动设置

            park.AddChild(group);

            TopoInfo building = CreateBuildingInitInfoByFloors(buildingName, floors);

            group.AddChild(building);

            BoundInfo parkBound = building.BoundInfo.CloneByXml();

            parkBound.SetRectangle();
            parkBound.Scale(2);//园区默认是比大楼周围一圈
            park.BoundInfo            = parkBound;
            park.BoundInfo.IsRelative = false;

            return(initInfo);
        }