示例#1
0
        public bool ShowInfo(Rectangle rect, int devId)
        {
            ArchorDevList archorList = ArchorHelper.ArchorList;

            TbCode.ItemsSource       = archorList.ArchorList;
            TbCode.DisplayMemberPath = "ArchorID";

            IPCode1.ItemsSource       = archorList.ArchorList;
            IPCode1.DisplayMemberPath = "ArchorIp";

            Bll bll = new Bll();

            this._dev  = bll.DevInfos.Find(devId);
            this._rect = rect;
            _archor    = bll.Archors.Find(i => i.DevInfoId == _dev.Id);
            if (_archor == null)
            {
                return(false);//不是基站的设备
            }
            _item      = new ArchorSetting(_archor.GetCode(), _archor.Id);
            _code      = _archor.Code;
            _item.Name = _archor.Name;

            var area = bll.GetAreaTree(false, _dev.ParentId);

            _item.RelativeMode = RelativeMode.相对楼层;

            x = _dev.PosX;
            z = _dev.PosZ;

            _item.SetRelative(x, z);
            _item.RelativeHeight = _dev.PosY;

            park = area;

            var minX = park.InitBound.MinX;
            var minY = park.InitBound.MinY;

            _item.SetAbsolute(x + minX, z + minY);

            LbId.Text     = _archor.Id + "";
            TbName.Text   = _archor.Name;
            TbCode.Text   = _archor.GetCode();
            IPCode1.Text  = _archor.Ip;
            TbHeight.Text = _item.RelativeHeight.ToString("F3");

            PcArchor.X = x;
            PcArchor.Y = z;


            PcArchor.IsEnabled = true;

            var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);

            if (setting != null)
            {
                //PcZero.X = setting.ZeroX.ToDouble();
                //PcZero.Y = setting.ZeroY.ToDouble();

                SetZeroPoint(setting.ZeroX.ToDouble(), setting.ZeroY.ToDouble());
                Title += " [已配置]";
            }
            else
            {
                SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                //PcZero.X = ArchorSettingContext.ZeroX;
                //PcZero.Y = ArchorSettingContext.ZeroY;
                //PcRelative.X = x - ArchorSettingContext.ZeroX;
                //PcRelative.Y = z - ArchorSettingContext.ZeroY;
            }

            PcAbsolute.X = PcZero.X + PcRelative.X;
            PcAbsolute.Y = PcZero.Y + PcRelative.Y;

            PcZero.ValueChanged     += PcZero_OnValueChanged;
            PcRelative.ValueChanged += PcRelative_OnValueChanged;

            return(true);
        }
        public bool ShowInfo(Rectangle rect, int devId)
        {
            PcZero.ValueChanged     -= PcZero_ValueChanged;
            PcRelative.ValueChanged -= PcRelative_ValueChanged;
            PcArchor.ValueChanged   -= PcArchor_ValueChanged;

            ArchorDevList archorList = ArchorHelper.ArchorList;

            TbCode.ItemsSource       = archorList.ArchorList;
            TbCode.DisplayMemberPath = "ArchorID";

            IPCode1.ItemsSource       = archorList.ArchorList;
            IPCode1.DisplayMemberPath = "ArchorIp";

            Bll bll = new Bll();

            this._dev  = bll.DevInfos.Find(devId);
            this._rect = rect;
            _archor    = bll.Archors.Find(i => i.DevInfoId == _dev.Id);
            if (_archor == null)
            {
                return(false);
            }
            _code = _archor.GetCode();

            _item      = new ArchorSetting(_code, _archor.Id);
            _item.Name = _archor.Name;
            var area = _dev.Parent;

            x = _dev.PosX;
            z = _dev.PosZ;

            _item.SetRelative(x, z);
            _item.RelativeHeight = _dev.PosY;

            _floor = area;

            _building = _floor.Parent;

            if (_building.Children == null)
            {
                _building.Children = bll.Areas.Where(i => i.ParentId == _building.Id);
            }
            floorHeight        = _floor.InitBound.MinZ;
            TbFloorHeight.Text = floorHeight.ToString("F3");

            //var building = areas.Find(j => j.Id == floor.ParentId);
            //_floor.InitBound.SetInitBound();
            var floorBound = _floor.InitBound;

            if (floorBound.Points == null)
            {
                floorBound.Points = bll.Points.FindAll(i => i.BoundId == floorBound.Id);
            }
            if (floorBound.MaxX == 0)
            {
                floorBound.SetMinMaxXY();
                bll.Bounds.Edit(floorBound);
            }
            var minX = floorBound.MinX + _building.InitBound.MinX;
            var minY = floorBound.MinY + _building.InitBound.MinY;

            _item.AbsoluteX = (x + minX).ToString("F3");
            _item.AbsoluteY = (z + minY).ToString("F3");

            //var rooms = areas.FindAll(j => j.ParentId == floor.Id);
            _room = Bll.GetDevRoom(_floor, _dev);
            //PropertyGrid3.SelectedObject = item;

            LbId.Text    = _archor.Id + "";
            TbName.Text  = _archor.Name;
            TbCode.Text  = _archor.GetCode();
            IPCode1.Text = _archor.Ip;
            double height = _item.RelativeHeight;

            //if (height == 2)
            //{
            //    height = 2.6;//现场实际一般高度是2.6左右
            //}
            TbHeight.Text       = height.ToString("F3");
            TbHeight2.Text      = (floorHeight + height).ToString("F3");
            PcArchor.X          = x;
            PcArchor.Y          = z;
            TbBuildingName.Text = _building.Name;
            TbFloorName.Text    = _floor.Name;

            PcAbsolute.X = _building.InitBound.MinX + _floor.InitBound.MinX + x;
            PcAbsolute.Y = _building.InitBound.MinY + _floor.InitBound.MinY + z;

            if (_room != null)
            {
                TbRoomName.Text    = _room.Name;
                PcArchor.IsEnabled = false;
                var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);
                if (setting != null)
                {
                    SetZeroPoint(setting.ZeroX.ToFloat(), setting.ZeroY.ToFloat());
                    Title += " [已配置]";
                }
                else
                {
                    if (ArchorSettingContext.ZeroX != 0)
                    {
                        SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                    }
                    else
                    {
                        SetZeroPoint(_room.InitBound.MinX, _room.InitBound.MinY);
                    }
                }
            }
            else
            {
                var setting = bll.ArchorSettings.GetByCode(_code, _archor.Id);
                if (setting != null)
                {
                    SetZeroPoint(setting.ZeroX.ToFloat(), setting.ZeroY.ToFloat());
                    Title += " [已配置]";
                }
                else
                {
                    PcArchor.IsEnabled = true;
                    PcRelative.X       = PcArchor.X;
                    PcRelative.Y       = PcArchor.Y;

                    if (ArchorSettingContext.ZeroX != 0)
                    {
                        SetZeroPoint(ArchorSettingContext.ZeroX, ArchorSettingContext.ZeroY);
                    }
                }
            }

            PcZero.ValueChanged     += PcZero_ValueChanged;
            PcRelative.ValueChanged += PcRelative_ValueChanged;
            PcArchor.ValueChanged   += PcArchor_ValueChanged;

            //OnShowPoint();
            return(true);
        }