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(); } }
public CameraSelector() { InitializeComponent(); //Set the data context this.DataContext = CameraSelectorViewModel.GetInstance(); }
/// <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); }
private void RefreshButton_Click(object sender, RoutedEventArgs e) { CameraSelectorViewModel vm = this.DataContext as CameraSelectorViewModel; if (vm != null) { vm.RefreshCameraList(); } }
private void OK_Button_Click(object sender, RoutedEventArgs e) { CameraSelectorViewModel vm = this.DataContext as CameraSelectorViewModel; if (vm != null) { vm.ResultOK = true; } this.Close(); }