Inheritance: CameraViewStatusChangedEventArgs
コード例 #1
0
 protected virtual void OnCameraViewBeforeStartEvent(CameraViewBeforeStartEventArgs e)
 {
     if (this.EventBeforeStart != null)
     {
         EventBeforeStart(this, e);
     }
 }
コード例 #2
0
 public void Start()
 {
     if (false == this.CameraClass.ValidCheck(true))
     {
         return;
     }
     this.Cursor = Cursors.WaitCursor;
     try
     {
         CameraViewBeforeStartEventArgs e = new CameraViewBeforeStartEventArgs(this.Status, this);
         OnCameraViewBeforeStartEvent(e);
         if (e.Cancel == false)
         {
             OnCameraViewLog(new CameraViewLogEventArgs(ZForge.Controls.Logs.LogLevel.LOG_INFO, string.Format(Translator.Instance.T("启动摄像头[{0}]."), this.CameraClass.Name), this));
             AForge.Video.IVideoSource source = this.CameraClass.VideoSource;
             if (source == null)
             {
                 throw new System.NullReferenceException();
             }
             OpenVideoSource(source);
             this.SetStatus(Motion.Core.CameraStatus.STOPPED, false);
             this.SetStatus(Motion.Core.CameraStatus.STARTED, true);
         }
         e = null;
     }
     catch (Exception)
     {
         MessageBox.Show(string.Format(Translator.Instance.T("启动摄像头[{0}]失败!"), this.CameraClass.Name), MotionPreference.Instance.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         OnCameraViewLog(new CameraViewLogEventArgs(ZForge.Controls.Logs.LogLevel.LOG_ERROR, string.Format(Translator.Instance.T("启动摄像头[{0}]失败!"), this.CameraClass.Name), this));
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
コード例 #3
0
ファイル: CameraEditForm.cs プロジェクト: unixcrh/Motion
 private void cameraViewTest_CameraViewBeforeStart(object sender, CameraViewBeforeStartEventArgs e)
 {
     e.Cancel = this.Camera.ValidCheck(true) ? false : true;
     if (!e.Cancel)
     {
         this.cameraViewTest.CameraClass = this.Camera;
     }
 }
コード例 #4
0
ファイル: CameraEditForm.cs プロジェクト: zhuangyy/Motion
 private void cameraViewTest_CameraViewBeforeStart(object sender, CameraViewBeforeStartEventArgs e)
 {
     e.Cancel = this.Camera.ValidCheck(true) ? false : true;
     if (!e.Cancel)
     {
         this.cameraViewTest.CameraClass = this.Camera;
     }
 }
コード例 #5
0
ファイル: CameraView.cs プロジェクト: zhuangyy/Motion
 protected virtual void OnCameraViewBeforeStartEvent(CameraViewBeforeStartEventArgs e)
 {
     if (this.EventBeforeStart != null)
     {
         EventBeforeStart(this, e);
     }
 }
コード例 #6
0
ファイル: CameraView.cs プロジェクト: zhuangyy/Motion
 public void Start()
 {
     if (false == this.CameraClass.ValidCheck(true))
     {
         return;
     }
     this.Cursor = Cursors.WaitCursor;
     try
     {
         CameraViewBeforeStartEventArgs e = new CameraViewBeforeStartEventArgs(this.Status, this);
         OnCameraViewBeforeStartEvent(e);
         if (e.Cancel == false)
         {
             OnCameraViewLog(new CameraViewLogEventArgs(ZForge.Controls.Logs.LogLevel.LOG_INFO, string.Format(Translator.Instance.T("启动摄像头[{0}]."), this.CameraClass.Name), this));
             AForge.Video.IVideoSource source = this.CameraClass.VideoSource;
             if (source == null)
             {
                 throw new System.NullReferenceException();
             }
             OpenVideoSource(source);
             this.SetStatus(Motion.Core.CameraStatus.STOPPED, false);
             this.SetStatus(Motion.Core.CameraStatus.STARTED, true);
         }
         e = null;
     }
     catch (Exception)
     {
         MessageBox.Show(string.Format(Translator.Instance.T("启动摄像头[{0}]失败!"), this.CameraClass.Name), MotionPreference.Instance.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         OnCameraViewLog(new CameraViewLogEventArgs(ZForge.Controls.Logs.LogLevel.LOG_ERROR, string.Format(Translator.Instance.T("启动摄像头[{0}]失败!"), this.CameraClass.Name), this));
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }