private void InitTopoTreeAreaMenu(WPFClientControlLib.TopoTreeView topoTree) { topoTree.AreaMenu = new ContextMenu(); topoTree.AreaMenu.AddMenu("添加区域", (obj) => { var area = topoTree.SelectedObject as AreaEntity; var win = new NewAreaWindow(area, 0); win.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); }; if (win.ShowDialog() == true) { var newArea = win.NewArea; area.AddChild(newArea.ToTModel()); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); } }); topoTree.AreaMenu.AddMenu("添加区域(柱子)", (obj) => { var area = topoTree.SelectedObject as AreaEntity; var win = new NewAreaWindow(area, 1); win.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); }; if (win.ShowDialog() == true) { var newArea = win.NewArea; area.AddChild(newArea.ToTModel()); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); } }); topoTree.AreaMenu.AddMenu("设置区域", (tag) => { var area = topoTree.SelectedObject as AreaEntity; ShowAreaInfo(area); }); topoTree.AreaMenu.AddMenu("删除区域", (tag) => { var area = topoTree.SelectedObject as AreaEntity; RemoveArea(area); }); topoTree.AreaMenu.AddMenu("添加基站", (tag) => { var area = topoTree.SelectedObject as AreaEntity; var archor = new TArchor(); archor.X = 10; archor.Y = 10; archor.Name = "NewArchor"; archor.Code = ""; archor.Ip = ""; archor.ParentId = area.Id; var archorNew = archorService.Post(archor); archorNew.Code = "Code_" + archorNew.Id; archorService.Put(archorNew); area.AddLeaf(archorNew.DevInfo); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); }); //topoTree.AreaMenu.AddMenu("调整子区域坐标", (tag) => //{ // var area = topoTree.SelectedObject as AreaEntity; // var bound = area.InitBound; // var x = bound.MinX; // var y = bound.MinY; // var boundList = new List<Bound>(); // foreach (var subArea in area.Children) // { // var subBound = subArea.InitBound; // if (subBound != null) // { // var points = subBound.Points; // if (points != null) // { // foreach (var point in points) // { // point.X -= x; // point.Y -= y; // } // bll.Points.EditRange(points.ToDbModel()); // } // subBound.SetMinMaxXY(); // boundList.Add(subBound); // } // } // bll.Bounds.EditRange(boundList.ToDbModel()); //}); topoTree.AreaMenu.AddMenu("复制结构", (tag) => { var area = topoTree.SelectedObject as AreaEntity; var area1 = areaService.GetEntity("240", true); area.InitBound.SetMinMaxXY(); bll.Bounds.Edit(area.InitBound.ToDbModel()); var children = area1.Children.CloneObjectList().ToList(); var newBounds = new List <Bound>(); foreach (var item in children) { if (item.InitBound.Points == null) { item.InitBound.Points = bll.Points.FindAll(i => i.BoundId == item.Id).ToTModel(); } newBounds.Add(item.InitBound); } var dbBounds = newBounds.ToDbModel(); bll.Bounds.AddRange(dbBounds); for (int i = 0; i < children.Count; i++) { AreaEntity item = children[i]; item.ParentId = area.Id; item.InitBoundId = dbBounds[i].Id; } foreach (var item in dbBounds) { var points = item.Points.CloneObjectList(); foreach (var point in points) { point.BoundId = item.Id; } bll.Points.AddRange(points); } var dbChildren = children.ToDbModel(); bll.Areas.AddRange(dbChildren); var devs = area1.LeafNodes.CloneObjectList().ToList();; foreach (var item in devs) { item.ParentId = area.Id; item.Code = ""; item.IP = ""; item.DevDetail = bll.Archors.Find(i => i.DevInfoId == item.Id).ToTModel(); } var dbDevs = devs.ToDbModel(); bll.DevInfos.AddRange(dbDevs); var archors = new List <TModel.Location.AreaAndDev.Archor>(); for (int i = 0; i < devs.Count; i++) { DevEntity dev = devs[i]; var archor = dev.DevDetail as TModel.Location.AreaAndDev.Archor; archor.Code = ""; archor.Ip = ""; archor.ParentId = area.Id; archor.DevInfoId = dbDevs[i].Id; archors.Add(archor); } bll.Archors.AddRange(archors.ToDbModel()); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); }); }
private void LoadAreaTree() { var tree = areaService.GetTree(1); if (tree == null) { return; } var devList = tree.GetAllDev(); var archorList = archorService.GetList(); foreach (var dev in devList) { if (archorList != null) { dev.DevDetail = archorList.FirstOrDefault(i => i.DevInfoId == dev.Id); } } var topoTree = ResourceTreeView1.TopoTree; topoTree.AreaMenu = new ContextMenu(); topoTree.AreaMenu.AddMenu("添加区域", (obj) => { var area = topoTree.SelectedObject as AreaEntity; var win = new NewAreaWindow(area); win.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); }; if (win.ShowDialog() == true) { var newArea = win.NewArea; area.AddChild(newArea.ToTModel()); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); } }); topoTree.AreaMenu.AddMenu("设置区域", (tag) => { var area = topoTree.SelectedObject as AreaEntity; ShowAreaInfo(area); }); topoTree.AreaMenu.AddMenu("删除区域", (tag) => { var area = topoTree.SelectedObject as AreaEntity; RemoveArea(area); }); topoTree.AreaMenu.AddMenu("添加基站", (tag) => { var area = topoTree.SelectedObject as AreaEntity; var archor = new TArchor(); archor.X = 10; archor.Y = 10; archor.Name = "NewArchor"; archor.Code = ""; archor.Ip = ""; archor.ParentId = area.Id; var archorNew = archorService.Post(archor); archorNew.Code = "Code_" + archorNew.Id; archorService.Put(archorNew); area.AddLeaf(archorNew.DevInfo); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); }); //topoTree.AreaMenu.AddMenu("调整子区域坐标", (tag) => //{ // var area = topoTree.SelectedObject as AreaEntity; // var bound = area.InitBound; // var x = bound.MinX; // var y = bound.MinY; // var boundList = new List<Bound>(); // foreach (var subArea in area.Children) // { // var subBound = subArea.InitBound; // if (subBound != null) // { // var points = subBound.Points; // if (points != null) // { // foreach (var point in points) // { // point.X -= x; // point.Y -= y; // } // bll.Points.EditRange(points.ToDbModel()); // } // subBound.SetMinMaxXY(); // boundList.Add(subBound); // } // } // bll.Bounds.EditRange(boundList.ToDbModel()); //}); topoTree.AreaMenu.AddMenu("复制结构", (tag) => { var area = topoTree.SelectedObject as AreaEntity; var area1 = areaService.GetEntity("240", true); area.InitBound.SetMinMaxXY(); bll.Bounds.Edit(area.InitBound.ToDbModel()); var children = area1.Children.CloneObjectList().ToList(); var newBounds = new List <Bound>(); foreach (var item in children) { if (item.InitBound.Points == null) { item.InitBound.Points = bll.Points.FindAll(i => i.BoundId == item.Id).ToTModel(); } newBounds.Add(item.InitBound); } var dbBounds = newBounds.ToDbModel(); bll.Bounds.AddRange(dbBounds); for (int i = 0; i < children.Count; i++) { AreaEntity item = children[i]; item.ParentId = area.Id; item.InitBoundId = dbBounds[i].Id; } foreach (var item in dbBounds) { var points = item.Points.CloneObjectList(); foreach (var point in points) { point.BoundId = item.Id; } bll.Points.AddRange(points); } var dbChildren = children.ToDbModel(); bll.Areas.AddRange(dbChildren); var devs = area1.LeafNodes.CloneObjectList().ToList();; foreach (var item in devs) { item.ParentId = area.Id; item.Code = ""; item.IP = ""; item.DevDetail = bll.Archors.Find(i => i.DevInfoId == item.Id).ToTModel(); } var dbDevs = devs.ToDbModel(); bll.DevInfos.AddRange(dbDevs); var archors = new List <TModel.Location.AreaAndDev.Archor>(); for (int i = 0; i < devs.Count; i++) { DevEntity dev = devs[i]; var archor = dev.DevDetail as TModel.Location.AreaAndDev.Archor; archor.Code = ""; archor.Ip = ""; archor.ParentId = area.Id; archor.DevInfoId = dbDevs[i].Id; archors.Add(archor); } bll.Archors.AddRange(archors.ToDbModel()); //var archor = new TArchor(); //archor.X = 10; //archor.Y = 10; //archor.Name = "NewArchor"; //archor.Code = ""; //archor.Ip = ""; //archor.ParentId = area.Id; //var archorNew = archorService.Post(archor); //archorNew.Code = "Code_" + archorNew.Id; //archorService.Put(archorNew); //area.AddLeaf(archorNew.DevInfo); topoTree.RefreshCurrentNode <AreaEntity, DevEntity>(area); AreaCanvas1.Refresh(); }); topoTree.DevMenu = new ContextMenu(); topoTree.DevMenu.AddMenu("设置设备", (tag) => { var dev = topoTree.SelectedObject as DevEntity; SetDevInfo(null, dev); }); topoTree.DevMenu.AddMenu("基站配置", (tag) => { //var dev = topoTree.SelectedObject as DevEntity; //SetDevInfo(null, dev); }); topoTree.DevMenu.AddMenu("删除设备", (tag) => { var dev = topoTree.SelectedObject as DevEntity; RemoveDev(dev); }); topoTree.LoadDataEx <AreaEntity, DevEntity>(tree); topoTree.Tree.SelectedItemChanged += Tree_SelectedItemChanged; topoTree.ExpandLevel(2); if (_archors != null) { List <int> ids = new List <int>(); foreach (var archor in _archors) { topoTree.SelectNode((int)archor.ParentId, archor.DevInfoId); ids.Add(archor.DevInfoId); } AreaCanvas1.SelectDevsById(ids); } else { topoTree.SelectFirst(); } }
public TEntity Put(TEntity item) { return(service.Put(item)); }
public static void EditProperty(this DbModel.Location.AreaAndDev.Archor item2, TModel.Location.AreaAndDev.Archor item1) { item2.Code = item1.Code; item2.Name = item1.Name; item2.X = item1.X; item2.Y = item1.Y; item2.Z = item1.Z; item2.Type = item1.Type; item2.IsAutoIp = item1.IsAutoIp; item2.Ip = item1.Ip; item2.ServerIp = item1.ServerIp; item2.ServerPort = item1.ServerPort; item2.Power = item1.Power; item2.AliveTime = item1.AliveTime; item2.Enable = item1.Enable; item2.ParentId = item1.ParentId; }