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. --- .../Tango.MachineStudio.Developer.csproj | 4 + .../ViewModels/MainViewVM.cs | 35 +++++++ .../Views/MainView.xaml | 114 ++++++++++++++------- .../Views/MainView.xaml.cs | 14 ++- 4 files changed, 129 insertions(+), 38 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 9696f47ca..622e4f51c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -167,6 +167,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {9652f972-2bd1-4283-99cb-fc6240434c17} + Tango.Video + {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common 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; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index b2d553ff2..cf5d1e19e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -16,6 +16,7 @@ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:observables="clr-namespace:Tango.Integration.Observables;assembly=Tango.Integration" xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + xmlns:video="clr-namespace:Tango.Video.DirectCapture;assembly=Tango.Video" xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" @@ -1502,46 +1503,87 @@ - + USB CAMERAS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs index cdf2248a6..16427c42b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs @@ -54,8 +54,18 @@ namespace Tango.MachineStudio.Developer.Views ViewAttached?.Invoke(this, this); }; - chkGraphs.Checked += (x, y) => { graphRowDefinition.Height = new GridLength(440, GridUnitType.Pixel); }; - chkGraphs.Unchecked += (x, y) => { graphRowDefinition.Height = new GridLength(80, GridUnitType.Pixel); }; + chkGraphs.Checked += (x, y) => + { + graphRowDefinition.Height = new GridLength(440, GridUnitType.Pixel); + //dockCameras.Width = 270; + //dockCameras.Height = 600; + }; + chkGraphs.Unchecked += (x, y) => + { + graphRowDefinition.Height = new GridLength(80, GridUnitType.Pixel); + //dockCameras.Width = 330; + //dockCameras.Height = 850; + }; _jobBrushTimer = new DispatcherTimer(); _jobBrushTimer.Interval = TimeSpan.FromSeconds(1); -- cgit v1.3.1