From eb2c264422b98458979bc96504ce8830a527d48c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 1 Feb 2018 16:40:13 +0200 Subject: Added Tango.Video project. Implemented USB video device capture for developer module. --- .../ViewModels/MainViewVM.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index a9e71de5a..7086cfb4d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -18,6 +18,7 @@ using System.Runtime.CompilerServices; using System.Windows.Threading; using Tango.Settings; using Tango.MachineStudio.Developer.Views; +using Tango.Video.DirectCapture; namespace Tango.MachineStudio.Developer.ViewModels { @@ -286,6 +287,10 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _isJobCanceled = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the capture devices. + /// + public ObservableCollection CaptureDevices { get; set; } #endregion #region Commands @@ -365,6 +370,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand CloseJobCompletionStatusCommand { get; set; } + /// + /// Gets or sets the toggle camera command. + /// + public RelayCommand ToggleCameraCommand { get; set; } + #endregion #region Constructors @@ -412,6 +422,23 @@ namespace Tango.MachineStudio.Developer.ViewModels StartJobCommand = new RelayCommand(StartJob, () => SelectedJob != null && !IsJobRunning); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); + + CaptureDevices = new ObservableCollection(); + var availableDevices = CaptureDevice.GetAvailableCaptureDevices(); + + for (int i = 0; i < 3; i++) + { + if (i > availableDevices.Count - 1) + { + CaptureDevices.Add(new CaptureDevice() { Device = null }); + } + else + { + CaptureDevices.Add(new CaptureDevice() { Device = availableDevices[i] }); + } + } + + ToggleCameraCommand = new RelayCommand(ToggleCamera); } #endregion @@ -526,6 +553,14 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods + private void ToggleCamera(CaptureDevice captureDevice) + { + if (captureDevice.Device != null) + { + captureDevice.IsStarted = !captureDevice.IsStarted; + } + } + private void CloseJobCompletionStatusBar() { IsJobCompleted = false; -- cgit v1.3.1