Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            //Display the window
            CameraSelector camera_selector = new CameraSelector();

            camera_selector.ShowDialog();

            //Get the result of the dialog
            CameraSelectorViewModel selector_result = CameraSelectorViewModel.GetInstance();

            if (selector_result.ResultOK)
            {
                //Start playing from the webcam
                string moniker_string = selector_result.AvailableCameras[selector_result.SelectedCameraIndex].ModelCamera.CameraInfo.MonikerString;
                var    camera         = new VideoCaptureDevice(moniker_string);
                CameraVideoSourcePlayer.VideoSource = camera;
                CameraVideoSourcePlayer.Start();

                //Set the data context of the main window
                DataContext = new MainWindowViewModel(moniker_string);
            }
            else
            {
                this.Close();
            }
        }
Exemple #2
0
        private void Window_Closed(object sender, EventArgs e)
        {
            //Stop the camera from playing
            CameraVideoSourcePlayer.Stop();

            //Get the camera object
            var camera = CameraVideoSourcePlayer.VideoSource as VideoCaptureDevice;

            //Stop saving frames to the file
            MainWindowViewModel vm = DataContext as MainWindowViewModel;

            if (vm != null)
            {
                vm.StopRecording(camera);
            }
        }