Пример #1
0
        private void BtnSave_OnClick(object sender, RoutedEventArgs e)
        {
            Bll bll = AppContext.GetLocationBll();

            var area = new Area();

            area.Name     = TbName.Text;
            area.Type     = (AreaTypes)TbType.SelectedItem;
            area.ParentId = parent.Id;

            if (CbHaveBound.IsChecked == true)
            {
                float x1    = (float)(TbCenterPosition.X - TbSize.X / 2 + TbZero.X);
                float y1    = (float)(TbCenterPosition.Y - TbSize.Y / 2 + TbZero.Y);
                float x2    = (float)(TbCenterPosition.X + TbSize.X / 2 + TbZero.X);
                float y2    = (float)(TbCenterPosition.Y + TbSize.Y / 2 + TbZero.Y);
                var   bound = new Bound(x1, y1, x2, y2, 0, 0.5f, false);
                if (bll.Bounds.Add(bound) == false)
                {
                    MessageBox.Show("坐标添加失败");
                }
                area.SetBound(bound);
            }
            else
            {
            }

            if (bll.Areas.Add(area) == false)
            {
                MessageBox.Show("区域添加失败");
            }
            NewArea           = area;
            this.DialogResult = true;
        }
Пример #2
0
        /// <summary>
        /// 根据节点修改监控范围
        /// </summary>
        public bool EditMonitorRange(PhysicalTopology pt)
        {
            var  initializer = new AreaTreeInitializer(db);
            Area area        = db.Areas.Find((i) => i.Id == pt.Id);

            if (area != null)
            {
                pt.InitBound.SetInitBound(pt.Transfrom);
                area.SetTransform(pt.Transfrom.ToDbModel());
                DbModel.Location.AreaAndDev.Bound InitBoundT = pt.InitBound.ToDbModel();
                db.Bounds.Edit(InitBoundT);
                area.SetBound(InitBoundT);
                var points = area.InitBound.Points;
                //foreach (DbModel.Location.AreaAndDev.Point p in points)
                //{
                //    DbModel.Location.AreaAndDev.Point pointT = db.Points.Find((i) => i.BoundId == InitBoundT.Id && i.Index == p.Index);
                //    if (pointT != null)
                //    {
                //        db.Points.Edit(pointT);
                //    }
                //    else
                //    {
                //        db.Points.Add(pointT);
                //    }
                //}
                db.Points.EditRange(points);
                return(db.Areas.Edit(area));
            }
            else
            {
                return(false);
            }
            //return db.Areas.Edit(pt.ToDbModel());
        }
Пример #3
0
        public void SetBound(Bound bound)
        {
            IsRelative = bound.IsRelative;
            X          = (float)((bound.MinX + bound.MaxX) / 2.0);
            Z          = (float)((bound.MinY + bound.MaxY) / 2.0);//Z和Y调换一下
            Y          = (float)((bound.MinZ + bound.MaxZ) / 2.0);

            SX = (bound.MaxX - bound.MinX);
            SZ = (bound.MaxY - bound.MinY);//Z和Y调换一下
            SY = (bound.MaxZ - bound.MinZ);

            RX = 0;
            RY = 0;
            RZ = 0;

            InitBound = bound;
        }
Пример #4
0
 public Bound CreateBoundByChildren()
 {
     InitBound = new Bound();
     if (Children != null)
     {
         foreach (var level1Item in Children) //建筑群
         {
             InitBound.Combine(level1Item.InitBound);
             if (level1Item.Children != null)
             {
                 foreach (var level2Item in level1Item.Children) //建筑
                 {
                     InitBound.Combine(level2Item.InitBound);
                 }
             }
         }
     }
     return(InitBound);
 }
        //    private void SetInitBound(Area topo, DbModel.Location.AreaAndDev.Point[] points, float thicknessT, bool isRelative = true,
        //float bottomHeightT = 0, bool isOnNormalArea = true, bool isOnAlarmArea = false, bool isOnLocationArea = false)
        //    {
        //        DbModel.Location.AreaAndDev.Bound initBound = new DbModel.Location.AreaAndDev.Bound(points, bottomHeightT, thicknessT, isRelative);
        //        DbModel.Location.AreaAndDev.Bound editBound = new DbModel.Location.AreaAndDev.Bound(points, bottomHeightT, thicknessT, isRelative);
        //        TransformM transfrom = new TransformM(initBound);
        //        db.Bounds.Add(initBound);
        //        db.Bounds.Add(editBound);
        //        transfrom.IsCreateAreaByData = isOnNormalArea;
        //        transfrom.IsOnAlarmArea = isOnAlarmArea;
        //        transfrom.IsOnLocationArea = isOnLocationArea;
        //        //TransformMs.Add(transfrom);

        //        topo.SetTransform(transfrom);
        //        topo.InitBound = initBound;
        //        topo.EditBound = editBound;
        //        Areas.Edit(topo);
        //    }

        ///// <summary>
        ///// 根据节点修改监控范围
        ///// </summary>
        //public bool EditMonitorRangeTransformM(int physicalTopologyId, TransformM tranM)
        //{
        //    //db.TransformMs.Edit(pt.Transfrom);
        //    Area area = db.Areas.Find((i) => i.Id == physicalTopologyId);
        //    if (area != null)
        //    {
        //        area.SetTransform(tranM.ToDbModel());
        //        return db.Areas.Edit(area);
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //    //return db.Areas.Edit(pt.ToDbModel());
        //}

        /// <summary>
        /// 根据节点添加子监控范围
        /// </summary>
        public PhysicalTopology AddMonitorRange(PhysicalTopology pt)
        {
            //return db.Areas.Add(pt.ToDbModel());
            var areaT = pt.ToDbModel();

            pt.InitBound            = new Location.TModel.Location.AreaAndDev.Bound();
            pt.InitBound.IsRelative = pt.IsRelative;
            pt.InitBound.SetInitBound(pt.Transfrom);
            areaT.SetTransform(pt.Transfrom.ToDbModel());
            DbModel.Location.AreaAndDev.Bound InitBoundT = pt.InitBound.ToDbModel();
            db.Bounds.Add(InitBoundT);
            areaT.SetBound(InitBoundT);
            var points = areaT.InitBound.Points;
            //db.Points.AddRange(points);

            var result = db.Areas.Add(areaT);

            if (result)
            {
                return(areaT.ToTModel());
            }
            return(null);
        }
Пример #6
0
        public string GetSvgXml(Bound bound, List <Point> pointlist, int Scale, double OffsetX, double OffsetY, double CanvaHeight)
        {
            int    nCount    = 0;
            string strReturn = "";
            string strPoints = "";

            if (bound == null)
            {
                return(strReturn);
            }

            foreach (var item in bound.GetPointsByPointList(pointlist))
            {
                double x  = (item.X - OffsetX) * Scale;
                double y  = CanvaHeight - ((item.Y - OffsetY) * Scale);
                string sx = Convert.ToString(x);
                string sy = Convert.ToString(y);

                if (nCount == 0)
                {
                    strPoints = sx + "," + sy;
                    nCount    = 1;
                }
                else
                {
                    strPoints += " " + sx + "," + sy;
                }
            }

            if (strPoints != "")
            {
                strReturn = "<polygon id = \"" + Convert.ToString(Id) + "\" name = \"" + Name + "\" class=\"cls-1\" points=\"" + strPoints + "\" />";
            }

            return(strReturn);
        }
Пример #7
0
 public Area(Bound bound)
 {
     SetBound(bound);
 }