diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-22 17:52:43 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-22 17:52:43 +0200 |
| commit | a02a7380e56b0bca78d6a177c3419cba93696d3f (patch) | |
| tree | da8e5239b654b95019d666164a512fdaccf51a6e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs | |
| parent | a56e7e064ff906471eca2db5cf03f7b1eea03047 (diff) | |
| parent | 86197cd0ec87a6cc186e90f75d848adc6dfa2285 (diff) | |
| download | Tango-a02a7380e56b0bca78d6a177c3419cba93696d3f.tar.gz Tango-a02a7380e56b0bca78d6a177c3419cba93696d3f.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs index 9062da11a..b3d717263 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs @@ -7,6 +7,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; +using System.Windows.Media.Imaging; using Tango.Core.Commands; using Tango.Integration.Diagnostics; using Tango.Integration.Operation; @@ -89,6 +90,16 @@ namespace Tango.MachineStudio.DataCapture.ViewModels /// </summary> public IMachineOperator MachineOperator { get; set; } + private List<CaptureDevice> _captureDevices; + /// <summary> + /// Gets or sets the capture devices. + /// </summary> + public List<CaptureDevice> CaptureDevices + { + get { return _captureDevices; } + set { _captureDevices = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -172,7 +183,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels MediaSeekForwardCommand = new RelayCommand(MediaSeekForward, () => !Recorder.IsRecording && Player.IsPlaying); MediaSeekBackwardCommand = new RelayCommand(MediaSeekBackward, () => !Recorder.IsRecording && Player.IsPlaying); MediaSeekCommand = new RelayCommand<double>(MediaSeek, (x) => Player.IsPlaying); - MediaSeekHoldCommand = new RelayCommand(MediaSeekHold,() => Player.IsPlaying); + MediaSeekHoldCommand = new RelayCommand(MediaSeekHold, () => Player.IsPlaying); _recordingsFolder = Path.Combine(SettingsManager.DefaultFolder, "Recordings"); Directory.CreateDirectory(_recordingsFolder); @@ -184,6 +195,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels _recordingBarItem = new BarItem(_notification, new RecordingBarView() { DataContext = this }); _playerBarItem = new BarItem(_notification, new PlayingBarView() { DataContext = this }); + CaptureDevices = VideoCaptureProvider.AvailableCaptureDevices.ToList(); + LoadRecordings(); } @@ -204,6 +217,14 @@ namespace Tango.MachineStudio.DataCapture.ViewModels if (Recorder.IsRecording) { Recorder.Write(frame); + + Task.Factory.StartNew(() => + { + CaptureDevices.First().Invoke(() => + { + Recorder.Write(CaptureDevices.Where(x => x.VideoSource != null).Select(x => x.VideoSource.GetAsFrozen() as BitmapSource)); + }); + }); } } } @@ -289,6 +310,8 @@ namespace Tango.MachineStudio.DataCapture.ViewModels Player = player; Player.FrameReceived += Player_FrameReceived; } + + CaptureDevices.ForEach(x => x.DisableSourceUpdate()); } private void Player_FrameReceived(object sender, DataFileFrame frame) @@ -296,6 +319,14 @@ namespace Tango.MachineStudio.DataCapture.ViewModels if (_frameProvider.Disable) { _frameProvider.PushFrame(frame.PushDiagnosticsResponse); + + CaptureDevices.First().BeginInvoke(() => + { + for (int i = 0; i < frame.VideoFrames.Count; i++) + { + CaptureDevices[i].VideoSource = frame.VideoFrames[i].ToByteArray().ToBitmapSource(); + } + }); } } @@ -339,6 +370,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels else if (Player.IsPlaying) { await Player.Stop(); + CaptureDevices.ForEach(x => x.EnableSourceUpdate()); _frameProvider.Disable = false; _playerBarItem.Pop(); } |
