Пример #1
0
        private void OpenVideo(Camera getCamera)
        {
            List <IntPtr> handelList = new List <IntPtr>();
            PictureBox    pb         = new PictureBox()
            {
                BackColor = System.Drawing.Color.Black, Margin = new Padding(3, 0, 3, 0), Dock = DockStyle.Fill
            };                                                                                                                                   //Pink 改为 black 2016-3-3 11:25:18……

            handelList.Add(pb.Handle);
            formHostBig.Child = pb;
            if (gCfg == null)
            {
                gCfg = InfoExchange.Clone(cfg);//InitReadVideoConfig();
            }
            gCfg.CameraList.Clear();
            getCamera.Position = "1";
            gCfg.CameraList.Add(getCamera);
            if (_curVideoController != null)
            {
                _curVideoController.Stop();
                _curVideoController.Close();
            }
            _curVideoController = null;
            System.GC.Collect();
            _curVideoController = new VideoController(new FtpConfig(), gCfg, handelList);
            _curVideoController.OnShowErrMsg += _curVideoController_OnShowErrMsg;
            _curVideoController.Open();
            _curVideoController.Start();
        }
Пример #2
0
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                VideoMonitorViewModel vm = (VideoMonitorViewModel)this.DataContext;

                #region 关闭语音对讲
                if (vm.audioController != null)
                {
                    vm.audioController.Stop();
                    vm.audioController.Close();
                }
                VoiceRemindHelper.SendVoiceTalkEndToMeasure(vm.CurClientModel.ClientId);
                #region 写日志
                LogModel log = new LogModel()
                {
                    CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Direction    = LogConstParam.Directions_Out,
                    FunctionName = "视频监控窗体_窗体关闭事件",
                    Level        = LogConstParam.LogLevel_Info,
                    Msg          = "关闭【语音对讲】,同时通知任务服务器",
                    Origin       = LoginUser.Role.Name,
                    Data         = new { clientid = vm.CurClientModel.ClientId, cmd = ParamCmd.Voice_Prompt, msg = "语音对讲结束" },
                    IsDataValid  = LogConstParam.DataValid_Ok,
                    ParamList    = new List <DataParam>()
                    {
                        new DataParam()
                        {
                            ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client
                        }
                    },
                    OperateUserName = LoginUser.Name
                };
                Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log));
                #endregion
                #endregion

                #region 关闭视频
                if (_curVideoController != null)
                {
                    _curVideoController.Stop();
                    _curVideoController.Close();
                    #region 写日志
                    LogModel log1 = new LogModel()
                    {
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Direction       = LogConstParam.Directions_Out,
                        FunctionName    = "视频监控窗体_窗体关闭事件",
                        Level           = LogConstParam.LogLevel_Info,
                        Msg             = "关闭视频成功",
                        Origin          = LoginUser.Role.Name,
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1));
                    #endregion
                }
                _curVideoController = null;
                #endregion

                #region 关闭视频回放

                if (_curVideoPlayBackController != null)
                {
                    _curVideoPlayBackController.PlayStop();
                    #region 写日志
                    LogModel log2 = new LogModel()
                    {
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Direction       = LogConstParam.Directions_Out,
                        FunctionName    = "视频监控窗体_窗体关闭事件",
                        Level           = LogConstParam.LogLevel_Info,
                        Msg             = "关闭历史回放视频成功",
                        Origin          = LoginUser.Role.Name,
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log2));
                    #endregion
                }
                _curVideoPlayBackController = null;
                #endregion

                #region 释放视频监控资源
                try
                {
                    #region 内存日志
                    long     memorySize = GetMemoryAmount();
                    LogModel log3       = new LogModel()
                    {
                        CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        FunctionName = "视频监控_释放WindowsFormsHost前",
                        Msg          = "释放WindowsFormsHost前,当前线程使用内存大小:" + memorySize + "字节(" + Math.Round((double)memorySize / (1024 * 1024), 2) + "M)"
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log3));
                    #endregion
                    this.formHostBig.Dispose();
                    this.formHostBig = null;
                    #region 内存日志
                    memorySize = GetMemoryAmount();
                    LogModel log4 = new LogModel()
                    {
                        CreateTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        FunctionName = "视频监控_释放WindowsFormsHost后",
                        Msg          = "释放WindowsFormsHost后,当前线程使用内存大小:" + memorySize + "字节(" + Math.Round((double)memorySize / (1024 * 1024), 2) + "M)"
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log4));
                    #endregion
                }
                catch (Exception ex)
                {
                    #region 写日志
                    LogModel log1 = new LogModel()
                    {
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Direction       = LogConstParam.Directions_Out,
                        FunctionName    = "视频监控窗体_窗体关闭事件",
                        Level           = LogConstParam.LogLevel_Error,
                        Msg             = "释放视频资源时异常:" + ex.Message,
                        Origin          = LoginUser.Role.Name,
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1));
                    #endregion
                }
                #endregion

                #region 释放历史回放监控资源
                try
                {
                    this.formHis.Dispose();
                    this.formHis = null;
                    #region 写日志
                    LogModel log2 = new LogModel()
                    {
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Direction       = LogConstParam.Directions_Out,
                        FunctionName    = "视频监控窗体_窗体关闭事件",
                        Level           = LogConstParam.LogLevel_Info,
                        Msg             = "释放历史回放视频资源成功",
                        Origin          = LoginUser.Role.Name,
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log2));
                    #endregion
                }
                catch (Exception ex)
                {
                    #region 写日志
                    LogModel log1 = new LogModel()
                    {
                        CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Direction       = LogConstParam.Directions_Out,
                        FunctionName    = "视频监控窗体_窗体关闭事件",
                        Level           = LogConstParam.LogLevel_Error,
                        Msg             = "释放历史回放视频资源时异常:" + ex.Message,
                        Origin          = LoginUser.Role.Name,
                        OperateUserName = LoginUser.Name
                    };
                    Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1));
                    #endregion
                }
                #endregion

                this.Close();
            }
            catch (Exception ex)
            {
                #region 写日志
                LogModel log1 = new LogModel()
                {
                    CreateTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Direction       = LogConstParam.Directions_Out,
                    FunctionName    = "视频监控窗体_窗体关闭事件",
                    Level           = LogConstParam.LogLevel_Error,
                    Msg             = "窗体关闭时异常:" + ex.Message,
                    Origin          = LoginUser.Role.Name,
                    OperateUserName = LoginUser.Name
                };
                Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1));
                #endregion
            }
        }
Пример #3
0
        /// <summary>
        /// 打开配置文件中的所有视频
        /// </summary>
        private void OpenVideos()
        {
            List <IntPtr> handelList = new List <IntPtr>();

            for (int i = 0; i < cfg.CameraList.Count; i++)
            {
                if (i == 0)
                {
                    videoBig.MouseUp += videoMin_MouseUp;
                    handelList.Add(videoBig.Handle);
                }
                else
                {
                    PictureBox pb = new PictureBox()
                    {
                        BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
                    };
                    pb.MouseUp += videoMin_MouseUp;
                    handelList.Add(pb.Handle);
                    this.panel2.Controls.Add(pb);
                }
            }
            if (handelList.Count > 0)
            {
                _curVideoController = new VideoController(new FtpConfig(), cfg, handelList);
                _curVideoController.OnShowErrMsg += _curVideoController_OnShowErrMsg;
                _curVideoController.Open();
                _curVideoController.Start();
            }
            PictureBox pb1 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb1.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\1.png");
            PictureBox pb2 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb2.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\2.png");
            PictureBox pb3 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb3.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\3.png");
            PictureBox pb4 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb4.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\4.png");
            PictureBox pb5 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb5.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\5.png");
            PictureBox pb6 = new PictureBox()
            {
                BackColor = System.Drawing.Color.Pink, Width = 100, Height = 120, Margin = new Padding(3, 0, 3, 0)
            };

            pb6.Image = System.Drawing.Image.FromFile(@"D:\work\远程计量\计量改版程序新\Talent.Measure.Solution\Talent.RemoteCarMeasure\Image\CarImage\6.png");
            this.panel2.Controls.Add(pb1);
            this.panel2.Controls.Add(pb2);
            this.panel2.Controls.Add(pb3);
            this.panel2.Controls.Add(pb4);
            this.panel2.Controls.Add(pb5);
            this.panel2.Controls.Add(pb6);
        }