/// <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); } }
/// <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("主窗体置顶"); } }
/// <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); } } } } }