client/src/Iri.Modernisation.Controls/View/WebCamControl/WebCamControl.xaml.cs
changeset 29 5f8d275750e7
child 35 43bb1b8ed555
equal deleted inserted replaced
28:2d4ec5ab2a40 29:5f8d275750e7
       
     1 using System;
       
     2 using System.Windows;
       
     3 using System.Windows.Controls;
       
     4 using System.Windows.Documents;
       
     5 using System.Windows.Ink;
       
     6 using System.Windows.Input;
       
     7 using System.Windows.Media;
       
     8 using System.Windows.Media.Animation;
       
     9 using System.Windows.Shapes;
       
    10 using Iri.Modernisation.BaseMVVM.Commands;
       
    11 namespace Iri.Modernisation.Controls.View
       
    12 {
       
    13 	public partial class WebCamControl : UserControl
       
    14     {
       
    15         private CaptureSource _captureSource;
       
    16 		public WebCamControl()
       
    17 		{
       
    18 			// Required to initialize variables
       
    19 			InitializeComponent();
       
    20             _captureSource = new CaptureSource()
       
    21             {
       
    22                 VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice(),
       
    23                 AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice()
       
    24             };
       
    25             VideoBrush vidBrush = new VideoBrush();
       
    26             vidBrush.SetSource(_captureSource);
       
    27             VideoScreen.Fill = vidBrush;
       
    28 
       
    29             Commands.WebCamControl.CamRecordLanch.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordLanch_Executed);
       
    30             Commands.WebCamControl.CamRecordStop.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordStop_Executed);
       
    31             Commands.WebCamControl.CamRecordEnd.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordEnd_Executed);
       
    32             Commands.WebCamControl.CamRecordBegin.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordBegin_Executed);
       
    33 		}
       
    34 
       
    35         void CamRecordStop_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    36         {
       
    37             _captureSource.Stop();
       
    38         }
       
    39 
       
    40         void CamRecordEnd_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    41         {
       
    42          
       
    43         }
       
    44 
       
    45         void CamRecordLanch_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    46         {
       
    47             if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
       
    48             {
       
    49                 _captureSource.Start();
       
    50             }
       
    51         }
       
    52 
       
    53         void CamRecordBegin_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    54         {
       
    55             
       
    56         }
       
    57 	}
       
    58 }