//private void CreateDevInfo(int areaId,Point point)
        //{
        //    //DevEntity

        //    var area= areaId
        //}

        private Window SetDevInfo(Rectangle rect, DevEntity obj, bool isShow = true)
        {
            var parentArea = areaService.GetEntity(obj.ParentId + "");

            if (parentArea.IsPark()) //电厂
            {
                var bound      = parentArea.InitBound;
                var leftBottom = bound.GetLeftBottomPoint();

                parkArchorSettingWnd             = new ParkArchorSettingWindow();
                ArchorSettingContext.ZeroX       = leftBottom.X;
                ArchorSettingContext.ZeroY       = leftBottom.Y;
                parkArchorSettingWnd.RefreshDev += (dev) => {
                    archorSettings = bll.ArchorSettings.ToList();
                    obj.Refresh(dev);
                    AreaCanvas1.RefreshDev(dev);
                };
                parkArchorSettingWnd.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); };
                parkArchorSettingWnd.Closed         += (sender, e) => { parkArchorSettingWnd = null; };

                if (isShow)
                {
                    parkArchorSettingWnd.Show();
                }

                if (parkArchorSettingWnd.ShowInfo(rect, obj.Id) == false)
                {
                    parkArchorSettingWnd.Close();
                    parkArchorSettingWnd = null;
                }
                return(parkArchorSettingWnd);
            }
            else
            {
                roomArchorSettingWnd = new RoomArchorSettingWindow();
                //roomArchorSettingWnd.Owner = this;
                roomArchorSettingWnd.RefreshDev += (dev) => {
                    archorSettings = bll.ArchorSettings.ToList();
                    obj.Refresh(dev);
                    AreaCanvas1.RefreshDev(dev);
                };
                roomArchorSettingWnd.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); };
                roomArchorSettingWnd.Closed         += (sender, e) => { roomArchorSettingWnd = null; };
                if (isShow)
                {
                    roomArchorSettingWnd.Show();
                }
                if (roomArchorSettingWnd.ShowInfo(rect, obj.Id) == false)
                {
                    roomArchorSettingWnd.Close();
                    roomArchorSettingWnd = null;
                }
                return(roomArchorSettingWnd);
            }
        }
示例#2
0
        private void SetDevInfo(Rectangle rect, DevEntity obj)
        {
            var parentArea = areaService.GetEntity(obj.ParentId + "");

            //obj.Parent
            if (parentArea.IsPark()) //电厂
            {
                var bound = parentArea.InitBound;
                //if (bound.Points == null)
                //{
                //    bound.Points = new Bll().Points.FindAll(i => i.BoundId == bound.Id);
                //}
                var leftBottom = bound.GetLeftBottomPoint();

                parkArchorSettingWnd       = new ParkArchorSettingWindow();
                ArchorSettingContext.ZeroX = leftBottom.X;
                ArchorSettingContext.ZeroY = leftBottom.Y;
                //win2.Owner = this;
                parkArchorSettingWnd.RefreshDev += (dev) => {
                    archorSettings = bll.ArchorSettings.ToList();
                    AreaCanvas1.RefreshDev(dev);
                };
                parkArchorSettingWnd.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); };
                parkArchorSettingWnd.Closed         += (sender, e) => { parkArchorSettingWnd = null; };
                parkArchorSettingWnd.Show();

                if (parkArchorSettingWnd.ShowInfo(rect, obj.Id) == false)
                {
                    parkArchorSettingWnd.Close();
                    parkArchorSettingWnd = null;
                    return;
                }
            }
            else
            {
                roomArchorSettingWnd = new RoomArchorSettingWindow();
                //roomArchorSettingWnd.Owner = this;
                roomArchorSettingWnd.RefreshDev += (dev) => {
                    archorSettings = bll.ArchorSettings.ToList();
                    AreaCanvas1.RefreshDev(dev);
                };
                roomArchorSettingWnd.ShowPointEvent += (x, y) => { AreaCanvas1.ShowPoint(x, y); };
                roomArchorSettingWnd.Closed         += (sender, e) => { roomArchorSettingWnd = null; };
                roomArchorSettingWnd.Show();
                if (roomArchorSettingWnd.ShowInfo(rect, obj.Id) == false)
                {
                    roomArchorSettingWnd.Close();
                    roomArchorSettingWnd = null;
                    return;
                }
            }
        }
        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();
            });
        }
示例#4
0
        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();
            }
        }