|
29
|
1 |
using System; |
|
|
2 |
using System.Net; |
|
|
3 |
using System.Windows; |
|
|
4 |
using System.Windows.Controls; |
|
|
5 |
using System.Windows.Documents; |
|
|
6 |
using System.Windows.Ink; |
|
|
7 |
using System.Windows.Input; |
|
|
8 |
using System.Windows.Media; |
|
|
9 |
using System.Windows.Media.Animation; |
|
|
10 |
using System.Windows.Shapes; |
|
|
11 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
12 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
13 |
{ |
|
|
14 |
public class WebCamControlVM : BaseMVVM.ViewModel.ViewModel |
|
|
15 |
{ |
|
|
16 |
|
|
|
17 |
|
|
35
|
18 |
private CaptureSource _captureSource {get;set;} |
|
|
19 |
public CaptureSource CaptureSource |
|
|
20 |
{ |
|
|
21 |
get |
|
|
22 |
{ |
|
|
23 |
return _captureSource; |
|
|
24 |
} |
|
|
25 |
set |
|
|
26 |
{ |
|
|
27 |
_captureSource = value; |
|
|
28 |
OnPropertyChanged("CaputreSource"); |
|
|
29 |
} |
|
|
30 |
} |
|
29
|
31 |
public WebCamControlVM() |
|
|
32 |
{ |
|
35
|
33 |
Commands.WebCamControl.CamRecordLanch.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordLanch_Executed); |
|
|
34 |
Commands.WebCamControl.CamRecordStop.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordStop_Executed); |
|
|
35 |
Commands.WebCamControl.CamRecordEnd.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordEnd_Executed); |
|
|
36 |
Commands.WebCamControl.CamRecordBegin.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CamRecordBegin_Executed); |
|
|
37 |
|
|
|
38 |
CaptureSource = new CaptureSource() |
|
|
39 |
{ |
|
|
40 |
VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice(), |
|
|
41 |
AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice() |
|
|
42 |
}; |
|
|
43 |
} |
|
|
44 |
void CamRecordStop_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
45 |
{ |
|
|
46 |
_captureSource.Stop(); |
|
|
47 |
} |
|
|
48 |
|
|
|
49 |
void CamRecordEnd_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
50 |
{ |
|
|
51 |
|
|
|
52 |
} |
|
|
53 |
|
|
|
54 |
void CamRecordLanch_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
55 |
{ |
|
|
56 |
if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess()) |
|
|
57 |
{ |
|
|
58 |
_captureSource.Start(); |
|
|
59 |
} |
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
void CamRecordBegin_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
63 |
{ |
|
|
64 |
|
|
29
|
65 |
} |
|
|
66 |
} |
|
|
67 |
} |