void InitAreaCanvas() { AreaCanvas1.Init(); AreaCanvas1.udpArchorList = ArchorManager.LoadArchorListResult(); ContextMenu devContextMenu = new ContextMenu(); devContextMenu.AddMenu("设置设备", (tag) => { SetDevInfo(AreaCanvas1.SelectedDev, AreaCanvas1.SelectedDev.Tag as DevEntity); }); devContextMenu.AddMenu("删除设备", (tag) => { var dev = AreaCanvas1.SelectedDev.Tag as DevEntity; RemoveDev(dev); }); devContextMenu.AddMenu("复制设备", (tag) => { var dev = AreaCanvas1.SelectedDev.Tag as DevEntity; dev.Pos.PosX += 5; dev.Pos.PosY += 5; dev.Name += " Copy"; dev.Code = ""; //dev.Ip = ""; var dev2 = devService.Post(dev); var archor = dev.DevDetail as TArchor; if (archor != null) { archor.X += 5; archor.Y += 5; archor.Name += " Copy"; archor.Code = ""; archor.Ip = ""; archor.DevInfoId = dev2.Id; var archorNew = archorService.Post(archor); archorNew.Code = "Code_" + archorNew.Id; archorService.Put(archorNew); } LoadData(); }); AreaCanvas1.DevContextMenu = devContextMenu; ContextMenu areaContextMenu = new ContextMenu(); areaContextMenu.AddMenu("设置区域", (tag) => { var area = AreaCanvas1.SelectedArea; ShowAreaInfo(area); }); areaContextMenu.AddMenu("删除区域", (tag) => { var area = AreaCanvas1.SelectedArea; RemoveArea(area); }); areaContextMenu.AddMenu("删除区域内设备", (tag) => { var area = AreaCanvas1.SelectedArea; RemoveAreaDevs(area); }); areaContextMenu.AddMenu("添加测量点", (tag) => { var area = AreaCanvas1.SelectedArea; TrackPointWindow win = new TrackPointWindow(); if (win.Show(area.Id, AreaCanvas1.SelectedPoint2) == true) { var newDev = win._tp; area.AddLeafNode(newDev.ToTModel()); AreaCanvas1.Refresh(); var newDevRect = AreaCanvas1.GetDev(newDev.Id); Window wnd = SetDevInfo(newDevRect, newDevRect.Tag as DevEntity); if (wnd is RoomArchorSettingWindow) { (wnd as RoomArchorSettingWindow).SaveInfo(false); //wnd.Close(); } } //RoomArchorSettingWindow win = new RoomArchorSettingWindow(); //var dev = topoTree.SelectedObject as DevEntity; //SetDevInfo(null, null); }); AreaCanvas1.AreaContextMenu = areaContextMenu; archorSettings = bll.ArchorSettings.ToList(); AreaCanvas1.GetSettingFunc = (dev) => { object detail = dev.DevDetail; if (detail is TArchor) { var archor = detail as TArchor; return(archorSettings.Find(i => i.Code == archor.Code)); } return(null); }; }
void InitAreaCanvas() { AreaCanvas1.Init(); ContextMenu devContextMenu = new ContextMenu(); devContextMenu.AddMenu("设置设备", (tag) => { SetDevInfo(AreaCanvas1.SelectedDev, AreaCanvas1.SelectedDev.Tag as DevEntity); }); devContextMenu.AddMenu("删除设备", (tag) => { var dev = AreaCanvas1.SelectedDev.Tag as DevEntity; RemoveDev(dev); }); devContextMenu.AddMenu("复制设备", (tag) => { var dev = AreaCanvas1.SelectedDev.Tag as DevEntity; dev.Pos.PosX += 5; dev.Pos.PosY += 5; dev.Name += " Copy"; dev.Code = ""; //dev.Ip = ""; var dev2 = devService.Post(dev); var archor = dev.DevDetail as TArchor; archor.X += 5; archor.Y += 5; archor.Name += " Copy"; archor.Code = ""; archor.Ip = ""; archor.DevInfoId = dev2.Id; var archorNew = archorService.Post(archor); archorNew.Code = "Code_" + archorNew.Id; archorService.Put(archorNew); LoadData(); }); AreaCanvas1.DevContextMenu = devContextMenu; ContextMenu areaContextMenu = new ContextMenu(); areaContextMenu.AddMenu("设置区域", (tag) => { var area = AreaCanvas1.SelectedArea; ShowAreaInfo(area); }); areaContextMenu.AddMenu("删除区域", (tag) => { var area = AreaCanvas1.SelectedArea; RemoveArea(area); }); areaContextMenu.AddMenu("删除区域内设备", (tag) => { var area = AreaCanvas1.SelectedArea; RemoveAreaDevs(area); }); AreaCanvas1.AreaContextMenu = areaContextMenu; archorSettings = bll.ArchorSettings.ToList(); AreaCanvas1.GetSettingFunc = (dev) => { object detail = dev.DevDetail; if (detail is TArchor) { var archor = detail as TArchor; return(archorSettings.Find(i => i.Code == archor.Code)); } return(null); }; }