Example #1
0
        /// <summary>
        /// 单击节点,跳转到设备所在的位置。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void advTreeMeshList_NodeClick(object sender, TreeNodeMouseEventArgs e)
        {
            DevComponents.AdvTree.Node selectNode = advTreeMeshList.SelectedNode;

            //设备不在线,不执行后续操作
            if (selectNode == null || selectNode.Level != 1)
            {
                return;
            }

            Cell selectCell = selectNode.GetCellAt(e.X, e.Y);

            if (selectCell == null)
            {
                return;
            }

            if (selectNode.Level == 1 && selectCell.Images != null)
            {
                MeshAllInfo mai = (MeshAllInfo)selectNode.Tag;
                GPSInfo     vp  = mai.MeshGPSInfo;
                //GPS坐标为(0,0),不能执行定位操作
                if (selectCell.Images.ImageIndex == 9 && BuddyBMapControl != null)
                {//点中了离线设备
                    BuddyBMapControl.SelectMeshDevice(null);
                }
                if (selectCell.Images.ImageIndex == 10 &&
                    vp.Lat != 0 && vp.Lon != 0 &&
                    BuddyBMapControl != null)
                {
                    //地图上跳转到设备所在的位置
                    BuddyBMapControl.Center = new LatLngPoint(vp.Lon, vp.Lat);
                    BuddyBMapControl.Locate(false);
                    //选中目标Mesh设备
                    BuddyBMapControl.SelectMeshDevice(mai.BuddyBMeshPoint);
                }
                else if (selectCell.Images.ImageIndex == 11)
                {
                    MessageBox.Show("设备不在线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (selectCell.Images.ImageIndex == 12 && selectNode.Cells[1].Text.Equals("在线"))
                {
                    if (BuddyBMapControl != null)
                    {
                        BuddyBMapControl_OnOpenVideo(mai.BuddyBMeshPoint);
                    }
                    else if (BuddyGrid != null)
                    {
                        VideoInject inject = new VideoInject(mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerIPV4],
                                                             mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerUserName],
                                                             mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerPassword]);
                        Panel   panel   = BuddyGrid.GetNextAvailablePanel();
                        Process process = inject.injectPanel(panel,
                                                             mFormMain.GetVideoFullScreenLocation(),
                                                             BuddyGrid.GetFullScreenPanel(),
                                                             mai.PlanInfo.Model265ID, "0");
                        BuddyGrid.BindPanelProcess(panel, process);
                        mFormMain.VideoProcesses.Add(process);
                        logger.Info(string.Format("在第{0}个Panel中打开了视频。", panel.Tag.ToString()));
                    }
                }
                else if (selectCell.Images.ImageIndex == 13 && BuddyBMapControl != null)
                {
                    bool isDrawingRoute = (bool)selectCell.Tag;
                    if (isDrawingRoute)
                    {//已经绘制,再次点击的时候隐藏已绘制的轨迹
                        BuddyBMapControl.DeleteDeviceRoute(mai.PlanInfo.Model265ID);
                        selectCell.Tag = false;
                    }
                    else
                    {
                        //在地图上绘制轨迹记录
                        FGPSTimeSelect fgpsts = new FGPSTimeSelect();
                        fgpsts.StartDateTime = DateTime.Today.Subtract(new TimeSpan(1, 0, 0, 0));
                        fgpsts.StopDateTime  = DateTime.Today;
                        if (DialogResult.OK == fgpsts.ShowDialog() && BuddyBMapControl != null)
                        {
                            BMeshRoute bmr = FileUtils.ReadMeshRouteFromGPSLogs(
                                mai.PlanInfo.Model265ID,
                                fgpsts.StartDateTime, fgpsts.StopDateTime);
                            if (bmr.DeviceLocationList.Count > 0)
                            {
                                BuddyBMapControl.AddDeviceRoute(bmr);
                                //地图上跳转到设备所在的位置
                                BuddyBMapControl.Center = bmr.DeviceLocationList[0];
                                BuddyBMapControl.Locate(false);
                                BuddyBMapControl.Zoom = 16;
                                selectCell.Tag        = true; //标识已经绘制了路径
                                logger.Info(string.Format("查看{0}设备的GPS轨迹记录,供{1}条GPS记录。",
                                                          mai.PlanInfo.Model265ID, bmr.DeviceLocationList.Count));
                            }
                            else
                            {
                                MessageBox.Show("无历史轨迹记录。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                        }
                    }
                }
            }
        }