-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCameraEventListener.cs
86 lines (73 loc) · 3.49 KB
/
CameraEventListener.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/******************************************************************************
* *
* PROJECT : Eos Digital camera Software Development Kit EDSDK *
* *
* Description: This is the Sample code to show the usage of EDSDK. *
* *
* *
*******************************************************************************
* *
* Written and developed by Canon Inc. *
* Copyright Canon Inc. 2018 All Rights Reserved *
* *
*******************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace CameraControl
{
class CameraEventListener
{
public static uint HandleObjectEvent(uint inEvent, IntPtr inRef, IntPtr inContext)
{
GCHandle handle = GCHandle.FromIntPtr(inContext);
CameraController controller = (CameraController)handle.Target;
switch (inEvent)
{
//case EDSDKLib.EDSDK.ObjectEvent_DirItemCreated :
case EDSDKLib.EDSDK.ObjectEvent_DirItemRequestTransfer:
FireEvent(ref controller, ActionEvent.Command.DOWNLOAD, inRef);
break;
default:
//Object without the necessity is released
if (inRef != IntPtr.Zero)
{
EDSDKLib.EDSDK.EdsRelease(inRef);
}
break;
}
return EDSDKLib.EDSDK.EDS_ERR_OK;
}
public static uint HandlePropertyEvent(uint inEvent, uint inPropertyID, uint inParam, IntPtr inContext)
{
GCHandle handle = GCHandle.FromIntPtr(inContext);
CameraController controller = (CameraController)handle.Target;
switch (inEvent)
{
case EDSDKLib.EDSDK.PropertyEvent_PropertyChanged:
FireEvent(ref controller, ActionEvent.Command.GET_PROPERTY, (IntPtr)inPropertyID);
break;
case EDSDKLib.EDSDK.PropertyEvent_PropertyDescChanged:
FireEvent(ref controller, ActionEvent.Command.GET_PROPERTYDESC, (IntPtr)inPropertyID);
break;
}
return EDSDKLib.EDSDK.EDS_ERR_OK;
}
public static uint HandleStateEvent(uint inEvent, uint inParameter, IntPtr inContext)
{
GCHandle handle = GCHandle.FromIntPtr(inContext);
CameraController controller = (CameraController)handle.Target;
switch (inEvent)
{
case EDSDKLib.EDSDK.StateEvent_Shutdown:
FireEvent(ref controller, ActionEvent.Command.SHUT_DOWN, IntPtr.Zero);
break;
}
return EDSDKLib.EDSDK.EDS_ERR_OK;
}
private static void FireEvent(ref CameraController controller, ActionEvent.Command command, IntPtr arg)
{
ActionEvent e = new ActionEvent(command, arg);
controller.ActionPerformed(e);
}
}
}