Example #1
0
        private void DrawFloor(AreaEntity area, double scale, double devSize)
        {
            Clear();
            var bound = area.InitBound;

            if (bound == null)
            {
                return;
            }
            if (bound.MaxX == 0)
            {
                bound.SetMinMaxXY();
            }
            Scale          = scale;
            CanvasMargin   = 10;
            OffsetX        = -CanvasMargin / 2;
            OffsetY        = -CanvasMargin / 2;
            Canvas1.Width  = (bound.MaxX + CanvasMargin) * scale;
            Canvas1.Height = (bound.MaxY + CanvasMargin) * scale;
            DrawMode       = 2;
            AddAreaRect(area, null, scale);
            if (area.Children != null)
            {
                area.Children.Sort();
                foreach (var level1Item in area.Children) //机房
                {
                    level1Item.Parent = area;
                    AddAreaRect(level1Item, area, scale, true);

                    ShowDevs(level1Item.GetLeafNodes(), scale, devSize);//机房内设备
                }
            }

            ShowDevs(area.GetLeafNodes(), scale, devSize);//楼层内设备

            AddZeroPoint(scale, new Vector(0, 0));
        }
Example #2
0
        private void DrawPark(AreaEntity area, int scale, double devSize)
        {
            var bound = area.InitBound;

            //if (bound == null)
            //{
            //    bound=area.CreateBoundByChildren();
            //}
            if (bound == null)
            {
                return;
            }
            //bound=area.SetBoundByDevs();
            Scale          = scale;
            CanvasMargin   = 20;
            OffsetX        = bound.MinX - CanvasMargin;
            OffsetY        = bound.MinY - CanvasMargin;
            Canvas1.Width  = (bound.MaxX - OffsetX + CanvasMargin) * scale;
            Canvas1.Height = (bound.MaxY - OffsetY + CanvasMargin) * scale;

            DrawMode = 1;

            AddAreaRect(area, null, scale);

            if (area.Children != null)
            {
                foreach (var level1Item in area.Children) //建筑群
                {
                    level1Item.Parent = area;
                    AddAreaRect(level1Item, area, scale);
                    if (level1Item.Children != null)
                    {
                        foreach (var level2Item in level1Item.Children) //建筑
                        {
                            level2Item.Parent = level1Item;
                            AddAreaRect(level2Item, level1Item, scale);

                            if (ShowFloor > 0)
                            {
                                var floor = level2Item.GetChild(ShowFloor - 1);//楼层

                                if (floor != null)
                                {
                                    if (level2Item.InitBound != null)
                                    {
                                        AddAreaRect(floor, level2Item, scale);//楼层画出来
                                    }
                                    if (floor.Children != null)
                                    {
                                        foreach (var room in floor.Children)//机房
                                        {
                                            if (room == null)
                                            {
                                                continue;
                                            }
                                            room.Parent = floor;
                                            AddAreaRect(room, floor, scale);
                                            ShowDevs(room.GetLeafNodes(), scale, devSize / 5);//机房内设备
                                        }
                                    }

                                    ShowDevs(floor.GetLeafNodes(), scale, devSize / 5);//楼层内设备
                                }
                            }
                        }
                    }
                }
            }
            ShowDevs(area.GetLeafNodes(), scale, devSize);
            AddZeroPoint(scale, new Vector(bound.MinX, bound.MinY));
        }