Пример #1
0
        /// <summary>
        /// 将视频面板置顶
        /// </summary>
        private void SetVideoPanelTop()
        {
            //如果存在已经打开的全屏视频,则继续恢复该全屏视频
            string fullScreenVideoProcessID = FileUtils.ReadFullScreenVideoProcessID();

            if (fullScreenVideoProcessID != null)
            {
                //通过句柄设置当前窗体置顶
                VideoInject.SetForegroundWindow(Process.GetProcessById(int.Parse(fullScreenVideoProcessID)).MainWindowHandle);
                logger.Info("九宫格置顶窗体:" + Process.GetProcessById(int.Parse(fullScreenVideoProcessID)).ProcessName);
            }
        }
Пример #2
0
        /// <summary>
        /// 置顶主窗体
        /// </summary>
        private void SetFormMainTop()
        {
            // 获取查找窗体句柄(通过窗体标题名)
            IntPtr mainHandle = VideoInject.FindWindow(null, this.Text);

            logger.Info("主窗体句柄:" + mainHandle.ToString());
            if (mainHandle != IntPtr.Zero)
            {
                SetVideoPanelTop();
                //通过句柄设置当前窗体置顶
                VideoInject.SetForegroundWindow(mainHandle);
                logger.Info("主窗体置顶");
            }
        }
Пример #3
0
        /// <summary>
        /// GIS地图上点击打开视频事件
        /// </summary>
        /// <param name="p"></param>
        private void BuddyBMapControl_OnOpenVideo(BMeshPoint p)
        {
            VideoInject inject = new VideoInject(mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerIPV4],
                                                 mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerUserName],
                                                 mFormMain.AllApplicationSetting[ApplicationSettingKey.VideoServerPassword]);
            Process process = mFormMain.VideoWindowProcesses.Find(ps => ps.StartInfo.Arguments.Contains(p.Model265ID));

            if (BuddyBMapControl != null)
            {
                //查找曾经试图关闭视频进程的进程是否已经完全结束,如果没有结束再自动Kill一次
                foreach (string pidf in Directory.GetFiles(FileUtils.VIDEO_PROCESS_ID_DIRECTORY))
                {
                    string  pid   = Path.GetFileNameWithoutExtension(pidf);
                    Process tempP = mFormMain.VideoWindowProcesses.Find(ps => ps.Id.ToString() == pid);
                    if (tempP != null && !tempP.HasExited)
                    {//说明进程曾经试图关闭自己,但是没有关闭掉
                        tempP.Kill();
                        mFormMain.VideoProcesses.Remove(tempP);
                    }
                    if (File.Exists(pidf))
                    {
                        File.Delete(pidf);
                    }
                }

                if (process == null)
                {
                    mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                }
                else
                {
                    if (process.HasExited)
                    {
                        mFormMain.VideoWindowProcesses.Remove(process);
                        mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                    }
                    else
                    {
                        //进程ID文件
                        string idFile = Path.Combine(FileUtils.VIDEO_PROCESS_ID_DIRECTORY, process.Id + ".txt");
                        if (File.Exists(idFile))
                        {
                            if (File.Exists(idFile))
                            {
                                File.Delete(idFile);
                            }
                            if (!process.HasExited)
                            {
                                process.Kill();
                            }
                            mFormMain.VideoWindowProcesses.Remove(process);
                            mFormMain.VideoWindowProcesses.Add(inject.injectWindow(p.Model265ID));
                        }
                        else
                        {
                            //如果已经打开过该视频,则直接将视频窗口置顶
                            VideoInject.SetForegroundWindow(process.MainWindowHandle);
                        }
                    }
                }
            }
        }
Пример #4
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);
                            }
                        }
                    }
                }
            }
        }