예제 #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();
            }
        }
예제 #2
0
        public CameraSelector()
        {
            InitializeComponent();

            //Set the data context
            this.DataContext = CameraSelectorViewModel.GetInstance();
        }
예제 #3
0
        /// <summary>
        /// Gets the one and only instance of this class that is allowed to exist.
        /// </summary>
        /// <returns>Instance of ArdyMotorBoard class</returns>
        public static CameraSelectorViewModel GetInstance()
        {
            if (_instance == null)
            {
                _instance = new CameraSelectorViewModel();
            }

            return(_instance);
        }
예제 #4
0
        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            CameraSelectorViewModel vm = this.DataContext as CameraSelectorViewModel;

            if (vm != null)
            {
                vm.RefreshCameraList();
            }
        }
예제 #5
0
        private void OK_Button_Click(object sender, RoutedEventArgs e)
        {
            CameraSelectorViewModel vm = this.DataContext as CameraSelectorViewModel;

            if (vm != null)
            {
                vm.ResultOK = true;
            }

            this.Close();
        }