public bool StartPreview(CameraInfo camera, VideoSourceInfo videoSourceInfo, VideoControl vc, int streamIndex = 0) { if (vc.Locked == true)//图像被锁定 { return(false); } vc.ErrorMessage = ""; this.LogModule?.Debug($"准备打开实时预览: ({camera.ID}){camera.Name} 设备:{videoSourceInfo.IP}:{videoSourceInfo.Port} 连接码:{camera.CameraCode}"); //关闭已经打开的视频 if (vc.Mode != ShowMode.Stop) { this.StopVideo(vc); } VideoSourceBase vs = this.getVideoSourceByType(videoSourceInfo.Type); if (vs == null) { this.LogModule?.Error("未支持的设备类型"); return(false); } camera.VideoSourceInfo = videoSourceInfo; bool ret = vs.StartPreview(camera, vc, streamIndex); if (ret == true) { vc.Mode = ShowMode.Real; this.m_VideoControlTable[vc] = vs; vc.CurrentCamera = camera; } return(ret); }
public Control CreateVideoPanel(string key, int VideoControlCount = 16, string layoutName = "1") { VideoPanel panel = this.m_VideoPanelTable[key] as VideoPanel; if (panel != null) { return(panel); } panel = new VideoPanel(); List <VideoControl> vcList = new List <VideoControl>(); for (int i = 0; i < VideoControlCount; i++) { VideoControl vc = this.CreateVideoControl($"{key}_{i}"); vcList.Add(vc); } panel.VCList = vcList; panel.ControlChanged += Panel_ControlChanged; panel.CurLayout = this.layoutConfig.Layouts.First(l => l.Name == layoutName) ?? this.layoutConfig.Layouts[0] ?? Layout.GetNormalLayou("1", 1, 1); panel.Init(); this.m_VideoPanelTable[key] = panel; return(panel); }
public void Init() { this.Controls.AddRange(this.VCList.ToArray()); Form parentForm = this.FindForm(); if (parentForm != null) { parentForm.ResizeEnd += new EventHandler(VideoPanelManager_ResizeEnd); parentForm.Resize += new EventHandler(VideoPanelManager_Resize); } else { this.Resize += new EventHandler(RefreshPanel); } foreach (VideoControl vc in this.VCList) { //vc.ControlSeleted += new EventHandler(vc_ControlSeleted); vc.ActionEvent += new VideoControlEventHandle(vc_ActionProc); } this.VCList[0].Selected = true; this.m_CurControl = this.VCList[0]; if (parentForm != null) { parentForm.FindForm().BackColor = this.VCList[0].VControl.BackColor; } this.BackColor = this.VCList[0].VControl.BackColor; }
/// <summary> /// 切换码流 /// </summary> /// <param name="vc"></param> /// <param name="streamIndex"></param> public void ChangeStreamIndex(VideoControl vc, int streamIndex) { if (vc.CurrentCamera == null) { return; } if (vc.Mode != ShowMode.Real) { return; } //this.m_StreamManager.ChangeStreamIndex(vc.VControl, streamIndex); }
private void openSound_VC(VideoControl vc) { var vs = this.getVideoSourceByVideoControl(vc); switch (vc.Mode) { case ShowMode.Real: vs?.CloseSound(vc); break; case ShowMode.Playback: case ShowMode.PlayFile: break; } }
public VideoControl CreateVideoControl(string key = "") { VideoControl vc = new VideoControl(); vc.SetVideoControlConfig(this.config.VideoControlConfig); vc.CanControl = true; vc.Mode = ShowMode.Stop; vc.CanSelected = true; vc.Visible = false; vc.Name = key; vc.ActionEvent += Vc_ActionEvent; vc.PtzEvent += Vc_PtzEvent; this.m_VideoControlList.Add(vc); return(vc); }
public VideoControl GetVideoControl(string panelID, int index) { VideoControl ret = default; VideoPanel panel = this.m_VideoPanelTable[panelID] as VideoPanel; if (panel == null) { this.LogModule.Error($"未找到相应的视频面板: {panelID}"); return(ret); } if (index < 0 || index >= panel.CurLayout.ControlList.Count) { this.LogModule.Error($"索引有误: {index}"); return(ret); } return(panel.CurLayout.ControlList[index].Control); }
void vc_ControlSeleted(object sender, EventArgs e) { ControlChangedEventArgs cce = new ControlChangedEventArgs(); for (int i = 0; i < this.m_Layout.ControlList.Count; i++) { if (sender == this.VCList[i]) { cce.Sn = i; cce.VControl = this.VCList[i]; this.m_CurControl = this.VCList[i]; continue; } this.VCList[i].Selected = false; } this.ControlChanged(this, cce); }
private void closeVideo(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); switch (vc.Mode) { case ShowMode.Real: vs?.StopPreview(vc); break; case ShowMode.Playback: case ShowMode.PlayFile: vs?.StopPlayback(vc); break; default: break; } }
/// <summary> /// 关闭视频 /// </summary> /// <param name="vc"></param> public void StopVideo(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); switch (vc.Mode) { case ShowMode.Real: vs?.StopPreview(vc); break; case ShowMode.Playback: case ShowMode.PlayFile: vs?.StopPlayback(vc); vc.PBStatus = VideoControl.PB_Status.BeforeStart; break; default: break; } vc.Mode = ShowMode.Stop; vc.CurrentCamera = null; this.m_VideoControlTable[vc] = null; vc.ErrorMessage = ""; }
/// <summary> /// 交换位置 /// </summary> /// <param name="index1"></param> /// <param name="index2"></param> public void Transposition(int index1, int index2) { VideoControl vc1 = this.VCList[index1]; VideoControl vc2 = this.VCList[index2]; vc1.Name = index2.ToString(); vc2.Name = index1.ToString(); VideoControl temp = new VideoControl() { Location = new System.Drawing.Point(vc1.Location.X, vc1.Location.Y), Width = vc1.Width, Height = vc1.Height }; vc1.Location = new System.Drawing.Point(vc2.Location.X, vc2.Location.Y); vc1.Width = vc2.Width; vc1.Height = vc2.Height; vc2.Location = new System.Drawing.Point(temp.Location.X, temp.Location.Y); vc2.Width = temp.Width; vc2.Height = temp.Height; this.VCList[index2] = vc1; this.VCList[index1] = vc2; }
private void stopDownload(VideoControl vc) { //todo }
private void snap(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); bool? ret = false; string file = ""; switch (vc.Mode) { case ShowMode.Real: file = getFileName(DateTime.Now); ret = vs?.Snap(vc, file); //this.SnapPicture(vca.VControl); break; case ShowMode.Playback: DateTime time = DateTime.Now; vs.PB_GetCurTime(vc, out time); file = getFileName(time); ret = vs?.PB_Snap(vc, file); break; } if (ret == true) { this.SnapEvent?.Invoke(this, new Event.SnapEventArgs() { VC = vc, FileName = file }); } //获取文件名 string getFileName(DateTime time) { CameraInfo camera = vc.CurrentCamera; string fileName = $"{ FileHelper.GetCorrectFileName(camera.Name)}{time.ToString("yyyyMMddhhmmss")}.jpg"; if (string.IsNullOrEmpty(this.config.SnapPath) == true) { System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JPG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp|AllFile(*.*)|*.*"; sfd.FilterIndex = 1; sfd.DefaultExt = "jpg"; sfd.FileName = fileName; if (sfd.ShowDialog() == DialogResult.OK) { fileName = sfd.FileName; } } else { if (this.config.SnapPath.EndsWith("\\") == false) { this.config.SnapPath += "\\"; } fileName = $"{this.config.SnapPath}{fileName}"; } return(fileName); } }
private VideoSourceBase getVideoSourceByVideoControl(VideoControl vc) { var ret = this.m_VideoControlTable[vc] as VideoSourceBase; return(ret); }
/// <summary> /// 设置控件选中 /// </summary> /// <param name="vc"></param> private void setSelected(VideoControl vc) { this.m_VideoControlList.Where(c => c != vc).ToList().ForEach(c => c.Selected = false); }
public bool StartPlayback(CameraInfo camera, VideoSourceInfo videoSourceInfo, VideoControl vc, DateTime start, DateTime end) { if (vc.Locked == true)//图像被锁定 { return(false); } this.LogModule?.Debug($"准备打开回放: ({camera.ID}){camera.Name} 设备:{videoSourceInfo.IP}:{videoSourceInfo.Port} 连接码:{camera.CameraCode} 时间:{start}--{end}"); vc.ErrorMessage = ""; //关闭已经打开的视频 if (vc.Mode != ShowMode.Stop) { this.StopVideo(vc); } VideoSourceBase vs = this.getVideoSourceByType(videoSourceInfo.Type); if (vs == null) { this.LogModule?.Error("未支持的设备类型"); return(false); } camera.VideoSourceInfo = videoSourceInfo; bool ret = vs.StartPlaybackByTime(camera, vc, start, end); if (ret == true) { vc.Mode = ShowMode.Playback; this.m_VideoControlTable[vc] = vs; vc.CurrentCamera = camera; vc.PBStatus = VideoControl.PB_Status.Play; } return(ret); }