public PhysicalTopology AddMonitorRange(PhysicalTopology pt) { try { if (pt == null) { return(null); } var transform = pt.Transfrom; //var parent = db.Areas.Find(pt.ParentId);//父区域 //var parentBound = db.Bounds.Find(parent.InitBoundId);//父区域的范围 //if (parent.Type == AreaTypes.楼层 && pt.IsRelative)//加上偏移量 //{ // transform.X += parentBound.MinX; // transform.Z += parentBound.MinY; //} //return db.Areas.Add(pt.ToDbModel()); var areaNew = pt.ToDbModel(); pt.InitBound = NewBound(pt); var newTransform = transform.ToDbModel(); areaNew.SetTransform(newTransform); var newBound = pt.InitBound.ToDbModel(); db.Bounds.Add(newBound); areaNew.SetBound(newBound); var points = areaNew.InitBound.Points; //db.Points.AddRange(points); var addR = db.Areas.Add(areaNew); if (addR) { TagRelationBuffer.Instance().PuUpdateData(); BLL.Buffers.AuthorizationBuffer.Instance(db).PubUpdateData(); var result = areaNew.ToTModel(); //if (parent.Type == AreaTypes.楼层 && pt.IsRelative)//减去偏移量 //{ // result.Transfrom.X -= parentBound.MinX; // result.Transfrom.Z -= parentBound.MinY; //} return(result); } return(null); } catch (Exception e) { Log.Error(tag, "AddMonitorRange", e.ToString()); return(null); } }
private void BtnSelectZero_Click(object sender, RoutedEventArgs e) { var win = new PointSelectWindow(parent.ToDbModel(), null, 1); win.SelectedAreaChanged += (area) => { }; win.SelectedPointChanged += (point) => { //SetZeroPoint(point.X, point.Y); TbZero.X = point.X; TbZero.Y = point.Y; OnShowPoint(); }; win.Owner = this; win.Show(); }
// 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); }
// 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 bool AddMonitorRange(PhysicalTopology pt) { return(db.Areas.Add(pt.ToDbModel())); }
/// <summary> /// 根据节点添加监控范围 /// </summary> public bool EditMonitorRange(PhysicalTopology pt) { //db.TransformMs.Edit(pt.Transfrom); return(db.Areas.Edit(pt.ToDbModel())); }