diff --git a/ASCOM.DSLR.TestAppForm/ASCOM.DSLR.TestAppForm.csproj b/ASCOM.DSLR.TestAppForm/ASCOM.DSLR.TestAppForm.csproj index e839aaf..e398bad 100644 --- a/ASCOM.DSLR.TestAppForm/ASCOM.DSLR.TestAppForm.csproj +++ b/ASCOM.DSLR.TestAppForm/ASCOM.DSLR.TestAppForm.csproj @@ -27,6 +27,7 @@ prompt 4 false + true x86 @@ -40,17 +41,30 @@ AnyCPU - bin\Debug\ + ..\bin\ false + true AnyCPU bin\Release\ false + + ASCOM.DSLR.Program + + + + app.manifest + + + ASCOM.ico + + + @@ -87,6 +101,7 @@ Designer + SettingsSingleFileGenerator @@ -104,13 +119,18 @@ ASCOM.DSLR + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + diff --git a/ASCOM.DSLR.TestAppForm/packages.config b/ASCOM.DSLR.TestAppForm/packages.config index 076a52e..8db3468 100644 --- a/ASCOM.DSLR.TestAppForm/packages.config +++ b/ASCOM.DSLR.TestAppForm/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/ASCOM.DSLR.sln b/ASCOM.DSLR.sln index 01ab652..3d60d03 100644 --- a/ASCOM.DSLR.sln +++ b/ASCOM.DSLR.sln @@ -1,95 +1,267 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASCOM.DSLR", "ASCOM.DSLR\ASCOM.DSLR.csproj", "{64308775-BD4A-469C-BCAB-3ED830B811AF}" + ProjectSection(ProjectDependencies) = postProject + {7EB5D33D-E000-4766-9119-EDA40D04AF74} = {7EB5D33D-E000-4766-9119-EDA40D04AF74} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASCOM.DSLR.TestAppForm", "ASCOM.DSLR.TestAppForm\ASCOM.DSLR.TestAppForm.csproj", "{8E8D406C-1838-4914-867D-AB602D0EAF3E}" + ProjectSection(ProjectDependencies) = postProject + {7EB5D33D-E000-4766-9119-EDA40D04AF74} = {7EB5D33D-E000-4766-9119-EDA40D04AF74} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EDSDKLib", "EDSDKLib\EDSDKLib.csproj", "{15E99248-6161-46A4-9183-609CA62406A6}" + ProjectSection(ProjectDependencies) = postProject + {7EB5D33D-E000-4766-9119-EDA40D04AF74} = {7EB5D33D-E000-4766-9119-EDA40D04AF74} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTelescope.API", "OTelescope.API\OTelescope.API.csproj", "{B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}" + ProjectSection(ProjectDependencies) = postProject + {7EB5D33D-E000-4766-9119-EDA40D04AF74} = {7EB5D33D-E000-4766-9119-EDA40D04AF74} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registrar", "Registrar\Registrar.csproj", "{2F2993A5-1A52-4BFE-8A09-86B7BB97820C}" ProjectSection(ProjectDependencies) = postProject {64308775-BD4A-469C-BCAB-3ED830B811AF} = {64308775-BD4A-469C-BCAB-3ED830B811AF} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CameraControl.Devices", "DigiCamControl\CameraControl.Devices\CameraControl.Devices.csproj", "{E8572D8B-C987-4D20-BD88-1F8925A64A82}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canon.Eos.Framework", "DigiCamControl\Canon.Eos.Framework\Canon.Eos.Framework.csproj", "{F809DBB6-E0E8-47A8-92ED-C24575576A5D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortableDeviceLib", "DigiCamControl\PortableDeviceLib\PortableDeviceLib.csproj", "{E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DigiCamControl", "DigiCamControl", "{4FC379CE-DD0C-4628-9639-E232474A1F70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logging", "ErrorLogging\Logging.csproj", "{7EB5D33D-E000-4766-9119-EDA40D04AF74}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nikoncswrapper", "nikoncswrapper\nikoncswrapper.csproj", "{AADE1DF5-4C46-4760-B72B-474D90336F5B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClearDSLRSCProfile", "ClearDSLRProfile\ClearDSLRSCProfile.csproj", "{8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Capture.Workflow|Any CPU = Capture.Workflow|Any CPU + Capture.Workflow|x64 = Capture.Workflow|x64 Capture.Workflow|x86 = Capture.Workflow|x86 Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|x64.ActiveCfg = Debug|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|x64.Build.0 = Debug|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|x86.ActiveCfg = Release|x86 {64308775-BD4A-469C-BCAB-3ED830B811AF}.Capture.Workflow|x86.Build.0 = Release|x86 {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|x64.ActiveCfg = Debug|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|x64.Build.0 = Debug|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|x86.ActiveCfg = Debug|x86 {64308775-BD4A-469C-BCAB-3ED830B811AF}.Debug|x86.Build.0 = Debug|x86 {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|Any CPU.Build.0 = Release|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|x64.ActiveCfg = Release|Any CPU + {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|x64.Build.0 = Release|Any CPU {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|x86.ActiveCfg = Release|x86 {64308775-BD4A-469C-BCAB-3ED830B811AF}.Release|x86.Build.0 = Release|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|x64.ActiveCfg = Debug|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|x64.Build.0 = Debug|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|x86.ActiveCfg = Release|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Capture.Workflow|x86.Build.0 = Release|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|x64.ActiveCfg = Debug|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|x64.Build.0 = Debug|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|x86.ActiveCfg = Debug|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Debug|x86.Build.0 = Debug|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|Any CPU.Build.0 = Release|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|x64.ActiveCfg = Release|Any CPU + {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|x64.Build.0 = Release|Any CPU {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|x86.ActiveCfg = Release|x86 {8E8D406C-1838-4914-867D-AB602D0EAF3E}.Release|x86.Build.0 = Release|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|x64.ActiveCfg = Debug|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|x64.Build.0 = Debug|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|x86.ActiveCfg = Release|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Capture.Workflow|x86.Build.0 = Release|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Debug|x64.ActiveCfg = Debug|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Debug|x64.Build.0 = Debug|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Debug|x86.ActiveCfg = Debug|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Debug|x86.Build.0 = Debug|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Release|Any CPU.Build.0 = Release|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Release|x64.ActiveCfg = Release|Any CPU + {15E99248-6161-46A4-9183-609CA62406A6}.Release|x64.Build.0 = Release|Any CPU {15E99248-6161-46A4-9183-609CA62406A6}.Release|x86.ActiveCfg = Release|x86 {15E99248-6161-46A4-9183-609CA62406A6}.Release|x86.Build.0 = Release|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|x64.ActiveCfg = Debug|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|x64.Build.0 = Debug|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|x86.ActiveCfg = Release|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Capture.Workflow|x86.Build.0 = Release|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|x64.ActiveCfg = Debug|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|x64.Build.0 = Debug|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|x86.ActiveCfg = Debug|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Debug|x86.Build.0 = Debug|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|Any CPU.Build.0 = Release|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|x64.ActiveCfg = Release|Any CPU + {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|x64.Build.0 = Release|Any CPU {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|x86.ActiveCfg = Release|x86 {B7E42253-59AB-4CE0-B1E7-43FC61F4CD07}.Release|x86.Build.0 = Release|x86 {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|Any CPU.ActiveCfg = Debug|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|Any CPU.Build.0 = Debug|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|x64.ActiveCfg = Release|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|x64.Build.0 = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|x86.ActiveCfg = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Capture.Workflow|x86.Build.0 = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|x64.ActiveCfg = Debug|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|x64.Build.0 = Debug|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|x86.ActiveCfg = Debug|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Debug|x86.Build.0 = Debug|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|Any CPU.Build.0 = Release|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|x64.ActiveCfg = Release|Any CPU + {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|x64.Build.0 = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|x86.ActiveCfg = Release|Any CPU {2F2993A5-1A52-4BFE-8A09-86B7BB97820C}.Release|x86.Build.0 = Release|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|Any CPU.ActiveCfg = Capture.Workflow|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|Any CPU.Build.0 = Capture.Workflow|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|x64.ActiveCfg = Capture.Workflow|x64 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|x64.Build.0 = Capture.Workflow|x64 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|x86.ActiveCfg = Capture.Workflow|x86 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Capture.Workflow|x86.Build.0 = Capture.Workflow|x86 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|x64.ActiveCfg = Debug|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|x64.Build.0 = Debug|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|x86.ActiveCfg = Debug|x86 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Debug|x86.Build.0 = Debug|x86 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|Any CPU.Build.0 = Release|Any CPU + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|x64.ActiveCfg = Release|x64 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|x64.Build.0 = Release|x64 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|x86.ActiveCfg = Release|x86 + {E8572D8B-C987-4D20-BD88-1F8925A64A82}.Release|x86.Build.0 = Release|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|Any CPU.ActiveCfg = Capture.Workflow|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|Any CPU.Build.0 = Capture.Workflow|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|x64.ActiveCfg = Capture.Workflow|x64 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|x64.Build.0 = Capture.Workflow|x64 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|x86.ActiveCfg = Capture.Workflow|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Capture.Workflow|x86.Build.0 = Capture.Workflow|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|x64.ActiveCfg = Debug|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|x64.Build.0 = Debug|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|x86.ActiveCfg = Debug|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Debug|x86.Build.0 = Debug|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|Any CPU.Build.0 = Release|Any CPU + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|x64.ActiveCfg = Release|x64 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|x64.Build.0 = Release|x64 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|x86.ActiveCfg = Release|x86 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D}.Release|x86.Build.0 = Release|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|Any CPU.ActiveCfg = Capture.Workflow|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|Any CPU.Build.0 = Capture.Workflow|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|x64.ActiveCfg = Capture.Workflow|x64 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|x64.Build.0 = Capture.Workflow|x64 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|x86.ActiveCfg = Capture.Workflow|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Capture.Workflow|x86.Build.0 = Capture.Workflow|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|x64.ActiveCfg = Debug|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|x64.Build.0 = Debug|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|x86.ActiveCfg = Debug|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Debug|x86.Build.0 = Debug|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|Any CPU.Build.0 = Release|Any CPU + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|x64.ActiveCfg = Release|x64 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|x64.Build.0 = Release|x64 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|x86.ActiveCfg = Release|x86 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D}.Release|x86.Build.0 = Release|x86 + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|x64.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|x64.Build.0 = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|x86.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Capture.Workflow|x86.Build.0 = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|x64.ActiveCfg = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|x64.Build.0 = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|x86.ActiveCfg = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Debug|x86.Build.0 = Debug|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|Any CPU.Build.0 = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|x64.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|x64.Build.0 = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|x86.ActiveCfg = Release|Any CPU + {7EB5D33D-E000-4766-9119-EDA40D04AF74}.Release|x86.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|x64.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|x64.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|x86.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Capture.Workflow|x86.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|x64.ActiveCfg = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|x64.Build.0 = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|x86.ActiveCfg = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Debug|x86.Build.0 = Debug|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|Any CPU.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|x64.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|x64.Build.0 = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|x86.ActiveCfg = Release|Any CPU + {AADE1DF5-4C46-4760-B72B-474D90336F5B}.Release|x86.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|Any CPU.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|Any CPU.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|x64.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|x64.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|x86.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Capture.Workflow|x86.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|x64.ActiveCfg = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|x64.Build.0 = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|x86.ActiveCfg = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Debug|x86.Build.0 = Debug|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|Any CPU.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|x64.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|x64.Build.0 = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|x86.ActiveCfg = Release|Any CPU + {8C96928D-E6B9-46E4-BA5B-BB0BBA4A7C60}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E8572D8B-C987-4D20-BD88-1F8925A64A82} = {4FC379CE-DD0C-4628-9639-E232474A1F70} + {F809DBB6-E0E8-47A8-92ED-C24575576A5D} = {4FC379CE-DD0C-4628-9639-E232474A1F70} + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D} = {4FC379CE-DD0C-4628-9639-E232474A1F70} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AB1F058A-E42A-455B-A367-CDFF8B8BD485} EndGlobalSection diff --git a/ASCOM.DSLR/ASCOM.DSLR.csproj b/ASCOM.DSLR/ASCOM.DSLR.csproj index 90d4b53..364f321 100644 --- a/ASCOM.DSLR/ASCOM.DSLR.csproj +++ b/ASCOM.DSLR/ASCOM.DSLR.csproj @@ -17,7 +17,7 @@ 3.5 v4.6 ASCOM.ico - true + false ASCOMDriverTemplate.snk publish\ true @@ -56,6 +56,7 @@ ..\bin\ false true + false AnyCPU @@ -63,6 +64,7 @@ false true + @@ -72,6 +74,9 @@ + + ..\packages\Rssdp.4.0.0\lib\net45\Rssdp.dll + @@ -82,6 +87,7 @@ + @@ -97,9 +103,14 @@ + + + + + @@ -119,6 +130,7 @@ Settings.settings + Form @@ -141,6 +153,111 @@ + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + Designer @@ -152,19 +269,271 @@ Settings.Designer.cs - + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + Always Always - + + Always + + Always Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + @@ -184,10 +553,22 @@ + + {e8572d8b-c987-4d20-bd88-1f8925a64a82} + CameraControl.Devices + {15e99248-6161-46a4-9183-609ca62406a6} EDSDKLib + + {7eb5d33d-e000-4766-9119-eda40d04af74} + Logging + + + {aade1df5-4c46-4760-b72b-474d90336f5b} + nikoncswrapper + {b7e42253-59ab-4ce0-b1e7-43fc61f4cd07} OTelescope.API @@ -198,12 +579,12 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DSLR.Camera Setup.exe b/DSLR.Camera Setup.exe index 7e34f55..478f088 100644 Binary files a/DSLR.Camera Setup.exe and b/DSLR.Camera Setup.exe differ diff --git a/DSLR.Camera Setup.iss b/DSLR.Camera Setup.iss index a768632..4fcc605 100644 --- a/DSLR.Camera Setup.iss +++ b/DSLR.Camera Setup.iss @@ -1,18 +1,23 @@ ; ; Script generated by the ASCOM Driver Installer Script Generator 6.2.0.0 ; Generated by Volodymyr Torkalo on 03.01.2018 (UTC) +; Fixed by Cesar Mattos on 05.05.2020 (CST) ; + +#define ApplicationVersion GetFileVersion("bin\ASCOM.DSLR.Camera.dll") + + [Setup] AppID={{64931281-9e67-4d94-bc2a-083a023714fd} AppName=ASCOM DSLR.Camera Camera Driver AppVerName=ASCOM DSLR.Camera Camera Driver {#ApplicationVersion} AppVersion={#ApplicationVersion} -AppPublisher=Volodymyr Torkalo -AppPublisherURL=mailto:Torkalo@gmail.com +AppPublisher=Cesar Mattos +AppPublisherURL=mailto:cesar.mattos@gmail.com AppSupportURL=http://tech.groups.yahoo.com/group/ASCOM-Talk/ AppUpdatesURL=http://ascom-standards.org/ VersionInfoVersion={#ApplicationVersion} -MinVersion=0,5.0.2195sp4 +MinVersion=0,6.0 DefaultDirName="{cf}\ASCOM\Camera\ASCOM.DSLR.Camera" DisableDirPage=yes DisableProgramGroupPage=yes @@ -33,33 +38,219 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "{cf}\ASCOM\Uninstall\Camera\DSLR.Camera" ; TODO: Add subfolders below {app} as needed (e.g. Name: "{app}\MyFolder") +[Icons] +Name: "{userdesktop}\ASCOMDSLRTest"; Filename: "{app}\ASCOM.DSLR.Test.exe" +Name: "{userdesktop}\ClearDSLRSCProfile"; Filename: "{app}\ClearDSLRSCProfile.exe" + [Files] Source: "bin\ASCOM.DSLR.Camera.dll"; DestDir: "{app}" ;Source: "bin\ReadMe.htm"; DestDir: "{app}"; Flags: isreadme -Source: "bin\libraw.dll"; DestDir: "{app}" -Source: "bin\EDSDK.dll"; DestDir: "{app}" +Source: "bin\SDK\X64\libraw.dll"; DestDir: "{app}\SDK\X64\" +Source: "bin\SDK\X64\EDSDK.dll"; DestDir: "{app}\SDK\X64\" +Source: "bin\SDK\X86\libraw.dll"; DestDir: "{app}\SDK\X86\" +Source: "bin\SDK\X86\EDSDK.dll"; DestDir: "{app}\SDK\X86\" Source: "bin\EDSDKLib.dll"; DestDir: "{app}" Source: "bin\exiftool.exe"; DestDir: "{app}" +Source: "bin\Registrar.exe"; DestDir: "{app}" Source: "bin\OTelescope.API.dll"; DestDir: "{app}" +Source: "bin\Nlog.dll"; DestDir: "{app}" +Source: "bin\ErrorLogging.dll"; DestDir: "{app}" +Source: "bin\ClearDSLRSCProfile.exe"; DestDir: "{app}" ;Source: "bin\Newtonsoft.Json.dll"; DestDir: "{app}" +;Nikon and Pentax +Source: "bin\CameraControl.Devices.dll"; DestDir: "{app}" +Source: "bin\Canon.Eos.Framework.dll"; DestDir: "{app}" +Source: "bin\Interop.PortableDeviceApiLib.dll"; DestDir: "{app}" +Source: "bin\Interop.PortableDeviceTypesLib.dll"; DestDir: "{app}" +Source: "bin\Newtonsoft.Json.dll"; DestDir: "{app}" +Source: "bin\PortableDeviceLib.dll"; DestDir: "{app}" +Source: "bin\Rssdp.dll"; DestDir: "{app}" +Source: "bin\websocket-sharp.dll"; DestDir: "{app}" +Source: "bin\Accord.dll"; DestDir: "{app}" +Source: "bin\Accord.Video.DirectShow.dll"; DestDir: "{app}" +Source: "bin\Accord.Video.dll"; DestDir: "{app}" +Source: "bin\nikoncswrapper.dll"; DestDir: "{app}" + + + +Source: "pktriggercord\zlib1.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\pktriggercord_commandline.html"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\pktriggercord-cli.exe"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\pktriggercord.ui"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\pktriggercord.exe"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libpng16-16.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libpixman-1-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libpangowin32-1.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libpangocairo-1.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libpango-1.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libintl-8.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgtk-win32-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgobject-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgmodule-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libglib-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgio-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgdk_pixbuf-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgdk-win32-2.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libgcc_s_sjlj-1.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libffi-6.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libcairo-2.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\libatk-1.0-0.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\iconv.dll"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\COPYING"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\Changelog"; DestDir: "{app}/pktriggercord" +Source: "pktriggercord\pentax_settings.json"; DestDir: "{app}/pktriggercord" + +;New NikonSDK +;X64 +Source: "bin\SDK\X64\Nikon\Type0001\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0001\" +Source: "bin\SDK\X64\Nikon\Type0002\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0002\" +Source: "bin\SDK\X64\Nikon\Type0003\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0003\" +Source: "bin\SDK\X64\Nikon\Type0004\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0004\" +Source: "bin\SDK\X64\Nikon\Type0005\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0005\" +Source: "bin\SDK\X64\Nikon\Type0006\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0006\" +Source: "bin\SDK\X64\Nikon\Type0007\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0007\" +Source: "bin\SDK\X64\Nikon\Type0008\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0008\" +Source: "bin\SDK\X64\Nikon\Type0009\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0009\" +Source: "bin\SDK\X64\Nikon\Type0010\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0010\" +Source: "bin\SDK\X64\Nikon\Type0011\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0011\" +Source: "bin\SDK\X64\Nikon\Type0012\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0012\" +Source: "bin\SDK\X64\Nikon\Type0013\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0013\" +Source: "bin\SDK\X64\Nikon\Type0014\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0014\" +Source: "bin\SDK\X64\Nikon\Type0015\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0015\" +Source: "bin\SDK\X64\Nikon\Type0016\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0016\" +Source: "bin\SDK\X64\Nikon\Type0017\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0017\" +Source: "bin\SDK\X64\Nikon\Type0018\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0018\" +Source: "bin\SDK\X64\Nikon\Type0019\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0019\" +Source: "bin\SDK\X64\Nikon\Type0020\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0020\" +Source: "bin\SDK\X64\Nikon\Type0021\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0021\" +Source: "bin\SDK\X64\Nikon\Type0022\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0022\" +Source: "bin\SDK\X64\Nikon\Type0023\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0023\" +Source: "bin\SDK\X64\Nikon\Type0024\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0024\" +Source: "bin\SDK\X64\Nikon\Type0025\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0025\" +Source: "bin\SDK\X64\Nikon\Type0026\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0026\" +Source: "bin\SDK\X64\Nikon\Type0027\NkdPTP.dll"; DestDir: "{app}\SDK\X64\Nikon\Type0027\" +Source: "bin\SDK\X64\Nikon\Type0001\Type0001.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0001\" +Source: "bin\SDK\X64\Nikon\Type0002\Type0002.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0002\" +Source: "bin\SDK\X64\Nikon\Type0003\Type0003.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0003\" +Source: "bin\SDK\X64\Nikon\Type0004\Type0004.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0004\" +Source: "bin\SDK\X64\Nikon\Type0005\Type0005.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0005\" +Source: "bin\SDK\X64\Nikon\Type0006\Type0006.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0006\" +Source: "bin\SDK\X64\Nikon\Type0007\Type0007.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0007\" +Source: "bin\SDK\X64\Nikon\Type0008\Type0008.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0008\" +Source: "bin\SDK\X64\Nikon\Type0009\Type0009.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0009\" +Source: "bin\SDK\X64\Nikon\Type0010\Type0010.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0010\" +Source: "bin\SDK\X64\Nikon\Type0011\Type0011.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0011\" +Source: "bin\SDK\X64\Nikon\Type0012\Type0012.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0012\" +Source: "bin\SDK\X64\Nikon\Type0013\Type0013.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0013\" +Source: "bin\SDK\X64\Nikon\Type0014\Type0014.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0014\" +Source: "bin\SDK\X64\Nikon\Type0015\Type0015.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0015\" +Source: "bin\SDK\X64\Nikon\Type0016\Type0016.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0016\" +Source: "bin\SDK\X64\Nikon\Type0017\Type0017.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0017\" +Source: "bin\SDK\X64\Nikon\Type0018\Type0018.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0018\" +Source: "bin\SDK\X64\Nikon\Type0019\Type0019.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0019\" +Source: "bin\SDK\X64\Nikon\Type0020\Type0020.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0020\" +Source: "bin\SDK\X64\Nikon\Type0021\Type0021.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0021\" +Source: "bin\SDK\X64\Nikon\Type0022\Type0022.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0022\" +Source: "bin\SDK\X64\Nikon\Type0023\Type0023.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0023\" +Source: "bin\SDK\X64\Nikon\Type0024\Type0024.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0024\" +Source: "bin\SDK\X64\Nikon\Type0025\Type0025.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0025\" +Source: "bin\SDK\X64\Nikon\Type0026\Type0026.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0026\" +Source: "bin\SDK\X64\Nikon\Type0027\Type0027.md3"; DestDir: "{app}\SDK\X64\Nikon\Type0027\" +;X86 +Source: "bin\SDK\X86\Nikon\Type0001\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0001\" +Source: "bin\SDK\X86\Nikon\Type0002\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0002\" +Source: "bin\SDK\X86\Nikon\Type0003\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0003\" +Source: "bin\SDK\X86\Nikon\Type0004\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0004\" +Source: "bin\SDK\X86\Nikon\Type0005\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0005\" +Source: "bin\SDK\X86\Nikon\Type0006\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0006\" +Source: "bin\SDK\X86\Nikon\Type0007\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0007\" +Source: "bin\SDK\X86\Nikon\Type0008\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0008\" +Source: "bin\SDK\X86\Nikon\Type0009\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0009\" +Source: "bin\SDK\X86\Nikon\Type0010\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0010\" +Source: "bin\SDK\X86\Nikon\Type0011\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0011\" +Source: "bin\SDK\X86\Nikon\Type0012\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0012\" +Source: "bin\SDK\X86\Nikon\Type0013\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0013\" +Source: "bin\SDK\X86\Nikon\Type0014\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0014\" +Source: "bin\SDK\X86\Nikon\Type0015\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0015\" +Source: "bin\SDK\X86\Nikon\Type0016\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0016\" +Source: "bin\SDK\X86\Nikon\Type0017\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0017\" +Source: "bin\SDK\X86\Nikon\Type0018\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0018\" +Source: "bin\SDK\X86\Nikon\Type0019\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0019\" +Source: "bin\SDK\X86\Nikon\Type0020\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0020\" +Source: "bin\SDK\X86\Nikon\Type0021\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0021\" +Source: "bin\SDK\X86\Nikon\Type0022\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0022\" +Source: "bin\SDK\X86\Nikon\Type0023\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0023\" +Source: "bin\SDK\X86\Nikon\Type0024\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0024\" +Source: "bin\SDK\X86\Nikon\Type0025\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0025\" +Source: "bin\SDK\X86\Nikon\Type0026\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0026\" +Source: "bin\SDK\X86\Nikon\Type0027\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\Type0027\" +Source: "bin\SDK\X86\Nikon\D40_Mod\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\D40_Mod\" +Source: "bin\SDK\X86\Nikon\D40_Mod\NkdPTPDi.dll"; DestDir: "{app}\SDK\X86\Nikon\D40_Mod\" +Source: "bin\SDK\X86\Nikon\D60_Mod\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\D60_Mod\" +Source: "bin\SDK\X86\Nikon\D80_Mod\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\D80_Mod\" +Source: "bin\SDK\X86\Nikon\D200_Mod\NkdPTP.dll"; DestDir: "{app}\SDK\X86\Nikon\D200_Mod\" +Source: "bin\SDK\X86\Nikon\Type0001\Type0001.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0001\" +Source: "bin\SDK\X86\Nikon\Type0002\Type0002.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0002\" +Source: "bin\SDK\X86\Nikon\Type0003\Type0003.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0003\" +Source: "bin\SDK\X86\Nikon\Type0004\Type0004.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0004\" +Source: "bin\SDK\X86\Nikon\Type0005\Type0005.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0005\" +Source: "bin\SDK\X86\Nikon\Type0006\Type0006.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0006\" +Source: "bin\SDK\X86\Nikon\Type0007\Type0007.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0007\" +Source: "bin\SDK\X86\Nikon\Type0008\Type0008.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0008\" +Source: "bin\SDK\X86\Nikon\Type0009\Type0009.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0009\" +Source: "bin\SDK\X86\Nikon\Type0010\Type0010.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0010\" +Source: "bin\SDK\X86\Nikon\Type0011\Type0011.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0011\" +Source: "bin\SDK\X86\Nikon\Type0012\Type0012.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0012\" +Source: "bin\SDK\X86\Nikon\Type0013\Type0013.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0013\" +Source: "bin\SDK\X86\Nikon\Type0014\Type0014.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0014\" +Source: "bin\SDK\X86\Nikon\Type0015\Type0015.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0015\" +Source: "bin\SDK\X86\Nikon\Type0016\Type0016.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0016\" +Source: "bin\SDK\X86\Nikon\Type0017\Type0017.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0017\" +Source: "bin\SDK\X86\Nikon\Type0018\Type0018.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0018\" +Source: "bin\SDK\X86\Nikon\Type0019\Type0019.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0019\" +Source: "bin\SDK\X86\Nikon\Type0020\Type0020.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0020\" +Source: "bin\SDK\X86\Nikon\Type0021\Type0021.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0021\" +Source: "bin\SDK\X86\Nikon\Type0022\Type0022.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0022\" +Source: "bin\SDK\X86\Nikon\Type0023\Type0023.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0023\" +Source: "bin\SDK\X86\Nikon\Type0024\Type0024.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0024\" +Source: "bin\SDK\X86\Nikon\Type0025\Type0025.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0025\" +Source: "bin\SDK\X86\Nikon\Type0026\Type0026.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0026\" +Source: "bin\SDK\X86\Nikon\Type0027\Type0027.md3"; DestDir: "{app}\SDK\X86\Nikon\Type0027\" +Source: "bin\SDK\X86\Nikon\D40_Mod\D40_Mod.md3"; DestDir: "{app}\SDK\X86\Nikon\D40_Mod\" +Source: "bin\SDK\X86\Nikon\D60_Mod\D40_Mod.md3"; DestDir: "{app}\SDK\X86\Nikon\D60_Mod\" +Source: "bin\SDK\X86\Nikon\D80_Mod\D80_Mod.md3"; DestDir: "{app}\SDK\X86\Nikon\D80_Mod\" +Source: "bin\SDK\X86\Nikon\D200_Mod\D200_Mod.md3"; DestDir: "{app}\SDK\X86\Nikon\D200_Mod\" + +Source: "bin\ASCOM.DSLR.Test.exe"; DestDir: "{app}" + +;VC Runtime 2019 +Source: "Redist\VC_redist.x86.exe"; DestDir: {tmp} +Source: "Redist\VC_redist.x64.exe"; DestDir: {tmp} ; Only if driver is .NET [Run] ; Only for .NET assembly/in-proc drivers Filename: "{dotnet4032}\regasm.exe"; Parameters: "/codebase ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 32bit -;Filename: "{dotnet4064}\regasm.exe"; Parameters: "/codebase ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 64bit; Check: IsWin64 - +Filename: "{dotnet4064}\regasm.exe"; Parameters: "/codebase ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 64bit; Check: IsWin64 +Filename: "{tmp}\VC_redist.x86.exe"; Parameters: "/q /norestart"; \ + Check: VC2019RedistNeedsInstall('x86'); \ + Flags: waituntilterminated; StatusMsg: "Installing VC++ 2019 redistributables..." + +Filename: "{tmp}\VC_redist.x64.exe"; Parameters: "/q /norestart"; \ + Check: IsWin64 and VC2019RedistNeedsInstall('x64'); \ + Flags: waituntilterminated; StatusMsg: "Installing VC++ 2019 redistributables..." ; Only if driver is .NET [UninstallRun] ; Only for .NET assembly/in-proc drivers Filename: "{dotnet4032}\regasm.exe"; Parameters: "-u ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 32bit -; This helps to give a clean uninstall -;Filename: "{dotnet4064}\regasm.exe"; Parameters: "/codebase ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 64bit; Check: IsWin64 -;Filename: "{dotnet4064}\regasm.exe"; Parameters: "-u ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 64bit; Check: IsWin64 +Filename: "{dotnet4064}\regasm.exe"; Parameters: "-u ""{app}\ASCOM.DSLR.Camera.dll"""; Flags: runhidden 64bit; Check: IsWin64 +[UninstallDelete] +Type: files; Name: "{app}\SDK\X86\EDSDK.dll" +Type: files; Name: "{app}\SDK\X86\Nlog.dll" [CODE] // @@ -113,4 +304,16 @@ begin end end; end; - +//Runtime Function +function VC2019RedistNeedsInstall(Arch: string): Boolean; +var + Version: String; +begin + if RegQueryStringValue( + HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\' + Arch, + 'Version', Version) then + begin + Log('VC Redist Version check : found ' + Version); + Result := (CompareStr(Version, 'v14.26.28720.03')<0); + end; +end; \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/BaseCameraDevice.cs b/DigiCamControl/CameraControl.Devices/BaseCameraDevice.cs new file mode 100644 index 0000000..ada6b9d --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/BaseCameraDevice.cs @@ -0,0 +1,631 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using CameraControl.Devices.Classes; +using System.Text; + +#endregion + +namespace CameraControl.Devices +{ + public class BaseCameraDevice : BaseFieldClass, ICameraDevice + { + #region Implementation of ICameraDevice + + protected List Capabilities = new List(); + protected object Locker = new object(); // object used to lock multi threaded methods + + private bool _haveLiveView; + + private bool _isBusy; + + public bool IsBusy + { + get { return _isBusy; } + set + { + _isBusy = value; + NotifyPropertyChanged("IsBusy"); + } + } + + public virtual bool HaveLiveView + { + get { return _haveLiveView; } + set + { + _haveLiveView = value; + NotifyPropertyChanged("HaveLiveView"); + } + } + + private bool _captureInSdRam; + + public virtual bool CaptureInSdRam + { + get { return _captureInSdRam; } + set + { + _captureInSdRam = value; + NotifyPropertyChanged("CaptureInSdRam"); + } + } + + private PropertyValue _isoNumber; + + public virtual PropertyValue IsoNumber + { + get { return _isoNumber; } + set + { + _isoNumber = value; + NotifyPropertyChanged("IsoNumber"); + } + } + + private PropertyValue _shutterSpeed; + + public virtual PropertyValue ShutterSpeed + { + get { return _shutterSpeed; } + set + { + _shutterSpeed = value; + NotifyPropertyChanged("ShutterSpeed"); + } + } + + private PropertyValue _mode; + + public virtual PropertyValue Mode + { + get { return _mode; } + set + { + _mode = value; + NotifyPropertyChanged("Mode"); + } + } + + private PropertyValue _fNumber; + + public virtual PropertyValue FNumber + { + get { return _fNumber; } + set + { + _fNumber = value; + NotifyPropertyChanged("FNumber"); + } + } + + private PropertyValue _whiteBalance; + + public virtual PropertyValue WhiteBalance + { + get { return _whiteBalance; } + set + { + _whiteBalance = value; + NotifyPropertyChanged("WhiteBalance"); + } + } + + private PropertyValue _exposureCompensation; + + public virtual PropertyValue ExposureCompensation + { + get { return _exposureCompensation; } + set + { + _exposureCompensation = value; + NotifyPropertyChanged("ExposureCompensation"); + } + } + + private PropertyValue _compressionSetting; + + public virtual PropertyValue CompressionSetting + { + get { return _compressionSetting; } + set + { + _compressionSetting = value; + NotifyPropertyChanged("CompressionSetting"); + } + } + + private PropertyValue _exposureMeteringMode; + + public virtual PropertyValue ExposureMeteringMode + { + get { return _exposureMeteringMode; } + set + { + _exposureMeteringMode = value; + NotifyPropertyChanged("ExposureMeteringMode"); + } + } + + private PropertyValue _focusMode; + + public virtual PropertyValue FocusMode + { + get + { + return _focusMode; + } + set + { + _focusMode = value; + NotifyPropertyChanged("FocusMode"); + } + } + + private DateTime _dateTime; + + public virtual DateTime DateTime + { + get { return _dateTime; } + set + { + _dateTime = value; + NotifyPropertyChanged("DateTime"); + } + } + + public string PortName { get; set; } + + private string _deviceName; + + private bool _isChecked; + + public virtual bool IsChecked + { + get { return _isChecked; } + set + { + _isChecked = value; + NotifyPropertyChanged("IsChecked"); + } + } + + private object _attachedPhotoSession; + + public virtual object AttachedPhotoSession + { + get { return _attachedPhotoSession; } + set + { + _attachedPhotoSession = value; + NotifyPropertyChanged("AttachedPhotoSession"); + } + } + + public virtual string DeviceName + { + get { return _deviceName; } + set + { + _deviceName = value; + NotifyPropertyChanged("DeviceName"); + } + } + + private string _manufacturer; + + public virtual string Manufacturer + { + get { return _manufacturer; } + set + { + _manufacturer = value; + NotifyPropertyChanged("Manufacturer"); + } + } + + private string _serialNumber; + + public virtual string SerialNumber + { + get { return _serialNumber; } + set + { + _serialNumber = value; + NotifyPropertyChanged("SerialNumber"); + } + } + + private string _displayName; + + public virtual string DisplayName + { + get + { + if (string.IsNullOrEmpty(_displayName)) + return DeviceName + " (" + SerialNumber + ")"; + return _displayName; + } + set + { + _displayName = value; + NotifyPropertyChanged("DisplayName"); + } + } + + + private int _exposureStatus; + + public virtual int ExposureStatus + { + get { return _exposureStatus; } + set + { + _exposureStatus = value; + NotifyPropertyChanged("ExposureStatus"); + } + } + + public bool PreventShutDown + { + get { return _preventShutDown; } + set + { + _preventShutDown = value; + NotifyPropertyChanged("PreventShutDown"); + } + } + + private bool _isConnected; + + public virtual bool IsConnected + { + get { return _isConnected; } + set + { + _isConnected = value; + NotifyPropertyChanged("IsConnected"); + } + } + + + private int _battery; + + public virtual int Battery + { + get { return _battery; } + set + { + _battery = value; + NotifyPropertyChanged("Battery"); + } + } + + private uint _transferProgress; + + public uint TransferProgress + { + get { return _transferProgress; } + set + { + _transferProgress = value; + NotifyPropertyChanged("TransferProgress"); + } + } + + public virtual bool GetCapability(CapabilityEnum capabilityEnum) + { + return Capabilities.Contains(capabilityEnum); + } + + public virtual PropertyValue LiveViewImageZoomRatio { get; set; } + + public virtual bool Init(DeviceDescriptor deviceDescriptor) + { + return true; + } + + public virtual void StartLiveView() + { + } + + public virtual void StopLiveView() + { + } + + public virtual string GetLiveViewStream() + { + throw new NotImplementedException(); + } + + public virtual LiveViewData GetLiveViewImage() + { + return null; + } + + public virtual void AutoFocus() + { + } + + public virtual int Focus(int step) + { + return 0; + } + + public virtual void Focus(int x, int y) + { + } + + public virtual void Focus(FocusDirection direction, FocusAmount amount) + { + throw new NotImplementedException(); + } + + public virtual void CapturePhotoNoAf() + { + } + + public virtual void CapturePhoto() + { + } + + public virtual void StartRecordMovie() + { + } + + public virtual void StopRecordMovie() + { + } + + public virtual string GetProhibitionCondition(OperationEnum operationEnum) + { + return ""; + } + + public virtual bool GetStatus(OperationEnum operationEnum) + { + throw new NotImplementedException(); + } + + public virtual void EndBulbMode() + { + } + + public virtual void StartBulbMode() + { + } + + public virtual void LockCamera() + { + } + + public virtual void UnLockCamera() + { + } + + public virtual void Close() + { + } + + public virtual void StartZoom(ZoomDirection direction) + { + throw new NotImplementedException(); + } + + public virtual void StopZoom(ZoomDirection direction) + { + throw new NotImplementedException(); + } + + public virtual void ResetDevice() + { + + } + + public virtual void ReleaseResurce(object o) + { + + } + + public virtual void TransferFileThumb(object o, string filename) + { + TransferFile(o, filename); + } + + public virtual void ReadDeviceProperties(uint prop) + { + } + + public virtual void TransferFile(object o, string filename) + { + } + + public virtual void TransferFile(object o, System.IO.Stream stream) + { + } + + public void OnCaptureCompleted(object sender, EventArgs args) + { + if (CaptureCompleted != null) + { + CaptureCompleted(sender, args); + } + } + + public void OnPhotoCapture(object sender, PhotoCapturedEventArgs args) + { + if (PhotoCaptured != null) + { + PhotoCaptured(sender, args); + } + } + + public void OnCameraDisconnected(object sender, DisconnectCameraEventArgs eventHandler) + { + if (CameraDisconnected != null) + { + CameraDisconnected(sender, eventHandler); + } + } + + public event PhotoCapturedEventHandler PhotoCaptured; + public event EventHandler CaptureCompleted; + public event CameraDisconnectedEventHandler CameraDisconnected; + public event CameraDeviceManager.CameraConnectedEventHandler CameraInitDone; + + public void OnCameraInitDone() + { + try + { + CameraDeviceManager.CameraConnectedEventHandler handler = CameraInitDone; + if (handler != null) handler(this); + } + catch (Exception ex) + { + Log.Error("OnCameraInitDone", ex); + } + } + + private AsyncObservableCollection> _advancedProperties; + private AsyncObservableCollection> _properties; + private bool _preventShutDown; + + public AsyncObservableCollection> AdvancedProperties + { + get { return _advancedProperties; } + set + { + _advancedProperties = value; + NotifyPropertyChanged("AdvancedProperties"); + } + } + + public AsyncObservableCollection> Properties + { + get { return _properties; } + set + { + _properties = value; + NotifyPropertyChanged("Properties"); + } + } + + public virtual AsyncObservableCollection GetObjects(object storageId, bool loadThumbs) + { + throw new NotImplementedException(); + } + + public virtual void FormatStorage(object storageId) + { + throw new NotImplementedException(); + } + + public virtual bool DeleteObject(DeviceObject deviceObject) + { + throw new NotImplementedException(); + } + + /// + /// Sets the in comment field. + /// + /// + /// The comment. + public virtual void SetCameraField(CameraFieldType cameraFieldType, string comment) + { + } + + public virtual void WaitForReady() + { + + } + + #endregion + + public BaseCameraDevice() + { + IsChecked = true; + AdvancedProperties = new AsyncObservableCollection>(); + Properties = new AsyncObservableCollection>(); + Capabilities = new List(); + } + + public override string ToString() + { + return DisplayName; + } + + public virtual string ToStringCameraData() + { + // return DisplayName; + StringBuilder c = new StringBuilder("\n\nPost shot camera data:\n"); + try + { + if (PortName != null) + c.AppendFormat("Port: {0}\n", PortName); + c.AppendFormat(" {0}{1}", String.IsNullOrWhiteSpace(Manufacturer) ? "" : "(" + Manufacturer + ") ", DeviceName); + c.AppendFormat("\n\tSerial number........ {0}", SerialNumber); + c.AppendFormat("\n\tBusy..................{0}", IsBusy ? "Yes" : "No"); + c.AppendFormat("\n\tHave LiveView.........{0}", HaveLiveView ? "Yes" : "No"); + c.AppendFormat("\n\tCapture SDRam.........{0}", CaptureInSdRam ? "Yes" : "No"); + c.AppendFormat("\n\tIs Connected..........{0}", IsConnected ? "Yes" : "No"); + c.AppendFormat("\n\tMode..................{0}, {1} focus", Mode?.Value, FocusMode?.Value); + c.AppendFormat("\n\texposure..............{0} f{1} +/-{2}, ISO{3}", + ShutterSpeed.Value, + FNumber.Value, + ExposureCompensation.Value, + IsoNumber.Value); + c.AppendFormat("\n\tmetering mode.........{0}", ExposureMeteringMode.Value); + c.AppendFormat("\n\twhite balance.........{0}", WhiteBalance.Value); + c.AppendFormat("\n\tTransfer progress.....{0}%", TransferProgress); + + c.AppendFormat("\n\tExposure status.......{0}", ExposureStatus); + c.AppendFormat("\n\tBattery...............{0}%", Battery); + c.AppendFormat("\n\tCompression...........{0}%", CompressionSetting); + + if (Capabilities.Count > 0) + { + c.Append(String.Format("\n\tCapabilities ({0} present of {1}):", Capabilities.Count, Enum.GetValues(typeof(CapabilityEnum)).Length)); + foreach (CapabilityEnum x in Enum.GetValues(typeof(CapabilityEnum))) + { + c.AppendFormat("\n\t {0,-20}{1}", x.ToString(""), Capabilities.Contains(x) ? "Yes" : "No"); + } + } + + } + catch (Exception ex) + { + } + + return c.ToString(); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/BaseMTPCamera.cs b/DigiCamControl/CameraControl.Devices/BaseMTPCamera.cs new file mode 100644 index 0000000..ac315a7 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/BaseMTPCamera.cs @@ -0,0 +1,708 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using CameraControl.Devices.Classes; +using CameraControl.Devices.TransferProtocol; +using CameraControl.Devices.Xml; +using PortableDeviceLib; +using Timer = System.Timers.Timer; + +#endregion + +namespace CameraControl.Devices +{ + public class DeviceEventArgs : EventArgs + { + public uint Code { get; set; } + } + + public class BaseMTPCamera : BaseCameraDevice + { + /// + /// The number of times to retry failed transfers. + /// + public const int TransferRetries = 10; + + public delegate void DeviceEventHandler(object sender, DeviceEventArgs eventArgs); + + public event DeviceEventHandler DeviceEvent; + + public void OnDeviceEvent(DeviceEventArgs eventargs) + { + DeviceEventHandler handler = DeviceEvent; + if (handler != null) handler(this, eventargs); + } + + protected const string AppName = "CameraControl"; + protected const int AppMajorVersionNumber = 1; + protected const int AppMinorVersionNumber = 0; + + // common MTP commands + public const uint CONST_CMD_GetDevicePropValue = 0x1015; + public const uint CONST_CMD_SetDevicePropValue = 0x1016; + public const uint CONST_CMD_GetDevicePropDesc = 0x1014; + public const uint CONST_CMD_GetObject = 0x1009; + public const uint CONST_CMD_GetObjectHandles = 0x1007; + public const uint CONST_CMD_GetObjectInfo = 0x1008; + public const uint CONST_CMD_GetThumb = 0x100A; + public const uint CONST_CMD_DeleteObject = 0x100B; + public const uint CONST_CMD_InitiateCapture = 0x100E; + public const uint CONST_CMD_FormatStore = 0x100F; + public const uint CONST_CMD_GetStorageIDs = 0x1004; + + public const uint CONST_Event_ObjectAdded = 0x4002; + public const uint CONST_Event_ObjectAddedInSdram = 0xC101; + + public const uint CONST_PROP_BatteryLevel = 0x5001; + + private const int CONST_READY_TIME = 1; + private const int CONST_LOOP_TIME = 100; + + protected ITransferProtocol StillImageDevice = null; + protected bool DeviceIsBusy = false; + + /// + /// The timer for get periodically the event list + /// + protected Timer _timer = new Timer(1000 / 10); + + /// + /// Variable to check if event processing is in progress + /// + protected bool _eventIsbusy = false; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + StillImageDevice = deviceDescriptor.StillImageDevice; + StillImageDevice imageDevice = StillImageDevice as StillImageDevice; + if (imageDevice != null) + imageDevice.DeviceEvent += StillImageDevice_DeviceEvent; + IsConnected = true; + DeviceName = StillImageDevice.Model; + Manufacturer = StillImageDevice.Manufacturer; + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + return true; + } + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + public void StopEventTimer() + { + while (_eventIsbusy) + { + } + _timer.Stop(); + } + + public void StartEventTimer() + { + _timer.Start(); + } + + private void StillImageDevice_DeviceEvent(object sender, PortableDeviceEventArgs e) + { + if (e.EventType.EventGuid == PortableDeviceGuids.WPD_EVENT_DEVICE_REMOVED) + { + _timer.Stop(); + StillImageDevice.Disconnect(); + StillImageDevice.IsConnected = false; + IsConnected = false; + OnCameraDisconnected(this, new DisconnectCameraEventArgs { StillImageDevice = StillImageDevice }); + } + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + uint res = ExecuteWithNoData(CONST_CMD_DeleteObject, (uint)deviceObject.Handle); + return res == 0 || res == ErrorCodes.MTP_OK; + } + + public override AsyncObservableCollection GetObjects(object storageId, bool loadThumbs) + { + AsyncObservableCollection res = new AsyncObservableCollection(); + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetObjectHandles, 0xFFFFFFFF); + if (response.Data == null) + { + Log.Debug("Get object error :" + response.ErrorCode.ToString("X")); + ErrorCodes.GetException(response.ErrorCode); + return res; + } + int objCount = BitConverter.ToInt32(response.Data, 0); + for (int i = 0; i < objCount; i++) + { + DeviceObject deviceObject = new DeviceObject(); + uint handle = BitConverter.ToUInt32(response.Data, 4 * i + 4); + deviceObject.Handle = handle; + MTPDataResponse objectdata = ExecuteReadDataEx(CONST_CMD_GetObjectInfo, handle); + if (objectdata.Data != null) + { + uint objFormat = BitConverter.ToUInt16(objectdata.Data, 4); + if (objFormat == 0x3000 || objFormat == 0x3801 || objFormat == 0x3800) + { + deviceObject.FileName = Encoding.Unicode.GetString(objectdata.Data, 53, 12 * 2); + if (deviceObject.FileName.Contains("\0")) + deviceObject.FileName = deviceObject.FileName.Split('\0')[0]; + try + { + string datesrt = Encoding.Unicode.GetString(objectdata.Data, 53 + (12 * 2) + 3, 30); + //datesrt = datesrt.Replace("T", ""); + DateTime date = DateTime.MinValue; + if (DateTime.TryParseExact(datesrt, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture, + DateTimeStyles.None, out date)) + { + deviceObject.FileDate = date; + } + } + catch (Exception) + { + } + + if (loadThumbs) + { + MTPDataResponse thumbdata = ExecuteReadDataEx(CONST_CMD_GetThumb, handle); + deviceObject.ThumbData = thumbdata.Data; + } + res.Add(deviceObject); + } + } + } + return res; + } + + /// + /// Transfers the file and saves it to the specified filename. + /// + /// The object handle. + /// The filename. + public override void TransferFile(object o, string filename) + { + using (var fs = File.Open(filename, FileMode.Create)) + { + TransferFile(o, fs); + } + } + + /// + /// Transfers the file and writes it to the specified stream. + /// + /// The object handle. + /// The stream. + public override void TransferFile(object o, Stream stream) + { + // Sanity checks. + if (!stream.CanWrite) + throw new ArgumentException("Specified stream is not writable.", "stream"); + lock (Locker) + { + + string s = o as string; + if (s != null) + { + ((StillImageDevice)StillImageDevice).SaveFile(s, stream); + return; + } + int retryes = TransferRetries; + _timer.Stop(); + MTPDataResponse result = new MTPDataResponse(); + //=================== managed file write + do + { + try + { + //using (MemoryStream mStream = new MemoryStream()) + //{ + + result = StillImageDevice.ExecuteReadBigData(CONST_CMD_GetObject, stream, + (total, current) => + { + double i = (double) current / total; + TransferProgress = + Convert.ToUInt32(i * 100); + }, Convert.ToUInt32(o)); + //if (result != null && result.Data != null) + //{ + // stream.Write(result.Data, 0, result.Data.Length); + //} + //stream.Write(mStream.ToArray(), 0, (int)mStream.Length); + break; + //} + } + catch (COMException ex) + { + Log.Error("Transfer error", ex); + Thread.Sleep(200); + retryes--; + } + + } while (retryes > 0); + + //================================================================== + //=================== direct file write + //StillImageDevice.ExecuteReadBigDataWriteToFile(CONST_CMD_GetObject, + // Convert.ToInt32(o), -1, + // (total, current) => + // { + // double i = (double)current / total; + // TransferProgress = + // Convert.ToUInt32(i * 100); + + // }, filename); + + //================================================================== + _timer.Start(); + TransferProgress = 0; + } + } + + public override void FormatStorage(object storageId) + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetStorageIDs); + if (response.Data.Length > 4) + { + int objCount = BitConverter.ToInt32(response.Data, 0); + for (int i = 0; i < objCount; i++) + { + uint handle = BitConverter.ToUInt32(response.Data, 4 * i + 4); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_FormatStore, handle)); + } + } + } + + public MTPDataResponse ExecuteReadDataEx(uint code, uint param1, uint param2) + { + return ExecuteReadDataEx(code, param1, param2, CONST_LOOP_TIME, 0); + } + + public uint ExecuteWithNoData(uint code, uint param1) + { + return ExecuteWithNoData(code, param1, CONST_LOOP_TIME, 0); + } + + public uint ExecuteWithNoData(uint code, uint param1, uint param2, uint param3) + { + return ExecuteWithNoData(code, param1, param2, param3, CONST_LOOP_TIME, 0); + } + + public uint ExecuteWithNoData(uint code) + { + return ExecuteWithNoData(code, CONST_LOOP_TIME, 0); + } + + + public uint ExecuteWithNoData(uint code, uint param1, int loop, int counter) + { + uint res = 0; + bool allok; + do + { + allok = true; + res = StillImageDevice.ExecuteWithNoData(code, param1); + if ((res == ErrorCodes.MTP_Device_Busy || res == PortableDeviceErrorCodes.ERROR_BUSY) && counter < loop) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + return res; + } + + public uint ExecuteWithNoData(uint code, uint param1, uint param2, uint param3, int loop, int counter) + { + uint res = 0; + bool allok; + do + { + allok = true; + res = StillImageDevice.ExecuteWithNoData(code, param1, param2, param3); + if ((res == ErrorCodes.MTP_Device_Busy || res == PortableDeviceErrorCodes.ERROR_BUSY) && counter < loop) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + return res; + } + + public uint ExecuteWithNoData(uint code, int loop, int counter) + { + uint res = 0; + bool allok; + do + { + allok = true; + res = StillImageDevice.ExecuteWithNoData(code); + if ((res == ErrorCodes.MTP_Device_Busy || res == PortableDeviceErrorCodes.ERROR_BUSY) && counter < loop) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + return res; + } + + public uint ExecuteWithNoData(uint code, uint param1, uint param2) + { + uint res = StillImageDevice.ExecuteWithNoData(code, param1, param2); + return res; + } + + public MTPDataResponse ExecuteReadDataEx(uint code, uint param1, uint param2, int loop, int counter) + { + DeviceIsBusy = true; + MTPDataResponse res = new MTPDataResponse(); + bool allok; + do + { + allok = true; + res = StillImageDevice.ExecuteReadData(code, param1, param2); + if ((res.ErrorCode == ErrorCodes.MTP_Device_Busy || res.ErrorCode == PortableDeviceErrorCodes.ERROR_BUSY) && + counter < loop) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + DeviceIsBusy = false; + return res; + } + + public MTPDataResponse ExecuteReadDataEx(uint code, uint param1, uint param2, uint param3, int loop, int counter) + { + DeviceIsBusy = true; + MTPDataResponse res = new MTPDataResponse(); + bool allok; + do + { + allok = true; + res = StillImageDevice.ExecuteReadData(code, param1, param2, param3); + if ((res.ErrorCode == ErrorCodes.MTP_Device_Busy || res.ErrorCode == PortableDeviceErrorCodes.ERROR_BUSY) && + counter < loop) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + DeviceIsBusy = false; + return res; + } + + public MTPDataResponse ExecuteReadDataEx(uint code, uint param1) + { + int counter = 0; + DeviceIsBusy = true; + MTPDataResponse res = new MTPDataResponse(); + bool allok; + do + { + res = StillImageDevice.ExecuteReadData(code, param1); + allok = true; + if ((res.ErrorCode == ErrorCodes.MTP_Device_Busy || res.ErrorCode == PortableDeviceErrorCodes.ERROR_BUSY) && + counter < CONST_LOOP_TIME) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + DeviceIsBusy = false; + return res; + } + + public MTPDataResponse ExecuteReadDataEx(uint code) + { + int counter = 0; + DeviceIsBusy = true; + MTPDataResponse res = new MTPDataResponse(); + bool allok; + do + { + res = StillImageDevice.ExecuteReadData(code); + allok = true; + if ((res.ErrorCode == ErrorCodes.MTP_Device_Busy || res.ErrorCode == PortableDeviceErrorCodes.ERROR_BUSY) && + counter < CONST_LOOP_TIME) + { + Thread.Sleep(CONST_READY_TIME); + counter++; + allok = false; + } + } while (!allok); + DeviceIsBusy = false; + return res; + } + + + public void SetProperty(uint code, byte[] data, uint param1) + { + bool timerstate = _timer.Enabled; + _timer.Stop(); + bool retry = false; + int retrynum = 0; + //DeviceReady(); + do + { + if (retrynum > 5) + { + return; + } + try + { + retry = false; + uint resp = StillImageDevice.ExecuteWriteData(code, data, param1); + if (resp != 0 || resp != ErrorCodes.MTP_OK) + { + //Console.WriteLine("Retry ...." + resp.ToString("X")); + if (resp == ErrorCodes.MTP_Device_Busy || resp == 0x800700AA) + { + Thread.Sleep(50); + retry = true; + retrynum++; + } + else + { + ErrorCodes.GetException(resp); + } + } + } + catch (Exception exception) + { + Log.Debug("Error set property :" + param1.ToString("X"), exception); + } + } while (retry); + if (timerstate) + _timer.Start(); + } + + public void SetProperty(uint code, byte[] data, uint param1, uint param2) + { + bool timerstate = _timer.Enabled; + _timer.Stop(); + bool retry = false; + int retrynum = 0; + //DeviceReady(); + do + { + if (retrynum > 5) + { + return; + } + try + { + retry = false; + uint resp = StillImageDevice.ExecuteWriteData(code, data, param1, param2); + if (resp != 0 || resp != ErrorCodes.MTP_OK) + { + //Console.WriteLine("Retry ...." + resp.ToString("X")); + if (resp == ErrorCodes.MTP_Device_Busy || resp == 0x800700AA) + { + Thread.Sleep(50); + retry = true; + retrynum++; + } + else + { + ErrorCodes.GetException(resp); + } + } + } + catch (Exception exception) + { + Log.Debug("Error set property :" + param1.ToString("X"), exception); + } + } while (retry); + if (timerstate) + _timer.Start(); + } + + public void SetProperty(uint code, byte[] data, uint param1, uint param2, uint param3) + { + bool timerstate = _timer.Enabled; + _timer.Stop(); + bool retry = false; + int retrynum = 0; + //DeviceReady(); + do + { + if (retrynum > 5) + { + return; + } + try + { + retry = false; + uint resp = StillImageDevice.ExecuteWriteData(code, data, param1, param2, param3); + if (resp != 0 || resp != ErrorCodes.MTP_OK) + { + //Console.WriteLine("Retry ...." + resp.ToString("X")); + if (resp == ErrorCodes.MTP_Device_Busy || resp == 0x800700AA) + { + Thread.Sleep(100); + retry = true; + retrynum++; + } + else + { + ErrorCodes.GetException(resp); + } + } + } + catch (Exception exception) + { + Log.Debug("Error set property :" + param1.ToString("X"), exception); + } + } while (retry); + if (timerstate) + _timer.Start(); + } + + public static short ToInt16(byte[] value, int startIndex) + { + int i = (short)(value[startIndex] << 8 | value[startIndex + 1]); + return (short)(i); + //return System.BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex); + } + + public static UInt16 ToUInt16(byte[] value, int startIndex) + { + uint i = (uint)(value[startIndex] << 8 | value[startIndex + 1]); + return (UInt16)(i); + //return System.BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex); + } + + public static int ToInt32(byte[] value, int startIndex) + { + int i = (value[startIndex] << 24 | value[startIndex + 1] << 16 | value[startIndex + 2] << 8 | value[startIndex + 3]); + return i; + //return System.BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex); + } + + public decimal ToDeciaml(byte[] value, int startIndex) + { + int i = ToUInt16(value, startIndex); + int d = ToUInt16(value, startIndex + 2); + if (d == 0 && i == 0) + return 0; + string s = i + "." + d; + return Convert.ToDecimal(s, new CultureInfo("en-US")); + } + + + protected XmlDeviceData LoadDeviceData(MTPDataResponse res) + { + XmlDeviceData deviceInfo = new XmlDeviceData(); + ErrorCodes.GetException(res.ErrorCode); + deviceInfo.Manufacturer = Manufacturer; + int index = 2 + 4 + 2; + int vendorDescCount = res.Data[index]; + index += vendorDescCount * 2; + index += 3; + int comandsCount = res.Data[index]; + index += 2; + // load commands + for (int i = 0; i < comandsCount; i++) + { + index += 2; + deviceInfo.AvaiableCommands.Add(new XmlCommandDescriptor() { Code = BitConverter.ToUInt16(res.Data, index) }); + } + index += 2; + int eventcount = res.Data[index]; + index += 2; + // load events + for (int i = 0; i < eventcount; i++) + { + index += 2; + deviceInfo.AvaiableEvents.Add(new XmlEventDescriptor() { Code = BitConverter.ToUInt16(res.Data, index) }); + } + index += 2; + int propertycount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < propertycount; i++) + { + index += 2; + deviceInfo.AvaiableProperties.Add(new XmlPropertyDescriptor() { Code = BitConverter.ToUInt16(res.Data, index) }); + } + try + { + MTPDataResponse vendor_res = ExecuteReadDataEx(0x90CA); + if (vendor_res.Data.Length > 0) + { + index = 0; + propertycount = vendor_res.Data[index]; + index += 2; + for (int i = 0; i < propertycount; i++) + { + index += 2; + deviceInfo.AvaiableProperties.Add(new XmlPropertyDescriptor() { Code = BitConverter.ToUInt16(vendor_res.Data, index) }); + } + } + } + catch (Exception) + { + } + return deviceInfo; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/CameraControl.Devices.csproj b/DigiCamControl/CameraControl.Devices/CameraControl.Devices.csproj new file mode 100644 index 0000000..e686327 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/CameraControl.Devices.csproj @@ -0,0 +1,312 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {E8572D8B-C987-4D20-BD88-1F8925A64A82} + Library + Properties + CameraControl.Devices + CameraControl.Devices + v4.6 + 512 + + + + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + false + AnyCPU + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + true + true + false + bin\x86\Debug\CameraControl.Devices.XML + + + bin\Release\ + TRACE + true + none + x86 + prompt + true + true + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + prompt + true + true + false + + + bin\x64\Release\ + TRACE + true + x64 + prompt + true + true + false + false + + + true + bin\Capture.Workflow\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + true + bin\x86\Capture.Workflow\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\x64\Capture.Workflow\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + false + + + CameraControl.Devices.snk + + + + ..\..\packages\Accord.3.8.2-alpha\lib\net46\Accord.dll + + + ..\..\packages\Accord.Video.3.8.0\lib\net46\Accord.Video.dll + + + ..\..\packages\Accord.Video.DirectShow.3.8.0\lib\net46\Accord.Video.DirectShow.dll + + + ..\..\refs\Interop.WIA.dll + True + + + ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + True + + + + + ..\..\packages\Rssdp.4.0.0\lib\net45\Rssdp.dll + + + + + + + + + + + + + + ..\..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {F809DBB6-E0E8-47A8-92ED-C24575576A5D} + Canon.Eos.Framework + + + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D} + PortableDeviceLib + False + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/CameraControl.Devices.snk b/DigiCamControl/CameraControl.Devices/CameraControl.Devices.snk new file mode 100644 index 0000000..b86ef48 Binary files /dev/null and b/DigiCamControl/CameraControl.Devices/CameraControl.Devices.snk differ diff --git a/DigiCamControl/CameraControl.Devices/CameraDeviceManager.cs b/DigiCamControl/CameraControl.Devices/CameraDeviceManager.cs new file mode 100644 index 0000000..3a740d2 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/CameraDeviceManager.cs @@ -0,0 +1,1018 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.ExceptionServices; +using System.Threading; +using CameraControl.Devices.Canon; +using CameraControl.Devices.Classes; +using CameraControl.Devices.Custom; +using CameraControl.Devices.Nikon; +using CameraControl.Devices.Others; +using CameraControl.Devices.TransferProtocol; +using CameraControl.Devices.TransferProtocol.DDServer; +using CameraControl.Devices.TransferProtocol.PtpIp; +using CameraControl.Devices.Wifi; +using Canon.Eos.Framework; +using PortableDeviceLib; +using WIA; +using Accord.Video.DirectShow; + +#endregion + +namespace CameraControl.Devices +{ + public class CameraDeviceManager : BaseFieldClass + { + private const string AppName = "CameraControl"; + private const int AppMajorVersionNumber = 1; + private const int AppMinorVersionNumber = 0; + private bool _connectionInProgress = false; + private DeviceDescriptorEnumerator _deviceEnumerator; + private EosFramework _framework; + private object _locker = new object(); + private List _deviceDescriptions = new List(); + + public ConcurrentDictionary LiveViewImage; + public ConcurrentDictionary LastCapturedImage; + + /// + /// Gets or sets a value indicating whether use experimental drivers. + /// Experimental drivers isn't tested and may not implement all camera possibilities + /// + /// + /// true if [use experimental drivers]; otherwise, false. + /// + public bool UseExperimentalDrivers { get; set; } + + public bool LoadWiaDevices { get; set; } + + /// + /// Gets or sets the natively supported model dictionary. + /// This property is used to find the right driver for connected camera, + /// if model not found in this dictionary generic wia driver will used. + /// + /// + /// The device class. + /// + public static Dictionary DeviceClass { get; set; } + //Test + //public Dictionary CustomDeviceClass { get; set; } + + public List WifiDeviceProviders { get; set; } + + private ICameraDevice _selectedCameraDevice; + + /// + /// Gets or sets the default selected camera device. When new camera connected this property set automatically to new device + /// + /// + /// The selected camera device. + /// + public ICameraDevice SelectedCameraDevice + { + get { return _selectedCameraDevice; } + set + { + ICameraDevice device = _selectedCameraDevice; + _selectedCameraDevice = value ?? (ConnectedDevices.Count > 0 + ? ConnectedDevices[0] + : new NotConnectedCameraDevice()); + + CameraSelected?.Invoke(device, _selectedCameraDevice); + + NotifyPropertyChanged("SelectedCameraDevice"); + } + } + + /// + /// If enabled the application will detect the connected webcams + /// + /// + /// true if [detect webcams]; otherwise, false. + /// + public bool DetectWebcams { get; set; } + + + public bool StartInNewThread { get; set; } + + private AsyncObservableCollection _connectedDevices; + + public AsyncObservableCollection ConnectedDevices + { + get { return _connectedDevices; } + set + { + _connectedDevices = value; + NotifyPropertyChanged("ConnectedDevices"); + } + } + + private void PopulateDeviceClass() + { + + DeviceClass = new Dictionary + { + {"D200", typeof(NikonD40)}, + {"D3", typeof(NikonD90)}, + {"D3S", typeof(NikonD90)}, + {"D3X", typeof(NikonD3X)}, + {"D300", typeof(NikonD300)}, + {"D300s", typeof(NikonD300)}, + {"D300S", typeof(NikonD300)}, + {"D3200", typeof(NikonD3200)}, + {"D3300", typeof(NikonD3X00Base)}, + {"D3400", typeof(NikonD3X00Base)}, + {"D3500", typeof(NikonD3X00Base)}, + {"D4", typeof(NikonD4)}, + {"D4s", typeof(NikonD4)}, + {"D4S", typeof(NikonD4)}, + {"D40", typeof(NikonD40)}, + {"D40X", typeof(NikonD40)}, + {"D5", typeof(NikonD5)}, + {"D50", typeof(NikonD40)}, + {"D500", typeof(NikonD500)}, + {"D5600", typeof(NikonD5200)}, + {"D5500", typeof(NikonD5200)}, + {"D5300", typeof(NikonD5200)}, + {"D5200", typeof(NikonD5200)}, + {"D5100", typeof(NikonD5100)}, + {"D5000", typeof(NikonD90)}, + {"D60", typeof(NikonD60)}, + {"D610", typeof(NikonD600Base)}, + {"D600", typeof(NikonD600)}, + {"D70", typeof(NikonD40)}, + {"D70s", typeof(NikonD40)}, + {"D700", typeof(NikonD700)}, + {"D750", typeof(NikonD750)}, + {"D7000", typeof(NikonD7000)}, + {"D7100", typeof(NikonD7100)}, + {"D7200", typeof(NikonD7100)}, + {"D7500", typeof(NikonD7500)}, + {"D80", typeof(NikonD80)}, + {"D800", typeof(NikonD800)}, + {"D800E", typeof(NikonD800)}, + {"D800e", typeof(NikonD800)}, + {"D810", typeof(NikonD810)}, + {"D810A", typeof(NikonD810)}, + {"D810a", typeof(NikonD810)}, + {"D850", typeof(NikonD850)}, + {"D90", typeof(NikonD90)}, + {"V1", typeof(NikonD5100)}, + {"V2", typeof(NikonD5100)}, + {"V3", typeof(NikonD600Base)}, + {"J3", typeof(NikonD600Base)}, + {"J4", typeof(NikonD600Base)}, + {"J5", typeof(NikonD600Base)}, + {"Df", typeof(NikonD600Base)}, + {"L830", typeof(NikonL830)}, + {"L840", typeof(NikonL830)}, + {"Z 50", typeof(NikonZ6)}, + {"Z 6", typeof(NikonZ6)}, + {"Z 7", typeof(NikonZ7)}, + //{"Canon EOS 5D Mark II", typeof (CanonSDKBase)}, + {"MTP Sim", typeof(BaseMTPCamera)}, + //{"D.*", typeof (NikonBase)}, + // for mtp simulator + //{"Test Camera ", typeof (NikonBase)}, + }; + //if(UseExperimentalDrivers) + //{ + // DeviceClass.Add("Canon EOS.*", typeof(CanonSDKBase)); + //} + WifiDeviceProviders.Add(new DDServerProvider()); + WifiDeviceProviders.Add(new PtpIpProvider()); + WifiDeviceProviders.Add(new YiCameraProvider()); + WifiDeviceProviders.Add(new SonyProvider()); + WifiDeviceProviders.Add(new PanonoProvider()); + WifiDeviceProviders.Add(new OscProvider()); + //Test + /*foreach (var type in CustomDeviceClass) + { + DeviceClass.Add(type.Key, type.Value); + }*/ + } + + public CameraDeviceManager(string datafolder=null) + { + UseExperimentalDrivers = false; + LoadWiaDevices = true; + StartInNewThread = false; + DetectWebcams = false; + //Test + //CustomDeviceClass = new Dictionary(); + SelectedCameraDevice = new NotConnectedCameraDevice(); + ConnectedDevices = new AsyncObservableCollection(); + _deviceEnumerator = new DeviceDescriptorEnumerator(); + LiveViewImage = new ConcurrentDictionary(); + LastCapturedImage = new ConcurrentDictionary(); + WifiDeviceProviders = new List(); + + + // prevent program crash in something wrong with wia + try + { + WiaDeviceManager = new DeviceManager(); + WiaDeviceManager.RegisterEvent(Conts.wiaEventDeviceConnected, "*"); + WiaDeviceManager.RegisterEvent(Conts.wiaEventDeviceDisconnected, "*"); + WiaDeviceManager.OnEvent += DeviceManager_OnEvent; + Log.Error("Wia initialized"); + } + catch (Exception exception) + { + Log.Error("Error initialize WIA", exception); + } + if (datafolder != null && Directory.Exists(datafolder)) + { + try + { + var files = Directory.GetFiles(datafolder, "*.xml"); + foreach (var file in files) + { + var device = DeviceDescription.Load(file); + if (device != null) + _deviceDescriptions.Add(device); + } + } + catch (Exception) + { + Log.Error("Error loading custom data"); + } + } + } + + private void InitCanon() + { + try + { + if (_framework == null) + { + _framework = new EosFramework(); + _framework.CameraAdded += _framework_CameraAdded; + } + AddCanonCameras(); + } + catch (Exception exception) + { + Log.Error("Unable init canon driver", exception); + /* Give specific guidance if the error is a missing DLL */ + if ((exception.InnerException != null) && (exception.InnerException.Message != null) && (exception.InnerException.Message.Contains("EDSDK.dll"))) + { + Console.WriteLine("\n**CRITICAL ERROR**\n\nCanon EOS camera library, EDSDK.dll is missing\nInstall it after downloading from Canon's site\n"); + } + } + } + + private void _framework_CameraAdded(object sender, EventArgs e) + { + AddCanonCameras(); + } + + public IEnumerable GetEosCameras() + { + using (EosCameraCollection cameras = _framework.GetCameraCollection()) + return cameras.ToArray(); + } + + private void AddWebcameras() + { + try + { + List monikers = new List(); + var loaclWebCamsCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice); + foreach (Accord.Video.DirectShow.FilterInfo localcamera in loaclWebCamsCollection) + { + monikers.Add(localcamera.MonikerString); + bool added = false; + foreach (ICameraDevice device in ConnectedDevices) + { + WebCameraDevice webCamera = device as WebCameraDevice; + if (webCamera != null) + { + if (webCamera.PortName == localcamera.MonikerString) + { + added = true; + } + } + } + + if (added) + continue; + + WebCameraDevice camera = new WebCameraDevice(); + camera.Init(localcamera.MonikerString); + camera.DeviceName = localcamera.Name; + camera.SerialNumber = localcamera.MonikerString; + + ConnectedDevices.Add(camera); + + SelectedCameraDevice = camera; + + camera.PhotoCaptured += cameraDevice_PhotoCaptured; + camera.CameraDisconnected += cameraDevice_CameraDisconnected; + + CameraConnected?.Invoke(camera); + } + //List devicesToDisconnect = ConnectedDevices.OfType() + // .Where(webCamera => !monikers.Contains(webCamera.PortName)) + // .ToList(); + //foreach (var webCamera in devicesToDisconnect) + //{ + // cameraDevice_CameraDisconnected(webCamera, new DisconnectCameraEventArgs() { }); + //} + } + catch (Exception ex) + { + Log.Error("Unable to connect to a webcamera", ex); + } + + } + + private void AddCanonCameras() + { + lock (_locker) + { + foreach (EosCamera eosCamera in GetEosCameras()) + { + bool shouldbeadded = + ConnectedDevices.OfType().All(camera => camera.PortName != eosCamera.PortName); + + if (shouldbeadded) + { + Log.Debug("New canon camera found !"); + CanonSDKBase camera = new CanonSDKBase(); + Log.Debug("Pas 1"); + DeviceDescriptor descriptor = new DeviceDescriptor {EosCamera = eosCamera}; + descriptor.CameraDevice = camera; + Log.Debug("Pas 2"); + camera.Init(eosCamera); + Log.Debug("Pas 3"); + ConnectedDevices.Add(camera); + Log.Debug("Pas 4"); + _deviceEnumerator.Add(descriptor); + Log.Debug("Pas 5"); + NewCameraConnected(camera); + Log.Debug("New canon camera found done!"); + } + } + //Thread.Sleep(2500); + } + } + + private ICameraDevice GetWiaIDevice(IDeviceInfo devInfo) + { + // if camera already is connected do nothing + if (_deviceEnumerator.GetByWiaId(devInfo.DeviceID) != null) + return _deviceEnumerator.GetByWiaId(devInfo.DeviceID).CameraDevice; + _deviceEnumerator.RemoveDisconnected(); + DeviceDescriptor descriptor = new DeviceDescriptor {WiaDeviceInfo = devInfo, WiaId = devInfo.DeviceID}; + + ICameraDevice cameraDevice = new WiaCameraDevice(); + bool isConnected = cameraDevice.Init(descriptor); + + descriptor.CameraDevice = cameraDevice; + _deviceEnumerator.Add(descriptor); + ConnectedDevices.Add(cameraDevice); + + if (isConnected) + { + NewCameraConnected(cameraDevice); + } + //ServiceProvider.DeviceManager.SelectedCameraDevice.ReadDeviceProperties(0); + + return SelectedCameraDevice; + } + + private void cameraDevice_CameraDisconnected(object sender, DisconnectCameraEventArgs e) + { + if (e.StillImageDevice != null) + { + DisconnectCamera(e.StillImageDevice); + } + if (e.EosCamera != null) + { + DisconnectCamera(e.EosCamera); + } + OnCameraDisconnected((ICameraDevice) sender); + } + + /// + /// Raise CameraDisconnected event. + /// + /// The camera device. + public void OnCameraDisconnected(ICameraDevice cameraDevice) + { + if (CameraDisconnected != null) + CameraDisconnected(cameraDevice); + } + + private void cameraDevice_PhotoCaptured(object sender, PhotoCapturedEventArgs eventArgs) + { + if (PhotoCaptured != null) + PhotoCaptured(sender, eventArgs); + } + + public void OnPhotoCaptured(object sender, PhotoCapturedEventArgs eventArgs) + { + if (PhotoCaptured != null) + PhotoCaptured(sender, eventArgs); + } + + private void ConnectDevices() + { + if (_connectionInProgress) + return; + _connectionInProgress = true; + if (PortableDeviceCollection.Instance == null) + { + PortableDeviceCollection.CreateInstance(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + PortableDeviceCollection.Instance.AutoConnectToPortableDevice = false; + } + _deviceEnumerator.RemoveDisconnected(); + + Log.Debug("Connection device start" ); + try + { + var devices = PortableDeviceCollection.Instance.Devices; + foreach (PortableDevice portableDevice in devices) + { + Log.Debug("Connection device " + portableDevice.DeviceId); + //TODO: avoid to load some mass storage in my computer need to find a general solution + if (!portableDevice.DeviceId.StartsWith("\\\\?\\usb") && + !portableDevice.DeviceId.StartsWith("\\\\?\\comp")) + continue; + // ignore some Canon cameras + if (!SupportedCanonCamera(portableDevice.DeviceId)) + continue; + portableDevice.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + + if (_deviceEnumerator.GetByWpdId(portableDevice.DeviceId) == null && + GetNativeDriver(portableDevice.Model) != null) + { + ICameraDevice cameraDevice; + DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = portableDevice.DeviceId}; + cameraDevice = (ICameraDevice) Activator.CreateInstance(GetNativeDriver(portableDevice.Model)); + MtpProtocol device = new MtpProtocol(descriptor.WpdId); + device.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + + descriptor.StillImageDevice = device; + + cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + + if (string.IsNullOrWhiteSpace(cameraDevice.SerialNumber)) + cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + + ConnectedDevices.Add(cameraDevice); + NewCameraConnected(cameraDevice); + + descriptor.CameraDevice = cameraDevice; + _deviceEnumerator.Add(descriptor); + } + + if (_deviceEnumerator.GetByWpdId(portableDevice.DeviceId) == null && + GetNativeDriver(portableDevice.Model) == null) + { + var description = getDeviceDescription(portableDevice.Model); + if (description != null) + { + CustomDevice cameraDevice = new CustomDevice(); + DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = portableDevice.DeviceId}; + MtpProtocol device = new MtpProtocol(descriptor.WpdId); + device.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + + descriptor.StillImageDevice = device; + + cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor, description); + + ConnectedDevices.Add(cameraDevice); + NewCameraConnected(cameraDevice); + + descriptor.CameraDevice = cameraDevice; + _deviceEnumerator.Add(descriptor); + break; + } + + } + + } + + } + catch (Exception exception) + { + Log.Error("Unable to connect to cameras ", exception); + } + + _connectionInProgress = false; + } + + private DeviceDescription getDeviceDescription(string model) + { + return _deviceDescriptions.FirstOrDefault(description => description.Model == model); + } + + public void AddDevice(DeviceDescriptor descriptor) + { + _deviceEnumerator.RemoveDisconnected(); + ConnectedDevices.Add(descriptor.CameraDevice); + NewCameraConnected(descriptor.CameraDevice); + _deviceEnumerator.Add(descriptor); + } + + public void ConnectToServer(string s, int type) + { + if(string.IsNullOrEmpty(s)) + return; + + if (type == 0) + { + int port = 15740; + string ip = s; + if (s.Contains(":")) + { + ip = s.Split(':')[0]; + int.TryParse(s.Split(':')[1], out port); + } + ConnectDevicesPtpIp(ip, port); + } + + if (type == 1) + { + int port = 4757; + string ip = s; + if (s.Contains(":")) + { + ip = s.Split(':')[0]; + int.TryParse(s.Split(':')[1], out port); + } + ConnectDevicesDDServer(ip, port); + } + } + + public void ConnectDevicesDDServer(string ip, int port) + { + if (_connectionInProgress) + return; + try + { + _connectionInProgress = true; + _deviceEnumerator.RemoveDisconnected(); + DdClient client = new DdClient(); + if (!client.Open(ip, port)) + throw new Exception("No server was found!"); + var devices = client.GetDevices(); + if (devices.Count == 0) + throw new Exception("No connected device was found!"); + + client.Connect(devices[0]); + DdServerProtocol protocol = new DdServerProtocol(client); + + if (GetNativeDriver(protocol.Model) != null) + { + ICameraDevice cameraDevice; + DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = "ddserver"}; + cameraDevice = (ICameraDevice) Activator.CreateInstance(GetNativeDriver(protocol.Model)); + descriptor.StillImageDevice = protocol; + + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + ConnectedDevices.Add(cameraDevice); + NewCameraConnected(cameraDevice); + + descriptor.CameraDevice = cameraDevice; + _deviceEnumerator.Add(descriptor); + } + else + { + throw new Exception("Not Supported device " + protocol.Model); + } + } + finally + { + _connectionInProgress = false; + } + } + + public void ConnectDevicesPtpIp(string ip, int port) + { + if (_connectionInProgress) + return; + try + { + _connectionInProgress = true; + _deviceEnumerator.RemoveDisconnected(); + + PtpIpClient client = new PtpIpClient(); + if (!client.Open(ip, 15740)) + throw new Exception("No server was found!"); + PtpIpProtocol protocol = new PtpIpProtocol(client); + protocol.ExecuteWithNoData(0x1002, 1); + + if (GetNativeDriver(protocol.Model) != null) + { + ICameraDevice cameraDevice; + DeviceDescriptor descriptor = new DeviceDescriptor { WpdId = "ptpip" }; + cameraDevice = (ICameraDevice)Activator.CreateInstance(GetNativeDriver(protocol.Model)); + descriptor.StillImageDevice = protocol; + + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + ConnectedDevices.Add(cameraDevice); + NewCameraConnected(cameraDevice); + + descriptor.CameraDevice = cameraDevice; + _deviceEnumerator.Add(descriptor); + } + else + { + throw new Exception("Not Supported device " + protocol.Model); + } + } + finally + { + _connectionInProgress = false; + } + } + + private bool SupportedCanonCamera(string id) + { + // isn't canon the manufacturer + if (!id.Contains("vid_04a9")) + return true; + return false; + } + + + private void NewCameraConnected(ICameraDevice cameraDevice) + { + const string usbPrefix = "\\\\?\\usb"; + + StaticHelper.Instance.SystemMessage = "New Camera is connected ! Driver :" + cameraDevice.DeviceName; + Log.Debug("===========Camera is connected=============="); + + if (cameraDevice.PortName != null && cameraDevice.PortName.Substring(0, usbPrefix.Length).Equals(usbPrefix)) + { + string vid = ""; + string pid = ""; + char[] delimiterChars = { '#', '&', '_' }; + + string[] words = cameraDevice.PortName.Split(delimiterChars); + + for (int i = 1; i < words.Length - 1; i++) + { + if (words[i].Equals("pid")) + pid = words[i + 1]; + else if (words[i].Equals("vid")) + vid = words[i + 1]; + } + + if (!vid.Equals("") && !pid.Equals("")) + Log.Debug("USB : VID=" + vid + ", PID=" + pid); + } + + Log.Debug("Driver :" + cameraDevice.GetType().Name); + Log.Debug("Name :" + cameraDevice.DeviceName); + Log.Debug("Manufacturer :" + cameraDevice.Manufacturer); + if (CameraConnected != null) + CameraConnected(cameraDevice); + SelectedCameraDevice = cameraDevice; + cameraDevice.PhotoCaptured += cameraDevice_PhotoCaptured; + cameraDevice.CameraDisconnected += cameraDevice_CameraDisconnected; + } + + /// + /// Gets the native driver based on camera model. + /// + /// The model name. + /// If the model not supported return null else the driver type + public static Type GetNativeDriver(string model) + { + if (String.IsNullOrEmpty(model)) + return null; + // first check if driver exist with same driver name + if (DeviceClass.ContainsKey(model)) + return DeviceClass[model]; + return null; + //// in driver not found will check with regex name + //return (from keyValuePair in DeviceClass + // let regex = new Regex(keyValuePair.Key) + // where regex.IsMatch(model) + // select keyValuePair.Value).FirstOrDefault(); + } + + [HandleProcessCorruptedStateExceptions] + public void DisconnectCamera(ICameraDevice cameraDevice) + { + + cameraDevice.PhotoCaptured -= cameraDevice_PhotoCaptured; + cameraDevice.CameraDisconnected -= cameraDevice_CameraDisconnected; + ConnectedDevices.Remove(cameraDevice); + StaticHelper.Instance.SystemMessage = "Camera disconnected :" + cameraDevice.DeviceName; + Log.Debug("===========Camera disconnected=============="); + Log.Debug("Name :" + cameraDevice.DeviceName); + + cameraDevice.Close(); + OnCameraDisconnected(cameraDevice); + } + + private void DisconnectCamera(string wiaId) + { + DeviceDescriptor descriptor = _deviceEnumerator.GetByWiaId(wiaId); + if (descriptor != null) + { + descriptor.CameraDevice.PhotoCaptured -= cameraDevice_PhotoCaptured; + descriptor.CameraDevice.CameraDisconnected -= cameraDevice_CameraDisconnected; + ConnectedDevices.Remove(descriptor.CameraDevice); + StaticHelper.Instance.SystemMessage = "Camera disconnected :" + descriptor.CameraDevice.DeviceName; + Log.Debug("===========Camera disconnected=============="); + Log.Debug("Name :" + descriptor.CameraDevice.DeviceName); + + _deviceEnumerator.Remove(descriptor); + descriptor.CameraDevice.Close(); + var wiaCameraDevice = descriptor.CameraDevice as WiaCameraDevice; + if (wiaCameraDevice != null) + { + OnCameraDisconnected(wiaCameraDevice); + } + if (PortableDeviceCollection.Instance != null) + PortableDeviceCollection.Instance.RefreshDevices(); + } + } + + private void DisconnectCamera(ITransferProtocol device) + { + DeviceDescriptor descriptor = _deviceEnumerator.GetByWpdId(device.DeviceId); + if (descriptor != null) + { + descriptor.CameraDevice.PhotoCaptured -= cameraDevice_PhotoCaptured; + descriptor.CameraDevice.CameraDisconnected -= cameraDevice_CameraDisconnected; + StaticHelper.Instance.SystemMessage = "Camera disconnected :" + descriptor.CameraDevice.DeviceName; + Log.Debug("===========Camera disconnected=============="); + Log.Debug("Name :" + descriptor.CameraDevice.DeviceName); + PortableDeviceCollection.Instance.RemoveDevice(device.DeviceId); + device.IsConnected = false; + ConnectedDevices.Remove(descriptor.CameraDevice); + descriptor.CameraDevice.Close(); + _deviceEnumerator.Remove(descriptor); + _deviceEnumerator.RemoveDisconnected(); + } + RemoveDisconnected(); + } + + private void DisconnectCamera(EosCamera device) + { + DeviceDescriptor descriptor = _deviceEnumerator.GetByEosCamera(device); + if (descriptor != null) + { + descriptor.CameraDevice.PhotoCaptured -= cameraDevice_PhotoCaptured; + descriptor.CameraDevice.CameraDisconnected -= cameraDevice_CameraDisconnected; + StaticHelper.Instance.SystemMessage = "Camera disconnected :" + descriptor.CameraDevice.DeviceName; + Log.Debug("===========Camera disconnected=============="); + Log.Debug("Name :" + descriptor.CameraDevice.DeviceName); + ConnectedDevices.Remove(descriptor.CameraDevice); + descriptor.CameraDevice.Close(); + _deviceEnumerator.Remove(descriptor); + _deviceEnumerator.RemoveDisconnected(); + } + RemoveDisconnected(); + } + + private void RemoveDisconnected() + { + List removedCameras = ConnectedDevices.Where(device => !device.IsConnected).ToList(); + foreach (ICameraDevice device in removedCameras) + { + ConnectedDevices.Remove(device); + } + } + + private DeviceManager WiaDeviceManager { get; set; } + + /// + /// Gets or sets a value for disabling native drivers. + /// + /// + /// true all devices are loaded like WIA devices false If native driver are available for connected model the will be loaded that driver else will be loaded WIA driver. + /// + public bool DisableNativeDrivers { get; set; } + + + private void DeviceManager_OnEvent(string eventId, string deviceId, string itemId) + { + //if (!LoadWiaDevices) + // return; + + if (eventId == Conts.wiaEventDeviceConnected) + { + if (StartInNewThread) + { + Thread _thread = new Thread(() => ConnectToCamera(true)); + _thread.SetApartmentState(ApartmentState.MTA); + _thread.Start(); + } + else + { + ConnectToCamera(true); + } + } + else if (eventId == Conts.wiaEventDeviceDisconnected) + { + DisconnectCamera(deviceId); + } + } + + + public bool ConnectToCamera() + { + if (UseExperimentalDrivers) + InitCanon(); + return ConnectToCamera(true); + } + + public void AddFakeCamera() + { + FakeCameraDevice device = new FakeCameraDevice(); + ConnectedDevices.Add(device); + NewCameraConnected(device); + } + + /// + /// Populate the ConnectedDevices list with connected cameras. This method will be called automatically every time new devices will be connected + /// Except Canon cameras that is handled by framework event handler + /// + /// + public bool ConnectToCamera(bool retry) + { + if (DeviceClass == null || DeviceClass.Count == 0) + PopulateDeviceClass(); + + if(DetectWebcams) + AddWebcameras(); + + if (!DisableNativeDrivers) + { + ConnectDevices(); + } + else + { + Log.Debug("Native drivers are disabled !!!!"); + } + // if canon camera is connected don't use wia driver + if (UseExperimentalDrivers && _framework != null && _framework.GetCameraCollection().Count > 0) + return true; + + if (!LoadWiaDevices) + return true; + + bool ret = false; + bool noDriversDetected = ConnectedDevices.Count == 0; + int retries = 0; + foreach (IDeviceInfo devInfo in new DeviceManager().DeviceInfos) + { + // Look for CameraDeviceType devices + string model = devInfo.Properties["Name"].get_Value(); + // skip canon cameras + //if (!string.IsNullOrEmpty(model) && model.Contains("Canon")) + // continue; + if (getDeviceDescription(model) != null) + continue; + + var nativeDriver = GetNativeDriver(model); + ret = nativeDriver != null; + + if ((devInfo.Type == WiaDeviceType.CameraDeviceType || devInfo.Type == WiaDeviceType.VideoDeviceType) + && (nativeDriver == null || DisableNativeDrivers || noDriversDetected) && retries < 3) + { + do + { + Log.Debug("Wia Camera Found: " + model); + try + { + GetWiaIDevice(devInfo); + retries = 4; + ret = true; + } + catch (Exception exception) + { + Log.Error("Unable to connect to the camera", exception); + retries++; + if (retries < 3) + { + Log.Debug("Retrying"); + StaticHelper.Instance.SystemMessage = "Unable to connect to the camera. Retrying"; + } + else + { + StaticHelper.Instance.SystemMessage = + "Unable to connect to the camera. Please reconnect your camera !"; + } + Thread.Sleep(1000); + } + } while (retries < 3); + } + } + return ret; + } + + public void CloseAll() + { + foreach ( + ICameraDevice connectedDevice in ConnectedDevices.Where(connectedDevice => connectedDevice.IsConnected)) + { + connectedDevice.Close(); + } + } + + public event PhotoCapturedEventHandler PhotoCaptured; + + public delegate void CameraConnectedEventHandler(ICameraDevice cameraDevice); + + /// + /// Occurs when a new camera is connected. + /// + public event CameraConnectedEventHandler CameraConnected; + + /// + /// Occurs when a camera disconnected. + /// + public event CameraConnectedEventHandler CameraDisconnected; + + public delegate void CameraSelectedEventHandler(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice); + + /// + /// Occurs when SelectedCameraDevice property changed. + /// + public event CameraSelectedEventHandler CameraSelected; + + + public void SelectNextCamera() + { + if (ConnectedDevices.Count == 0) + return; + int idx = 0; + for (int i = 0; i < ConnectedDevices.Count; i++) + { + var device = ConnectedDevices[i]; + if (device == SelectedCameraDevice) + { + idx = i; + break; + } + } + idx++; + if (idx < ConnectedDevices.Count) + SelectedCameraDevice = ConnectedDevices[idx]; + } + + public void SelectPrevCamera() + { + if (ConnectedDevices.Count == 0) + return; + int idx = 0; + for (int i = 0; i < ConnectedDevices.Count; i++) + { + var device = ConnectedDevices[i]; + if (device == SelectedCameraDevice) + { + idx = i; + break; + } + } + idx--; + if (idx >= 0) + SelectedCameraDevice = ConnectedDevices[idx]; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Canon/CanonBase.cs b/DigiCamControl/CameraControl.Devices/Canon/CanonBase.cs new file mode 100644 index 0000000..6d79c14 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Canon/CanonBase.cs @@ -0,0 +1,473 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using PortableDeviceLib.Model; + +#endregion + +namespace CameraControl.Devices.Canon +{ + public class CanonBase : BaseMTPCamera + { + public const int CONST_CMD_CANON_EOS_RemoteRelease = 0x910F; + public const int CONST_CMD_CANON_EOS_BulbStart = 0x9125; + public const int CONST_CMD_CANON_EOS_BulbEnd = 0x9126; + public const int CONST_CMD_CANON_EOS_SetEventMode = 0x9115; + public const int CONST_CMD_CANON_EOS_SetRemoteMode = 0x9114; + public const int CONST_CMD_CANON_EOS_GetEvent = 0x9116; + public const int CONST_CMD_CANON_EOS_DoAf = 0x9154; + public const int CONST_CMD_CANON_EOS_GetViewFinderData = 0x9153; + public const int CONST_CMD_CANON_EOS_GetObjectInfo = 0x9103; + + public const int CONST_CMD_CANON_EOS_SetDevicePropValueEx = 0x9110; + public const int CONST_CMD_CANON_EOS_RequestDevicePropValue = 0x9109; + + public const int CONST_PROP_EOS_ShutterSpeed = 0xD102; + public const int CONST_PROP_EOS_LiveView = 0xD1B0; + + public const int CONST_Event_CANON_EOS_PropValueChanged = 0xc189; + public const int CONST_Event_CANON_EOS_ObjectAddedEx = 0xc181; + + //private bool _eventIsbusy = false; + + protected Dictionary _shutterTable = new Dictionary + { + {0, "30"}, + {1, "25"}, + {2, "20"}, + {3, "15"}, + {4, "13"}, + {5, "10"}, + {6, "8"}, + {7, "6"}, + {8, "5"}, + {9, "4"}, + {10, "3.2"}, + {11, "2.5"}, + {12, "2"}, + {13, "1.6"}, + {14, "1.3"}, + {15, "1"}, + {16, "0.8"}, + {17, "0.6"}, + {18, "0.5"}, + {19, "0.4"}, + {20, "0.3"}, + {21, "1/4"}, + {22, "1/5"}, + {23, "1/6"}, + {24, "1/8"}, + {25, "1/10"}, + {26, "1/13"}, + {27, "1/15"}, + {28, "1/20"}, + {29, "1/25"}, + {30, "1/30"}, + {31, "1/40"}, + {32, "1/50"}, + {33, "1/60"}, + {34, "1/80"}, + {35, "1/100"}, + {36, "1/125"}, + {37, "1/160"}, + {38, "1/200"}, + {39, "1/250"}, + {40, "1/320"}, + {41, "1/400"}, + {42, "1/500"}, + {43, "1/640"}, + {44, "1/800"}, + {45, "1/1000"}, + {46, "1/1250"}, + {47, "1/1600"}, + {48, "1/2000"}, + {49, "1/2500"}, + {50, "1/3200"}, + {51, "1/4000"}, + {52, "1/5000"}, + {53, "1/6400"}, + {54, "1/8000"} + }; + + public CanonBase() + { + _timer.AutoReset = true; + _timer.Elapsed += _timer_Elapsed; + } + + private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + _timer.Stop(); + try + { + lock (Locker) + { + Thread thread = new Thread(getEvent); + thread.Start(); + } + } + catch (Exception) + { + } + // + } + + + private void getEvent() + { + try + { + if (_eventIsbusy) + return; + _eventIsbusy = true; + //DeviceReady(); + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_CANON_EOS_GetEvent); + + if (response.Data == null) + { + Log.Debug("Get event error :" + response.ErrorCode.ToString("X")); + return; + } + int eventCount = BitConverter.ToInt16(response.Data, 0); + Log.Debug("Number of events " + eventCount); + if (eventCount > 0) + { + Console.WriteLine("Event queue length " + eventCount); + for (int i = 0; i < eventCount; i++) + { + try + { + uint eventCode = BitConverter.ToUInt16(response.Data, 6*i + 2); + ushort eventParam = BitConverter.ToUInt16(response.Data, 6*i + 4); + int longeventParam = BitConverter.ToInt32(response.Data, 6*i + 4); + switch (eventCode) + { + case CONST_Event_CANON_EOS_PropValueChanged: + Log.Debug("EOS property changed " + eventParam.ToString("X")); + //ReadDeviceProperties(eventParam); + break; + case CONST_Event_CANON_EOS_ObjectAddedEx: + case CONST_Event_ObjectAddedInSdram: + case CONST_Event_ObjectAdded: + { + try + { + MTPDataResponse objectdata = + ExecuteReadDataEx(CONST_CMD_CANON_EOS_GetObjectInfo, + (uint) longeventParam); + string filename = "DSC_0000.JPG"; + if (objectdata.Data != null) + { + filename = Encoding.Unicode.GetString(objectdata.Data, 53, 12*2); + if (filename.Contains("\0")) + filename = filename.Split('\0')[0]; + } + else + { + Log.Error("Error getting file name"); + } + Log.Debug("File transfer " + filename); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = + new PortableDeviceEventArgs(new PortableDeviceEventType + () + { + ObjectHandle + = + ( + uint + ) + longeventParam + }), + CameraDevice = this, + FileName = filename, + Handle = (uint) longeventParam + }; + OnPhotoCapture(this, args); + } + catch (Exception exception) + { + Log.Error("Object added error", exception); + } + } + break; + //case CONST_Event_CaptureComplete: + //case CONST_Event_CaptureCompleteRecInSdram: + // { + // OnCaptureCompleted(this, new EventArgs()); + // } + // break; + //case CONST_Event_ObsoleteEvent: + // break; + default: + //Console.WriteLine("Unknown event code " + eventCode.ToString("X")); + Log.Debug("Unknown event code :" + eventCode.ToString("X") + "|" + + longeventParam.ToString("X")); + break; + } + } + catch (Exception exception) + { + Log.Error("Event queue processing error ", exception); + } + } + } + } + catch (InvalidComObjectException) + { + return; + } + catch (Exception) + { + //Log.Error("Event exception ", exception); + } + _eventIsbusy = false; + _timer.Start(); + } + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + StillImageDevice = deviceDescriptor.StillImageDevice; + //StillImageDevice.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + //StillImageDevice.DeviceEvent += _stillImageDevice_DeviceEvent; + DeviceName = StillImageDevice.Model; + Manufacturer = StillImageDevice.Manufacturer; + Capabilities.Add(CapabilityEnum.Bulb); + Capabilities.Add(CapabilityEnum.LiveView); + InitShutterSpeed(); + IsConnected = true; + ExecuteWithNoData(CONST_CMD_CANON_EOS_SetRemoteMode, 1); + ExecuteWithNoData(CONST_CMD_CANON_EOS_SetEventMode, 1); + _timer.Start(); + return true; + } + + private void InitShutterSpeed() + { + ShutterSpeed = new PropertyValue(); + ShutterSpeed.Name = "ShutterSpeed"; + ShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ReInitShutterSpeed() + { + lock (Locker) + { + try + { + //byte datasize = 4; + ShutterSpeed.Clear(); + foreach (KeyValuePair keyValuePair in _shutterTable) + { + ShutterSpeed.AddValues(keyValuePair.Value, keyValuePair.Key); + } + //byte[] result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, CONST_PROP_EOS_ShutterSpeed); + //int type = BitConverter.ToInt16(result, 2); + //byte formFlag = result[(2 * datasize) + 5]; + //UInt32 defval = BitConverter.ToUInt32(result, datasize + 5); + //for (int i = 0; i < result.Length - ((2 * datasize) + 6 + 2); i += datasize) + //{ + // UInt32 val = BitConverter.ToUInt32(result, ((2 * datasize) + 6 + 2) + i); + // ShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + //} + //ShutterSpeed.SetValue(defval); + } + catch (Exception ex) + { + Log.Debug("EOS Shutter speed init", ex); + } + } + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_CANON_EOS_SetDevicePropValueEx, BitConverter.GetBytes(val), + CONST_PROP_EOS_ShutterSpeed); + SetEOSProperty(CONST_PROP_EOS_ShutterSpeed, (uint) val); + } + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_CANON_EOS_RemoteRelease)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + private void _stillImageDevice_DeviceEvent(object sender, PortableDeviceEventArgs e) + { + if (e.EventType.EventGuid == PortableDeviceGuids.WPD_EVENT_DEVICE_REMOVED) + { + StillImageDevice.Disconnect(); + StillImageDevice.IsConnected = false; + IsConnected = false; + + OnCameraDisconnected(this, new DisconnectCameraEventArgs {StillImageDevice = StillImageDevice}); + } + else + { + getEvent(); + } + } + + public override void StartBulbMode() + { + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_CANON_EOS_BulbStart)); + } + + public override void EndBulbMode() + { + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_CANON_EOS_BulbEnd)); + } + + public override LiveViewData GetLiveViewImage() + { + _timer.Stop(); + LiveViewData viewData = new LiveViewData(); + if (Monitor.TryEnter(Locker, 10)) + { + try + { + //DeviceReady(); + viewData.HaveFocusData = false; + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_CANON_EOS_GetViewFinderData, 0x00100000); + ErrorCodes.GetException(response.ErrorCode); + if (response.Data == null) + { + _timer.Start(); + return null; + } + viewData.ImageDataPosition = 0; + viewData.ImageData = response.Data; + } + catch (Exception e) + { + Log.Error("Error get live view image ", e); + } + finally + { + Monitor.Exit(Locker); + } + } + _timer.Start(); + return viewData; + } + + public override void StartLiveView() + { + SetProperty(CONST_CMD_CANON_EOS_SetDevicePropValueEx, BitConverter.GetBytes(2), + CONST_PROP_EOS_LiveView); + SetEOSProperty(CONST_PROP_EOS_LiveView, (uint) 2); + } + + public override void StopLiveView() + { + SetProperty(CONST_CMD_CANON_EOS_SetDevicePropValueEx, BitConverter.GetBytes(0), + CONST_PROP_EOS_LiveView); + SetEOSProperty(CONST_PROP_EOS_LiveView, (uint) 0); + } + + + public void SetEOSProperty(uint prop, uint val) + { + bool timerstate = _timer.Enabled; + _timer.Stop(); + bool retry = false; + int retrynum = 0; + //DeviceReady(); + do + { + if (retrynum > 5) + { + return; + } + try + { + retry = false; + uint resp = ExecuteWithNoData(CONST_CMD_CANON_EOS_SetDevicePropValueEx, 0x0000000C, (int) prop, + (int) val); + + if (resp != 0 || resp != ErrorCodes.MTP_OK) + { + //Console.WriteLine("Retry ...." + resp.ToString("X")); + if (resp == ErrorCodes.MTP_Device_Busy || resp == 0x800700AA) + { + Thread.Sleep(100); + retry = true; + retrynum++; + } + else + { + ErrorCodes.GetException(resp); + } + } + } + catch (Exception exception) + { + Log.Debug("Error EOS set property :" + prop.ToString("X"), exception); + } + } while (retry); + if (timerstate) + _timer.Start(); + } + + public override string ToString() + { + /* Canon Base, just note it for now */ + return base.ToString() + "\n\tType..................Canon (base)"; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Canon/CanonSDKBase.cs b/DigiCamControl/CameraControl.Devices/Canon/CanonSDKBase.cs new file mode 100644 index 0000000..34d4a7a --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Canon/CanonSDKBase.cs @@ -0,0 +1,1982 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Timers; +using CameraControl.Devices.Classes; +using Canon.Eos.Framework; +using Canon.Eos.Framework.Eventing; +using Canon.Eos.Framework.Internal; +using Canon.Eos.Framework.Internal.SDK; + +#endregion + +namespace CameraControl.Devices.Canon +{ + public class CanonSDKBase : BaseMTPCamera + { + private EosLiveImageEventArgs _liveViewImageData = null; + private bool _recording = false; + + public EosCamera Camera = null; + private System.Timers.Timer _shutdownTimer = new System.Timers.Timer(1000*60); + + protected Dictionary _shutterTable = new Dictionary + { + {0x0C, "Bulb"}, + {0x10, "30"}, + {0x13, "25"}, + {0x14, "20"}, + {0x15, "20"}, + {0x18, "15"}, + {0x1B, "13"}, + {0x1C, "10"}, + {0x1D, "10"}, + {0x20, "8"}, + {0x23, "6"}, + {0x24, "6"}, + {0x25, "5"}, + {0x28, "4"}, + {0x2B, "3.2"}, + {0x2C, "3"}, + {0x2D, "2.5"}, + {0x30, "2"}, + {0x33, "1.6"}, + {0x34, "1.5"}, + {0x35, "1.3"}, + {0x38, "1"}, + {0x3B, "0.8"}, + {0x3C, "0.7"}, + {0x3D, "0.6"}, + {0x40, "0.5"}, + {0x43, "0.4"}, + {0x44, "0.3"}, + {0x45, "0.3"}, + {0x48, "1/4"}, + {0x4B, "1/5"}, + {0x4C, "1/6"}, + {0x4D, "1/5"}, + {0x50, "1/8"}, + {0x53, "1/10"}, + {0x54, "1/10"}, + {0x55, "1/13"}, + {0x58, "1/15"}, + {0x5B, "1/20"}, + {0x5C, "1/20"}, + {0x5D, "1/25"}, + {0x60, "1/30"}, + {0x63, "1/40"}, + {0x64, "1/45"}, + {0x65, "1/50"}, + {0x68, "1/60"}, + {0x6B, "1/80"}, + {0x6C, "1/90"}, + {0x6D, "1/100"}, + {0x70, "1/125"}, + {0x73, "1/160"}, + {0x74, "1/180"}, + {0x75, "1/200"}, + {0x78, "1/250"}, + {0x7B, "1/320"}, + {0x7C, "1/350"}, + {0x7D, "1/400"}, + {0x80, "1/500"}, + {0x83, "1/640"}, + {0x84, "1/750"}, + {0x85, "1/800"}, + {0x88, "1/1000"}, + {0x8B, "1/1250"}, + {0x8C, "1/1500"}, + {0x8D, "1/1600"}, + {0x90, "1/2000"}, + {0x93, "1/2500"}, + {0x94, "1/3000"}, + {0x95, "1/3200"}, + {0x98, "1/4000"}, + {0x9B, "1/5000"}, + {0x9C, "1/6000"}, + {0x9D, "1/6400"}, + {0xA0, "1/8000"}, + }; + + protected Dictionary _apertureTable = new Dictionary + { + {0x08, "1.0"}, + {0x0B, "1.1"}, + {0x0C, "1.2"}, + {0x0D, "1.0"}, + {0x10, "1.4"}, + {0x13, "1.6"}, + {0x14, "1.8"}, + {0x15, "1.8"}, + {0x18, "2.0"}, + {0x1B, "2.2"}, + {0x1C, "2.5"}, + {0x1D, "2.5"}, + {0x20, "2.8"}, + {0x23, "3.2"}, + {0x24, "3.5"}, + {0x25, "3.5"}, + {0x28, "4.0"}, + {0x2B, "4.5"}, + {0x2C, "4.5"}, + {0x2D, "5.0"}, + {0x30, "5.6"}, + {0x33, "6.3"}, + {0x34, "6.7"}, + {0x35, "7.1"}, + {0x38, "8.0"}, + {0x3B, "9.0"}, + {0x3C, "9.5"}, + {0x3D, "10.0"}, + {0x40, "11.0"}, + {0x43, "13.0"}, + {0x44, "13.0"}, + {0x45, "14.0"}, + {0x48, "16.0"}, + {0x4B, "18.0"}, + {0x4C, "19.0"}, + {0x4D, "20.0"}, + {0x50, "22.0"}, + {0x53, "25.0"}, + {0x54, "27.0"}, + {0x55, "29.0"}, + {0x58, "32.0"}, + {0x5B, "36.0"}, + {0x5C, "38.0"}, + {0x5D, "40.0"}, + {0x60, "45.0"}, + {0x63, "51.0"}, + {0x64, "54.0"}, + {0x65, "57.0"}, + {0x68, "64.0"}, + {0x6B, "72.0"}, + {0x6C, "76.0"}, + {0x6D, "80.0"}, + {0x70, "91.0"}, + }; + + protected Dictionary _exposureModeTable = new Dictionary() + { + {0, "P"}, + {1, "Tv"}, + {2, "Av"}, + {3, "M"}, + {4, "Bulb"}, + {5, "A-DEP"}, + {6, "DEP"}, + {7, "Camera settings registered"}, + {8, "Lock"}, + {9, "Auto"}, + {10, "Night scene Portrait"}, + {11, "Sport"}, + {12, "Portrait"}, + {13, "Landscape"}, + {14, "Close-Up"}, + {15, "Flash Off"}, + {19, "Creative Auto"}, + {21, "Photo in Movie"}, + }; + + protected Dictionary _isoTable = new Dictionary() + { + {0x00000000, "Auto"}, + {0x00000028, "6"}, + {0x00000030, "12"}, + {0x00000038, "25"}, + {0x00000040, "50"}, + {0x00000048, "100"}, + {0x0000004B, "125"}, + {0x0000004D, "160"}, + {0x00000050, "200"}, + {0x00000053, "250"}, + {0x00000055, "320"}, + {0x00000058, "400"}, + {0x0000005B, "500"}, + {0x0000005D, "640"}, + {0x00000060, "800"}, + {0x00000063, "1000"}, + {0x00000065, "1250"}, + {0x00000068, "1600"}, + {0x00000070, "3200"}, + {0x00000078, "6400"}, + {0x00000080, "12800"}, + {0x00000088, "25600"}, + {0x00000090, "51200"}, + {0x00000098, "102400"}, + }; + + protected Dictionary _ec = new Dictionary() + { + {0x18, "+3.0"}, + {0x15, "+2 2/3"}, + {0x14, "+2.5"}, + {0x13, "+2 1/3"}, + {0x10, "+2.0"}, + {0x0D, "+1 2/3"}, + {0x0C, "+1.5"}, + {0x0B, "+1 1/3"}, + {0x08, "+1"}, + {0x05, "+2/3"}, + {0x04, "+0.5"}, + {0x03, "+1/3"}, + {0x00, "0.0"}, + {0xFD, "-1/3"}, + {0xFC, "-0.5"}, + {0xFB, "-2/3"}, + {0xF8, "-1"}, + {0xF5, "-1 1/3"}, + {0xF4, "-1.5"}, + {0xF3, "-1 2/3"}, + {0xF0, "-2"}, + {0xED, "-2 1/3"}, + {0xEC, "-2.5"}, + {0xEB, "-3 2/3"}, + {0xE8, "-3"}, + }; + + protected Dictionary _wbTable = new Dictionary() + { + {0, "Auto"}, + {1, "Daylight"}, + {2, "Cloudy"}, + {3, "Tungsten"}, + {4, "Fluorescent"}, + {5, "Flash"}, + {6, "Manual"}, + {8, "Shade"}, + {9, "Color temperature"}, + {10, "Custom white balance: PC-1"}, + {11, "Custom white balance: PC-2"}, + {12, "Custom white balance: PC-3"}, + {15, "Manual 2"}, + {16, "Manual 3"}, + {18, "Manual 4"}, + {19, "Manual 5"}, + {20, "Custom white balance: PC-4"}, + {21, "Custom white balance: PC-5"}, + }; + + protected Dictionary _meteringTable = new Dictionary() + { + {1, "Spot metering"}, + {3, "Evaluative metering"}, + {4, "Partial metering"}, + {5, "Center-weighted averaging metering"}, + {0xFFFFFFFF, "Not valid/no settings changes"}, + }; + + protected Dictionary _focusModeTable = new Dictionary() + { + {0, "One-Shot AF"}, + {1, "AI Servo AF"}, + {2, "AI Focus AF"}, + {3, "Manual Focus"}, + {0xFFFFFFFF, "Not valid/no settings changes"}, + }; + + public CanonSDKBase() + { + } + + public override bool CaptureInSdRam + { + get { return base.CaptureInSdRam; } + set + { + base.CaptureInSdRam = value; + try + { + if (IsConnected && Camera != null) + { + if (!base.CaptureInSdRam) + { + Camera.SavePicturesToCamera(); + } + else + { + Camera.SavePicturesToHost(Path.GetTempPath()); + } + } + } + catch (Exception exception) + { + Log.Error("Error set CaptureInSdram", exception); + } + } + + } + + private DateTime _dateTime; + + public override DateTime DateTime + { + get { return _dateTime; } + + + + + + + + + + + + set + { + _dateTime = value; + + + NotifyPropertyChanged("DateTime"); + + + + + + + } + } + + public bool Init(EosCamera camera) + { + try + { + PreventShutDown = true; + IsBusy = true; + Camera = camera; + Camera.IsErrorTolerantMode = false; + DeviceName = Camera.DeviceDescription; + PortName = camera.PortName; + Manufacturer = "Canon Inc."; + Camera.SetEventHandlers(); + Camera.EnsureOpenSession(); + Camera.Error += _camera_Error; + Camera.Shutdown += _camera_Shutdown; + Camera.LiveViewPaused += Camera_LiveViewPaused; + Camera.LiveViewUpdate += Camera_LiveViewUpdate; + Camera.PictureTaken += Camera_PictureTaken; + Capabilities.Add(CapabilityEnum.Bulb); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.SimpleManualFocus); + IsConnected = true; + LoadProperties(); + Thread thread = new Thread(() => + { + Thread.Sleep(200); + OnCameraInitDone(); + }); + thread.Start(); + _shutdownTimer.Elapsed += _shutdownTimer_Elapsed; + return true; + } + catch (Exception exception) + { + Log.Error("Error initialize EOS camera object ", exception); + return false; + } + } + + private void _shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) + { + if (IsBusy) + return; + if (Monitor.TryEnter(Locker, 10)) + { + try + { + Camera_WillShutdown(null, null); + } + finally + { + Monitor.Exit(Locker); + } + } + } + + public void LoadProperties() + { + InitMode(); + InitShutterSpeed(); + InitFNumber(); + InitIso(); + InitEc(); + InitWb(); + InitMetering(); + InitFocus(); + InitOther(); + InitCompression(); + Battery = (int) Camera.BatteryLevel + 20; + IsBusy = false; + CaptureInSdRam = true; + Camera.PropertyChanged += Camera_PropertyChanged; + Camera.WillShutdown += Camera_WillShutdown; + SerialNumber = Camera.SerialNumber; + AddAditionalProps(); + } + + private void Camera_WillShutdown(object sender, EventArgs e) + { + try + { + if (PreventShutDown) + { + Camera.SendCommand(Edsdk.CameraCommand_ExtendShutDownTimer); + } + } + catch (Exception exception) + { + Log.Debug("PreventShutDown", exception); + } + } + + public virtual void AddAditionalProps() + { + AdvancedProperties.Add(InitDriveMode()); + //AdvancedProperties.Add(InitFlahEc()); + AdvancedProperties.Add(InitBracket()); + //AdvancedProperties.Add(InitAEBracket()); + foreach (PropertyValue value in AdvancedProperties) + { + value.SetValue((long)Camera.GetProperty(value.Code), false); + } + } + + private PropertyValue InitFlahEc() + { + PropertyValue res = new PropertyValue() + { + Name = "Flash Compensation", + IsEnabled = true, + Code = Edsdk.PropID_FlashCompensation, + SubType = typeof(UInt32), + DisableIfWrongValue = true + }; + + var data = GetSettingsList(Edsdk.PropID_FlashCompensation); + + res.ValueChanged += FlashExposureCompensation_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _ec) + { + if (data.Count == 0) + { + res.AddValues(keyValuePair.Value, (int)keyValuePair.Key); + } + else + { + if (data.Contains((int)keyValuePair.Key)) + res.AddValues(keyValuePair.Value, (int)keyValuePair.Key); + } + } + res.ReloadValues(); + res.IsEnabled = true; + res.SetValue((int)Camera.GetProperty(Edsdk.PropID_FlashCompensation), false); + } + catch (Exception exception) + { + Log.Debug("Error get EC", exception); + } + return res; + } + + private void FlashExposureCompensation_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_FlashCompensation, val); + } + catch (Exception exception) + { + Log.Debug("Error set EC to camera", exception); + } + } + + private PropertyValue InitDriveMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Drive Mode", + IsEnabled = true, + Code = Edsdk.PropID_DriveMode, + SubType = typeof (UInt32), + DisableIfWrongValue = true + }; + var r = Camera.GetPropertyDescription(Edsdk.PropID_DriveMode); + var rr = r.PropDesc.Take(r.NumElements).ToArray(); + if (rr.Contains(0)) + res.AddValues("Single-Frame Shooting", 0); + if (rr.Contains(1)) + res.AddValues("Continuous Shooting", 1); + if (rr.Contains(2)) + res.AddValues("Video", 2); + //res.AddValues("Not used", 3); + if (rr.Contains(4)) + res.AddValues("High-Speed Continuous Shooting", 4); + if (rr.Contains(5)) + res.AddValues("Low-Speed Continuous Shooting", 5); + if (rr.Contains(6)) + res.AddValues("Silent single shooting", 6); + if (rr.Contains(7)) + res.AddValues("10-Sec Self-Timer plus continuous shots", 7); + if (rr.Contains(10)) + res.AddValues("10-Sec Self-Timer", 10); + if (rr.Contains(11)) + res.AddValues("2-Sec Self-Timer", 11); + if (rr.Contains(12)) + res.AddValues("14fps super high speed", 12); + if (rr.Contains(13)) + res.AddValues("Silent single shooting", 13); + if (rr.Contains(14)) + res.AddValues("Silent contin shooting", 14); + if (rr.Contains(15)) + res.AddValues("Silent HS continuous", 15); + if (rr.Contains(16)) + res.AddValues("Silent LS continuous", 16); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => Camera.SetProperty(res.Code, val); + return res; + } + + private PropertyValue InitFlash() + { + PropertyValue res = new PropertyValue() + { + Name = "Flash", + IsEnabled = true, + Code = Edsdk.PropID_FlashOn, + SubType = typeof(UInt32), + DisableIfWrongValue = true + }; + res.AddValues("No flash", 0); + res.AddValues("Flash", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => Camera.SetProperty(res.Code, val); + return res; + } + + private PropertyValue InitBracket() + { + PropertyValue res = new PropertyValue() + { + Name = "Bracketing", + IsEnabled = false, + Code = Edsdk.PropID_Bracket, + SubType = typeof(UInt32), + DisableIfWrongValue = true + }; + res.AddValues("Bracket off", 0xFFFFFFFF); + res.AddValues("AE bracket", 1); + res.AddValues("ISO bracket", 2); + res.AddValues("WB bracket", 3); + res.AddValues("FE bracket", 4); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => Camera.SetProperty(res.Code, val); + return res; + } + + private PropertyValue InitAEBracket() + { + PropertyValue res = new PropertyValue() + { + Name = "AE Bracketing", + IsEnabled = true, + Code = Edsdk.PropID_AEBracket, + SubType = typeof(UInt32), + DisableIfWrongValue = true + }; + var r = Camera.GetPropertyDescription(Edsdk.PropID_AEBracket); + res.AddValues("Bracket off", 0); + for (int i = 1; i < r.NumElements; i++) + { + res.AddValues("Step "+i, r.PropDesc[i]); + } + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => + { + Camera.SetProperty(res.Code, val); + }; + return res; + } + private void InitOther() + { + LiveViewImageZoomRatio = new PropertyValue {Name = "LiveViewImageZoomRatio"}; + LiveViewImageZoomRatio.AddValues("All", 1); + LiveViewImageZoomRatio.AddValues("5x", 5); + //LiveViewImageZoomRatio.AddValues("10x", 10); + LiveViewImageZoomRatio.SetValue("All"); + LiveViewImageZoomRatio.ReloadValues(); + LiveViewImageZoomRatio.ValueChanged += LiveViewImageZoomRatio_ValueChanged; + } + + private void InitCompression() + { + var data = GetSettingsList(Edsdk.PropID_ImageQuality); + CompressionSetting = new PropertyValue(); + CompressionSetting.AddValues("Large Fine JPEG", (int) new EosImageQuality(){PrimaryCompressLevel = EosCompressLevel.Fine,PrimaryImageFormat = EosImageFormat.Jpeg,PrimaryImageSize = EosImageSize.Large,SecondaryCompressLevel = EosCompressLevel.Unknown,SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown}.ToBitMask()); + CompressionSetting.AddValues("Large Normal JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Normal, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Large, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Medium Fine JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Fine, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Middle, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Medium Normal JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Normal, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Middle, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Small Fine JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Fine, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Small2, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Small Normal JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Normal, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Small2, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Smaller JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Fine, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Small3, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("Tiny JPEG", (int)new EosImageQuality() { PrimaryCompressLevel = EosCompressLevel.Fine, PrimaryImageFormat = EosImageFormat.Jpeg, PrimaryImageSize = EosImageSize.Small4, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown }.ToBitMask()); + CompressionSetting.AddValues("RAW + Large Fine JPEG", (int)new EosImageQuality() {PrimaryImageFormat =EosImageFormat.Cr2,PrimaryCompressLevel = EosCompressLevel.Lossless, PrimaryImageSize = EosImageSize.Large, SecondaryImageSize =EosImageSize.Large,SecondaryCompressLevel = EosCompressLevel.Fine, SecondaryImageFormat = EosImageFormat.Jpeg }.ToBitMask()); + CompressionSetting.AddValues("RAW", (int)new EosImageQuality() { PrimaryImageFormat = EosImageFormat.Cr2, PrimaryCompressLevel = EosCompressLevel.Lossless, PrimaryImageSize = EosImageSize.Large, SecondaryCompressLevel = EosCompressLevel.Unknown, SecondaryImageFormat = EosImageFormat.Unknown, SecondaryImageSize = EosImageSize.Unknown}.ToBitMask()); + CompressionSetting.Filter(data.Select(i => (long) i).ToList()); + CompressionSetting.SetValue((int) Camera.ImageQuality.ToBitMask()); + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + } + + private void CompressionSetting_ValueChanged(object sender, string key, long val) + { + Camera.ImageQuality = EosImageQuality.Create(val); + } + + + private void LiveViewImageZoomRatio_ValueChanged(object sender, string key, long val) + { + Camera.SetProperty(Edsdk.PropID_Evf_Zoom, val); + //Camera.LiveViewqueue.Enqueue(() => Camera.SetProperty(Edsdk.PropID_Evf_Zoom, val)); + } + + + private void Camera_PropertyChanged(object sender, EosPropertyEventArgs e) + { + if (IsBusy) + return; + lock (Locker) + { + + try + { + // Log.Debug("Property changed " + e.PropertyId.ToString("X")); + switch (e.PropertyId) + { + case Edsdk.PropID_ExposureCompensation: + ExposureCompensation.SetValue((int) Camera.GetProperty(Edsdk.PropID_ExposureCompensation), + false); + break; + case Edsdk.PropID_AEMode: + ReInitFNumber(true); + ReInitShutterSpeed(); + Mode.SetValue((uint)Camera.GetProperty(Edsdk.PropID_AEMode), false); + break; + case Edsdk.PropID_WhiteBalance: + WhiteBalance.SetValue(Camera.GetProperty(Edsdk.PropID_WhiteBalance), false); + break; + case Edsdk.PropID_ISOSpeed: + IsoNumber.SetValue(Camera.GetProperty(Edsdk.PropID_ISOSpeed), false); + break; + case Edsdk.PropID_Tv: + ShutterSpeed.SetValue(Camera.GetProperty(Edsdk.PropID_Tv), false); + break; + case Edsdk.PropID_Av: + FNumber.SetValue((int) Camera.GetProperty(Edsdk.PropID_Av), false); + break; + case Edsdk.PropID_MeteringMode: + ExposureMeteringMode.SetValue((int) Camera.GetProperty(Edsdk.PropID_MeteringMode), false); + break; + case Edsdk.PropID_AFMode: + FocusMode.SetValue((int) Camera.GetProperty(Edsdk.PropID_AFMode), false); + break; + case Edsdk.PropID_ImageQuality: + int i = (int) Camera.GetProperty(Edsdk.PropID_ImageQuality); + CompressionSetting.SetValue((int) Camera.ImageQuality.ToBitMask(), false); + break; + case Edsdk.PropID_BatteryLevel: + Battery = (int) Camera.BatteryLevel + 20; + break; + case Edsdk.PropID_AEBracketType: + int ae = (int)Camera.GetProperty(Edsdk.PropID_AEBracketType); + //ResetShutterButton(); + break; + case Edsdk.PropID_Bracket: + int br = (int)Camera.GetProperty(Edsdk.PropID_Bracket); + //ResetShutterButton(); + break; + + case Edsdk.PropID_FocusInfo: + //ResetShutterButton(); + break; + } + foreach ( + PropertyValue advancedProperty in + AdvancedProperties.Where(advancedProperty => advancedProperty.Code == e.PropertyId)) + { + advancedProperty.SetValue((long) Camera.GetProperty(advancedProperty.Code), false); + } + } + catch (Exception exception) + { + Log.Error("Error set property " + e.PropertyId.ToString("X"), exception); + } + } + } + + private void Camera_PictureTaken(object sender, EosImageEventArgs e) + { + try + { + Log.Debug("Picture taken event received type" + e.GetType().ToString()); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + //EventArgs = + // new PortableDeviceEventArgs(new PortableDeviceEventType() + // { + // ObjectHandle = + // (uint)longeventParam + // }), + CameraDevice = this, + FileName = "IMG0000.jpg", + Handle =e.Pointer.ToInt64() != 0?(object) e.Pointer: e + }; + + EosFileImageEventArgs file = e as EosFileImageEventArgs; + if (file != null) + { + args.FileName = Path.GetFileName(file.ImageFilePath); + } + EosMemoryImageEventArgs memory = e as EosMemoryImageEventArgs; + if (memory != null) + { + if (!string.IsNullOrEmpty(memory.FileName)) + args.FileName = Path.GetFileName(memory.FileName); + } + OnPhotoCapture(this, args); + OnCaptureCompleted(this, new EventArgs()); + } + catch (Exception exception) + { + Log.Error("EOS Picture taken event error", exception); + } + } + + private void Camera_LiveViewUpdate(object sender, EosLiveImageEventArgs e) + { + _liveViewImageData = e; + } + + private void Camera_LiveViewPaused(object sender, EventArgs e) + { + try + { + //Camera.ResetShutterButton(); + //Camera.TakePictureNoAf(); + //Camera.ResetShutterButton(); + //Camera.ResumeLiveview(); + } + catch (Exception exception) + { + IsBusy = false; + Log.Debug("Live view pause error", exception); + } + } + + private void _camera_Shutdown(object sender, EventArgs e) + { + IsConnected = false; + OnCameraDisconnected(this, new DisconnectCameraEventArgs {StillImageDevice = null, EosCamera = Camera}); + } + + public override void Close() + { + HaveLiveView = false; + Camera.Error -= _camera_Error; + Camera.Shutdown -= _camera_Shutdown; + Camera.LiveViewPaused -= Camera_LiveViewPaused; + Camera.LiveViewUpdate -= Camera_LiveViewUpdate; + Camera.PictureTaken -= Camera_PictureTaken; + Camera.PropertyChanged -= Camera_PropertyChanged; + // this block the application + //Camera.Dispose(); + Camera = null; + } + + + private void _camera_Error(object sender, EosExceptionEventArgs e) + { + try + { + Log.Error("Canon error", e.Exception); + StaticHelper.Instance.SystemMessage = e.Exception.Message; + } + catch (Exception exception) + { + Log.Error("Error get camera error", exception); + StaticHelper.Instance.SystemMessage = exception.Message; + } + } + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + //StillImageDevice = new StillImageDevice(deviceDescriptor.WpdId); + //StillImageDevice.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); + //StillImageDevice.DeviceEvent += _stillImageDevice_DeviceEvent; + Capabilities.Add(CapabilityEnum.Bulb); + Capabilities.Add(CapabilityEnum.LiveView); + + IsConnected = true; + return true; + } + + + private void InitShutterSpeed() + { + ShutterSpeed = new PropertyValue(); + ShutterSpeed.Name = "ShutterSpeed"; + ShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ReInitShutterSpeed() + { + lock (Locker) + { + try + { + ShutterSpeed.Clear(); + var data = GetSettingsList(Edsdk.PropID_Tv); + foreach (KeyValuePair keyValuePair in _shutterTable) + { + if (data.Count > 0) + { + if (data.Contains((int) keyValuePair.Key)) + ShutterSpeed.AddValues(keyValuePair.Value, keyValuePair.Key); + } + else + { + ShutterSpeed.AddValues(keyValuePair.Value, keyValuePair.Key); + } + } + ShutterSpeed.ReloadValues(); + long value = Camera.GetProperty(Edsdk.PropID_Tv); + if (value == 0) + { + ShutterSpeed.IsEnabled = false; + } + else + { + ShutterSpeed.IsEnabled = true; + ShutterSpeed.SetValue(Camera.GetProperty(Edsdk.PropID_Tv), false); + } + } + catch (Exception ex) + { + Log.Debug("EOS Shutter speed init", ex); + } + } + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_Tv, val); + } + catch (Exception exception) + { + Log.Error("Error set property sP", exception); + } + } + + #region F number + + private void InitFNumber() + { + FNumber = new PropertyValue {IsEnabled = true, Name = "FNumber"}; + FNumber.ValueChanged += FNumber_ValueChanged; + ReInitFNumber(true); + } + + private void FNumber_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_Av, val); + } + catch (Exception exception) + { + Log.Error("Error set property AV", exception); + } + } + + private void ReInitFNumber(bool trigervaluchange) + { + try + { + var data = GetSettingsList(Edsdk.PropID_Av); + long value = Camera.GetProperty(Edsdk.PropID_Av); + bool shouldinit = FNumber.Values.Count == 0; + + if (data.Count > 0) + FNumber.Clear(); + + if (shouldinit && data.Count == 0) + { + foreach (KeyValuePair keyValuePair in _apertureTable) + { + FNumber.AddValues(keyValuePair.Value, keyValuePair.Key); + } + } + else + { + foreach ( + KeyValuePair keyValuePair in + _apertureTable.Where(keyValuePair => data.Count > 0).Where( + keyValuePair => data.Contains(keyValuePair.Key))) + { + FNumber.AddValues(keyValuePair.Value, keyValuePair.Key); + } + } + FNumber.ReloadValues(); + if (value == 0) + { + FNumber.IsEnabled = false; + } + else + { + FNumber.SetValue((int) value, false); + FNumber.IsEnabled = true; + } + } + catch (Exception ex) + { + Log.Debug("Error set aperture ", ex); + } + } + + #endregion + + private void InitIso() + { + IsoNumber = new PropertyValue(); + IsoNumber.Name = "ISOSpeed"; + IsoNumber.ValueChanged += IsoNumber_ValueChanged; + ReInitIso(); + } + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + try + { + Camera.PauseLiveview(); + Camera.SetProperty(Edsdk.PropID_ISOSpeed, val); + Camera.ResumeLiveview(); + } + catch (Exception exception) + { + Log.Debug("Error set ISO to camera", exception); + } + } + + public List GetSettingsList(uint PropID) + { + if (Camera.Handle!= IntPtr.Zero) + { + //get the list of possible values + Edsdk.EdsPropertyDesc des = new Edsdk.EdsPropertyDesc(); + var Error = Edsdk.EdsGetPropertyDesc(Camera.Handle, PropID, out des); + return des.PropDesc.Take(des.NumElements).ToList(); + } + return new List(); + } + + private void ReInitIso() + { + try + { + var data = GetSettingsList(Edsdk.PropID_ISOSpeed); + long value = Camera.GetProperty(Edsdk.PropID_ISOSpeed); + bool shouldinit = IsoNumber.Values.Count == 0; + + if (data.Count > 0) + IsoNumber.Clear(); + + if (shouldinit && data.Count == 0) + { + foreach (KeyValuePair keyValuePair in _isoTable) + { + IsoNumber.AddValues(keyValuePair.Value, (int) keyValuePair.Key); + } + } + else + { + foreach ( + KeyValuePair keyValuePair in + _isoTable.Where(keyValuePair => data.Count > 0).Where( + keyValuePair => data.Contains((int) keyValuePair.Key))) + { + IsoNumber.AddValues(keyValuePair.Value, (int) keyValuePair.Key); + } + } + IsoNumber.ReloadValues(); + IsoNumber.SetValue((int)value, false); + IsoNumber.IsEnabled = true; + + } + catch (Exception ex) + { + Log.Debug("Error set iso ", ex); + } + } + + private void InitMode() + { + Mode = new PropertyValue(); + Mode.ValueChanged += Mode_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _exposureModeTable) + { + Mode.AddValues(keyValuePair.Value, keyValuePair.Key); + } + Mode.ReloadValues(); + Mode.SetValue((uint) Camera.GetProperty(Edsdk.PropID_AEMode), false); + Mode.IsEnabled = true; + } + catch (Exception ex) + { + Log.Debug("Error set aperture ", ex); + } + } + + private void Mode_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_AEModeSelect, val); + //Camera.SetProperty(Edsdk.PropID_AEMode, val); + //Thread.Sleep(200); + //ReInitFNumber(true); + //ReInitShutterSpeed(); + } + catch (Exception exception) + { + Log.Debug("Error set EC to camera", exception); + } + } + + private void InitEc() + { + var data = GetSettingsList(Edsdk.PropID_ExposureCompensation); + ExposureCompensation = new PropertyValue(); + ExposureCompensation.ValueChanged += ExposureCompensation_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _ec) + { + if (data.Count == 0) + { + ExposureCompensation.AddValues(keyValuePair.Value, (int)keyValuePair.Key); + } + else + { + if (data.Contains((int)keyValuePair.Key)) + ExposureCompensation.AddValues(keyValuePair.Value, (int)keyValuePair.Key); + } + } + ExposureCompensation.ReloadValues(); + ExposureCompensation.IsEnabled = true; + ExposureCompensation.SetValue((int) Camera.GetProperty(Edsdk.PropID_ExposureCompensation), false); + } + catch (Exception exception) + { + Log.Debug("Error get EC", exception); + } + } + + private void InitWb() + { + var data = GetSettingsList(Edsdk.PropID_WhiteBalance); + WhiteBalance = new PropertyValue(); + WhiteBalance.ValueChanged += WhiteBalance_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _wbTable) + { + if (data.Count > 0 && data.Contains((int) keyValuePair.Key)) + WhiteBalance.AddValues(keyValuePair.Value, (int) keyValuePair.Key); + } + WhiteBalance.ReloadValues(); + WhiteBalance.IsEnabled = true; + WhiteBalance.SetValue((long) Camera.GetProperty(Edsdk.PropID_WhiteBalance), false); + } + catch (Exception exception) + { + Log.Debug("Error get EC", exception); + } + } + + private void WhiteBalance_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_WhiteBalance, val); + } + catch (Exception exception) + { + Log.Debug("Error set WB to camera", exception); + } + } + + private void InitMetering() + { + var data = GetSettingsList(Edsdk.PropID_MeteringMode); + ExposureMeteringMode = new PropertyValue(); + ExposureMeteringMode.ValueChanged += ExposureMeteringMode_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _meteringTable) + { + if (data.Contains((int) keyValuePair.Key)) + ExposureMeteringMode.AddValues(keyValuePair.Value, (int) keyValuePair.Key); + } + ExposureMeteringMode.ReloadValues(); + ExposureMeteringMode.IsEnabled = true; + ExposureMeteringMode.SetValue((int) Camera.GetProperty(Edsdk.PropID_MeteringMode), false); + } + catch (Exception exception) + { + Log.Debug("Error get metering", exception); + } + } + + private void InitFocus() + { + var data = GetSettingsList(Edsdk.PropID_AFMode); + FocusMode = new PropertyValue(); + FocusMode.ValueChanged += FocusMode_ValueChanged; + try + { + foreach (KeyValuePair keyValuePair in _focusModeTable) + { + if (data.Contains((int) keyValuePair.Key)) + FocusMode.AddValues(keyValuePair.Value, (int) keyValuePair.Key); + } + FocusMode.ReloadValues(); + FocusMode.IsEnabled = true; + FocusMode.SetValue((int) Camera.GetProperty(Edsdk.PropID_AFMode), false); + } + catch (Exception exception) + { + Log.Debug("Error get focus mode", exception); + } + } + + private void FocusMode_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_AFMode, val); + } + catch (Exception exception) + { + Log.Debug("Error set focus mode to camera", exception); + } + } + + private void ExposureMeteringMode_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_MeteringMode, val); + } + catch (Exception exception) + { + Log.Debug("Error set metering mode to camera", exception); + } + } + + private void ExposureCompensation_ValueChanged(object sender, string key, long val) + { + try + { + Camera.SetProperty(Edsdk.PropID_ExposureCompensation, val); + } + catch (Exception exception) + { + Log.Debug("Error set EC to camera", exception); + } + } + + public override void CapturePhoto() + { + Log.Debug("EOS capture start"); + Monitor.Enter(Locker); + try + { + IsBusy = true; + if (Camera.IsInHostLiveViewMode) + { + if (Camera.ImageQuality.SecondaryImageFormat != EosImageFormat.Unknown) + { + throw new Exception("RAW+JPG capture in live view not supported"); + } + Camera.PauseLiveview(); + Camera.ResetShutterButton(); + ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_TakePicture)); + Camera.ResetShutterButton(); + } + else + { + Camera.TakePicture(); + } + } + catch (COMException comException) + { + IsBusy = false; + Camera.ResumeLiveview(); + ErrorCodes.GetException(comException); + } + catch + { + Camera.ResumeLiveview(); + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + Log.Debug("EOS capture end"); + } + + private uint ResetShutterButton() + { + Camera.SendCommand(Edsdk.CameraCommand_DoEvfAf, 0); + //ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_DoEvfAf, 0)); + return Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, + (int) Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF); + } + + public void PressButton() + { + ResetShutterButton(); + ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Completely)); + } + + public void PressHalfButton() + { + ResetShutterButton(); + ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Halfway)); + } + + public void ReleaseButton() + { + Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton,(int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF); + } + + + public override void CapturePhotoNoAf() + { + Log.Debug("EOS capture start"); + Monitor.Enter(Locker); + try + { + if (Camera.IsInHostLiveViewMode && Camera.ImageQuality.SecondaryImageFormat != EosImageFormat.Unknown) + { + throw new Exception("RAW+JPG capture in live view not supported"); + } + IsBusy = true; + Camera.PauseLiveview(); + ErrorCodes.GetCanonException(ResetShutterButton()); + ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Completely_NonAF)); + ResetShutterButton(); + + //if (Camera.IsInHostLiveViewMode) + //{ + // Camera.TakePictureInLiveview(); + //} + //else + //{ + // Camera.TakePicture(); + //} + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + Log.Debug("EOS capture end"); + } + + public override void StartBulbMode() + { + Camera.BulbStart(); + } + + public override void EndBulbMode() + { + Camera.BulbEnd(); + } + + public override void StartRecordMovie() + { + lock (Locker) + { + _recording = true; + ResetShutterButton(); + Camera.StartRecord(); + } + } + + public override void StopRecordMovie() + { + lock (Locker) + { + Camera.StopRecord(); + _recording = false; + } + } + + /*public override void Focus(int x, int y) + { + lock (Locker) + { + ResetShutterButton(); + if (_liveViewImageData != null) + { + x -= (_liveViewImageData.ZommBounds.Width/2); + y -= (_liveViewImageData.ZommBounds.Height/2); + } + if (x < 0) + x = 0; + if (y < 0) + y = 0; + Camera.LiveViewqueue.Enqueue( + () => + Camera.SetPropertyIntegerArrayData(Edsdk.PropID_Evf_ZoomPosition, + new uint[] {(uint) x, (uint) y})); + } + }*/ + + public override LiveViewData GetLiveViewImage() + { + + LiveViewData viewData = new LiveViewData(); + if (Monitor.TryEnter(Locker, 10)) + { + try + { + if (Camera == null) + return viewData; + Camera.DownloadEvf(); + if (_liveViewImageData != null) + { + //DeviceReady(); + viewData.HaveFocusData = true; + viewData.ImageDataPosition = 0; + viewData.ImageData = _liveViewImageData.ImageData; + viewData.ImageHeight = _liveViewImageData.ImageSize.Height; + viewData.ImageWidth = _liveViewImageData.ImageSize.Width; + viewData.LiveViewImageHeight = 100; + viewData.LiveViewImageWidth = 100; + viewData.FocusX = _liveViewImageData.ZommBounds.X + + (_liveViewImageData.ZommBounds.Width / 2); + viewData.FocusY = _liveViewImageData.ZommBounds.Y + + (_liveViewImageData.ZommBounds.Height / 2); + viewData.FocusFrameXSize = _liveViewImageData.ZommBounds.Width; + viewData.FocusFrameYSize = _liveViewImageData.ZommBounds.Height; + viewData.MovieIsRecording = _recording; + } + } + catch (Exception) + { + //Log.Error("Error get live view image ", e); + } + finally + { + Monitor.Exit(Locker); + } + } + return viewData; + } + + public override void StartLiveView() + { + _recording = false; + ResetShutterButton(); + //if (!Camera.IsInLiveViewMode) + Camera.StartLiveView(EosLiveViewAutoFocus.LiveMode); + } + + public void StartLiveViewCamera() + { + _recording = false; + ResetShutterButton(); + //if (!Camera.IsInLiveViewMode) + Camera.StartLiveViewCamera(); + } + + public override void StopLiveView() + { + if (Camera == null) + return; + ResetShutterButton(); + //if (Camera.IsInLiveViewMode) + Camera.StopLiveView(); + } + + public override void AutoFocus() + { + ResetShutterButton(); + Camera.PauseLiveview(); + + try + { + ErrorCodes.GetCanonException(Camera.SendCommand(Edsdk.CameraCommand_DoEvfAf, 1)); + // ErrorCodes.GetCanonException( + //Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, + // (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF)); + // ErrorCodes.GetCanonException( + // Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, + // (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Halfway)); + // ErrorCodes.GetCanonException( + // Camera.SendCommand(Edsdk.CameraCommand_PressShutterButton, + // (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF)); + + } + finally + { + Camera.ResumeLiveview(); + } + } + + public override int Focus(int step) + { + ResetShutterButton(); + + int focus = 0; + var res = Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, + (int) (step < 0 ? Edsdk.EvfDriveLens_Near1 : Edsdk.EvfDriveLens_Far1)); + //if (i%10 == 0) + // Camera.DownloadEvfInternal(); + if (res == Edsdk.EDS_ERR_OK) + focus += step < 0 ? -1 : 1; + + //Camera.SendCommand(Edsdk.CameraCommand_DoEvfAf, 0); + return focus; + } + + public override void Focus(FocusDirection direction, FocusAmount amount) + { + ResetShutterButton(); + switch (direction) + { + case FocusDirection.Far: + switch (amount) + { + case FocusAmount.Small: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int) Edsdk.EvfDriveLens_Far1); + break; + case FocusAmount.Medium: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int) Edsdk.EvfDriveLens_Far2); + break; + case FocusAmount.Large: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int) Edsdk.EvfDriveLens_Far3); + break; + default: + throw new ArgumentOutOfRangeException(nameof(amount), amount, null); + } + break; + case FocusDirection.Near: + switch (amount) + { + case FocusAmount.Small: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int)Edsdk.EvfDriveLens_Near1); + break; + case FocusAmount.Medium: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int)Edsdk.EvfDriveLens_Near2); + break; + case FocusAmount.Large: + Camera.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int)Edsdk.EvfDriveLens_Near3); + break; + default: + throw new ArgumentOutOfRangeException(nameof(amount), amount, null); + } + break; + + } + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + if (deviceObject.Handle is IntPtr) + { + Camera.DeleteItem((IntPtr)deviceObject.Handle); + } + return true; + } + + public override void ReleaseResurce(object o) + { + if (o is IntPtr) + { + Edsdk.EdsRelease((IntPtr)o); + } + } + + public override void TransferFileThumb(object o, string filename) + { + base.TransferFileThumb(o, filename); + } + + public override void TransferFile(object o, string filename) + { + lock (Locker) + { + IsBusy = true; + if (o is IntPtr) + { + Log.Debug("Pointer file transfer started"); + try + { + IsBusy = true; + Camera.PauseLiveview(); + Log.Debug("Camera.PauseLiveview();"); + var transporter = new EosImageTransporter(); + transporter.ProgressEvent += (i) => TransferProgress = (uint) i; + Log.Debug("TransportAsFileName"); + transporter.TransportAsFileName((IntPtr) o, filename, Camera.Handle); + Log.Debug("TransportAsFileName DONE"); + Camera.ResumeLiveview(); + Log.Debug("Camera.ResumeLiveview(); DONE"); + } + catch (Exception exception) + { + Log.Error("Error transfer memory file", exception); + File.Delete(filename); + } + } + EosFileImageEventArgs file = o as EosFileImageEventArgs; + if (file != null) + { + Log.Debug("File transfer started"); + try + { + if (File.Exists(file.ImageFilePath)) + { + File.Copy(file.ImageFilePath, filename, true); + File.Delete(file.ImageFilePath); + } + else + { + Log.Error("Base file not found " + file.ImageFilePath); + } + } + catch (Exception exception) + { + Log.Error("Transfer error ", exception); + } + } + EosMemoryImageEventArgs memory = o as EosMemoryImageEventArgs; + if (memory != null) + { + Log.Debug("Memory file transfer started"); + try + { + using (FileStream fileStream = File.Create(filename, (int) memory.ImageData.Length)) + { + fileStream.Write(memory.ImageData, 0, memory.ImageData.Length); + } + } + catch (Exception exception) + { + Log.Error("Error transfer memory file", exception); + } + } + string fil = o as string; + if (fil != null) + { + GetFile(fil, filename); + } + } + } + + public override string GetProhibitionCondition(OperationEnum operationEnum) + { + switch (operationEnum) + { + case OperationEnum.Capture: + break; + case OperationEnum.RecordMovie: + if (Camera.GetProperty(Edsdk.PropID_Record) == 4) + return "LabelRecordInProgres"; + if (Camera.LiveViewDevice==EosLiveViewDevice.None) + return "LabelWrongLiveViewType"; + break; + case OperationEnum.AutoFocus: + break; + case OperationEnum.ManualFocus: + break; + case OperationEnum.LiveView: + break; + default: + throw new ArgumentOutOfRangeException("operationEnum", operationEnum, null); + } + return ""; + } + + //private bool ArrayContainValue(IEnumerable data, uint value) + //{ + // return ArrayContainValue(data, (int) value); + //} + + //private bool ArrayContainValue(IEnumerable data, int value) + //{ + // return data.Any(i => i == (int) value); + //} + + public override AsyncObservableCollection GetObjects(object storageId, bool loadThumbs) + { + List list = new List(); + int count = 0; + Edsdk.EdsGetChildCount(Camera.Handle, out count); + for (int i = 0; i < count; i++) + { + IntPtr volumePtr; + Edsdk.EdsGetChildAtIndex(Camera.Handle, i, out volumePtr); + Edsdk.EdsVolumeInfo vinfo; + Edsdk.EdsGetVolumeInfo(volumePtr, out vinfo); + if (vinfo.StorageType == 0) + throw new Exception("No memory card inserted"); + //ignore the HDD + if (vinfo.szVolumeLabel != "HDD") + { + //get all child entries on this volume + list.AddRange(GetChildren(volumePtr, loadThumbs)); + } + Edsdk.EdsRelease(volumePtr); + } + return new AsyncObservableCollection(list); + } + + private List GetChildren(IntPtr ptr, bool loadThumbs) + { + int ChildCount; + //get children of first pointer + List list = new List(); + Edsdk.EdsGetChildCount(ptr, out ChildCount); + if (ChildCount > 0) + { + //if it has children, create an array of entries + for (int i = 0; i < ChildCount; i++) + { + IntPtr ChildPtr; + //get children of children + Edsdk.EdsGetChildAtIndex(ptr, i, out ChildPtr); + //get the information about this children + Edsdk.EdsDirectoryItemInfo ChildInfo; + Edsdk.EdsGetDirectoryItemInfo(ChildPtr, out ChildInfo); + + if (ChildInfo.isFolder == 0) + { + //if it's not a folder, create thumbnail and safe it to the entry + if (loadThumbs) + { + IntPtr stream; + Edsdk.EdsCreateMemoryStream(0, out stream); + Edsdk.EdsDownloadThumbnail(ChildPtr, stream); + list.Add(new DeviceObject() + { + FileName = ChildInfo.szFileName, + ThumbData = GetImage(stream, Edsdk.EdsImageSource.Thumbnail), + Handle = ChildInfo.szFileName + }); + if (stream != IntPtr.Zero) + Edsdk.EdsRelease(stream); + } + else + { + list.Add(new DeviceObject() + { + FileName = ChildInfo.szFileName, + Handle = ChildPtr + }); + } + } + else + { + //if it's a folder, check for children with recursion + list.AddRange(GetChildren(ChildPtr, loadThumbs)); + Edsdk.EdsRelease(ChildPtr); + } + //release current children + + } + } + return list; + } + + public void GetFile(string fileName,string outFileName) + { + int count = 0; + Edsdk.EdsGetChildCount(Camera.Handle, out count); + for (int i = 0; i < count; i++) + { + IntPtr volumePtr; + Edsdk.EdsGetChildAtIndex(Camera.Handle, i, out volumePtr); + Edsdk.EdsVolumeInfo vinfo; + Edsdk.EdsGetVolumeInfo(volumePtr, out vinfo); + //ignore the HDD + if (vinfo.szVolumeLabel != "HDD") + { + GetFile(volumePtr, fileName, outFileName); + } + Edsdk.EdsRelease(volumePtr); + } + } + + private void GetFile(IntPtr ptr,string fileName, string outfileName) + { + int ChildCount; + //get children of first pointer + List list = new List(); + Edsdk.EdsGetChildCount(ptr, out ChildCount); + if (ChildCount > 0) + { + //if it has children, create an array of entries + for (int i = 0; i < ChildCount; i++) + { + IntPtr ChildPtr; + //get children of children + Edsdk.EdsGetChildAtIndex(ptr, i, out ChildPtr); + //get the information about this children + Edsdk.EdsDirectoryItemInfo ChildInfo; + Edsdk.EdsGetDirectoryItemInfo(ChildPtr, out ChildInfo); + + if (ChildInfo.isFolder == 0) + { + if(ChildInfo.szFileName==fileName) + { + Camera._transporter.TransportAsFileName(ChildPtr, outfileName, Camera.Handle); + } + } + else + { + //if it's a folder, check for children with recursion + GetFile(ChildPtr, fileName, outfileName); + } + //release current children + Edsdk.EdsRelease(ChildPtr); + } + } + } + + private byte[] GetImage(IntPtr img_stream, Edsdk.EdsImageSource imageSource) + { + IntPtr stream = IntPtr.Zero; + IntPtr img_ref = IntPtr.Zero; + IntPtr streamPointer = IntPtr.Zero; + Edsdk.EdsImageInfo imageInfo; + Edsdk.EdsSize outputSize = new Edsdk.EdsSize(); + Byte[] buffer; + Byte temp; + + //create reference to image + Edsdk.EdsCreateImageRef(img_stream, out img_ref); + //get information about image + Edsdk.EdsGetImageInfo(img_ref, imageSource, out imageInfo); + + //calculate size, stride and buffersize + outputSize.width = imageInfo.EffectiveRect.width; + outputSize.height = imageInfo.EffectiveRect.height; + int Stride = ((outputSize.width*3) + 3) & ~3; + uint bufferSize = (uint) (outputSize.height*Stride); + + //Init buffer + buffer = new Byte[bufferSize]; + //Create memory stream to buffer + Edsdk.EdsCreateMemoryStreamFromPointer(buffer, bufferSize, out stream); + //copy image into buffer + Edsdk.EdsGetImage(img_ref, imageSource, Edsdk.EdsTargetImageType.RGB, imageInfo.EffectiveRect, outputSize, + stream); + + //makes RGB out of BGR + if (outputSize.width%4 == 0) + { + for (int t = 0; t < bufferSize; t += 3) + { + temp = buffer[t]; + buffer[t] = buffer[t + 2]; + buffer[t + 2] = temp; + } + } + else + { + int Padding = Stride - (outputSize.width*3); + for (int y = outputSize.height - 1; y > -1; y--) + { + int RowStart = (outputSize.width*3)*y; + int TargetStart = Stride*y; + + Array.Copy(buffer, RowStart, buffer, TargetStart, outputSize.width*3); + + for (int t = TargetStart; t < TargetStart + (outputSize.width*3); t += 3) + { + temp = buffer[t]; + buffer[t] = buffer[t + 2]; + buffer[t + 2] = temp; + } + } + } + + //create pointer to image data + Edsdk.EdsGetPointer(stream, out streamPointer); + //Release all ressources + Edsdk.EdsRelease(img_stream); + Edsdk.EdsRelease(img_ref); + Edsdk.EdsRelease(stream); + try + { + var bitmap = new Bitmap(outputSize.width, outputSize.height, Stride, PixelFormat.Format24bppRgb, + streamPointer); + using (MemoryStream memostream = new MemoryStream()) + { + bitmap.Save(memostream, ImageFormat.Bmp); + memostream.Close(); + + return memostream.ToArray(); + } + } + catch (Exception exception) + { + Log.Error("Error loading image ", exception); + } + return new byte[0]; + } + + public override void FormatStorage(object storageId) + { + try + { + lock (Locker) + { + Camera.Lock(); + int count = 0; + Log.Debug("EdsGetChildCount"); + if (Edsdk.EdsGetChildCount(Camera.Handle, out count) != Edsdk.EDS_ERR_OK) + throw new DeviceException("Error EdsGetChildCount"); + for (int i = 0; i < count; i++) + { + IntPtr volumePtr; + Log.Debug("EdsGetChildAtIndex"); + if (Edsdk.EdsGetChildAtIndex(Camera.Handle, i, out volumePtr) != Edsdk.EDS_ERR_OK) + throw new DeviceException("Error EdsGetChildAtIndex"); + Edsdk.EdsVolumeInfo vinfo; + Log.Debug("EdsGetVolumeInfo"); + if (Edsdk.EdsGetVolumeInfo(volumePtr, out vinfo) != Edsdk.EDS_ERR_OK) + throw new DeviceException("Error EdsGetVolumeInfo"); + //ignore the HDD + if (vinfo.szVolumeLabel != "HDD") + { + Log.Debug("EdsFormatVolume"); + if (Edsdk.EdsFormatVolume(volumePtr) != Edsdk.EDS_ERR_OK) + throw new DeviceException("Error EdsFormatVolume"); + } + Log.Debug("EdsRelease"); + if (Edsdk.EdsRelease(volumePtr) != Edsdk.EDS_ERR_OK) + throw new DeviceException("Error EdsRelease"); + } + } + } + finally + { + Camera.Unlock(); + } + } + + public override string ToStringCameraData() + { + /* Canon SDK adds a EosCamera object + BatteryLevel (long) and BatteryQuality (string) + Copyright (string) + FirmwareVersion (string) + ImageQuality + PrimaryCompressLevel + PrimateImageFormat + PrimateImageSize + IsInLiveViewMode (bool) + */ + + StringBuilder c = new StringBuilder(base.ToStringCameraData() + "\n\tType..................Canon (SDK)"); + + if (Camera != null) + { + c.AppendFormat("\n\tFirmware version......{0}", Camera.FirmwareVersion); + c.AppendFormat("\n\tDate/Time.............{0}", DateTime.ToString()); + c.AppendFormat("\n\tBattery...............{0,3}%, quality {1}, (note base class value is this + 20)", Camera.BatteryLevel, Camera.BatteryQuality); + c.AppendFormat("\n\tIs in LiveView Mode...{0}", Camera.IsInLiveViewMode ? "Yes" : "No"); + c.Append("\n\tImage Quality - Primary"); + c.AppendFormat("\n\t Format..............{0}", Camera.ImageQuality.PrimaryImageFormat); + c.AppendFormat("\n\t Size................{0}", Camera.ImageQuality.PrimaryImageSize); + c.AppendFormat("\n\t Compression.........{0}", Camera.ImageQuality.PrimaryCompressLevel); + if (!Camera.ImageQuality.SecondaryImageFormat.Equals(EosImageFormat.Unknown)) + { + c.Append("\n\tImage Quality - Secondary"); + c.AppendFormat("\n\t Format..............{0}", Camera.ImageQuality.SecondaryImageFormat); + c.AppendFormat("\n\t Size................{0}", Camera.ImageQuality.SecondaryImageSize); + c.AppendFormat("\n\t Compression.........{0}", Camera.ImageQuality.SecondaryCompressLevel); + } + c.AppendFormat("\n\tArtist................{0}", Camera.Artist); + c.AppendFormat("\n\tCopyright (c).........{0}", Camera.Copyright); + c.AppendFormat("\n\tDepth Preview.........{0}", Camera.DepthOfFieldPreview ? "Yes" : "No"); + c.AppendFormat("\n\tWhite Balance.........{0}", Camera.WhiteBalance); + } + return c.ToString(); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/AsyncObservableCollection.cs b/DigiCamControl/CameraControl.Devices/Classes/AsyncObservableCollection.cs new file mode 100644 index 0000000..87649cb --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/AsyncObservableCollection.cs @@ -0,0 +1,143 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Windows.Data; +using System.ComponentModel; +using System.Linq; +using System.Threading; +using System.Windows.Threading; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class AsyncObservableCollection : ObservableCollection + { + private SynchronizationContext _synchronizationContext = SynchronizationContext.Current; + + public AsyncObservableCollection() + { + enableCollectionSynchronization(this, _syncLock); + } + + public AsyncObservableCollection(IEnumerable list) + : base(list) + { + enableCollectionSynchronization(this, _syncLock); + } + + + + private void RaiseCollectionChanged(object param) + { + // We are in the creator thread, call the base implementation directly + try + { + base.OnCollectionChanged((NotifyCollectionChangedEventArgs) param); + } + catch (Exception) + { + } + } + + protected override void OnPropertyChanged(PropertyChangedEventArgs e) + { + if (SynchronizationContext.Current == _synchronizationContext) + { + // Execute the PropertyChanged event on the current thread + RaisePropertyChanged(e); + } + else + { + // Post the PropertyChanged event on the creator thread + if (_synchronizationContext != null) + _synchronizationContext.Post(RaisePropertyChanged, e); + } + } + + private void RaisePropertyChanged(object param) + { + // We are in the creator thread, call the base implementation directly + base.OnPropertyChanged((PropertyChangedEventArgs) param); + } + + public override event NotifyCollectionChangedEventHandler CollectionChanged; + private static object _syncLock = new object(); + + + protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) + { + using (BlockReentrancy()) + { + try + { + var eh = CollectionChanged; + if (eh == null) return; + + var dispatcher = (from NotifyCollectionChangedEventHandler nh in eh.GetInvocationList() + let dpo = nh.Target as DispatcherObject + where dpo != null + select dpo.Dispatcher).FirstOrDefault(); + + if (dispatcher != null && dispatcher.CheckAccess() == false) + { + dispatcher.Invoke(DispatcherPriority.DataBind, (Action)(() => OnCollectionChanged(e))); + } + else + { + foreach (NotifyCollectionChangedEventHandler nh in eh.GetInvocationList()) + nh.Invoke(this, e); + } + + } + catch (Exception) + { + + } + } + } + + private static void enableCollectionSynchronization(IEnumerable collection, object lockObject) + { + var method = typeof(BindingOperations).GetMethod("EnableCollectionSynchronization", + new Type[] { typeof(IEnumerable), typeof(object) }); + if (method != null) + { + // It's .NET 4.5 + method.Invoke(null, new object[] { collection, lockObject }); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/BaseFieldClass.cs b/DigiCamControl/CameraControl.Devices/Classes/BaseFieldClass.cs new file mode 100644 index 0000000..4d10b5f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/BaseFieldClass.cs @@ -0,0 +1,113 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections; +using System.ComponentModel; +using System.Reflection; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class BaseFieldClass : INotifyPropertyChanged + { + #region Implementation of IEditableObject + + private Hashtable props = null; + + public virtual void BeginEdit() + { + PropertyInfo[] properties = (GetType()).GetProperties + (BindingFlags.Public | BindingFlags.Instance); + + props = new Hashtable(properties.Length - 1); + + for (int i = 0; i < properties.Length; i++) + { + //check if there is set accessor + + if (null != properties[i].GetSetMethod()) + { + object value = properties[i].GetValue(this, null); + props.Add(properties[i].Name, value); + } + } + } + + public virtual void EndEdit() + { + props = null; + } + + public virtual void CancelEdit() + { + //check for inappropriate call sequence + + if (null == props) return; + + //restore old values + + PropertyInfo[] properties = (GetType()).GetProperties + (BindingFlags.Public | BindingFlags.Instance); + for (int i = 0; i < properties.Length; i++) + { + //check if there is set accessor + + if (null != properties[i].GetSetMethod()) + { + object value = props[properties[i].Name]; + properties[i].SetValue(this, value, null); + NotifyPropertyChanged(properties[i].Name); + } + } + + //delete current values + + props = null; + } + + #endregion + + #region Implementation of INotifyPropertyChanged + + public virtual event PropertyChangedEventHandler PropertyChanged; + + public virtual void NotifyPropertyChanged(String info) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(info)); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/CameraFieldType.cs b/DigiCamControl/CameraControl.Devices/Classes/CameraFieldType.cs new file mode 100644 index 0000000..8fd7d78 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/CameraFieldType.cs @@ -0,0 +1,37 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +namespace CameraControl.Devices.Classes +{ + public enum CameraFieldType + { + Comment, + Artist, + Copyright + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/Capability.cs b/DigiCamControl/CameraControl.Devices/Classes/Capability.cs new file mode 100644 index 0000000..7fbd970 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/Capability.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Classes +{ + public class Capability + { + /// + /// Current value of the specified parameter. + /// + public virtual T Current { set; get; } + + /// + /// Candidate values of the specified parameter. + /// + public virtual List Candidates { set; get; } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Classes/CapabilityEnum.cs b/DigiCamControl/CameraControl.Devices/Classes/CapabilityEnum.cs new file mode 100644 index 0000000..0dc61ed --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/CapabilityEnum.cs @@ -0,0 +1,44 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +namespace CameraControl.Devices.Classes +{ + public enum CapabilityEnum + { + LiveView, + LiveViewStream, + Bulb, + RecordMovie, + CanLockFocus, + CaptureInRam, + CaptureNoAf, + SimpleManualFocus, + Zoom + } + +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/Conts.cs b/DigiCamControl/CameraControl.Devices/Classes/Conts.cs new file mode 100644 index 0000000..4e41722 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/Conts.cs @@ -0,0 +1,65 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Runtime.InteropServices; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class Conts + { + [MarshalAs(UnmanagedType.LPStr)] public const string wiaEventDeviceConnected = + "{A28BBADE-64B6-11D2-A231-00C04FA31809}"; + + [MarshalAs(UnmanagedType.LPStr)] public const string wiaEventDeviceDisconnected = + "{143E4E83-6497-11D2-A231-00C04FA31809}"; + + [MarshalAs(UnmanagedType.LPStr)] public const string wiaEventItemCreated = + "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}"; + + [MarshalAs(UnmanagedType.LPStr)] public const string wiaEventItemDeleted = + "{1D22A559-E14F-11D2-B326-00C04F68CE61}"; + + [MarshalAs(UnmanagedType.LPStr)] public const string wiaCommandTakePicture = + "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}"; + + public const string CONST_PROP_F_Number = "F Number"; + public const string CONST_PROP_ISO_Number = "Exposure Index"; + public const string CONST_PROP_Exposure_Time = "Exposure Time"; + public const string CONST_PROP_WhiteBalance = "White Balance"; + public const string CONST_PROP_ExposureMode = "Exposure Mode"; + public const string CONST_PROP_ExposureCompensation = "Exposure Compensation"; + public const string CONST_PROP_BatteryStatus = "Battery Status"; + public const string CONST_PROP_CompressionSetting = "Compression Setting"; + public const string CONST_PROP_ExposureMeteringMode = "Exposure Metering Mode"; + public const string CONST_PROP_FocusMode = "Focus Mode"; + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DelayedDelegate.cs b/DigiCamControl/CameraControl.Devices/Classes/DelayedDelegate.cs new file mode 100644 index 0000000..0b9452f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DelayedDelegate.cs @@ -0,0 +1,79 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Timers; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class DelayedDelegate + { + private static Timer runDelegates; + private static Dictionary delayedDelegates = new Dictionary(); + + static DelayedDelegate() + { + runDelegates = new Timer(); + runDelegates.Interval = 250; + runDelegates.Elapsed += RunDelegates; + runDelegates.Enabled = true; + runDelegates.Start(); + } + + public static void Add(Action method, int delay) + { + delayedDelegates.Add(method, DateTime.Now + TimeSpan.FromMilliseconds(delay)); + } + + private static void RunDelegates(object sender, EventArgs e) + { + List removeDelegates = new List(); + + foreach (Action method in delayedDelegates.Keys) + { + if (DateTime.Now >= delayedDelegates[method]) + { + method(); + removeDelegates.Add(method); + } + } + + foreach (Action method in removeDelegates) + { + delayedDelegates.Remove(method); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptor.cs b/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptor.cs new file mode 100644 index 0000000..e9e82bb --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptor.cs @@ -0,0 +1,51 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using CameraControl.Devices.TransferProtocol; +using Canon.Eos.Framework; +using PortableDeviceLib; +using WIA; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class DeviceDescriptor + { + public string SerialNumber { get; set; } + public string WpdId { get; set; } + public ICameraDevice CameraDevice { get; set; } + public string WiaId { get; set; } + public IDeviceInfo WiaDeviceInfo { get; set; } + public Device WiaDevice { get; set; } + public EosCamera EosCamera { get; set; } + public ITransferProtocol StillImageDevice { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptorEnumerator.cs b/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptorEnumerator.cs new file mode 100644 index 0000000..3a13216 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DeviceDescriptorEnumerator.cs @@ -0,0 +1,88 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Collections.Generic; +using System.Linq; +using Canon.Eos.Framework; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class DeviceDescriptorEnumerator + { + public List Devices { get; set; } + + public DeviceDescriptorEnumerator() + { + Devices = new List(); + } + + public DeviceDescriptor GetBySerialNumber(string serial) + { + return Devices.FirstOrDefault(deviceDescriptor => deviceDescriptor.SerialNumber == serial); + } + + public DeviceDescriptor GetByWiaId(string id) + { + return Devices.FirstOrDefault(deviceDescriptor => deviceDescriptor.WiaId == id); + } + + public DeviceDescriptor GetByWpdId(string id) + { + return Devices.FirstOrDefault(deviceDescriptor => deviceDescriptor.WpdId == id); + } + + public DeviceDescriptor GetByEosCamera(EosCamera id) + { + return Devices.FirstOrDefault(deviceDescriptor => deviceDescriptor.EosCamera == id); + } + + public void RemoveDisconnected() + { + List removedDevices = + Devices.Where(deviceDescriptor => !deviceDescriptor.CameraDevice.IsConnected).ToList(); + foreach (DeviceDescriptor deviceDescriptor in removedDevices) + { + Devices.Remove(deviceDescriptor); + } + } + + public void Add(DeviceDescriptor descriptor) + { + Devices.Add(descriptor); + } + + public void Remove(DeviceDescriptor descriptor) + { + Devices.Remove(descriptor); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DeviceException.cs b/DigiCamControl/CameraControl.Devices/Classes/DeviceException.cs new file mode 100644 index 0000000..fe8814f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DeviceException.cs @@ -0,0 +1,92 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Runtime.Serialization; + +#endregion + +namespace CameraControl.Devices.Classes +{ + [Serializable] + public class DeviceException : Exception + { + public uint ErrorCode { get; set; } + + public DeviceException(string message) + : base(message) + { + } + + public DeviceException(string message, uint errorcode) + : base(message) + { + ErrorCode = errorcode; + } + + public DeviceException(string message, int errorcode) + : base(message) + { + ErrorCode = (uint) errorcode; + } + + public DeviceException(string format, params object[] args) + : base(string.Format(format, args)) + { + } + + public DeviceException(string message, Exception innerException) + : base(message, innerException) + { + } + + public DeviceException(string message, Exception innerException, uint code) + : base(message, innerException) + { + ErrorCode = code; + } + + + public DeviceException(string format, Exception innerException, params object[] args) + : base(string.Format(format, args), innerException) + { + } + + protected DeviceException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + public DeviceException() + : base() + { + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DeviceObject.cs b/DigiCamControl/CameraControl.Devices/Classes/DeviceObject.cs new file mode 100644 index 0000000..b00f611 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DeviceObject.cs @@ -0,0 +1,44 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class DeviceObject + { + public object Handle { get; set; } + public string FileName { get; set; } + public byte[] ThumbData { get; set; } + public DateTime FileDate { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/DisconnectCameraEventArgs.cs b/DigiCamControl/CameraControl.Devices/Classes/DisconnectCameraEventArgs.cs new file mode 100644 index 0000000..6fabb67 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/DisconnectCameraEventArgs.cs @@ -0,0 +1,48 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using CameraControl.Devices.TransferProtocol; +using Canon.Eos.Framework; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public delegate void CameraDisconnectedEventHandler(object sender, DisconnectCameraEventArgs eventArgs); + + public class DisconnectCameraEventArgs : EventArgs + { + public string WiaId { get; set; } + public ITransferProtocol StillImageDevice { get; set; } + public EosCamera EosCamera { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/ErrorCodes.cs b/DigiCamControl/CameraControl.Devices/Classes/ErrorCodes.cs new file mode 100644 index 0000000..2102f85 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/ErrorCodes.cs @@ -0,0 +1,174 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Runtime.InteropServices; +using Canon.Eos.Framework.Internal.SDK; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class ErrorCodes + { + public const uint WIA_ERROR_GENERAL_ERROR = 0x80210001; + public const uint WIA_ERROR_OFFLINE = 0x80210005; + public const uint WIA_ERROR_BUSY = 0x80210006; + public const uint WIA_ERROR_DEVICE_COMMUNICATION = 0x8021000A; + public const uint WIA_ERROR_INVALID_COMMAND = 0x8021000B; + public const uint WIA_ERROR_INCORRECT_HARDWARE_SETTING = 0x8021000C; + public const uint WIA_ERROR_DEVICE_LOCKED = 0x8021000D; + public const uint WIA_ERROR_EXCEPTION_IN_DRIVER = 0x8021000E; + public const uint WIA_ERROR_INVALID_DRIVER_RESPONSE = 0x8021000F; + public const uint WIA_S_NO_DEVICE_AVAILABLE = 0x80210015; + public const uint WIA_ERROR_UNABLE_TO_FOCUS = 0x80004005; + + public const uint MTP_OK = 0x2001; + public const uint MTP_General_Error = 0x2002; + public const uint MTP_Device_Busy = 0x2019; + public const uint MTP_Set_Property_Not_Support = 0xA005; + public const uint MTP_Store_Not_Available = 0x2013; + public const uint MTP_Out_of_Focus = 0xA002; + public const uint MTP_Shutter_Speed_Bulb = 0xA008; + public const uint MTP_Store_Full = 0x200C; + public const uint MTP_Store_Read_Only = 0x200E; + public const uint MTP_Parameter_Not_Supported = 0x2006; + public const uint MTP_Not_LiveView = 0xA00B; + public const uint MTP_Invalid_Parameter = 0x201D; + public const uint MTP_Invalid_Status = 0xA004; + public const uint MTP_Operation_Not_Supported = 0x2005; + public const uint MTP_Access_Denied = 0x200F; + + + public const uint E_WPD_DEVICE_IS_HUNG = 0x802A0006; + public const uint ERROR_BUSY = 0x800700AA; + + public static void GetException(int code) + { + GetException((uint) code); + } + + public static void GetCanonException(uint code) + { + if (code != 0 && code != Edsdk.EDS_ERR_OK) + { + switch (code) + { + default: + throw new DeviceException("Canon error code: " + code.ToString("X"), code); + } + } + } + + public static void GetException(uint code) + { + if (code != 0 && code != MTP_OK) + { + switch (code) + { + case MTP_Device_Busy: + throw new DeviceException("Device MTP error: Device is busy", code); + case MTP_General_Error: + throw new DeviceException("General error. No focus ?", code); + case MTP_Store_Not_Available: + throw new DeviceException("The card cannot be accessed", code); + case MTP_Shutter_Speed_Bulb: + throw new DeviceException("Bulb mode isn't supported", code); + case MTP_Out_of_Focus: + throw new DeviceException("Unable to focus.", code); + case MTP_Store_Full: + throw new DeviceException("Storage is full.", code); + case MTP_Store_Read_Only: + throw new DeviceException("Storage is read only.", code); + case MTP_Not_LiveView: + throw new DeviceException("Not in live view.", code); + case MTP_Invalid_Parameter: + throw new DeviceException("Invalid parameter. Coding error !", code); + case MTP_Parameter_Not_Supported: + throw new DeviceException("Parameter Not Supported. Coding error !", code); + case MTP_Invalid_Status: + throw new DeviceException("Invalid status.", code); + case MTP_Access_Denied: + throw new DeviceException("Access denied.", code); + case MTP_Set_Property_Not_Support: + throw new DeviceException("Set Property Not Support.", code); + case E_WPD_DEVICE_IS_HUNG: + throw new DeviceException("E_WPD_DEVICE_IS_HUNG", code); + case ERROR_BUSY: + throw new DeviceException("MTP device busy", code); + case MTP_Operation_Not_Supported: + throw new DeviceException("Operation Not Supported", code); + default: + throw new DeviceException("Device MTP error code: " + code.ToString("X"), code); + } + } + } + + public static void GetException(COMException exception) + { + switch ((uint) exception.ErrorCode) + { + case WIA_ERROR_BUSY: + throw new DeviceException("Device is busy. Error code :WIA_ERROR_BUSY", exception, + (uint) exception.ErrorCode); + case WIA_ERROR_DEVICE_COMMUNICATION: + throw new DeviceException("Device communication error. Error code :WIA_ERROR_DEVICE_COMMUNICATION", + exception, (uint) exception.ErrorCode); + case WIA_ERROR_DEVICE_LOCKED: + throw new DeviceException("Device is locked. Error code :WIA_ERROR_DEVICE_LOCKED", exception, + (uint) exception.ErrorCode); + case WIA_ERROR_EXCEPTION_IN_DRIVER: + throw new DeviceException("Exception in driver. Error code :WIA_ERROR_EXCEPTION_IN_DRIVER", + exception, (uint) exception.ErrorCode); + case WIA_ERROR_GENERAL_ERROR: + throw new DeviceException("General error. Error code :WIA_ERROR_GENERAL_ERROR", exception, + (uint) exception.ErrorCode); + case WIA_ERROR_INCORRECT_HARDWARE_SETTING: + throw new DeviceException( + "Incorrect hardware error. Error code :WIA_ERROR_INCORRECT_HARDWARE_SETTING", exception, + (uint) exception.ErrorCode); + case WIA_ERROR_INVALID_COMMAND: + throw new DeviceException("Invalid command. Error code :WIA_ERROR_INVALID_COMMAND", exception, + (uint) exception.ErrorCode); + case WIA_ERROR_INVALID_DRIVER_RESPONSE: + throw new DeviceException("Invalid driver response. Error code :WIA_ERROR_INVALID_DRIVER_RESPONSE", + exception, (uint) exception.ErrorCode); + case WIA_ERROR_OFFLINE: + throw new DeviceException("Device is offline. Error code :WIA_ERROR_OFFLINE", exception, + WIA_ERROR_OFFLINE, (uint) exception.ErrorCode); + case WIA_ERROR_UNABLE_TO_FOCUS: + throw new DeviceException("Unable to focus. Error code :WIA_ERROR_UNABLE_TO_FOCUS", exception, + WIA_ERROR_UNABLE_TO_FOCUS, (uint) exception.ErrorCode); + default: + throw new DeviceException("Unknown error. Error code:" + (uint) exception.ErrorCode, exception, + (uint) exception.ErrorCode); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/FocusAmount.cs b/DigiCamControl/CameraControl.Devices/Classes/FocusAmount.cs new file mode 100644 index 0000000..9140859 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/FocusAmount.cs @@ -0,0 +1,9 @@ +namespace CameraControl.Devices.Classes +{ + public enum FocusAmount + { + Small, + Medium, + Large + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/FocusDirection.cs b/DigiCamControl/CameraControl.Devices/Classes/FocusDirection.cs new file mode 100644 index 0000000..7899f24 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/FocusDirection.cs @@ -0,0 +1,8 @@ +namespace CameraControl.Devices.Classes +{ + public enum FocusDirection + { + Near, + Far + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/HttpHelper.cs b/DigiCamControl/CameraControl.Devices/Classes/HttpHelper.cs new file mode 100644 index 0000000..66948d2 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/HttpHelper.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Classes +{ + public static class HttpHelper + { + public static void DownLoadFileByWebRequest(string urlAddress, string filePath, ICameraDevice device,long size=0) + { + try + { + HttpWebRequest request = null; + HttpWebResponse response = null; + request = (HttpWebRequest)WebRequest.Create(urlAddress); + request.Timeout = 30000; //8000 Not work + response = (HttpWebResponse)request.GetResponse(); + Stream s = response.GetResponseStream(); + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + + FileStream os = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); + byte[] buff = new byte[102400]; + int c = 0; + int totalsize = 0; + while ((c = s.Read(buff, 0, 102400)) > 0) + { + os.Write(buff, 0, c); + os.Flush(); + totalsize += c; + if (size > 0) + { + device.TransferProgress = (uint)(totalsize/(double)size*100.0); + } + else + { + device.TransferProgress += 1; + } + + } + os.Close(); + s.Close(); + device.TransferProgress = 100; + } + catch(Exception ex) + { + Log.Error("Error download file", ex); + } + finally + { + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Classes/LiveViewData.cs b/DigiCamControl/CameraControl.Devices/Classes/LiveViewData.cs new file mode 100644 index 0000000..fa5a604 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/LiveViewData.cs @@ -0,0 +1,132 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class LiveViewData + { + public int LiveViewImageWidth { get; set; } + public int LiveViewImageHeight { get; set; } + + /// + /// Gets or sets the width of the captured image. + /// + /// + /// The width of the image. + /// + public int ImageWidth { get; set; } + /// + /// Gets or sets the height of the captured image. + /// + /// + /// The height of the image. + /// + public int ImageHeight { get; set; } + + /// + /// Gets or sets the focus point x axis . + /// + /// + /// The focus x. + /// + public int FocusX { get; set; } + /// + /// Gets or sets the focus point y axis. + /// + /// + /// The focus y. + /// + public int FocusY { get; set; } + + public int FocusFrameXSize { get; set; } + public int FocusFrameYSize { get; set; } + + + /// + /// Gets or sets a value indicating whether focussing info included. + /// + /// + /// true if [have focus data]; otherwise, false. + /// + public bool HaveFocusData { get; set; } + + /// + /// Gets or sets the live view image data. + /// May contain additional information, use ImageDataPosition to get live view image + /// + /// + /// The image data. + /// + public byte[] ImageData { get; set; } + + public bool Focused { get; set; } + + /// + /// Gets or sets the image data starting position in ImageData. + /// + /// + /// The image data position. + /// + public int ImageDataPosition { get; set; } + + public int Rotation { get; set; } + + public bool MovieIsRecording { get; set; } + + public bool IsLiveViewRunning { get; set; } + + public bool HaveLevelAngleData { get; set; } + + public decimal LevelAngleRolling { get; set; } + + public decimal LevelAnglePitching { get; set; } + + public decimal LevelAngleYawing { get; set; } + + public decimal MovieTimeRemain { get; set; } + + public int SoundL { get; set; } + + public int SoundR { get; set; } + + public int PeakSoundL { get; set; } + + public int PeakSoundR { get; set; } + + public bool HaveSoundData { get; set; } + + public LiveViewData() + { + IsLiveViewRunning = true; + HaveLevelAngleData = false; + SoundL = 0; + SoundR = 0; + HaveSoundData = false; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/LogEventArgs.cs b/DigiCamControl/CameraControl.Devices/Classes/LogEventArgs.cs new file mode 100644 index 0000000..3ab0d96 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/LogEventArgs.cs @@ -0,0 +1,42 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class LogEventArgs : EventArgs + { + public object Message { get; set; } + public Exception Exception { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/OperationEnum.cs b/DigiCamControl/CameraControl.Devices/Classes/OperationEnum.cs new file mode 100644 index 0000000..46b9a62 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/OperationEnum.cs @@ -0,0 +1,39 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +namespace CameraControl.Devices.Classes +{ + public enum OperationEnum + { + Capture, + RecordMovie, + AutoFocus, + ManualFocus, + LiveView + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/PhotoCapturedEventArgs.cs b/DigiCamControl/CameraControl.Devices/Classes/PhotoCapturedEventArgs.cs new file mode 100644 index 0000000..6fc6bdc --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/PhotoCapturedEventArgs.cs @@ -0,0 +1,70 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using WIA; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public delegate void PhotoCapturedEventHandler(object sender, PhotoCapturedEventArgs eventArgs); + + public class PhotoCapturedEventArgs + { + private Item _wiaImageItem; + + public Item WiaImageItem + { + get { return _wiaImageItem; } + set + { + _wiaImageItem = value; + //ImageFile = (ImageFile)WiaImageItem.Transfer("{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"); + } + } + + public ImageFile ImageFile { get; set; } + + public bool Transfer(string fileName) + { + //imageFile.SaveFile(fileName); + return true; + } + + public object EventArgs { get; set; } + + public ICameraDevice CameraDevice { get; set; } + public string FileName { get; set; } + public object Handle { get; set; } + + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/PictureControl.cs b/DigiCamControl/CameraControl.Devices/Classes/PictureControl.cs new file mode 100644 index 0000000..facb7bf --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/PictureControl.cs @@ -0,0 +1,61 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class PictureControl + { + public byte ItemNumber { get; set; } + public bool IsLoaded { get; set; } + public bool Monocrome { get; set; } + public byte CustomFlag { get; set; } + public string RegistrationName { get; set; } + public byte QuickAdjustFlag { get; set; } + public sbyte QuickAdjust { get; set; } + public sbyte Saturation { get; set; } + public sbyte Hue { get; set; } + public sbyte Sharpening { get; set; } + public sbyte Contrast { get; set; } + public sbyte Brightness { get; set; } + public byte CustomCurveFlag { get; set; } + public byte[] CustomCurveData { get; set; } + //color + public byte FilterEffects { get; set; } + public byte Toning { get; set; } + public byte ToningDensity { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/PropertyValue.cs b/DigiCamControl/CameraControl.Devices/Classes/PropertyValue.cs new file mode 100644 index 0000000..ff6e5af --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/PropertyValue.cs @@ -0,0 +1,506 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Classes +{ + public class PropertyValue : BaseFieldClass + { + public delegate void ValueChangedEventHandler(object sender, string key, T val); + + public event ValueChangedEventHandler ValueChanged; + + private Dictionary _valuesDictionary; + private Dictionary _replaceValues; + private AsyncObservableCollection _numericValues = new AsyncObservableCollection(); + private AsyncObservableCollection _values = new AsyncObservableCollection(); + private bool _notifyValuChange = true; + private readonly object _syncRoot = new object(); + public string Tag { get; set; } + + + private uint _code; + + public uint Code + { + get { return _code; } + set + { + _code = value; + NotifyPropertyChanged("Code"); + } + } + /// + /// Indicate if the property is available and can be used + /// + public bool Available + { + get { return _available; } + set + { + _available = value; + NotifyPropertyChanged("Available"); + } + } + + /// + /// Gets or sets a value indicating the propertie + /// settings wasn't errorless. + /// + /// + /// true if [have error]; otherwise, false. + /// + public bool HaveError + { + get { return _haveError; } + set + { + _haveError = value; + NotifyPropertyChanged("HaveError"); + NotifyPropertyChanged("ErrorColor"); + } + } + + public string ErrorColor + { + get { return HaveError ? "Red" : "Transparent"; } + } + + public Type SubType { get; set; } + public bool DisableIfWrongValue { get; set; } + + private string _name; + + public string Name + { + get { return _name; } + set + { + _name = value; + NotifyPropertyChanged("Name"); + } + } + + private string _value; + + public string Value + { + get + { + if (_value != null && _replaceValues != null && _replaceValues.Count > 0) + { + foreach (var replaceValue in _replaceValues.Where(replaceValue => replaceValue.Value == _value)) + { + return replaceValue.Key; + } + } + return _value; + } + set + { + _value = value; + if (_value != null) + { + if (_replaceValues != null && _replaceValues.Count > 0 && _replaceValues.ContainsKey(_value)) + { + _value = _replaceValues[_value]; + } + + HaveError = false; + if (ValueChanged != null && _notifyValuChange) + { + if (_valuesDictionary.ContainsKey(_value)) + { + OnValueChanged(this, _value, _valuesDictionary[_value]); + } + } + } + else + { + + } + NotifyPropertyChanged("Value"); + } + } + + private T _numericValue; + + public T NumericValue + { + get { return _numericValue; } + set + { + _numericValue = value; + NotifyPropertyChanged("NumericValue"); + } + } + + public void NextValue() + { + lock (_syncRoot) + { + if (Values == null || Values.Count == 0 || !IsEnabled) + return; + int ind = Values.IndexOf(Value); + if (ind < 0) + return; + ind++; + if (ind < Values.Count) + Value = Values[ind]; + } + } + + public void PrevValue() + { + lock (_syncRoot) + { + if (Values == null || Values.Count == 0 || !IsEnabled) + return; + int ind = Values.IndexOf(Value); + ind--; + if (ind < 0) + return; + + if (ind < Values.Count) + Value = Values[ind]; + } + } + + + public void OnValueChanged(object sender, string key, T val) + { + Thread thread = new Thread(OnValueChangedThread); + thread.Name = "SetProperty thread " + Name; + thread.Start(new object[] { sender, key, val }); + thread.Join(200); + } + + public void OnValueChangedThread(object obj) + { + lock (_syncRoot) + { + object[] objparams = obj as object[]; + bool retry; + int retrynum = 5; + do + { + retry = false; + try + { + object sender = objparams[0]; + string key = objparams[1] as string; + T val = (T)objparams[2]; + ValueChanged(sender, key, val); + } + catch (DeviceException exception) + { + if ((exception.ErrorCode == ErrorCodes.ERROR_BUSY || + exception.ErrorCode == ErrorCodes.MTP_Device_Busy) && retrynum > 0) + { + retrynum--; + retry = true; + Thread.Sleep(100); + } + } + } while (retry); + } + } + + private bool _isEnabled; + private bool _haveError; + private bool _available; + + public bool IsEnabled + { + get + { + //if (Values == null || Values.Count==0) + // return false; + //if (DisableIfWrongValue) + //{ + // return _isEnabled && !string.IsNullOrEmpty(Value); + //} + //else + //{ + // return _isEnabled; + //} + return _isEnabled; + } + set + { + _isEnabled = value; + NotifyPropertyChanged("IsEnabled"); + } + } + + public AsyncObservableCollection Values + { + get + { + //if (_valuesDictionary.Count > 0 && _values.Count == 0) + // ReloadValues(); + return _values; + } + } + + public AsyncObservableCollection NumericValues + { + get { return _numericValues; } + } + + public PropertyValue() + { + _valuesDictionary = new Dictionary(); + _replaceValues = new Dictionary(); + DisableIfWrongValue = false; + IsEnabled = true; + Available = true; + } + + public void SetValue(T o, bool notifyValuChange) + { + _notifyValuChange = notifyValuChange; + SetValue(o); + _notifyValuChange = true; + } + + public void SetValue(T o) + { + lock (_syncRoot) + { + NumericValue = o; + foreach (KeyValuePair keyValuePair in _valuesDictionary) + { + if (EqualityComparer.Default.Equals(keyValuePair.Value, o)) + //(keyValuePair.Value== o) + { + Value = keyValuePair.Key; + return; + } + } + } + } + + public void Filter(List values) + { + var old = new Dictionary(_valuesDictionary); + _valuesDictionary.Clear(); + foreach (var val in old) + { + if (values.Contains(val.Value)) + _valuesDictionary.Add(val.Key, val.Value); + } + _values = new AsyncObservableCollection(_valuesDictionary.Keys); + _numericValues = new AsyncObservableCollection(_valuesDictionary.Values); + NotifyPropertyChanged("Values"); + } + + public void SetValue() + { + Value = Value; + } + + + public void SetValue(string o, bool notifyValuChange = true) + { + lock (_syncRoot) + { + foreach (KeyValuePair keyValuePair in _valuesDictionary) + { + if (keyValuePair.Key == o) + { + _notifyValuChange = notifyValuChange; + Value = keyValuePair.Key; + _notifyValuChange = true; + return; + } + } + } + } + + public void SetValue(byte[] ba, bool notifyValuChange) + { + _notifyValuChange = notifyValuChange; + SetValue(ba); + _notifyValuChange = true; + } + + public void SetValue(MTPDataResponse data, bool notifyValuChange) + { + _notifyValuChange = notifyValuChange; + SetValue(data.Data); + _notifyValuChange = true; + } + + public void SetValue(byte[] ba) + { + if (ba == null || ba.Length < 1) + return; + if (typeof(T) == typeof(int)) + { + int val = ba.Length == 1 ? ba[0] : BitConverter.ToInt16(ba, 0); + SetValue((T)((object)val)); + } + if (typeof(T) == typeof(uint)) + { + uint val = BitConverter.ToUInt16(ba, 0); + SetValue((T)((object)val)); + } + if (typeof(T) == typeof(long) && SubType == typeof(sbyte)) + { + long val = Convert.ToSByte(ba[0]); + SetValue((T)((object)val)); + return; + } + if (typeof(T) == typeof(long) && ba.Length == 1) + { + long val = ba[0]; + SetValue((T)((object)val)); + return; + } + if (typeof(T) == typeof(long) && ba.Length == 2 && SubType == typeof(UInt16)) + { + long val = BitConverter.ToUInt16(ba, 0); + SetValue((T)((object)val)); + return; + } + if (typeof(T) == typeof(long) && ba.Length == 2) + { + long val = BitConverter.ToInt16(ba, 0); + SetValue((T)((object)val)); + return; + } + if (typeof(T) == typeof(long) && ba.Length == 4) + { + long val = BitConverter.ToUInt32(ba, 0); + SetValue((T)((object)val)); + return; + } + if (typeof(T) == typeof(long)) + { + long val = BitConverter.ToInt64(ba, 0); + SetValue((T)((object)val)); + } + if (typeof(T) == typeof(uint)) + { + uint val = BitConverter.ToUInt16(ba, 0); + SetValue((T)((object)val)); + } + } + + /// + /// After value add finished, ReloadValues should be called + /// + /// + /// + public void AddValues(string key, T value) + { + + if (!_valuesDictionary.ContainsKey(key)) + _valuesDictionary.Add(key, value); + } + + /// + /// Reload display values + /// Should be called always after AddValues + /// + public void ReloadValues() + { + _values = new AsyncObservableCollection(_valuesDictionary.Keys); + _numericValues = new AsyncObservableCollection(_valuesDictionary.Values); + NotifyPropertyChanged("Values"); + } + + /// + /// Refresh display values based on replace values + /// + public void GetValues() + { + lock (_syncRoot) + { + string newVal = Value; + _values.Clear(); + NotifyPropertyChanged("Values"); + _values = new AsyncObservableCollection(_valuesDictionary.Keys); + if (_replaceValues != null && _replaceValues.Count > 0) + { + for (int i = 0; i < _values.Count; i++) + { + if (_replaceValues.ContainsValue(_values[i])) + { + foreach (var value in _replaceValues) + { + if (value.Value == _values[i]) + _values[i] = value.Key; + } + } + } + } + _numericValues = new AsyncObservableCollection(_valuesDictionary.Values); + NotifyPropertyChanged("Values"); + Value = newVal; + } + } + + /// + /// Replace a displayed value + /// GetValues() call is required + /// + /// + /// + public void ReplaceValue(string oldVal, string newVal) + { + lock (_syncRoot) + { + if (!_replaceValues.ContainsKey(newVal)) + { + _replaceValues.Add(newVal, oldVal); + } + } + } + + + public void Clear(bool notify = true) + { + _valuesDictionary.Clear(); + _values.Clear(); + _numericValues.Clear(); + if (notify) + NotifyPropertyChanged("Values"); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Classes/ZoomDirection.cs b/DigiCamControl/CameraControl.Devices/Classes/ZoomDirection.cs new file mode 100644 index 0000000..63cb993 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Classes/ZoomDirection.cs @@ -0,0 +1,8 @@ +namespace CameraControl.Devices.Classes +{ + public enum ZoomDirection + { + In, + Out + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Custom/CustomDevice.cs b/DigiCamControl/CameraControl.Devices/Custom/CustomDevice.cs new file mode 100644 index 0000000..e3ae087 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Custom/CustomDevice.cs @@ -0,0 +1,111 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using PortableDeviceLib.Model; + +namespace CameraControl.Devices.Custom +{ + public class CustomDevice:BaseMTPCamera + { + public CustomDevice() + { + + } + + public bool Init(DeviceDescriptor deviceDescriptor,DeviceDescription description) + { + base.Init(deviceDescriptor); + StillImageDevice imageDevice = StillImageDevice as StillImageDevice; + if (imageDevice != null) + imageDevice.DeviceEvent += StillImageDevice_DeviceEvent; + foreach (var property in description.Properties) + { + if (!string.IsNullOrEmpty(property.Name)) + { + try + { + MTPDataResponse result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, property.Code); + + ErrorCodes.GetException(result.ErrorCode); + uint dataType = BitConverter.ToUInt16(result.Data, 2); + int dataLength = StaticHelper.GetDataLength(dataType); + + var value = new PropertyValue { Code = property.Code, Name = property.Name }; + foreach (var propertyValue in property.Values) + { + value.AddValues(propertyValue.Name, propertyValue.Value); + } + value.ValueChanged += value_ValueChanged; + + AdvancedProperties.Add(value); + } + catch (Exception ex) + { + Log.Error("Error ger property ", ex); + } + } + } + return true; + } + + void value_ValueChanged(object sender, string key, long val) + { + PropertyValue res = sender as PropertyValue; + if (res != null) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + } + + private void StillImageDevice_DeviceEvent(object sender, PortableDeviceEventArgs e) + { + if (e.EventType.EventGuid == PortableDeviceGuids.WPD_EVENT_OBJECT_ADDED) + { + var id = e.EventType.DeviceObject.ID; + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + CameraDevice = this, + FileName = e.EventType.DeviceObject.Name, + Handle = e.EventType.DeviceObject.ID + }; + OnPhotoCapture(this, args); + } + } + + public override void TransferFile(object o, Stream stream) + { + ((StillImageDevice) StillImageDevice).SaveFile((string) o, stream); + } + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + ErrorCodes.GetException( ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Custom/DeviceDescription.cs b/DigiCamControl/CameraControl.Devices/Custom/DeviceDescription.cs new file mode 100644 index 0000000..8f981bb --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Custom/DeviceDescription.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml.Serialization; + +namespace CameraControl.Devices.Custom +{ + public class DeviceDescription + { + [XmlAttribute] + public string Model { get; set; } + [XmlAttribute] + public string BaseDevice { get; set; } + [XmlAttribute] + public string Manufacturer { get; set; } + + public string Description { get; set; } + + public List Properties { get; set; } + + public DeviceDescription() + { + Properties = new List(); + } + + public void Save(string file) + { + XmlSerializer serializer = new XmlSerializer(typeof(DeviceDescription)); + Stream writer = new FileStream(file, FileMode.Create); + serializer.Serialize(writer, this); + writer.Close(); + } + + public static DeviceDescription Load(string file) + { + try + { + DeviceDescription settings = new DeviceDescription(); + XmlSerializer mySerializer = new XmlSerializer(typeof(DeviceDescription)); + FileStream myFileStream = new FileStream(file, FileMode.Open); + settings = (DeviceDescription)mySerializer.Deserialize(myFileStream); + myFileStream.Close(); + + return settings; + } + catch (Exception ex) + { + Log.Error("Error load device description "+file,ex); + return null; + + } + } + + } + +} diff --git a/DigiCamControl/CameraControl.Devices/Custom/DeviceProperty.cs b/DigiCamControl/CameraControl.Devices/Custom/DeviceProperty.cs new file mode 100644 index 0000000..8291bab --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Custom/DeviceProperty.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using CameraControl.Devices.Classes; + +namespace CameraControl.Devices.Custom +{ + public class DeviceProperty + { + [XmlAttribute] + public string Name { get; set; } + [XmlAttribute] + public uint Code { get; set; } + [XmlAttribute] + public bool ReadOnly { get; set; } + [XmlAttribute] + public string MapTo { get; set; } + + public List Values { get; set; } + + public DeviceProperty() + { + Values = new List(); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Custom/DevicePropertyValue.cs b/DigiCamControl/CameraControl.Devices/Custom/DevicePropertyValue.cs new file mode 100644 index 0000000..5723a46 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Custom/DevicePropertyValue.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; + +namespace CameraControl.Devices.Custom +{ + public class DevicePropertyValue + { + [XmlAttribute] + public long Value { get; set; } + [XmlAttribute] + public string Name { get; set; } + + } +} diff --git a/DigiCamControl/CameraControl.Devices/ICameraDevice.cs b/DigiCamControl/CameraControl.Devices/ICameraDevice.cs new file mode 100644 index 0000000..ffa657e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/ICameraDevice.cs @@ -0,0 +1,211 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices +{ + public interface ICameraDevice + { + /// + /// If false the camera is ready to take next capture + /// Should be handled by the user code + /// + bool IsBusy { get; set; } + + /// + /// This property will be removed, replaced by GetCapability + /// + bool HaveLiveView { get; set; } + + /// + /// Gets or sets a value indicating whether photos captured are captured in SDRam. + /// + /// + /// true if true photos are captured in SDRam; otherwise, false photos will be recorded in card. + /// + bool CaptureInSdRam { get; set; } + + PropertyValue FNumber { get; set; } + PropertyValue IsoNumber { get; set; } + PropertyValue ShutterSpeed { get; set; } + PropertyValue WhiteBalance { get; set; } + PropertyValue Mode { get; set; } + PropertyValue ExposureCompensation { get; set; } + PropertyValue CompressionSetting { get; set; } + PropertyValue ExposureMeteringMode { get; set; } + PropertyValue FocusMode { get; set; } + DateTime DateTime { get; set; } + /// + /// Gets or sets a unique indentifier for device based on connection mode. + /// + /// + /// The name of the port. + /// + string PortName { get; set; } + + /// + /// Gets or sets a value indicating whether the camera is connected. + /// + /// + /// true if this instance is connected; otherwise, false. + /// + bool IsConnected { get; set; } + + bool IsChecked { get; set; } + + /// + /// Gets or sets the attached abject to the camera . + /// + /// + /// The attached photo session. + /// + object AttachedPhotoSession { get; set; } + + string DeviceName { get; set; } + string Manufacturer { get; set; } + string SerialNumber { get; set; } + string DisplayName { get; set; } + int ExposureStatus { get; set; } + bool PreventShutDown { get; set; } + + /// + /// Check is a capability is supported + /// + /// The capability enum. + /// true if capability supported + bool GetCapability(CapabilityEnum capabilityEnum); + + /// + /// The current file transfer progress (0-100 %) + /// + /// + /// The transfer progress. + /// + uint TransferProgress { get; set; } + + int Battery { get; set; } + PropertyValue LiveViewImageZoomRatio { get; set; } + + bool Init(DeviceDescriptor deviceDescriptor); + void StartLiveView(); + void StopLiveView(); + string GetLiveViewStream(); + + LiveViewData GetLiveViewImage(); + void AutoFocus(); + int Focus(int step); + void Focus(int x, int y); + void Focus(FocusDirection direction, FocusAmount amount); + void CapturePhotoNoAf(); + void CapturePhoto(); + void StartRecordMovie(); + void StopRecordMovie(); + /// + /// Gets the prohibition condition for the specified operation. + /// If a operation can be executed empty string will returned, + /// Else the error code or error description + /// + /// The operation enum. + /// + string GetProhibitionCondition(OperationEnum operationEnum); + bool GetStatus(OperationEnum operationEnum); + /// + /// Support only if capability Bulb is specified + /// + void EndBulbMode(); + + /// + /// Support only if capability Bulb is specified + /// + void StartBulbMode(); + + void LockCamera(); + void UnLockCamera(); + void Close(); + + void StartZoom(ZoomDirection direction); + void StopZoom(ZoomDirection direction); + + /// + /// Should be called after file tranferred + /// + /// The o. + void ReleaseResurce(object o); + + void TransferFileThumb(object o, string filename); + void TransferFile(object o, string filename); + void TransferFile(object o, System.IO.Stream stream); + + /// + /// Occurs when photo captured. + /// + event PhotoCapturedEventHandler PhotoCaptured; + + /// + /// Occurs when all capture images done. + /// + event EventHandler CaptureCompleted; + + /// + /// Occurs when [camera disconnected]. + /// + event CameraDisconnectedEventHandler CameraDisconnected; + + event CameraDeviceManager.CameraConnectedEventHandler CameraInitDone; + + /// + /// Gets or sets the arbitrary number of advanced properties. + /// + /// + /// The advanced properties. + /// + AsyncObservableCollection> AdvancedProperties { get; set; } + + AsyncObservableCollection> Properties { get; set; } + /// + /// Gets files stored in card. + /// + /// The storage id. + /// Load thumbnail atached to object + /// + AsyncObservableCollection GetObjects(object storageId, bool loadThumbs); + + void FormatStorage(object storageId); + bool DeleteObject(DeviceObject deviceObject); + + void SetCameraField(CameraFieldType cameraFieldType, string comment); + + void WaitForReady(); + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/IWifiDeviceProvider.cs b/DigiCamControl/CameraControl.Devices/IWifiDeviceProvider.cs new file mode 100644 index 0000000..065526b --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/IWifiDeviceProvider.cs @@ -0,0 +1,11 @@ +using CameraControl.Devices.Classes; + +namespace CameraControl.Devices +{ + public interface IWifiDeviceProvider + { + string Name { get; set; } + string DefaultIp { get; set; } + DeviceDescriptor Connect(string address); + } +} diff --git a/DigiCamControl/CameraControl.Devices/Log.cs b/DigiCamControl/CameraControl.Devices/Log.cs new file mode 100644 index 0000000..0306c21 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Log.cs @@ -0,0 +1,135 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices +{ + public delegate void LogEventHandler(LogEventArgs e); + + public static class Log + { + public static event LogEventHandler LogDebug; + public static event LogEventHandler LogError; + public static event LogEventHandler LogInfo; + + public static bool IsVerbose { get; set; } = false; + + /* The xxxWithWritexxx methods are for convenience instead of doing + * Console.WriteLine(String.Format("...format...", objects)); + * Log.Verbose(String.Format("...format...", objects)); + * with all the overhead twice... */ + + public static void Debug(object message, Exception exception) + { + if (LogDebug != null) + LogDebug(new LogEventArgs() {Exception = exception, Message = message}); + } + + public static void Debug(object message) + { + Debug(message, null); + } + + public static void Error(object message, Exception exception) + { + if (LogError != null) + LogError(new LogEventArgs() {Exception = exception, Message = message}); + } + + public static void Error(object message) + { + Error(message, null); + } + + public static void Info(object message, Exception exception) + { + if (LogInfo != null) + LogInfo(new LogEventArgs() {Exception = exception, Message = message}); + } + + public static void Info(object message) + { + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + + public static void InfoWithWriteLine(object message) + { + Console.WriteLine(message); + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + + public static void Verbose(object message) + { + if (IsVerbose) + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + + public static void VerboseWithWriteLine(object message) + { + if (IsVerbose) + { + Console.WriteLine(message); + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + } + + public static void VerboseWithWriteLineAlways(object message) + { + Console.WriteLine(message); + if (IsVerbose) + { + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + } + + public static void VerboseWithWrite(object message) + { + if (IsVerbose) + { + Console.Write(message); + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + } + + public static void VerboseWithWriteAlways(object message) + { + Console.Write(message); + if (IsVerbose) + { + LogInfo?.Invoke(new LogEventArgs() { Exception = null, Message = message }); + } + } + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonBase.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonBase.cs new file mode 100644 index 0000000..759a4ba --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonBase.cs @@ -0,0 +1,2623 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Timers; +using CameraControl.Devices.Classes; +using CameraControl.Devices.Xml; +using PortableDeviceLib; +using PortableDeviceLib.Model; +using Timer = System.Timers.Timer; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + /// + /// Base Nikon driver + /// + public class NikonBase : BaseMTPCamera + { + public const uint CONST_CMD_AfDrive = 0x90C1; + public const uint CONST_CMD_StartLiveView = 0x9201; + public const uint CONST_CMD_EndLiveView = 0x9202; + public const uint CONST_CMD_GetLiveViewImage = 0x9203; + public const uint CONST_CMD_InitiateCaptureRecInMedia = 0x9207; + public const uint CONST_CMD_AfAndCaptureRecInSdram = 0x90CB; + public const uint CONST_CMD_InitiateCaptureRecInSdram = 0x90C0; + public const uint CONST_CMD_ChangeAfArea = 0x9205; + public const uint CONST_CMD_MfDrive = 0x9204; + public const uint CONST_CMD_GetLargeThumb = 0x90C4; + + public const uint CONST_CMD_GetEvent = 0x90C7; + + public const uint CONST_CMD_DeviceReady = 0x90C8; + public const uint CONST_CMD_ChangeCameraMode = 0x90C2; + public const uint CONST_CMD_StartMovieRecInCard = 0x920A; + public const uint CONST_CMD_EndMovieRec = 0x920B; + + public const uint CONST_PROP_ImageSize = 0x5003; + public const uint CONST_PROP_Fnumber = 0x5007; + public const uint CONST_PROP_MovieFnumber = 0xD1A9; + public const uint CONST_PROP_ExposureIndex = 0x500F; + public const uint CONST_PROP_ExposureIndexEx = 0xD0B4; + public const uint CONST_PROP_MovieExposureIndex = 0xD1AA; + public const uint CONST_PROP_ExposureTime = 0x500D; + public const uint CONST_PROP_ShutterSpeed = 0xD100; + public const uint CONST_PROP_MovieShutterSpeed = 0xD1A8; + public const uint CONST_PROP_WhiteBalance = 0x5005; + public const uint CONST_PROP_ExposureProgramMode = 0x500E; + public const uint CONST_PROP_ExposureBiasCompensation = 0x5010; + public const uint CONST_PROP_MovieExposureBiasCompensation = 0xD1AB; + public const uint CONST_PROP_DateTime = 0x5011; + public const uint CONST_PROP_LiveViewImageZoomRatio = 0xD1A3; + public const uint CONST_PROP_AFModeSelect = 0xD161; + public const uint CONST_PROP_AfModeAtLiveView = 0xD061; + public const uint CONST_PROP_CompressionSetting = 0x5004; + public const uint CONST_PROP_ExposureMeteringMode = 0x500B; + public const uint CONST_PROP_FocusMode = 0x500A; + public const uint CONST_PROP_LiveViewStatus = 0xD1A2; + public const uint CONST_PROP_LiveViewSelector = 0xD1A6; + public const uint CONST_PROP_ExposureIndicateStatus = 0xD1B1; + public const uint CONST_PROP_RecordingMedia = 0xD10B; + public const uint CONST_PROP_NoiseReduction = 0xD06B; + public const uint CONST_PROP_ApplicationMode = 0xD1F0; + public const uint CONST_PROP_RawCompressionType = 0xD016; + public const uint CONST_PROP_RawCompressionBitMode = 0xD149; + public const uint CONST_PROP_ActivePicCtrlItem = 0xD200; + public const uint CONST_PROP_ColorSpace = 0xD032; + public const uint CONST_PROP_WbTuneFluorescentType = 0xD14F; + public const uint CONST_PROP_WbColorTemp = 0xD01E; + public const uint CONST_PROP_ISOAutoHighLimit = 0xD183; + public const uint CONST_PROP_FlashCompensation = 0xD124; + + public const uint CONST_Event_DevicePropChanged = 0x4006; + public const uint CONST_Event_StoreFull = 0x400A; + public const uint CONST_Event_CaptureComplete = 0x400D; + public const uint CONST_Event_CaptureCompleteRecInSdram = 0xC102; + public const uint CONST_Event_ObsoleteEvent = 0xC104; + + + protected Dictionary _isoTable = new Dictionary() + { + {0x0064, "100"}, + {0x007D, "125"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "Hi 0.3"}, + {0x2710, "Hi 0.7"}, + {0x3200, "Hi 1"}, + {0x6400, "Hi 2"}, + }; + + protected Dictionary _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "400"}, + {2, "800"}, + {3, "1600"}, + {4, "3200"}, + {5, "6400"}, + {6, "Hi 1.7"}, + {7, "Hi 2"}, + }; + + protected Dictionary _shutterTable = new Dictionary + { + {1, "1/6400"}, + {2, "1/4000"}, + {3, "1/3200"}, + {4, "1/2500"}, + {5, "1/2000"}, + {6, "1/1600"}, + {8, "1/1250"}, + {10, "1/1000"}, + {12, "1/800"}, + {13, "1/750"}, + {15, "1/640"}, + {20, "1/500"}, + {25, "1/400"}, + {28, "1/350"}, + {31, "1/320"}, + {40, "1/250"}, + {50, "1/200"}, + {55, "1/180"}, + {62, "1/160"}, + {80, "1/125"}, + {100, "1/100"}, + {111, "1/90"}, + {125, "1/80"}, + {166, "1/60"}, + {200, "1/50"}, + {222, "1/45"}, + {250, "1/40"}, + {333, "1/30"}, + {400, "1/25"}, + {500, "1/20"}, + {666, "1/15"}, + {769, "1/13"}, + {1000, "1/10"}, + {1250, "1/8"}, + {1666, "1/6"}, + {2000, "1/5"}, + {2500, "1/4"}, + {3333, "1/3"}, + {4000, "1/2.5"}, + {5000, "1/2"}, + {6250, "1/1.6"}, + {6666, "1/1.5"}, + {7692, "1/1.3"}, + {10000, "1s"}, + {13000, "1.3s"}, + {15000, "1.5s"}, + {16000, "1.6s"}, + {20000, "2s"}, + {25000, "2.5s"}, + {30000, "3s"}, + {40000, "4s"}, + {50000, "5s"}, + {60000, "6s"}, + {80000, "8s"}, + {100000, "10s"}, + {130000, "13s"}, + {150000, "15s"}, + {200000, "20s"}, + {250000, "25s"}, + {300000, "30s"}, + {0xFFFFFFFF, "Bulb"}, + }; + + private Dictionary _exposureModeTable = new Dictionary() + { + {1, "M"}, + {2, "P"}, + {3, "A"}, + {4, "S"}, + {0x8010, "[Scene mode] AUTO"}, + {0x8011, "[Scene mode] Portrait"}, + {0x8012, "[Scene mode] Landscape"}, + {0x8013, "[Scene mode] Close up"}, + {0x8014, "[Scene mode] Sports"}, + {0x8016, "[Scene mode] Flash prohibition AUTO"}, + {0x8017, "[Scene mode] Child"}, + {0x8018, "[Scene mode] SCENE"}, + {0x8019, "[EffectMode] EFFECTS"}, + }; + + private Dictionary _wbTable = new Dictionary() + { + {2, "Auto"}, + {4, "Daylight"}, + {5, "Fluorescent"}, + {6, "Incandescent"}, + {7, "Flash"}, + {0x8010, "Cloudy"}, + {0x8011, "Shade"}, + {0x8012, "Kelvin"}, + {0x8013, "Custom"}, + {0x8016, "Natural Light Auto"} + }; + + protected Dictionary _csTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (NORMAL)"}, + {2, "JPEG (FINE)"}, + {3, "TIFF (RGB)"}, + {4, "RAW"}, + {5, "RAW + JPEG (BASIC)"}, + {6, "RAW + JPEG (NORMAL)"}, + {7, "RAW + JPEG (FINE)"} + }; + + private Dictionary _emmTable = new Dictionary + { + {2, "Center-weighted metering"}, + {3, "Multi-pattern metering"}, + {4, "Spot metering"}, + {0x8010, "Highlight-weighted"} + }; + + private Dictionary _fmTable = new Dictionary() + { + {1, "[M] Manual focus"}, + {0x8010, "[S] Single AF servo"}, + {0x8011, "[C] Continuous AF servo"}, + {0x8012, "[A] AF servo mode automatic switching"}, + {0x8013, "[F] Constant AF servo"}, + }; + + public bool LiveViewOn + { + get { return _liveViewOn; } + set + { + _liveViewOn = value; + FocusMode = LiveViewOn ? LiveViewFocusMode : NormalFocusMode; + SetMovieMode(); + } + } + + /// + /// Gets or sets a value indicating whether the camera swich is in movie mode. + /// + /// + /// true if [live view is in movie mode]; otherwise, false. + /// + public bool LiveViewMovieOn + { + get { return _liveViewMovieOn; } + set + { + _liveViewMovieOn = value; + SetMovieMode(); + } + } + + public PropertyValue LiveViewFocusMode { get; set; } + public PropertyValue NormalFocusMode { get; set; } + + public PropertyValue NormalFNumber { get; set; } + public PropertyValue MovieFNumber { get; set; } + + public PropertyValue NormalIsoNumber { get; set; } + public PropertyValue MovieIsoNumber { get; set; } + + public PropertyValue NormalShutterSpeed { get; set; } + public PropertyValue MovieShutterSpeed { get; set; } + + public PropertyValue NormalExposureCompensation { get; set; } + public PropertyValue MovieExposureCompensation { get; set; } + + public NikonBase() + { + _timer.AutoReset = true; + _timer.Elapsed += _timer_Elapsed; + SlowDownEventTimer(); + } + + private void SetMovieMode() + { + if (LiveViewOn && LiveViewMovieOn) + { + FNumber = MovieFNumber ; + IsoNumber = MovieIsoNumber; + ShutterSpeed = MovieShutterSpeed; + ExposureCompensation = MovieExposureCompensation; + } + else + { + FNumber = NormalFNumber; + IsoNumber = NormalIsoNumber; + ShutterSpeed = NormalShutterSpeed; + ExposureCompensation = NormalExposureCompensation; + } + } + + private void SlowDownEventTimer() + { + _timer.Interval = 1000/10; + } + + private void SpeedUpEventTimer() + { + _timer.Interval = 1000/10; + } + + private void _timer_Elapsed(object sender, ElapsedEventArgs e) + { + try + { + _timer.Stop(); + lock (Locker) + { + ThreadPool.QueueUserWorkItem(GetEvent); + } + } + catch (Exception) + { + } + //_timer.Start(); + } + + public PictureControl GetPictureControl(byte slotnum) + { + PictureControl control = new PictureControl(); + MTPDataResponse result = ExecuteReadDataEx(0x90CC, slotnum, 0); + if (result.Data != null && result.Data.Length > 30) + { + control.IsLoaded = true; + control.ItemNumber = slotnum; + control.Monocrome = result.Data[1] == 1; + control.CustomFlag = result.Data[2]; + string name = Encoding.ASCII.GetString(result.Data, 3, 20); + control.RegistrationName = name.Contains("\0") ? name.Split('\0')[0] : name; + if (!control.Monocrome) + { + control.QuickAdjustFlag = result.Data[23]; + control.QuickAdjust = (sbyte) result.Data[24]; + control.Saturation = (sbyte) result.Data[25]; + control.Hue = (sbyte) result.Data[26]; + } + else + { + control.FilterEffects = result.Data[23]; + control.Toning = result.Data[24]; + control.ToningDensity = result.Data[25]; + //control.Hue = result.Data[27]; + } + control.Sharpening = (sbyte) result.Data[27]; + control.Contrast = (sbyte) result.Data[28]; + control.Brightness = (sbyte) result.Data[29]; + control.CustomCurveFlag = result.Data[30]; + if (control.CustomCurveFlag == 1) + result.Data.CopyTo(control.CustomCurveData, 31); + } + else + { + return null; + } + return control; + } + + public void SetPictureControl(PictureControl control) + { + } + + protected virtual PropertyValue InitHostMode() + { + var res = new PropertyValue() { Name = "Lock", IsEnabled = true }; + res.AddValues("OFF", 0); + res.AddValues("ON", 1); + res.ReloadValues(); + res.Value = "OFF"; + res.ValueChanged += delegate (object sender, string key, long val) + { + ExecuteWithNoData(CONST_CMD_ChangeCameraMode, (uint) (key == "OFF" ? 0 : 1)); + Mode.IsEnabled = key == "ON"; + GetEvent(null); + ReadDeviceProperties(CONST_PROP_ExposureProgramMode); + }; + return res; + } + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + try + { + IsBusy = true; + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + StillImageDevice = deviceDescriptor.StillImageDevice; + // check if is mtp device + StillImageDevice imageDevice = StillImageDevice as StillImageDevice; + if (imageDevice != null) + imageDevice.DeviceEvent += _stillImageDevice_DeviceEvent; + HaveLiveView = true; + DeviceReady(); + DeviceName = StillImageDevice.Model; + Manufacturer = StillImageDevice.Manufacturer; + IsConnected = true; + CaptureInSdRam = true; + PropertyChanged += NikonBase_PropertyChanged; + var ser = StillImageDevice.SerialNumber; + Log.Debug("Serial number" + ser ?? ""); + if (ser != null && ser.Length >= 7) + { + SerialNumber = ser.Substring(0, 7); + // there in some cases the leading zero order differs + if (SerialNumber == "0000000") + { + SerialNumber = ser.Substring(ser.Length-7,7); + } + } + // load advanced properties in a separated thread to speed up camera connection + //var thread = new Thread(LoadProperties) {Priority = ThreadPriority.Lowest}; + //thread.Start(); + LoadProperties(); + //FearL0rd test + Thread thread = new Thread(() => + { + Thread.Sleep(200); + OnCameraInitDone(); + }); + } + catch (Exception exception) + { + Log.Error("Error initialize device", exception); + } + return true; + } + + public void LoadProperties() + { + try + { + InitIso(); + InitShutterSpeed(); + InitFNumber(); + ReadDeviceProperties(CONST_PROP_LiveViewSelector); + InitMode(); + InitWhiteBalance(); + InitExposureCompensation(); + InitCompressionSetting(); + InitExposureMeteringMode(); + InitFocusMode(); + InitOther(); + ReadDeviceProperties(CONST_PROP_BatteryLevel); + ReadDeviceProperties(CONST_PROP_ExposureIndicateStatus); + AddAditionalProps(); + ReInitShutterSpeed(); + ReadDeviceProperties(CONST_PROP_LiveViewStatus); + _timer.Start(); + OnCameraInitDone(); + + } + catch (Exception exception) + { + Log.Error("Error load device properties", exception); + } + IsBusy = false; + } + + public virtual void AddAditionalProps() + { + AdvancedProperties.Add(InitImageSize()); + AdvancedProperties.Add(InitRawQuality()); + AdvancedProperties.Add(InitBurstNumber()); + AdvancedProperties.Add(InitStillCaptureMode()); + AdvancedProperties.Add(InitOnOffProperty("Auto Iso", 0xD054)); + AdvancedProperties.Add(InitFlash()); + AdvancedProperties.Add(InitOnOffProperty("Long exp NR", CONST_PROP_NoiseReduction)); + AdvancedProperties.Add(InitNRHiIso()); + AdvancedProperties.Add(InitExposureDelay()); + AdvancedProperties.Add(InitLock()); + AdvancedProperties.Add(InitPictControl()); + AdvancedProperties.Add(InitRawBit()); + AdvancedProperties.Add(InitColorSpace()); //12 + AdvancedProperties.Add(InitWbTuneFluorescentType()); + AdvancedProperties.Add(InitWbColorTemp()); + AdvancedProperties.Add(InitOnOffProperty("Application mode", CONST_PROP_ApplicationMode)); + AdvancedProperties.Add(InitAutoIsoHight()); + AdvancedProperties.Add(CenterWeightedExRange()); + AdvancedProperties.Add(FlashCompensation()); + AdvancedProperties.Add(FlashSyncSpeed()); + AdvancedProperties.Add(CaptureAreaCrop()); + AdvancedProperties.Add(ActiveDLighting()); + AdvancedProperties.Add(HDRMode()); + AdvancedProperties.Add(HDREv()); + AdvancedProperties.Add(HDRSmoothing()); + AdvancedProperties.Add(ActiveSlot()); + AdvancedProperties.Add(LensSort()); + AdvancedProperties.Add(InitHostMode()); + try + { + var deviceinfo = LoadDeviceData(ExecuteReadDataEx(0x1001)); + foreach (PropertyValue value in AdvancedProperties) + { + if (!deviceinfo.PropertyExist(value.Code)) + value.Available = false; + } + } + catch (Exception ex) + { + Log.Error("Unable to check advanced proprties", ex); + } + foreach (PropertyValue value in AdvancedProperties) + { + ReadDeviceProperties(value.Code); + } + } + + protected virtual PropertyValue LensSort() + { + PropertyValue res = new PropertyValue() + { + Name = "Lens Sort", + IsEnabled = false, + Code = 0xD0E1, + SubType = typeof(sbyte) + }; + res.AddValues("Not mounted", 0); + res.AddValues("CPU lens mounted", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue ActiveSlot() + { + PropertyValue res = new PropertyValue() + { + Name = "Active Slot", + IsEnabled = false, + Code = 0xD1F2, + SubType = typeof(sbyte) + }; + res.AddValues("Card not inserted", 0); + res.AddValues("CF slot", 1); + res.AddValues("SD slot", 2); + res.AddValues("CF slot & SD slot", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue FlashSyncSpeed() + { + PropertyValue res = new PropertyValue() + { + Name = "Flash sync speed", + IsEnabled = true, + Code = 0xD074, + SubType = typeof(sbyte) + }; + res.AddValues("1/320 sec. (auto FP)", 0); + res.AddValues("1/250 sec. (auto FP)", 1); + res.AddValues("1/250 sec.", 2); + res.AddValues("1/200 sec.", 3); + res.AddValues("1/160 sec.", 4); + res.AddValues("1/125 sec.", 5); + res.AddValues("1/100 sec.", 6); + res.AddValues("1/80 sec.", 7); + res.AddValues("1/60 sec.", 8); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue HDRSmoothing() + { + PropertyValue res = new PropertyValue() + { + Name = "HDR intensity", + IsEnabled = true, + Code = 0xD132, + SubType = typeof(sbyte) + }; + res.AddValues("High", 0); + res.AddValues("Normal", 1); + res.AddValues("Low", 2); + res.AddValues("Auto", 3); + res.AddValues("Extra high", 4); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue HDREv() + { + PropertyValue res = new PropertyValue() + { + Name = "HDR Exposure deviation", + IsEnabled = true, + Code = 0xD131, + SubType = typeof(sbyte) + }; + res.AddValues("Auto", 0); + res.AddValues("1 EV", 1); + res.AddValues("2 EV", 2); + res.AddValues("3 EV", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue HDRMode() + { + PropertyValue res = new PropertyValue() + { + Name = "HDRMode", + IsEnabled = true, + Code = 0xD130, + SubType = typeof(sbyte) + }; + res.AddValues("OFF", 0); + res.AddValues("ON (single)", 1); + res.AddValues("ON (sequence)", 2); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + + protected virtual PropertyValue ActiveDLighting() + { + PropertyValue res = new PropertyValue() + { + Name = "Active D-Lighting", + IsEnabled = true, + Code = 0xD14E, + SubType = typeof(sbyte) + }; + res.AddValues("Extra high", 0); + res.AddValues("High", 1); + res.AddValues("Normal", 2); + res.AddValues("Low", 3); + res.AddValues("Not performed", 4); + res.AddValues("Auto", 5); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue CaptureAreaCrop() + { + PropertyValue res = new PropertyValue() + { + Name = "Capture area crop", + IsEnabled = true, + Code = 0xD030, + SubType = typeof(sbyte) + }; + res.AddValues("FX format (36x24)", 0); + res.AddValues("DX format (24x16)", 1); + res.AddValues("5:4 (30x24)", 2); + res.AddValues("1.2x (30x20)", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue FlashCompensation () + { + PropertyValue res = new PropertyValue() + { + Name = "Ext. flash compensation", + IsEnabled = true, + Code = CONST_PROP_FlashCompensation, + SubType = typeof (sbyte) + }; + for (decimal i = -18; i <= 18; i++) + { + if (i > 0) + res.AddValues("+"+Decimal.Round(i/6, 1).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")), (long) i); + else + res.AddValues(Decimal.Round(i / 6, 1).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")), (long)i); + } + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((sbyte)val), res.Code); + return res; + } + + protected virtual PropertyValue CenterWeightedExRange() + { + PropertyValue res = new PropertyValue() + { + Name = "Center-weighted area", + IsEnabled = true, + Code = 0xD059, + SubType = typeof(byte) + }; + res.AddValues("6 mm", 0); + res.AddValues("8 mm", 1); + res.AddValues("10 mm", 2); + res.AddValues("10 mm", 3); + res.AddValues("Average on the entire screen", 4); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + public virtual PropertyValue InitAutoIsoHight() + { + var res = new PropertyValue(); + try + { + DeviceReady(); + byte datasize = 1; + res.Name = "ISO Auto High Limit"; + res.SubType = typeof (byte); + res.Code = CONST_PROP_ISOAutoHighLimit; + res.ValueChanged += + (sender, key, val) => + SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)val }, res.Code); + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ISOAutoHighLimit); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2*datasize) + 5]; + byte defval = result.Data[datasize + 5]; + + foreach (KeyValuePair pair in _autoIsoTable) + { + res.AddValues(pair.Value, pair.Key); + } + res.ReloadValues(); + res.SetValue(defval, false); + } + catch (Exception) + { + } + return res; + } + + + + protected virtual PropertyValue InitColorSpace() + { + PropertyValue res = new PropertyValue() + { + Name = "Color space", + IsEnabled = true, + Code = CONST_PROP_ColorSpace, + SubType = typeof (byte) + }; + res.AddValues("sRGB", 0); + res.AddValues("Adobe RGB", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue InitWbTuneFluorescentType() + { + PropertyValue res = new PropertyValue() + { + Name = "Fluorescent light type", + IsEnabled = WhiteBalance.NumericValue == 5, + Code = CONST_PROP_WbTuneFluorescentType, + SubType = typeof (byte), + DisableIfWrongValue = false + }; + res.AddValues("Sodium lamp mixed light", 0); + res.AddValues("Cool white fluorescent lamp", 1); + res.AddValues("Warm white fluorescent lamp", 2); + res.AddValues("White fluorescent lamp", 3); + res.AddValues("Day white fluorescent lamp", 4); + res.AddValues("Daylight fluorescent lamp", 5); + res.AddValues("High color-temperature mercury lamp", 6); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected virtual PropertyValue InitWbColorTemp() + { + PropertyValue res = new PropertyValue() + { + Name = "Temperature", + IsEnabled = WhiteBalance.NumericValue == 32786, + Code = CONST_PROP_WbColorTemp, + SubType = typeof (byte), + DisableIfWrongValue = false + }; + res.AddValues("2500 K", 0); + res.AddValues("2560 K", 1); + res.AddValues("2630 K", 2); + res.AddValues("2700 K", 3); + res.AddValues("2780 K", 4); + res.AddValues("2860 K", 5); + res.AddValues("2940 K", 6); + res.AddValues("3030 K", 7); + res.AddValues("3130 K", 8); + res.AddValues("3230 K", 9); + res.AddValues("3330 K", 10); + res.AddValues("3450 K", 11); + res.AddValues("3570 K", 12); + res.AddValues("3700 K", 13); + res.AddValues("3850 K", 14); + res.AddValues("4000 K", 15); + res.AddValues("4170 K", 16); + res.AddValues("4350 K", 17); + res.AddValues("4550 K", 18); + res.AddValues("4760 K", 19); + res.AddValues("5000 K", 20); + res.AddValues("5260 K", 21); + res.AddValues("5560 K", 22); + res.AddValues("5880 K", 23); + res.AddValues("6250 K", 24); + res.AddValues("6670 K", 25); + res.AddValues("7140 K", 26); + res.AddValues("7690 K", 27); + res.AddValues("8330 K", 28); + res.AddValues("9090 K", 29); + res.AddValues("10000 K", 30); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected virtual PropertyValue InitRawBit() + { + PropertyValue res = new PropertyValue() + { + Name = "Raw Recording bit mode", + IsEnabled = true, + Code = CONST_PROP_RawCompressionBitMode, + SubType = typeof (byte), + DisableIfWrongValue = true + }; + res.AddValues("12-bit recording", 0); + res.AddValues("14-bit recording", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue InitPictControl() + { + var res = new PropertyValue() + { + Name = "Picture control", + IsEnabled = true, + Code = CONST_PROP_ActivePicCtrlItem, + SubType = typeof(UInt16) + }; + res.AddValues("Standard", 1); + res.AddValues("Neutral", 2); + res.AddValues("Vivid", 3); + res.AddValues("Monochrome", 4); + res.AddValues("Portrait", 5); + res.AddValues("Landscape", 6); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + + try + { + for (byte i = 201; i < 210; i++) + { + PictureControl control = GetPictureControl(i); + if (control != null && (control.IsLoaded && !string.IsNullOrWhiteSpace(control.RegistrationName))) + res.AddValues(control.RegistrationName, i); + else + res.AddValues("Custom picture control " + (i - 200), i); + } + } + catch (Exception) + { + + } + res.ReloadValues(); + return res; + } + + protected virtual PropertyValue InitImageSize() + { + var res = new PropertyValue() {Name = "Image Size", IsEnabled = true, Code = CONST_PROP_ImageSize}; + res.ValueChanged += ImageSize_ValueChanged; + + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, res.Code); + + //ErrorCodes.GetException(result.ErrorCode); + + if (result.Data != null && result.Data.Length > 112) + { + res.AddValues(Encoding.Unicode.GetString(result.Data, 51, 20), 0); + res.AddValues(Encoding.Unicode.GetString(result.Data, 72, 20), 0); + res.AddValues(Encoding.Unicode.GetString(result.Data, 93, 20), 0); + res.SetValue(Encoding.Unicode.GetString(result.Data, 27, 20), false); + } + res.ReloadValues(); + return res; + } + + private void ImageSize_ValueChanged(object sender, string key, long val) + { + if (CompressionSetting != null && + (CompressionSetting.Value != null && CompressionSetting.Value.Contains("RAW"))) + return; + List vals = new List() {10}; + vals.AddRange(Encoding.Unicode.GetBytes(key)); + SetProperty(CONST_CMD_SetDevicePropValue, vals.ToArray(), CONST_PROP_ImageSize); + } + + protected virtual PropertyValue InitRawQuality() + { + PropertyValue res = new PropertyValue() + { + Name = "Raw Compression", + IsEnabled = true, + Code = CONST_PROP_RawCompressionType, + SubType = typeof (byte), + DisableIfWrongValue = true + }; + res.AddValues("Lossless compressed RAW", 0); + res.AddValues("Compressed RAW", 1); + res.AddValues("Uncompressed RAW", 2); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + protected virtual PropertyValue InitOnOffProperty(string name, uint code) + { + var res = new PropertyValue() {Name = name, IsEnabled = true, Code = code}; + res.AddValues("OFF", 0); + res.AddValues("ON", 1); + res.ReloadValues(); + res.ValueChanged += (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) val}, + res.Code); + return res; + } + + protected virtual PropertyValue InitLock() + { + var res = new PropertyValue() {Name = "Lock", IsEnabled = true}; + res.AddValues("OFF", 0); + res.AddValues("ON", 1); + res.ReloadValues(); + res.Value = "OFF"; + res.ValueChanged += delegate(object sender, string key, long val) + { + if (key == "OFF") + { + UnLockCamera(); + } + else + { + LockCamera(); + } + }; + return res; + } + + protected virtual PropertyValue InitFlash() + { + PropertyValue res = new PropertyValue() + {Name = "Flash", IsEnabled = true, Code = 0x500C, SubType = typeof (UInt16)}; + res.AddValues("Flash prohibited", 0x0002); + res.AddValues("Red-eye reduction", 0x0004); + res.AddValues("Normal synchronization", 0x8010); + res.AddValues("Slow synchronization", 0x8011); + res.AddValues("Rear synchronization", 0x8012); + res.AddValues("Red-eye reduction slow synchronization", 0x8013); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected virtual PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof (UInt16) + }; + res.AddValues("Single shot (single-frame shooting)", 0x0001); + res.AddValues("Continuous shot (continuous shooting)", 0x0002); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Quick-response remote", 0x8014); + res.AddValues("2s delayed remote", 0x8015); + res.AddValues("Quiet shooting", 0x8016); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected virtual PropertyValue InitBurstNumber() + { + PropertyValue res = new PropertyValue() + { + Name = "Burst Number", + IsEnabled = true, + Code = 0x5018, + SubType = typeof (UInt16) + }; + for (int i = 1; i < 100; i++) + { + res.AddValues(i.ToString(), i); + } + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + + protected virtual PropertyValue InitNRHiIso() + { + PropertyValue res = new PropertyValue() {Name = "High ISO NR", IsEnabled = true, Code = 0xD070}; + res.AddValues("Not performed", 0); + res.AddValues("Low", 1); + res.AddValues("Normal", 2); + res.AddValues("High", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) val}, res.Code); + return res; + } + + protected virtual PropertyValue InitExposureDelay() + { + PropertyValue res = new PropertyValue() + {Name = "Exposure delay mode", IsEnabled = true, Code = 0xD06A}; + res.AddValues("OFF", 0); + res.AddValues("ON", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) val}, res.Code); + return res; + } + + protected void NikonBase_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == "CaptureInSdRam") + { + SetProperty(CONST_CMD_SetDevicePropValue, CaptureInSdRam ? new[] {(byte) 1} : new[] {(byte) 0}, + CONST_PROP_RecordingMedia); + ReadDeviceProperties(CONST_PROP_RecordingMedia); + } + } + + private void _stillImageDevice_DeviceEvent(object sender, PortableDeviceEventArgs e) + { + if (e.EventType.EventGuid == PortableDeviceGuids.WPD_EVENT_DEVICE_REMOVED) + { + _timer.Stop(); + StillImageDevice.Disconnect(); + StillImageDevice.IsConnected = false; + IsConnected = false; + OnCameraDisconnected(this, new DisconnectCameraEventArgs {StillImageDevice = StillImageDevice}); + } + else + { + Thread thread = new Thread(GetEvent); + thread.Start(); + } + } + + private void InitOther() + { + LiveViewImageZoomRatio = new PropertyValue {Name = "LiveViewImageZoomRatio"}; + LiveViewImageZoomRatio.SubType = typeof(int); + LiveViewImageZoomRatio.AddValues("All", 0); + LiveViewImageZoomRatio.AddValues("25%", 1); + LiveViewImageZoomRatio.AddValues("33%", 2); + LiveViewImageZoomRatio.AddValues("50%", 3); + LiveViewImageZoomRatio.AddValues("66%", 4); + LiveViewImageZoomRatio.AddValues("100%", 5); + LiveViewImageZoomRatio.AddValues("200%", 6); + LiveViewImageZoomRatio.SetValue("All"); + LiveViewImageZoomRatio.ReloadValues(); + LiveViewImageZoomRatio.ValueChanged += LiveViewImageZoomRatio_ValueChanged; + } + + private void LiveViewImageZoomRatio_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_LiveViewImageZoomRatio); + } + } + + protected virtual void InitIso() + { + lock (Locker) + { + NormalIsoNumber = new PropertyValue(); + NormalIsoNumber.Name = "IsoNumber"; + NormalIsoNumber.SubType = typeof (int); + NormalIsoNumber.ValueChanged += IsoNumber_ValueChanged; + NormalIsoNumber.Clear(); + try + { + DeviceReady(); + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_ExposureIndex); + //IsoNumber.IsEnabled = result.Data[4] == 1; + UInt16 defval = BitConverter.ToUInt16(result.Data, 7); + for (int i = 0; i < result.Data.Length - 12; i += 2) + { + UInt16 val = BitConverter.ToUInt16(result.Data, 12 + i); + NormalIsoNumber.AddValues(_isoTable.ContainsKey(val) ? _isoTable[val] : val.ToString(), val); + } + NormalIsoNumber.ReloadValues(); + NormalIsoNumber.SetValue(defval, false); + IsoNumber = NormalIsoNumber; + } + catch (Exception) + { + NormalIsoNumber.IsEnabled = false; + } + + MovieIsoNumber = new PropertyValue(); + MovieIsoNumber.Name = "IsoNumber"; + MovieIsoNumber.SubType = typeof (int); + MovieIsoNumber.ValueChanged += MovieIsoNumber_ValueChanged; + MovieIsoNumber.Clear(); + try + { + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_MovieExposureIndex); + //IsoNumber.IsEnabled = result.Data[4] == 1; + UInt16 defval = BitConverter.ToUInt16(result.Data, 7); + for (int i = 0; i < result.Data.Length - 12; i += 2) + { + UInt16 val = BitConverter.ToUInt16(result.Data, 12 + i); + MovieIsoNumber.AddValues(_isoTable.ContainsKey(val) ? _isoTable[val] : val.ToString(CultureInfo.InvariantCulture), val); + } + MovieIsoNumber.ReloadValues(); + MovieIsoNumber.SetValue(defval, false); + } + catch (Exception) + { + MovieIsoNumber.IsEnabled = false; + } + } + } + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_ExposureIndex); + } + } + + private void MovieIsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_MovieExposureIndex); + } + } + + protected virtual void InitShutterSpeed() + { + NormalShutterSpeed = new PropertyValue(); + NormalShutterSpeed.Name = "ShutterSpeed"; + NormalShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + MovieShutterSpeed = new PropertyValue(); + MovieShutterSpeed.Name = "ShutterSpeed"; + MovieShutterSpeed.ValueChanged += MovieShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_ExposureTime); + } + + private void MovieShutterSpeed_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_MovieShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_MovieShutterSpeed); + } + + protected virtual void ReInitShutterSpeed() + { + lock (Locker) + { + DeviceReady(); + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ExposureTime); + if (result.Data == null) + return; + NormalShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb")) + NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + NormalShutterSpeed.ReloadValues(); + NormalShutterSpeed.SetValue(defval, false); + ShutterSpeed = NormalShutterSpeed; + } + catch (Exception) + { + } + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieShutterSpeed); + if (result.Data == null || result.Data.Length==0) + return; + MovieShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + MovieShutterSpeed.AddValues("1/" + (val-0x10000),val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb")) + MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + + MovieShutterSpeed.SetValue(defval, false); + } + catch (Exception) + { + } + } + } + + private void InitMode() + { + try + { + DeviceReady(); + byte datasize = 2; + Mode = new PropertyValue(); + Mode.SubType = typeof(uint); + Mode.Name = "Mode"; + Mode.IsEnabled = false; + Mode.ValueChanged += Mode_ValueChanged; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ExposureProgramMode); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt16 defval = BitConverter.ToUInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt16 val = BitConverter.ToUInt16(result.Data, ((2 * datasize) + 6 + 2) + i); + Mode.AddValues(_exposureModeTable.ContainsKey(val) ? _exposureModeTable[val] : val.ToString(), val); + } + Mode.ReloadValues(); + Mode.SetValue(defval); + } + catch (Exception) + { + } + } + + + private void Mode_ValueChanged(object sender, string key, long val) + { + try + { + switch (key) + { + case "M": + ShutterSpeed.IsEnabled = true; + NormalFNumber.IsEnabled = true; + //ReInitShutterSpeed(); + break; + case "P": + ShutterSpeed.IsEnabled = false; + FNumber.IsEnabled = false; + break; + case "A": + ShutterSpeed.IsEnabled = false; + NormalFNumber.IsEnabled = true; + break; + case "S": + ShutterSpeed.IsEnabled = true; + FNumber.IsEnabled = false; + //ReInitShutterSpeed(); + break; + default: + ShutterSpeed.IsEnabled = false; + FNumber.IsEnabled = false; + break; + } + if (Mode.IsEnabled) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_ExposureProgramMode); + } + catch (Exception ex) + { + Log.Error("Usable to set camera mode", ex); + } + } + + protected virtual void InitFNumber() + { + NormalFNumber = new PropertyValue {IsEnabled = true, Name = "FNumber"}; + NormalFNumber.ValueChanged += NormalFNumber_ValueChanged; + NormalFNumber.SubType = typeof (int); + MovieFNumber = new PropertyValue { IsEnabled = true, Name = "FNumber" }; + MovieFNumber.ValueChanged += MovieFNumber_ValueChanged; + MovieFNumber.SubType = typeof(int); + ReInitFNumber(false); + } + + private void MovieFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_MovieFnumber); + } + + private void NormalFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_Fnumber); + } + + + protected void ReInitFNumber(bool trigervaluchange) + { + try + { + DeviceReady(); + const byte datasize = 2; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, CONST_PROP_Fnumber); + if (result.Data != null) + { + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2*datasize) + 5]; + UInt16 defval = BitConverter.ToUInt16(result.Data, datasize + 5); + NormalFNumber.Clear(); + for (int i = 0; i < result.Data.Length - ((2*datasize) + 6 + 2); i += datasize) + { + UInt16 val = BitConverter.ToUInt16(result.Data, ((2*datasize) + 6 + 2) + i); + string s = (val/100.0).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")); + NormalFNumber.AddValues(s, val); + } + NormalFNumber.ReloadValues(); + NormalFNumber.SetValue(defval, trigervaluchange); + FNumber = NormalFNumber; + } + else + { + + } + result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, CONST_PROP_MovieFnumber); + if (result.Data != null && result.Data.Length > 0) + { + MovieFNumber.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt16 defval = BitConverter.ToUInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt16 val = BitConverter.ToUInt16(result.Data, ((2 * datasize) + 6 + 2) + i); + string s = (val / 100.0).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")); + MovieFNumber.AddValues(s, val); + } + MovieFNumber.ReloadValues(); + MovieFNumber.SetValue(defval, trigervaluchange); + } + } + catch (Exception) + { + } + } + + private void InitWhiteBalance() + { + try + { + DeviceReady(); + byte datasize = 2; + WhiteBalance = new PropertyValue(); + WhiteBalance.Name = "WhiteBalance"; + WhiteBalance.ValueChanged += WhiteBalance_ValueChanged; + var result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_WhiteBalance); + if (result.Data != null && result.Data.Length > 0) + { + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2*datasize) + 5]; + UInt16 defval = BitConverter.ToUInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2*datasize) + 6 + 2); i += datasize) + { + UInt16 val = BitConverter.ToUInt16(result.Data, ((2*datasize) + 6 + 2) + i); + WhiteBalance.AddValues(_wbTable.ContainsKey(val) ? _wbTable[val] : val.ToString(), val); + } + WhiteBalance.ReloadValues(); + WhiteBalance.SetValue(defval, false); + } + else + { + } + } + catch (Exception ex) + { + Log.Error("Error init white balance", ex); + } + } + + private void WhiteBalance_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) val), + CONST_PROP_WhiteBalance); + if (AdvancedProperties.Count > 13) + AdvancedProperties[13].IsEnabled = val == 5; + if (AdvancedProperties.Count > 14) + AdvancedProperties[14].IsEnabled = val == 32786; + } + + public void InitExposureCompensation() + { + try + { + DeviceReady(); + byte datasize = 2; + NormalExposureCompensation = new PropertyValue(); + NormalExposureCompensation.SubType = typeof(int); + NormalExposureCompensation.Name = "ExposureCompensation"; + NormalExposureCompensation.ValueChanged += ExposureCompensation_ValueChanged; + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ExposureBiasCompensation); + Int16 defval = BitConverter.ToInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2*datasize) + 6 + 2); i += datasize) + { + Int16 val = BitConverter.ToInt16(result.Data, ((2*datasize) + 6 + 2) + i); + decimal d = val; + string s = Decimal.Round(d/1000, 1).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")); + if (d > 0) + s = "+" + s; + NormalExposureCompensation.AddValues(s, val); + } + NormalExposureCompensation.ReloadValues(); + NormalExposureCompensation.SetValue(defval, false); + ExposureCompensation = NormalExposureCompensation; + } + catch (Exception) + { + } + try + { + DeviceReady(); + byte datasize = 2; + MovieExposureCompensation = new PropertyValue(); + MovieExposureCompensation.SubType = typeof(int); + MovieExposureCompensation.Name = "ExposureCompensation"; + MovieExposureCompensation.ValueChanged += MovieExposureCompensation_ValueChanged; + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieExposureBiasCompensation); + Int16 defval = BitConverter.ToInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + Int16 val = BitConverter.ToInt16(result.Data, ((2 * datasize) + 6 + 2) + i); + decimal d = val; + string s = Decimal.Round(d / 1000, 1).ToString("0.0", CultureInfo.CreateSpecificCulture("en-US")); + if (d > 0) + s = "+" + s; + MovieExposureCompensation.AddValues(s, val); + } + MovieExposureCompensation.ReloadValues(); + MovieExposureCompensation.SetValue(defval, false); + } + catch (Exception) + { + } + + } + + + private void MovieExposureCompensation_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_MovieExposureBiasCompensation); + } + } + + private void ExposureCompensation_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + CONST_PROP_ExposureBiasCompensation); + } + } + + protected virtual void InitCompressionSetting() + { + try + { + DeviceReady(); + byte datasize = 1; + CompressionSetting = new PropertyValue(); + CompressionSetting.SubType = typeof(int); + CompressionSetting.Name = "CompressionSetting "; + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_CompressionSetting); + if(result.Data.Length==0) + return; + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + byte defval = result.Data[datasize + 5]; + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + byte val = result.Data[((2 * datasize) + 6 + 2) + i]; + CompressionSetting.AddValues(_csTable.ContainsKey(val) ? _csTable[val] : val.ToString(), val); + } + CompressionSetting.ReloadValues(); + CompressionSetting.SetValue(defval, false); + } + catch (Exception) + { + } + } + + protected void CompressionSetting_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((byte) val), + CONST_PROP_CompressionSetting); + } + + public void InitExposureMeteringMode() + { + try + { + DeviceReady(); + byte datasize = 2; + ExposureMeteringMode = new PropertyValue(); + ExposureMeteringMode.SubType = typeof(int); + ExposureMeteringMode.Name = "ExposureMeteringMode"; + ExposureMeteringMode.ValueChanged += ExposureMeteringMode_ValueChanged; + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_ExposureMeteringMode); + UInt16 defval = BitConverter.ToUInt16(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2*datasize) + 6 + 2); i += datasize) + { + UInt16 val = BitConverter.ToUInt16(result.Data, ((2*datasize) + 6 + 2) + i); + ExposureMeteringMode.AddValues(_emmTable.ContainsKey(val) ? _emmTable[val] : val.ToString(), val); + } + ExposureMeteringMode.ReloadValues(); + ExposureMeteringMode.SetValue(defval, false); + } + catch (Exception) + { + } + } + + private void ExposureMeteringMode_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) val), + CONST_PROP_ExposureMeteringMode); + } + + protected virtual void InitFocusMode() + { + try + { + Log.Debug("InitFocusMode 1"); + DeviceReady(); + NormalFocusMode = new PropertyValue(); + NormalFocusMode.Name = "FocusMode"; + NormalFocusMode.Code = CONST_PROP_AFModeSelect; + NormalFocusMode.IsEnabled = true; + NormalFocusMode.AddValues("AF-S", 0); + NormalFocusMode.AddValues("AF-C", 1); + NormalFocusMode.AddValues("AF-A", 2); + NormalFocusMode.AddValues("MF (hard)", 3); + NormalFocusMode.AddValues("MF (soft)", 4); + NormalFocusMode.ReloadValues(); + NormalFocusMode.ValueChanged += NormalFocusMode_ValueChanged; + FocusMode = NormalFocusMode; + ReadDeviceProperties(NormalFocusMode.Code); + Log.Debug("InitFocusMode 2"); + LiveViewFocusMode = new PropertyValue(); + LiveViewFocusMode.Name = "FocusMode"; + LiveViewFocusMode.Code = CONST_PROP_AfModeAtLiveView; + LiveViewFocusMode.IsEnabled = true; + LiveViewFocusMode.AddValues("AF-S", 0); + LiveViewFocusMode.AddValues("AF-F", 2); + LiveViewFocusMode.AddValues("MF (hard)", 3); + LiveViewFocusMode.AddValues("MF (soft)", 4); + LiveViewFocusMode.ReloadValues(); + LiveViewFocusMode.ValueChanged += LiveViewFocusMode_ValueChanged; + ReadDeviceProperties(LiveViewFocusMode.Code); + Log.Debug("InitFocusMode 3"); + } + catch (Exception exception) + { + Log.Error("Unable to init focus mode property", exception); + } + } + + void LiveViewFocusMode_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((sbyte)val), + CONST_PROP_AfModeAtLiveView); + } + + private void NormalFocusMode_ValueChanged(object sender, string key, long val) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((sbyte) val), + CONST_PROP_AFModeSelect); + } + + public override void StartLiveView() + { + lock (Locker) + { + //DeviceReady(); + //check if the live view already is started if yes returning without doing anything + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + //ErrorCodes.GetException(response.ErrorCode); + if (response.Data != null && response.Data.Length > 0 && response.Data[0] > 0) + return; + DeviceReady(); + // this should improve focus staking performance + // anyway + //LockCamera(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_StartLiveView)); + DeviceReady(); + LiveViewImageZoomRatio.SetValue(); + } + } + + public override void StopLiveView() + { + lock (Locker) + { + DeviceReady(); + //UnLockCamera(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_EndLiveView)); + DeviceReady(); + } + } + + public override LiveViewData GetLiveViewImage() + { + _timer.Stop(); + LiveViewData viewData = new LiveViewData(); + if (Monitor.TryEnter(Locker, 10)) + { + try + { + //DeviceReady(); + viewData.HaveFocusData = true; + + const int headerSize = 384; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + if (result.Data == null || result.Data.Length <= headerSize) + { + _timer.Start(); + viewData.ImageData = null; + return viewData; + } + int cbBytesRead = result.Data.Length; + GetAdditionalLiveViewData(viewData, result.Data); + viewData.ImageDataPosition = 384; + viewData.ImageData = result.Data; + } + finally + { + Monitor.Exit(Locker); + } + } + _timer.Start(); + return viewData; + } + + [Obsolete("Use GetAdditionalLiveViewData instead.", false)] + protected virtual void GetAditionalLIveViewData(LiveViewData viewData, byte[] result) + { + GetAdditionalLiveViewData(viewData, result); + } + + protected virtual void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 0); + viewData.LiveViewImageHeight = ToInt16(result, 2); + + viewData.ImageWidth = ToInt16(result, 4); + viewData.ImageHeight = ToInt16(result, 6); + + viewData.FocusFrameXSize = ToInt16(result, 16); + viewData.FocusFrameYSize = ToInt16(result, 18); + + viewData.FocusX = ToInt16(result, 20); + viewData.FocusY = ToInt16(result, 22); + + viewData.MovieTimeRemain = ToDeciaml(result, 56); + + viewData.Focused = result[40] != 1; + if (result[29] == 1) + viewData.Rotation = -90; + if (result[29] == 2) + viewData.Rotation = 90; + viewData.MovieIsRecording = result[60] == 1; + } + + public override int Focus(int step) + { + if (step == 0) + return 0; + DeviceReady(); + uint resp =(step > 0? ExecuteWithNoData(CONST_CMD_MfDrive, 0x00000002, (uint) step) + : ExecuteWithNoData(CONST_CMD_MfDrive, 0x00000001, (uint) -step)); + ErrorCodes.GetException(resp); + DeviceReady(); + return step; + } + + + public override void Focus(FocusDirection direction, FocusAmount amount) + { + switch (direction) + { + case FocusDirection.Far: + switch (amount) + { + case FocusAmount.Small: + Focus(10); + break; + case FocusAmount.Medium: + Focus(100); + break; + case FocusAmount.Large: + Focus(500); + break; + default: + throw new ArgumentOutOfRangeException(nameof(amount), amount, null); + } + break; + case FocusDirection.Near: + switch (amount) + { + case FocusAmount.Small: + Focus(-10); + break; + case FocusAmount.Medium: + Focus(-100); + break; + case FocusAmount.Large: + Focus(-500); + break; + default: + throw new ArgumentOutOfRangeException(nameof(amount), amount, null); + } + break; + + } + } + + + public override void AutoFocus() + { + lock (Locker) + { + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_AfDrive)); + } + } + + public override void CapturePhoto() + { + SpeedUpEventTimer(); + Monitor.Enter(Locker); + try + { + IsBusy = true; + DeviceReady(); + ErrorCodes.GetException(CaptureInSdRam + ? ExecuteWithNoData(CONST_CMD_AfAndCaptureRecInSdram) + : ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + public override void CapturePhotoNoAf() + { + SpeedUpEventTimer(); + lock (Locker) + { + MTPDataResponse val = null; + byte oldval = 0; + try + { + IsBusy = true; + DeviceReady(); + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + //ErrorCodes.GetException(response.ErrorCode); + // test if live view is on + if (response.Data != null && response.Data.Length > 0 && response.Data[0] > 0) + { + if (CaptureInSdRam) + { + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF)); + return; + } + else + { + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInMedia, 0xFFFFFFFF, 0x0000)); + return; + } + StopLiveView(); + } + + val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect ); + if (val.Data != null && val.Data.Length > 0) + oldval = val.Data[0]; + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 4}, CONST_PROP_AFModeSelect); + DeviceReady(); + ErrorCodes.GetException(CaptureInSdRam + ? ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF) + : ExecuteWithNoData(CONST_CMD_InitiateCapture)); + //DeviceReady(); + } + catch + { + IsBusy = false; + throw; + } + finally + { + //IsBusy = false; + if (val != null && (val.Data != null && val.Data.Length > 0)) + SetProperty(CONST_CMD_SetDevicePropValue, new[] {oldval}, CONST_PROP_AFModeSelect); + } + } + } + + public override void Focus(int x, int y) + { + lock (Locker) + { + //DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_ChangeAfArea, (uint) x, (uint) y)); + } + } + + public override void Close() + { + lock (Locker) + { + try + { + IsConnected = false; + _timer.Stop(); + HaveLiveView = false; + StillImageDevice.Disconnect(); + } + catch (Exception exception) + { + Log.Error("Close camera error", exception); + } + } + } + + + //private byte _liveViewImageZoomRatio; + + //public override PropertyValue LiveViewImageZoomRatio + //{ + // get + // { + // if (_stillImageDevice == null) + // return 0; + // lock (Locker) + // { + // byte[] data = _stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_LiveViewImageZoomRatio, + // -1); + // if (data != null && data.Length == 1) + // { + // _liveViewImageZoomRatio = data[0]; + // ////NotifyPropertyChanged("LiveViewImageZoomRatio"); + // } + // } + // return _liveViewImageZoomRatio; + // } + // set + // { + // lock (Locker) + // { + // if (_stillImageDevice.ExecuteWriteData(CONST_CMD_SetDevicePropValue, new[] {value}, + // CONST_PROP_LiveViewImageZoomRatio, -1) == 0) + // _liveViewImageZoomRatio = value; + // NotifyPropertyChanged("LiveViewImageZoomRatio"); + // } + // } + //} + + public override void ReadDeviceProperties(uint prop) + { + //lock (Locker) + //{ + try + { + HaveLiveView = true; + switch (prop) + { + case CONST_PROP_Fnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_MovieFnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_ExposureIndex: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndex), false); + break; + case CONST_PROP_ExposureIndexEx: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndexEx), false); + break; + case CONST_PROP_MovieExposureIndex: + MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureIndex), false); + break; + case CONST_PROP_ExposureTime: + NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureTime), false); + break; + case CONST_PROP_MovieShutterSpeed: + MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieShutterSpeed), false); + break; + case CONST_PROP_WhiteBalance: + WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_WhiteBalance), false); + break; + case CONST_PROP_ExposureProgramMode: + Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureProgramMode), true); + break; + case CONST_PROP_ExposureBiasCompensation: + NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureBiasCompensation), + false); + break; + case CONST_PROP_MovieExposureBiasCompensation: + MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureBiasCompensation), + false); + break; + + case CONST_PROP_CompressionSetting: + CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_CompressionSetting), + false); + break; + case CONST_PROP_ExposureMeteringMode: + ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureMeteringMode), + false); + break; + case CONST_PROP_AFModeSelect: + NormalFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect), + false); + NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3; + break; + case CONST_PROP_AfModeAtLiveView: + LiveViewFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView), + false); + LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3; + break; + case CONST_PROP_BatteryLevel: + { + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + } + break; + case CONST_PROP_ExposureIndicateStatus: + { + var data = + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndicateStatus); + if (data.Data != null && data.Data.Length > 0) + { + sbyte i = + unchecked( + (sbyte)data.Data[0]); + ExposureStatus = Convert.ToInt32(i); + } + } + break; + case CONST_PROP_LiveViewStatus: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + if (response.Data != null && response.Data.Length > 0 ) + { + LiveViewOn = response.Data[0] == 1; + } + else + { + LiveViewOn = false; + } + break; + } + case CONST_PROP_LiveViewSelector: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewMovieOn = response.Data[0] == 1; + } + else + { + LiveViewMovieOn = false; + } + break; + } + default: + // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs + foreach (PropertyValue advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop)) + { + if (advancedProperty.Name == "Image Size") + { + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code); + if (val.Data != null && val.Data.Length > 0) + { + advancedProperty.SetValue( + Encoding.Unicode.GetString(val.Data, 1, 20), false); + } + } + else + { + advancedProperty.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code), false); + } + } + break; + } + } + catch (Exception ex) + { + Log.Error("ReadDeviceProperties error", ex); + } + //} + } + + public override void LockCamera() + { + ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 1); + Mode.IsEnabled = true; + } + + public override void UnLockCamera() + { + Mode.IsEnabled = false; + ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 0); + } + + public override void StartRecordMovie() + { + base.StartRecordMovie(); + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_StartMovieRecInCard)); + } + + public override void StopRecordMovie() + { + base.StopRecordMovie(); + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_EndMovieRec)); + } + + public override void SetCameraField(CameraFieldType cameraFieldType, string comment) + { + switch (cameraFieldType) + { + case CameraFieldType.Comment: + if (string.IsNullOrEmpty(comment)) + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, 0xD091); + } + else + { + comment = comment.Length > 36 ? comment.Substring(0, 36) : comment.PadRight(36); + List vals = new List(); + List valsnew = new List(); + valsnew.Add(36); + vals.AddRange(Encoding.UTF8.GetBytes(comment)); + foreach (byte val in vals) + { + valsnew.Add(val); + valsnew.Add(0); + } + valsnew.Add(0); + valsnew.Add(0); + SetProperty(CONST_CMD_SetDevicePropValue, valsnew.ToArray(), 0xD090); + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, 0xD091); + } + break; + case CameraFieldType.Artist: + if (string.IsNullOrEmpty(comment)) + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0, (byte) 0, (byte) 0}, 0xD072); + } + else + { + comment = comment.Length > 36 ? comment.Substring(0, 36) : comment.PadRight(36); + List vals = new List(); + List valsnew = new List(); + valsnew.Add(36); + vals.AddRange(Encoding.UTF8.GetBytes(comment)); + foreach (byte val in vals) + { + valsnew.Add(val); + valsnew.Add(0); + } + valsnew.Add(0); + valsnew.Add(0); + SetProperty(CONST_CMD_SetDevicePropValue, valsnew.ToArray(), 0xD072); + } + + break; + case CameraFieldType.Copyright: + if (string.IsNullOrEmpty(comment)) + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0, (byte) 0, (byte) 0}, 0xD073); + } + else + { + comment = comment.Length > 53 ? comment.Substring(0, 53) : comment.PadRight(53); + List vals = new List(); + List valsnew = new List(); + valsnew.Add(54); + vals.AddRange(Encoding.UTF8.GetBytes(comment)); + foreach (byte val in vals) + { + valsnew.Add(val); + valsnew.Add(0); + } + valsnew.Add(0); + valsnew.Add(0); + SetProperty(CONST_CMD_SetDevicePropValue, valsnew.ToArray(), 0xD073); + } + break; + default: + //throw new ArgumentOutOfRangeException("cameraFieldType"); + break; + } + } + + private DateTime _dateTime; + private bool _liveViewOn; + private bool _liveViewMovieOn; + + public override DateTime DateTime + { + get { return _dateTime; } + set + { + _dateTime = value; + try + { + string datestring = _dateTime.ToString("yyyyMMddTHHmmss"); + List vals = new List(); + List valsnew = new List(); + valsnew.Add(16); + vals.AddRange(Encoding.UTF8.GetBytes(datestring)); + foreach (byte val in vals) + { + valsnew.Add(val); + valsnew.Add(0); + } + valsnew.Add(0); + valsnew.Add(0); + SetProperty(CONST_CMD_SetDevicePropValue, valsnew.ToArray(), CONST_PROP_DateTime); + } + catch (Exception exception) + { + Log.Error("Error set camera DateTime", exception); + } + NotifyPropertyChanged("DateTime"); + } + } + + private void GetEvent(object state) + { + try + { + if (_eventIsbusy) + return; + _eventIsbusy = true; + //DeviceReady(); + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetEvent); + + if (response.Data == null || response.Data.Length == 0) + { + Log.Debug("Get event error :" + response.ErrorCode.ToString("X")); + _eventIsbusy = false; + return; + } + int eventCount = BitConverter.ToInt16(response.Data, 0); + if (eventCount > 0) + { + for (int i = 0; i < eventCount; i++) + { + try + { + uint eventCode = BitConverter.ToUInt16(response.Data, 6*i + 2); + ushort eventParam = BitConverter.ToUInt16(response.Data, 6*i + 4); + int longeventParam = BitConverter.ToInt32(response.Data, 6*i + 4); + switch (eventCode) + { + case CONST_Event_DevicePropChanged: + ReadDeviceProperties(eventParam); + break; + case CONST_Event_ObjectAddedInSdram: + case CONST_Event_ObjectAdded: + { + Log.Debug("CONST_Event_ObjectAddedInSdram" + eventCode.ToString("X")); + MTPDataResponse objectdata = ExecuteReadDataEx(CONST_CMD_GetObjectInfo, + (uint) longeventParam); + string filename = "DSC_0000.JPG"; + if (objectdata.Data != null) + { + filename = Encoding.Unicode.GetString(objectdata.Data, 53, 12*2); + if (filename.Contains("\0")) + filename = filename.Split('\0')[0]; + } + else + { + Log.Error("Error getting file name"); + } + Log.Debug("File name" + filename); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = + new PortableDeviceEventArgs(new PortableDeviceEventType + () + { + ObjectHandle + = + ( + uint + ) + longeventParam + }), + CameraDevice = this, + FileName = filename, + Handle = (uint) longeventParam + }; + OnPhotoCapture(this, args); + } + break; + case CONST_Event_CaptureComplete: + case CONST_Event_CaptureCompleteRecInSdram: + { + SlowDownEventTimer(); + OnCaptureCompleted(this, new EventArgs()); + } + break; + case CONST_Event_ObsoleteEvent: + break; + default: + //Console.WriteLine("Unknown event code " + eventCode.ToString("X")); + Log.Debug("Unknown event code :" + eventCode.ToString("X") + "|" + + longeventParam.ToString("X")); + break; + } + } + catch (Exception exception) + { + Log.Error("Event queue processing error ", exception); + } + } + } + } + catch (InvalidComObjectException) + { + //return; + } + catch (Exception) + { + //Log.Error("Event exception ", exception); + } + _eventIsbusy = false; + _timer.Start(); + } + + public void DeviceReady() + { + DeviceReady(0); + } + + public void ResetTimer() + { + _timer.Stop(); + _timer.Start(); + } + + public void DeviceReady(int retrynum) + { + //uint cod = Convert.ToUInt32(_stillImageDevice.ExecuteWithNoData(CONST_CMD_DeviceReady)); + while (true) + { + if (retrynum > 50) + return; + ulong cod = (ulong)ExecuteWithNoData(CONST_CMD_DeviceReady); + if (cod != 0 && cod != ErrorCodes.MTP_OK) + { + if (cod == ErrorCodes.MTP_Device_Busy || cod == 0x800700AA) + { + Console.WriteLine("Device not ready"); + Thread.Sleep(5); + retrynum++; + } + else + { + Console.WriteLine("Device ready code #0" + cod.ToString("X")); + return; + } + } + else + { + return; + } + + } + } + + public override void FormatStorage(object storageId) + { + DeviceReady(); + base.FormatStorage(storageId); + } + + public override void ResetDevice() + { + StillImageDevice imageDevice = StillImageDevice as StillImageDevice; + if (imageDevice != null) + { + var resp= imageDevice.ResetDevice(); + Console.WriteLine(resp.ToString("X")); + } + } + + public override string GetProhibitionCondition(OperationEnum operationEnum) + { + switch (operationEnum) + { + case OperationEnum.Capture: + return ""; + case OperationEnum.RecordMovie: + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, 0xD0A4); + if (response.Data != null && response.Data.Length > 0) + { + Int32 resp = BitConverter.ToInt32(response.Data, 0); + if (resp == 0) + return string.Empty; + if (StaticHelper.GetBit(resp, 0)) + return "LabelNoCardInserted"; + if (StaticHelper.GetBit(resp, 1)) + return "LabelCardError"; + if (StaticHelper.GetBit(resp, 2)) + return "LabelCardNotFormatted"; + if (StaticHelper.GetBit(resp, 3)) + return "LabelNoFreeAreaInCard"; + if (StaticHelper.GetBit(resp, 7)) + return "LabelCardBufferNotEmpty"; + if (StaticHelper.GetBit(resp, 8)) + return "LabelPcBufferNotEmpty"; + if (StaticHelper.GetBit(resp, 9)) + return "LabelBufferNotEmpty"; + if (StaticHelper.GetBit(resp, 10)) + return "LabelRecordInProgres"; + if (StaticHelper.GetBit(resp, 11)) + return "LabelCardProtected"; + if (StaticHelper.GetBit(resp, 12)) + return "LabelDuringEnlargedDisplayLiveView"; + if (StaticHelper.GetBit(resp, 13)) + return "LabelWrongLiveViewType"; + if (StaticHelper.GetBit(resp, 14)) + return ""; + //return "LabelNotInApplicationMode"; + } + return ""; + case OperationEnum.AutoFocus: + if (FocusMode != null && FocusMode.Value != null && FocusMode.Value.Contains("[M]")) + return "LabelMFError"; + // check if not Single AF servo + return ""; + case OperationEnum.ManualFocus: + if (FocusMode != null && FocusMode.Value != null && FocusMode.Value.Contains("[M]")) + return "LabelMFError"; + MTPDataResponse responselFocus = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, 0xD061); + if (responselFocus != null && (responselFocus.Data != null && responselFocus.Data.Length > 0)) + { + var resp = responselFocus.Data[0]; + if (resp == 2) + return "LabelNotAFSError"; + } + // check if not Single AF servo + return ""; + case OperationEnum.LiveView: + MTPDataResponse responsel = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, 0xD1A4); + if (responsel.Data != null && responsel.Data.Length > 0) + { + Int32 resp = BitConverter.ToInt32(responsel.Data, 0); + if (resp == 0) + return string.Empty; + if (StaticHelper.GetBit(resp, 0)) + return "LabelDestinationCardError"; + if (StaticHelper.GetBit(resp, 2)) + return "LabelSequenceError"; + if (StaticHelper.GetBit(resp, 4)) + return "LabelFullyPressedButtonError"; + if (StaticHelper.GetBit(resp, 5)) + return "LabelApertureValueError"; + if (StaticHelper.GetBit(resp, 6)) + return "LabelBulbError"; + if (StaticHelper.GetBit(resp, 7)) + return "LabelDuringCleaningMirror"; + if (StaticHelper.GetBit(resp, 8)) + return "LabelDuringInsufficiencyBattery"; + if (StaticHelper.GetBit(resp, 9)) + return "LabelTTLError"; + if (StaticHelper.GetBit(resp, 11)) + return "LabelNonCPULEnseError"; + if (StaticHelper.GetBit(resp, 12)) + return "LabelImageInRAM"; + if (StaticHelper.GetBit(resp, 13)) + return "LabelMirrorUpError2"; + if (StaticHelper.GetBit(resp, 14)) + return "LabelNoCardInsertedError"; + if (StaticHelper.GetBit(resp, 15)) + return "LabelCommandProcesingError"; + if (StaticHelper.GetBit(resp, 16)) + return "LabelShoutingInProgress"; + if (StaticHelper.GetBit(resp, 17)) + return "LabelOverHeatedError"; + if (StaticHelper.GetBit(resp, 18)) + return "LabelCardProtectedError"; + if (StaticHelper.GetBit(resp, 19)) + return "LabelCardError"; + if (StaticHelper.GetBit(resp, 20)) + return "LabelCardNotFormatted"; + if (StaticHelper.GetBit(resp, 21)) + return "LabelBulbError"; + if (StaticHelper.GetBit(resp, 22)) + return "LabelMirrorUpError"; + } + return ""; + default: + throw new ArgumentOutOfRangeException("operationEnum"); + } + } + + public override AsyncObservableCollection GetObjects(object storageId, bool loadThumbs) + { + DeviceReady(); + return base.GetObjects(storageId, loadThumbs); + } + + public override void TransferFileThumb(object o, string filename) + { + lock (Locker) + { + + using (var fs = File.Open(filename, FileMode.Create)) + { + MTPDataResponse result = StillImageDevice.ExecuteReadBigData(CONST_CMD_GetLargeThumb,fs, + (total, current) => + { + double i = (double) current/total; + TransferProgress = + Convert.ToUInt32(i*100); + }, Convert.ToUInt32(o)); + if (result.Data != null) + fs.Write(result.Data, 0, result.Data.Length); + } + _timer.Start(); + TransferProgress = 0; + } + } + + public override string ToStringCameraData() + { + StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................Nikon(" + ")"); + c.AppendFormat("\n\tLiveView:"); + c.AppendFormat("\n\t On..................{0}", LiveViewOn ? "Yes" : "No"); + c.AppendFormat("\n\t Focus Mode..........{0}", LiveViewFocusMode); + c.AppendFormat("\n\tNormal:"); + c.AppendFormat("\n\t Focus Mode..........{0}", NormalFocusMode); + c.AppendFormat("\n\texposure..............{0} f{1} +/-{2}, ISO{3}", + NormalShutterSpeed, + NormalFNumber, + NormalExposureCompensation, + NormalIsoNumber); + + return c.ToString(); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD300.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD300.cs new file mode 100644 index 0000000..92595b9 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD300.cs @@ -0,0 +1,126 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD300 : NikonD3X + { + public const int CONST_PROP_LiveViewMode = 0xD1A0; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + var res = base.Init(deviceDescriptor); + Capabilities.Remove(CapabilityEnum.CaptureNoAf); + return res; + } + + public override void StartLiveView() + { + if (!CaptureInSdRam) + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_RecordingMedia); + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_LiveViewMode); + base.StartLiveView(); + } + + public override void StopLiveView() + { + base.StopLiveView(); + if (!CaptureInSdRam) + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, CONST_PROP_RecordingMedia); + DeviceReady(); + } + + public override void CapturePhotoNoAf() + { + lock (Locker) + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus ); + ErrorCodes.GetException(response.ErrorCode); + // test if live view is on + if (response.Data != null && response.Data.Length > 0 && response.Data[0] > 0) + { + if (CaptureInSdRam) + { + DeviceReady(); + ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, + 0xFFFFFFFF)); + return; + } + StopLiveView(); + } + + DeviceReady(); + byte oldval = 0; + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect ); + if (val.Data != null && val.Data.Length > 0) + oldval = val.Data[0]; + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 4}, CONST_PROP_AFModeSelect); + DeviceReady(); + ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCapture)); + if (val.Data != null && val.Data.Length > 0) + SetProperty(CONST_CMD_SetDevicePropValue, new[] {oldval}, CONST_PROP_AFModeSelect); + } + } + + protected override PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof (UInt16) + }; + res.AddValues("Single shot (single-frame shooting)", 0x0001); + res.AddValues("Continuous high-speed shooting (CH)", 0x0002); + res.AddValues("Continuous low-speed shooting (CL)", 0x8010); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Mirror-up", 0x8012); + res.AddValues("Quiet shooting", 0x8016); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected override void InitFocusMode() + { + base.InitFocusMode(); + FocusMode.IsEnabled = false; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD3200.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3200.cs new file mode 100644 index 0000000..fe900e6 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3200.cs @@ -0,0 +1,110 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Runtime.InteropServices; +using System.Threading; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD3200 : NikonBase + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + CaptureInSdRam = false; + //PropertyChanged -= NikonBase_PropertyChanged; + return res; + } + + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + DeviceReady(); + ErrorCodes.GetException(CaptureInSdRam + ? ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF) + : ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + protected override void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 8); + viewData.LiveViewImageHeight = ToInt16(result, 10); + + viewData.ImageWidth = ToInt16(result, 12); + viewData.ImageHeight = ToInt16(result, 14); + + viewData.FocusFrameXSize = 800; + viewData.FocusFrameYSize = 800; + + viewData.FocusX = ToInt16(result, 20); + viewData.FocusY = ToInt16(result, 22); + + viewData.Focused = result[40] != 1; + } + + public override void StartRecordMovie() + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)1 }, CONST_PROP_ApplicationMode); + base.StartRecordMovie(); + } + + public override void StopRecordMovie() + { + base.StopRecordMovie(); + SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)0 }, CONST_PROP_ApplicationMode); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X.cs new file mode 100644 index 0000000..828d1e7 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X.cs @@ -0,0 +1,81 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.IO; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD3X : NikonBase + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool ret = base.Init(deviceDescriptor); + Capabilities.Add(CapabilityEnum.LiveView); + return ret; + } + + public override LiveViewData GetLiveViewImage() + { + LiveViewData viewData = new LiveViewData(); + viewData.HaveFocusData = true; + + const int headerSize = 64; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + if (result.Data == null || result.Data.Length <= headerSize) + return null; + int cbBytesRead = result.Data.Length; + GetAdditionalLiveViewData(viewData, result.Data); + + MemoryStream copy = new MemoryStream((int) cbBytesRead - headerSize); + copy.Write(result.Data, headerSize, (int)cbBytesRead - headerSize); + copy.Close(); + viewData.ImageData = copy.GetBuffer(); + + return viewData; + } + + protected override void InitFocusMode() + { + base.InitFocusMode(); + FocusMode.IsEnabled = false; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X00Base.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X00Base.cs new file mode 100644 index 0000000..cc114d5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD3X00Base.cs @@ -0,0 +1,603 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Threading; +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD3X00Base : NikonD800 + { + public NikonD3X00Base() + { + + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4650, "18000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "32000"}, + {0x8ca0, "36000"}, + {0x9c40, "40000"}, + {0xC800, "51200"}, + {0xFA00, "Hi 0.3"}, + {0x11940, "Hi 0.5"}, + {0x13d30, "Hi 0.7"}, + {0x19000, "Hi 1"}, + {0x32000, "Hi 2"}, + {0x64000, "Hi 3"}, + {0xC8320, "Hi 4"}, + {0x190640, "Hi 5"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "16000"}, + {26, "18000"}, + {27, "20000"}, + {28, "25600"}, + {29, "32000"}, + {30, "36000"}, + {31, "40000"}, + {32, "51200"}, + {33, "Hi 0.3"}, + {34, "Hi 0.5"}, + {35, "Hi 0.7"}, + {36, "Hi 1"}, + {37, "Hi 2"}, + {38, "Hi 3"}, + {39, "Hi 4"}, + {40, "Hi 5"}, + }; + + _shutterTable = new Dictionary + { + {0x00011f40, "1/8000"}, + {0x00011900, "1/6400"}, + {0x00011770, "1/6000"}, + {0x00011388, "1/5000"}, + {0x00010FA0, "1/4000"}, + {0x00010C80, "1/3200"}, + {0x000109C4, "1/2500"}, + {0x000107d0, "1/2000"}, + {0x00010640, "1/1600"}, + {0x000104e2, "1/1250"}, + {0x000103e8, "1/1000"}, + {0x00010320, "1/800"}, + {0x000102ee, "1/750"}, + {0x00010280, "1/640"}, + {0x000101f4, "1/500"}, + {0x00010190, "1/400"}, + {0x0001015e, "1/350"}, + {0x00010140, "1/320"}, + {0x000100fa, "1/250"}, + {0x000100c8, "1/200"}, + {0x000100b4, "1/180"}, + {0x000100a0, "1/160"}, + {0x0001007d, "1/125"}, + {0x00010064, "1/100"}, + {0x0001005a, "1/90"}, + {0x00010050, "1/80"}, + {0x0001003c, "1/60"}, + {0x00010032, "1/50"}, + {0x0001002d, "1/45"}, + {0x00010028, "1/40"}, + {0x0001001e, "1/30"}, + {0x00010019, "1/25"}, + {0x00010014, "1/20"}, + {0x0001000f, "1/15"}, + {0x0001000d, "1/13"}, + {0x0001000a, "1/10"}, + {0x00010008, "1/8"}, + {0x00010006, "1/6"}, + {0x00010005, "1/5"}, + {0x00010004, "1/4"}, + {0x00010003, "1/3"}, + {0x000a0019, "1/2.5"}, + {0x00010002, "1/2"}, + {0x000a0010, "1/1.6"}, + {0x000a000f, "1/1.5"}, + {0x000a000d, "1/1.3"}, + {0x00010001, "1s"}, + {0x000d000a, "1.3s"}, + {0x000f000a, "1.5s"}, + {0x0010000a, "1.6s"}, + {0x00020001, "2s"}, + {0x0019000a, "2.5s"}, + {0x00030001, "3s"}, + {0x00040001, "4s"}, + {0x00050001, "5s"}, + {0x00060001, "6s"}, + {0x00080001, "8s"}, + {0x000a0001, "10s"}, + {0x000d0001, "13s"}, + {0x000f0001, "15s"}, + {0x00140001, "20s"}, + {0x00190001, "25s"}, + {0x001e0001, "30s"}, + {0xFFFFFFFF, "Bulb"}, + {0xFFFFFFFD, "Time"}, + {0xFFFFFFFE, "Flash Sync"}, + }; + } + + + public override LiveViewData GetLiveViewImage() + { + LiveViewData viewData = new LiveViewData(); + if (Monitor.TryEnter(Locker, 10)) + { + try + { + //DeviceReady(); + viewData.HaveFocusData = true; + + const int headerSize = 384; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + if (result.Data == null || result.Data.Length <= headerSize) + return null; + GetAdditionalLiveViewData(viewData, result.Data); + viewData.ImageDataPosition = headerSize; + viewData.ImageData = result.Data; + } + finally + { + Monitor.Exit(Locker); + } + } + return viewData; + } + + protected override void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 8); + viewData.LiveViewImageHeight = ToInt16(result, 10); + + viewData.ImageWidth = ToInt16(result, 12); + viewData.ImageHeight = ToInt16(result, 14); + + viewData.FocusFrameXSize = ToInt16(result, 24); + viewData.FocusFrameYSize = ToInt16(result, 26); + + viewData.FocusX = ToInt16(result, 28); + viewData.FocusY = ToInt16(result, 30); + + viewData.Focused = result[48] != 1; + viewData.MovieIsRecording = result[68] == 1; + viewData.MovieTimeRemain = ToDeciaml(result, 64); + + if (result[37] == 1) + viewData.Rotation = -90; + if (result[37] == 2) + viewData.Rotation = 90; + + viewData.HaveLevelAngleData = true; + viewData.LevelAngleRolling = ToInt16(result, 52); + viewData.LevelAnglePitching = ToInt16(result, 56); + viewData.LevelAngleYawing = ToInt16(result, 60); + viewData.PeakSoundL = (int)(result[352] / 14.0 * 100); + viewData.PeakSoundR = (int)(result[353] / 14.0 * 100); + viewData.SoundL = (int)(result[354] / 14.0 * 100); + viewData.SoundR = (int)(result[355] / 14.0 * 100); + viewData.HaveSoundData = true; + } + + + protected override PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof(UInt16) + }; + res.AddValues("Single shot (single-frame shooting)", 0x0001); + res.AddValues("Continuous high-speed shooting (CH)", 0x0002); + res.AddValues("Continuous low-speed shooting (CL)", 0x8010); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Mirror-up", 0x8012); + res.AddValues("Quiet shooting", 0x8016); + res.AddValues("Remote control", 0x8017); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected override PropertyValue InitExposureDelay() + { + + PropertyValue res = new PropertyValue() + { + Name = "Exposure delay mode", + IsEnabled = true, + Code = 0xD06A + }; + res.AddValues("3 sec", 0); + res.AddValues("2 sec", 1); + res.AddValues("1 sec", 2); + res.AddValues("OFF", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)val }, res.Code); + return res; + } + + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_ExposureIndexEx); + } + } + + private void MovieIsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_MovieExposureIndex); + } + } + + protected override void InitShutterSpeed() + { + NormalShutterSpeed = new PropertyValue(); + NormalShutterSpeed.Name = "ShutterSpeed"; + NormalShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + MovieShutterSpeed = new PropertyValue(); + MovieShutterSpeed.Name = "ShutterSpeed"; + MovieShutterSpeed.ValueChanged += MovieShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_ShutterSpeed); + } + + private void MovieShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_MovieShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_MovieShutterSpeed); + } + + protected override void ReInitShutterSpeed() + { + lock (Locker) + { + DeviceReady(); + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ShutterSpeed); + if (result.Data == null) + return; + NormalShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb")) + NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + NormalShutterSpeed.ReloadValues(); + NormalShutterSpeed.SetValue(defval, false); + ShutterSpeed = NormalShutterSpeed; + } + catch (Exception) + { + } + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieShutterSpeed); + if (result.Data == null || result.Data.Length == 0) + return; + MovieShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + MovieShutterSpeed.AddValues("1/" + (val - 0x10000), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb")) + MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + + MovieShutterSpeed.SetValue(defval, false); + } + catch (Exception) + { + } + } + } + public override void ReadDeviceProperties(uint prop) + { + //lock (Locker) + //{ + try + { + HaveLiveView = true; + switch (prop) + { + case CONST_PROP_Fnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_MovieFnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + //case CONST_PROP_ExposureIndex: + // NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureIndex), false); + // break; + case CONST_PROP_ExposureIndexEx: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndexEx), false); + break; + case CONST_PROP_MovieExposureIndex: + MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureIndex), false); + break; + //case CONST_PROP_ExposureTime: + // NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureTime), false); + // break; + case CONST_PROP_ShutterSpeed: + NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ShutterSpeed), false); + break; + case CONST_PROP_MovieShutterSpeed: + MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieShutterSpeed), false); + break; + case CONST_PROP_WhiteBalance: + WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_WhiteBalance), false); + break; + case CONST_PROP_ExposureProgramMode: + Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureProgramMode), true); + break; + case CONST_PROP_ExposureBiasCompensation: + NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureBiasCompensation), + false); + break; + case CONST_PROP_MovieExposureBiasCompensation: + MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureBiasCompensation), + false); + break; + + case CONST_PROP_CompressionSetting: + CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_CompressionSetting), + false); + break; + case CONST_PROP_ExposureMeteringMode: + ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureMeteringMode), + false); + break; + case CONST_PROP_AFModeSelect: + NormalFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect), + false); + NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3; + break; + case CONST_PROP_AfModeAtLiveView: + LiveViewFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView), + false); + LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3; + break; + case CONST_PROP_BatteryLevel: + { + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + } + break; + case CONST_PROP_ExposureIndicateStatus: + { + var data = + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndicateStatus); + if (data.Data != null && data.Data.Length > 0) + { + sbyte i = + unchecked( + (sbyte)data.Data[0]); + ExposureStatus = Convert.ToInt32(i); + } + } + break; + case CONST_PROP_LiveViewStatus: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewOn = response.Data[0] == 1; + } + else + { + LiveViewOn = false; + } + break; + } + case CONST_PROP_LiveViewSelector: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewMovieOn = response.Data[0] == 1; + } + else + { + LiveViewMovieOn = false; + } + break; + } + default: + // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs + foreach (PropertyValue advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop)) + { + if (advancedProperty.Name == "Image Size") + { + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code); + if (val.Data != null && val.Data.Length > 0) + { + advancedProperty.SetValue( + Encoding.Unicode.GetString(val.Data, 1, 20), false); + } + } + else + { + advancedProperty.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code), false); + } + } + break; + } + } + catch (Exception ex) + { + Log.Error("ReadDeviceProperties error", ex); + } + //} + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD4.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD4.cs new file mode 100644 index 0000000..1886f69 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD4.cs @@ -0,0 +1,119 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD4 : NikonBase + { + public const int CONST_CMD_TerminateCapture = 0x920C; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.Bulb); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + return res; + } + + public override void StartBulbMode() + { + DeviceReady(); + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 1); + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) 0x0001), + CONST_PROP_ExposureProgramMode); + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt32) 0xFFFFFFFF), + CONST_PROP_ExposureTime); + + ErrorCodes.GetException(CaptureInSdRam + ? StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInMedia, + 0xFFFFFFFF, + 0x0001) + : StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInMedia, + 0xFFFFFFFF, + 0x0000)); + } + + public override void EndBulbMode() + { + lock (Locker) + { + DeviceReady(); + ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_TerminateCapture, 0, 0)); + DeviceReady(); + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 0); + } + } + + public override void LockCamera() + { + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 1); + } + + public override void UnLockCamera() + { + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 0); + } + + protected override PropertyValue InitExposureDelay() + { + PropertyValue res = new PropertyValue() + {Name = "Exposure delay mode", IsEnabled = true, Code = 0xD06A}; + res.AddValues("3 sec", 0); + res.AddValues("2 sec", 1); + res.AddValues("One sec", 1); + res.AddValues("OFF", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) val}, res.Code); + return res; + } + + public override void StartRecordMovie() + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_ApplicationMode); + base.StartRecordMovie(); + } + + public override void StopRecordMovie() + { + base.StopRecordMovie(); + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, CONST_PROP_ApplicationMode); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD40.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD40.cs new file mode 100644 index 0000000..9b9c2d0 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD40.cs @@ -0,0 +1,116 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD40 : NikonBase + { + public NikonD40() { + + + _csTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (NORMAL)"}, + {2, "JPEG (FINE)"}, + {3, "RAW"}, + {4, "RAW + JPEG (BASIC)"}, + {5, "RAW + JPEG (NORMAL)"}, + {6, "RAW + JPEG (FINE)"} + }; + } + + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + //Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Clear(); + HaveLiveView = false; + CaptureInSdRam = false; + + return res; + } + + public override void ReadDeviceProperties(uint prop) + { + base.ReadDeviceProperties(prop); + HaveLiveView = false; + } + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + protected override PropertyValue InitPictControl() + { + var res = new PropertyValue() + { + Name = "Picture control", + IsEnabled = false, + Code = CONST_PROP_ActivePicCtrlItem, + SubType = typeof(UInt16) + }; + return res; + } + + + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD5.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5.cs new file mode 100644 index 0000000..261f35e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5.cs @@ -0,0 +1,121 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD5 : NikonD500 + { + public NikonD5() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4650, "18000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "32000"}, + {0x8ca0, "36000"}, + {0x9c40, "40000"}, + {0xC800, "51200"}, + {0xFA00, "64000"}, + {0x11940, "72000"}, + {0x13d30, "81200"}, + {0x19000, "102400"}, + {0x1F400, "Hi 0.3"}, + {0x23280, "Hi 0.5"}, + {0x278d0, "Hi 0.7"}, + {0x32000, "Hi 1"}, + {0x64000, "Hi 2"}, + {0xC8320, "Hi 3"}, + {0x190640, "Hi 4"}, + {0x320c80, "Hi 5"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "16000"}, + {26, "18000"}, + {27, "20000"}, + {28, "25600"}, + {29, "32000"}, + {30, "36000"}, + {31, "40000"}, + {32, "51200"}, + {33, "64000"}, + {34, "72000"}, + {35, "81200"}, + {36, "102400"}, + {37, "Hi 0.3"}, + {38, "Hi 0.5"}, + {39, "Hi 0.7"}, + {40, "Hi 1"}, + {41, "Hi 2"}, + {42, "Hi 3"}, + {43, "Hi 4"}, + {44, "Hi 5"}, + }; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD500.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD500.cs new file mode 100644 index 0000000..0d39cf6 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD500.cs @@ -0,0 +1,158 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD500 : NikonD600Base + { + public NikonD500() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4650, "18000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "32000"}, + {0x8ca0, "36000"}, + {0x9c40, "40000"}, + {0xC800, "51200"}, + {0xFA00, "Hi 0.3"}, + {0x11940, "Hi 0.5"}, + {0x13d30, "Hi 0.7"}, + {0x19000, "Hi 1"}, + {0x32000, "Hi 2"}, + {0x64000, "Hi 3"}, + {0xC8320, "Hi 4"}, + {0x190640, "Hi 5"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "16000"}, + {26, "18000"}, + {27, "20000"}, + {28, "25600"}, + {29, "32000"}, + {30, "36000"}, + {31, "40000"}, + {32, "51200"}, + {33, "Hi 0.3"}, + {34, "Hi 0.5"}, + {35, "Hi 0.7"}, + {36, "Hi 1"}, + {37, "Hi 2"}, + {38, "Hi 3"}, + {39, "Hi 4"}, + {40, "Hi 5"}, + }; + } + + protected override void InitCompressionSetting() + { + _csTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (BASIC*)"}, + {2, "JPEG (NORMAL)"}, + {3, "JPEG (NORMAL*)"}, + {4, "JPEG (FINE)"}, + {5, "JPEG (FINE*)"}, + {6, "TIFF (RGB)"}, + {7, "RAW"}, + {8, "RAW + JPEG (BASIC)"}, + {9, "RAW + JPEG (BASIC*)"}, + {10, "RAW + JPEG (NORMAL)"}, + {11, "RAW + JPEG (NORMAL*)"}, + {12, "RAW + JPEG (FINE)"}, + {13, "RAW + JPEG (FINE*)"} + }; + base.InitCompressionSetting(); + } + + protected override PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof(UInt16) + }; + res.AddValues("Single frame (S)", 0x0001); + res.AddValues("Continuous low speed (CL)", 0x8010); + res.AddValues("Continuous high speed (CH)", 0x0002); + res.AddValues("Quiet shutter-release (Q)", 0x8016); + res.AddValues("Quiet continuous shutter-release (QC)", 0x8018); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Mirror up", 0x8012); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD5100.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5100.cs new file mode 100644 index 0000000..ed38947 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5100.cs @@ -0,0 +1,66 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD5100 : NikonBase + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + //Capabilities.Add(CapabilityEnum.Bulb); + return res; + } + + //public override void StartLiveView() + //{ + // //SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)1 }, CONST_PROP_RecordingMedia, -1); + // //DeviceReady(); + // base.StartLiveView(); + //} + + //public override void StopLiveView() + //{ + // base.StopLiveView(); + // DeviceReady(); + // //SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)0 }, CONST_PROP_RecordingMedia, -1); + // DeviceReady(); + //} + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD5200.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5200.cs new file mode 100644 index 0000000..9356d56 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD5200.cs @@ -0,0 +1,60 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD5200 : NikonD600Base + { + protected override PropertyValue InitExposureDelay() + { + + PropertyValue res = new PropertyValue() + { + Name = "Exposure delay mode", + IsEnabled = true, + Code = 0xD06A + }; + res.AddValues("OFF", 0); + res.AddValues("1 sec", 1); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)val }, res.Code); + return res; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD60.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD60.cs new file mode 100644 index 0000000..c633682 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD60.cs @@ -0,0 +1,92 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD60 : NikonBase + { + protected new Dictionary _csTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (NORMAL)"}, + {2, "JPEG (FINE)"}, + {3, "RAW"}, + {4, "RAW + JPEG (BASIC)"}, + }; + + + protected override void InitCompressionSetting() + { + try + { + byte datasize = 1; + CompressionSetting = new PropertyValue(); + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_CompressionSetting); + byte defval = result.Data[datasize + 5]; + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + byte val = result.Data[((2 * datasize) + 6 + 2) + i]; + CompressionSetting.AddValues(_csTable.ContainsKey(val) ? _csTable[val] : val.ToString(), val); + } + CompressionSetting.ReloadValues(); + CompressionSetting.SetValue(defval); + } + catch (Exception) + { + } + } + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + Capabilities.Add(CapabilityEnum.CaptureInRam); + HaveLiveView = false; + CaptureInSdRam = false; + PropertyChanged -= NikonBase_PropertyChanged; + return res; + } + + public override void ReadDeviceProperties(uint prop) + { + base.ReadDeviceProperties(prop); + HaveLiveView = false; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD600.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD600.cs new file mode 100644 index 0000000..ec48fb0 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD600.cs @@ -0,0 +1,426 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD600 : NikonD600Base + { + public NikonD600() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x2328, "Hi 0.5"}, + {0x3200, "Hi 1"}, + {0x6400, "Hi 2"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "Hi 0.3"}, + {22, "Hi 0.5"}, + {23, "Hi 0.7"}, + {24, "Hi 1"}, + {25, "Hi 2"}, + }; + + _shutterTable = new Dictionary + { + {0x00011f40, "1/8000"}, + {0x00011900, "1/6400"}, + {0x00011770, "1/6000"}, + {0x00011388, "1/5000"}, + {0x00010FA0, "1/4000"}, + {0x00010C80, "1/3200"}, + {0x000109C4, "1/2500"}, + {0x000107d0, "1/2000"}, + {0x00010640, "1/1600"}, + {0x000104e2, "1/1250"}, + {0x000103e8, "1/1000"}, + {0x00010320, "1/800"}, + {0x000102ee, "1/750"}, + {0x00010280, "1/640"}, + {0x000101f4, "1/500"}, + {0x00010190, "1/400"}, + {0x0001015e, "1/350"}, + {0x00010140, "1/320"}, + {0x000100fa, "1/250"}, + {0x000100c8, "1/200"}, + {0x000100b4, "1/180"}, + {0x000100a0, "1/160"}, + {0x0001007d, "1/125"}, + {0x00010064, "1/100"}, + {0x0001005a, "1/90"}, + {0x00010050, "1/80"}, + {0x0001003c, "1/60"}, + {0x00010032, "1/50"}, + {0x0001002d, "1/45"}, + {0x00010028, "1/40"}, + {0x0001001e, "1/30"}, + {0x00010019, "1/25"}, + {0x00010014, "1/20"}, + {0x0001000f, "1/15"}, + {0x0001000d, "1/13"}, + {0x0001000a, "1/10"}, + {0x00010008, "1/8"}, + {0x00010006, "1/6"}, + {0x00010005, "1/5"}, + {0x00010004, "1/4"}, + {0x00010003, "1/3"}, + {0x000a0019, "1/2.5"}, + {0x00010002, "1/2"}, + {0x000a0010, "1/1.6"}, + {0x000a000f, "1/1.5"}, + {0x000a000d, "1/1.3"}, + {0x00010001, "1s"}, + {0x000d000a, "1.3s"}, + {0x000f000a, "1.5s"}, + {0x0010000a, "1.6s"}, + {0x00020001, "2s"}, + {0x0019000a, "2.5s"}, + {0x00030001, "3s"}, + {0x00040001, "4s"}, + {0x00050001, "5s"}, + {0x00060001, "6s"}, + {0x00080001, "8s"}, + {0x000a0001, "10s"}, + {0x000d0001, "13s"}, + {0x000f0001, "15s"}, + {0x00140001, "20s"}, + {0x00190001, "25s"}, + {0x001e0001, "30s"}, + {0xFFFFFFFF, "Bulb"}, + {0xFFFFFFFD, "Time"}, + {0xFFFFFFFE, "Flash Sync"}, + }; + } + + protected override PropertyValue InitExposureDelay() + { + + PropertyValue res = new PropertyValue() + { + Name = "Exposure delay mode", + IsEnabled = true, + Code = 0xD06A + }; + res.AddValues("3 sec", 3); + res.AddValues("2 sec", 2); + res.AddValues("1 sec", 1); + res.AddValues("OFF", 0); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) val}, res.Code); + return res; + } + + protected override void InitShutterSpeed() + { + NormalShutterSpeed = new PropertyValue(); + NormalShutterSpeed.Name = "ShutterSpeed"; + NormalShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + MovieShutterSpeed = new PropertyValue(); + MovieShutterSpeed.Name = "ShutterSpeed"; + MovieShutterSpeed.ValueChanged += MovieShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_ShutterSpeed); + } + + private void MovieShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_MovieShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_MovieShutterSpeed); + } + + protected override void ReInitShutterSpeed() + { + lock (Locker) + { + DeviceReady(); + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ShutterSpeed); + if (result.Data == null) + return; + NormalShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb")) + NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + NormalShutterSpeed.ReloadValues(); + NormalShutterSpeed.SetValue(defval, false); + ShutterSpeed = NormalShutterSpeed; + } + catch (Exception) + { + } + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieShutterSpeed); + if (result.Data == null || result.Data.Length == 0) + return; + MovieShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + MovieShutterSpeed.AddValues("1/" + (val - 0x10000), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb")) + MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + + MovieShutterSpeed.SetValue(defval, false); + } + catch (Exception) + { + } + } + } + + public override void ReadDeviceProperties(uint prop) + { + //lock (Locker) + //{ + try + { + HaveLiveView = true; + switch (prop) + { + case CONST_PROP_Fnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_MovieFnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_ExposureIndex: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndex), false); + break; + //case CONST_PROP_ExposureIndexEx: + // NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureIndexEx), false); + // break; + case CONST_PROP_MovieExposureIndex: + MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureIndex), false); + break; + //case CONST_PROP_ExposureTime: + // NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureTime), false); + // break; + case CONST_PROP_ShutterSpeed: + NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ShutterSpeed), false); + break; + case CONST_PROP_MovieShutterSpeed: + MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieShutterSpeed), false); + break; + case CONST_PROP_WhiteBalance: + WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_WhiteBalance), false); + break; + case CONST_PROP_ExposureProgramMode: + Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureProgramMode), true); + break; + case CONST_PROP_ExposureBiasCompensation: + NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureBiasCompensation), + false); + break; + case CONST_PROP_MovieExposureBiasCompensation: + MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureBiasCompensation), + false); + break; + + case CONST_PROP_CompressionSetting: + CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_CompressionSetting), + false); + break; + case CONST_PROP_ExposureMeteringMode: + ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureMeteringMode), + false); + break; + case CONST_PROP_AFModeSelect: + NormalFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect), + false); + NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3; + break; + case CONST_PROP_AfModeAtLiveView: + LiveViewFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView), + false); + LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3; + break; + case CONST_PROP_BatteryLevel: + { + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + } + break; + case CONST_PROP_ExposureIndicateStatus: + { + var data = + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndicateStatus); + if (data.Data != null && data.Data.Length > 0) + { + sbyte i = + unchecked( + (sbyte)data.Data[0]); + ExposureStatus = Convert.ToInt32(i); + } + } + break; + case CONST_PROP_LiveViewStatus: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewOn = response.Data[0] == 1; + } + else + { + LiveViewOn = false; + } + break; + } + case CONST_PROP_LiveViewSelector: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewMovieOn = response.Data[0] == 1; + } + else + { + LiveViewMovieOn = false; + } + break; + } + default: + // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs + foreach (PropertyValue advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop)) + { + if (advancedProperty.Name == "Image Size") + { + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code); + if (val.Data != null && val.Data.Length > 0) + { + advancedProperty.SetValue( + Encoding.Unicode.GetString(val.Data, 1, 20), false); + } + } + else + { + advancedProperty.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code), false); + } + } + break; + } + } + catch (Exception ex) + { + Log.Error("ReadDeviceProperties error", ex); + } + //} + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD600Base.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD600Base.cs new file mode 100644 index 0000000..aefb297 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD600Base.cs @@ -0,0 +1,560 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Threading; +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD600Base : NikonD800 + { + public NikonD600Base() + { + _shutterTable = new Dictionary + { + {0x00011f40, "1/8000"}, + {0x00011900, "1/6400"}, + {0x00011770, "1/6000"}, + {0x00011388, "1/5000"}, + {0x00010FA0, "1/4000"}, + {0x00010C80, "1/3200"}, + {0x000109C4, "1/2500"}, + {0x000107d0, "1/2000"}, + {0x00010640, "1/1600"}, + {0x000104e2, "1/1250"}, + {0x000103e8, "1/1000"}, + {0x00010320, "1/800"}, + {0x000102ee, "1/750"}, + {0x00010280, "1/640"}, + {0x000101f4, "1/500"}, + {0x00010190, "1/400"}, + {0x0001015e, "1/350"}, + {0x00010140, "1/320"}, + {0x000100fa, "1/250"}, + {0x000100c8, "1/200"}, + {0x000100b4, "1/180"}, + {0x000100a0, "1/160"}, + {0x0001007d, "1/125"}, + {0x00010064, "1/100"}, + {0x0001005a, "1/90"}, + {0x00010050, "1/80"}, + {0x0001003c, "1/60"}, + {0x00010032, "1/50"}, + {0x0001002d, "1/45"}, + {0x00010028, "1/40"}, + {0x0001001e, "1/30"}, + {0x00010019, "1/25"}, + {0x00010014, "1/20"}, + {0x0001000f, "1/15"}, + {0x0001000d, "1/13"}, + {0x0001000a, "1/10"}, + {0x00010008, "1/8"}, + {0x00010006, "1/6"}, + {0x00010005, "1/5"}, + {0x00010004, "1/4"}, + {0x00010003, "1/3"}, + {0x000a0019, "1/2.5"}, + {0x00010002, "1/2"}, + {0x000a0010, "1/1.6"}, + {0x000a000f, "1/1.5"}, + {0x000a000d, "1/1.3"}, + {0x00010001, "1s"}, + {0x000d000a, "1.3s"}, + {0x000f000a, "1.5s"}, + {0x0010000a, "1.6s"}, + {0x00020001, "2s"}, + {0x0019000a, "2.5s"}, + {0x00030001, "3s"}, + {0x00040001, "4s"}, + {0x00050001, "5s"}, + {0x00060001, "6s"}, + {0x00080001, "8s"}, + {0x000a0001, "10s"}, + {0x000d0001, "13s"}, + {0x000f0001, "15s"}, + {0x00140001, "20s"}, + {0x00190001, "25s"}, + {0x001e0001, "30s"}, + {0xFFFFFFFF, "Bulb"}, + {0xFFFFFFFD, "Time"}, + {0xFFFFFFFE, "Flash Sync"}, + }; + } + + + public override LiveViewData GetLiveViewImage() + { + LiveViewData viewData = new LiveViewData(); + if (Monitor.TryEnter(Locker, 10)) + { + try + { + //DeviceReady(); + viewData.HaveFocusData = true; + + const int headerSize = 384; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + if (result.Data == null || result.Data.Length <= headerSize) + return null; + GetAdditionalLiveViewData(viewData, result.Data); + viewData.ImageDataPosition = headerSize; + viewData.ImageData = result.Data; + } + finally + { + Monitor.Exit(Locker); + } + } + return viewData; + } + + protected override void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 8); + viewData.LiveViewImageHeight = ToInt16(result, 10); + + viewData.ImageWidth = ToInt16(result, 12); + viewData.ImageHeight = ToInt16(result, 14); + + viewData.FocusFrameXSize = ToInt16(result, 24); + viewData.FocusFrameYSize = ToInt16(result, 26); + + viewData.FocusX = ToInt16(result, 28); + viewData.FocusY = ToInt16(result, 30); + + viewData.Focused = result[48] != 1; + viewData.MovieIsRecording = result[68] == 1; + viewData.MovieTimeRemain = ToDeciaml(result, 64); + + if (result[37] == 1) + viewData.Rotation = -90; + if (result[37] == 2) + viewData.Rotation = 90; + + viewData.HaveLevelAngleData = true; + viewData.LevelAngleRolling = ToInt16(result, 52); + viewData.LevelAnglePitching = ToInt16(result, 56); + viewData.LevelAngleYawing = ToInt16(result, 60); + viewData.PeakSoundL = (int)(result[352] / 14.0 * 100); + viewData.PeakSoundR = (int)(result[353] / 14.0 * 100); + viewData.SoundL = (int)(result[354] / 14.0 * 100); + viewData.SoundR = (int)(result[355] / 14.0 * 100); + viewData.HaveSoundData = true; + } + + + protected override PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof (UInt16) + }; + res.AddValues("Single shot (single-frame shooting)", 0x0001); + res.AddValues("Continuous high-speed shooting (CH)", 0x0002); + res.AddValues("Continuous low-speed shooting (CL)", 0x8010); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Mirror-up", 0x8012); + res.AddValues("Quiet shooting", 0x8016); + res.AddValues("Remote control", 0x8017); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + + protected override PropertyValue InitExposureDelay() + { + + PropertyValue res = new PropertyValue() + { + Name = "Exposure delay mode", + IsEnabled = true, + Code = 0xD06A + }; + res.AddValues("3 sec", 0); + res.AddValues("2 sec", 1); + res.AddValues("1 sec", 2); + res.AddValues("OFF", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)val }, res.Code); + return res; + } + + + protected override void InitIso() + { + lock (Locker) + { + NormalIsoNumber = new PropertyValue(); + NormalIsoNumber.Name = "IsoNumber"; + NormalIsoNumber.SubType = typeof(int); + NormalIsoNumber.ValueChanged += IsoNumber_ValueChanged; + NormalIsoNumber.Clear(); + try + { + DeviceReady(); + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_ExposureIndexEx); + //IsoNumber.IsEnabled = result.Data[4] == 1; + UInt32 defval = BitConverter.ToUInt32(result.Data, 9); + for (int i = 0; i < result.Data.Length - 16; i += 4) + { + UInt32 val = BitConverter.ToUInt32(result.Data, 16 + i); + NormalIsoNumber.AddValues(_isoTable.ContainsKey(val) ? _isoTable[val] : val.ToString(), val); + } + NormalIsoNumber.ReloadValues(); + NormalIsoNumber.SetValue(defval, false); + IsoNumber = NormalIsoNumber; + } + catch (Exception) + { + NormalIsoNumber.IsEnabled = false; + } + + MovieIsoNumber = new PropertyValue(); + MovieIsoNumber.Name = "IsoNumber"; + MovieIsoNumber.SubType = typeof(int); + MovieIsoNumber.ValueChanged += MovieIsoNumber_ValueChanged; + MovieIsoNumber.Clear(); + try + { + MTPDataResponse result = ExecuteReadDataEx(CONST_CMD_GetDevicePropDesc, CONST_PROP_MovieExposureIndex); + //IsoNumber.IsEnabled = result.Data[4] == 1; + UInt32 defval = BitConverter.ToUInt32(result.Data, 9); + for (int i = 0; i < result.Data.Length - 16; i += 4) + { + UInt32 val = BitConverter.ToUInt32(result.Data, 16 + i); + MovieIsoNumber.AddValues(_isoTable.ContainsKey(val) ? _isoTable[val] : val.ToString(CultureInfo.InvariantCulture), val); + } + MovieIsoNumber.ReloadValues(); + MovieIsoNumber.SetValue(defval, false); + } + catch (Exception) + { + MovieIsoNumber.IsEnabled = false; + } + } + } + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_ExposureIndexEx); + } + } + + private void MovieIsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((int)val), + CONST_PROP_MovieExposureIndex); + } + } + + protected override void InitShutterSpeed() + { + NormalShutterSpeed = new PropertyValue(); + NormalShutterSpeed.Name = "ShutterSpeed"; + NormalShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + MovieShutterSpeed = new PropertyValue(); + MovieShutterSpeed.Name = "ShutterSpeed"; + MovieShutterSpeed.ValueChanged += MovieShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_ShutterSpeed); + } + + private void MovieShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_MovieShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_MovieShutterSpeed); + } + + protected override void ReInitShutterSpeed() + { + lock (Locker) + { + DeviceReady(); + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ShutterSpeed); + if (result.Data == null) + return; + NormalShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb")) + NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + NormalShutterSpeed.ReloadValues(); + NormalShutterSpeed.SetValue(defval, false); + ShutterSpeed = NormalShutterSpeed; + } + catch (Exception) + { + } + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieShutterSpeed); + if (result.Data == null || result.Data.Length == 0) + return; + MovieShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + MovieShutterSpeed.AddValues("1/" + (val - 0x10000), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb")) + MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + + MovieShutterSpeed.SetValue(defval, false); + } + catch (Exception) + { + } + } + } + public override void ReadDeviceProperties(uint prop) + { + //lock (Locker) + //{ + try + { + HaveLiveView = true; + switch (prop) + { + case CONST_PROP_Fnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_MovieFnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + //case CONST_PROP_ExposureIndex: + // NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureIndex), false); + // break; + case CONST_PROP_ExposureIndexEx: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndexEx), false); + break; + case CONST_PROP_MovieExposureIndex: + MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureIndex), false); + break; + //case CONST_PROP_ExposureTime: + // NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureTime), false); + // break; + case CONST_PROP_ShutterSpeed: + NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ShutterSpeed), false); + break; + case CONST_PROP_MovieShutterSpeed: + MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieShutterSpeed), false); + break; + case CONST_PROP_WhiteBalance: + WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_WhiteBalance), false); + break; + case CONST_PROP_ExposureProgramMode: + Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureProgramMode), true); + break; + case CONST_PROP_ExposureBiasCompensation: + NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureBiasCompensation), + false); + break; + case CONST_PROP_MovieExposureBiasCompensation: + MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureBiasCompensation), + false); + break; + + case CONST_PROP_CompressionSetting: + CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_CompressionSetting), + false); + break; + case CONST_PROP_ExposureMeteringMode: + ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureMeteringMode), + false); + break; + case CONST_PROP_AFModeSelect: + NormalFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect), + false); + NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3; + break; + case CONST_PROP_AfModeAtLiveView: + LiveViewFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView), + false); + LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3; + break; + case CONST_PROP_BatteryLevel: + { + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + } + break; + case CONST_PROP_ExposureIndicateStatus: + { + var data = + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndicateStatus); + if (data.Data != null && data.Data.Length > 0) + { + sbyte i = + unchecked( + (sbyte)data.Data[0]); + ExposureStatus = Convert.ToInt32(i); + } + } + break; + case CONST_PROP_LiveViewStatus: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewOn = response.Data[0] == 1; + } + else + { + LiveViewOn = false; + } + break; + } + case CONST_PROP_LiveViewSelector: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewMovieOn = response.Data[0] == 1; + } + else + { + LiveViewMovieOn = false; + } + break; + } + default: + // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs + foreach (PropertyValue advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop)) + { + if (advancedProperty.Name == "Image Size") + { + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code); + if (val.Data != null && val.Data.Length > 0) + { + advancedProperty.SetValue( + Encoding.Unicode.GetString(val.Data, 1, 20), false); + } + } + else + { + advancedProperty.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code), false); + } + } + break; + } + } + catch (Exception ex) + { + Log.Error("ReadDeviceProperties error", ex); + } + //} + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD700.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD700.cs new file mode 100644 index 0000000..68de9b7 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD700.cs @@ -0,0 +1,141 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.IO; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD700 : NikonBase + { + //public const int CONST_PROP_RecordingMedia = 0xD10B; + public const int CONST_PROP_LiveViewMode = 0xD1A0; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + CaptureInSdRam = true; + return res; + } + + + public override void StartLiveView() + { + // set record media to SDRAM + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_RecordingMedia ); + DeviceReady(); + // set to Tripod shooting mode + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_LiveViewMode); + DeviceReady(); + base.StartLiveView(); + } + + public override void StopLiveView() + { + base.StopLiveView(); + DeviceReady(); + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, CONST_PROP_RecordingMedia); + DeviceReady(); + } + + public override void CapturePhotoNoAf() + { + lock (Locker) + { + try + { + IsBusy = true; + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + ErrorCodes.GetException(response.ErrorCode); + // test if live view is on + if (response.Data != null && response.Data.Length > 0 && response.Data[0] > 0) + { + if (CaptureInSdRam) + { + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF)); + return; + } + StopLiveView(); + } + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCapture)); + } + catch + { + IsBusy = false; + throw; + } + } + } + + public override LiveViewData GetLiveViewImage() + { + LiveViewData viewData = new LiveViewData(); + viewData.HaveFocusData = true; + + const int headerSize = 64; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + + if (result.Data == null || result.Data.Length <= headerSize) + return null; + int cbBytesRead = result.Data.Length; + GetAdditionalLiveViewData(viewData, result.Data); + + MemoryStream copy = new MemoryStream((int) cbBytesRead - headerSize); + copy.Write(result.Data, headerSize, (int)cbBytesRead - headerSize); + copy.Close(); + viewData.ImageData = copy.GetBuffer(); + + return viewData; + } + + protected override void InitFocusMode() + { + base.InitFocusMode(); + FocusMode.IsEnabled = false; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD7000.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7000.cs new file mode 100644 index 0000000..9327e2e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7000.cs @@ -0,0 +1,57 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD7000 : NikonBase + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + return res; + } + + public override void StartLiveView() + { + base.StartLiveView(); + //SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, CONST_PROP_AfModeAtLiveView ); + } + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD7100.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7100.cs new file mode 100644 index 0000000..f3853d9 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7100.cs @@ -0,0 +1,97 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD7100 : NikonD600Base + { + protected override void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 8); + viewData.LiveViewImageHeight = ToInt16(result, 10); + + viewData.ImageWidth = ToInt16(result, 12); + viewData.ImageHeight = ToInt16(result, 14); + + viewData.FocusFrameXSize = ToInt16(result, 24); + viewData.FocusFrameYSize = ToInt16(result, 26); + + viewData.FocusX = ToInt16(result, 28); + viewData.FocusY = ToInt16(result, 30); + + viewData.Focused = result[48] != 1; + viewData.MovieIsRecording = result[68] == 1; + viewData.MovieTimeRemain = ToDeciaml(result, 64); + + if (result[37] == 1) + viewData.Rotation = -90; + if (result[37] == 2) + viewData.Rotation = 90; + + viewData.HaveLevelAngleData = true; + viewData.LevelAngleRolling = ToInt16(result, 52); + viewData.PeakSoundL = (int)(result[352] / 14.0 * 100); + viewData.PeakSoundR = (int)(result[353] / 14.0 * 100); + viewData.SoundL = (int)(result[354] / 14.0 * 100); + viewData.SoundR = (int)(result[355] / 14.0 * 100); + viewData.HaveSoundData = true; + } + + protected override void InitFNumber() + { + base.InitFNumber(); + MovieFNumber.IsEnabled = false; + } + + protected override PropertyValue CaptureAreaCrop() + { + PropertyValue res = new PropertyValue() + { + Name = "Capture area crop", + IsEnabled = true, + Code = 0xD030, + SubType = typeof(sbyte) + }; + res.AddValues("DX", 0); + res.AddValues("1.3x", 1); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD750.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD750.cs new file mode 100644 index 0000000..3785fff --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD750.cs @@ -0,0 +1,114 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD750 : NikonD600 + { + public NikonD750() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3E80, "Hi 0.3"}, + {0x4650, "Hi 0.5"}, + {0x4E20, "Hi 0.7"}, + {0x6400, "Hi 1"}, + {0xC800, "Hi 2"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "Hi 0.3"}, + {26, "Hi 0.5"}, + {27, "Hi 0.7"}, + {28, "Hi 1"}, + {29, "Hi 2"}, + }; + } + + protected override PropertyValue InitStillCaptureMode() + { + PropertyValue res = new PropertyValue() + { + Name = "Still Capture Mode", + IsEnabled = true, + Code = 0x5013, + SubType = typeof(UInt16) + }; + res.AddValues("Single frame (S)", 0x0001); + res.AddValues("Continuous low speed (CL)", 0x8010); + res.AddValues("Continuous high speed (CH)", 0x0002); + res.AddValues("Quiet shutter-release (Q)", 0x8016); + res.AddValues("Quiet continuous shutter-release (QC)", 0x8018); + res.AddValues("Self-timer", 0x8011); + res.AddValues("Mirror up", 0x8012); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), + res.Code); + return res; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD7500.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7500.cs new file mode 100644 index 0000000..256a22d --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD7500.cs @@ -0,0 +1,113 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD7500: NikonD7100 + { + public NikonD7500() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4650, "18000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "32000"}, + {0x8ca0, "36000"}, + {0x9c40, "40000"}, + {0xC800, "51200"}, + {0xFA00, "Hi 0.3"}, + {0x11940, "Hi 0.5"}, + {0x13d30, "Hi 0.7"}, + {0x19000, "Hi 1"}, + {0x32000, "Hi 2"}, + {0x64000, "Hi 3"}, + {0xC8320, "Hi 4"}, + {0x190640, "Hi 5"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "16000"}, + {26, "18000"}, + {27, "20000"}, + {28, "25600"}, + {29, "32000"}, + {30, "36000"}, + {31, "40000"}, + {32, "51200"}, + {33, "Hi 0.3"}, + {34, "Hi 0.5"}, + {35, "Hi 0.7"}, + {36, "Hi 1"}, + {37, "Hi 2"}, + {38, "Hi 3"}, + {39, "Hi 4"}, + {40, "Hi 5"}, + }; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD80.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD80.cs new file mode 100644 index 0000000..16dc0ea --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD80.cs @@ -0,0 +1,116 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD80 : NikonBase + { + protected new Dictionary _csTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (NORMAL)"}, + {2, "JPEG (FINE)"}, + {3, "RAW"}, + {4, "RAW + JPEG (BASIC)"}, + {5, "RAW + JPEG (NORMAL)"}, + {6, "RAW + JPEG (FINE)"} + }; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + HaveLiveView = false; + CaptureInSdRam = false; + return res; + } + + protected override void InitCompressionSetting() + { + try + { + byte datasize = 1; + CompressionSetting = new PropertyValue(); + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_CompressionSetting); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + byte defval = result.Data[datasize + 5]; + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + byte val = result.Data[((2 * datasize) + 6 + 2) + i]; + CompressionSetting.AddValues(_csTable.ContainsKey(val) ? _csTable[val] : val.ToString(), val); + } + CompressionSetting.ReloadValues(); + CompressionSetting.SetValue(defval); + } + catch (Exception) + { + } + } + + public override void ReadDeviceProperties(uint prop) + { + base.ReadDeviceProperties(prop); + HaveLiveView = false; + } + + /// + /// Take picture with no autofocus + /// If live view runnig the live view is stoped after done restarted + /// + public override void CapturePhotoNoAf() + { + lock (Locker) + { + byte oldval = 0; + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect); + if (val.Data != null && val.Data.Length > 0) + oldval = val.Data[0]; + + ErrorCodes.GetException(StillImageDevice.ExecuteWriteData(CONST_CMD_SetDevicePropValue, new[] {(byte) 4}, + CONST_PROP_AFModeSelect)); + ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCapture)); + if (val.Data != null && val.Data.Length > 0) + ErrorCodes.GetException(StillImageDevice.ExecuteWriteData(CONST_CMD_SetDevicePropValue, + new[] {oldval}, + CONST_PROP_AFModeSelect)); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD800.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD800.cs new file mode 100644 index 0000000..177f55e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD800.cs @@ -0,0 +1,560 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD800 : NikonBase + { + + public NikonD800() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1f40, "Hi 0.3"}, + {0x2328, "Hi 0.5"}, + {0x2710, "Hi 0.7"}, + {0x3200, "Hi 1"}, + {0x6400, "Hi 2"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "Hi 0.3"}, + {22, "Hi 0.5"}, + {23, "Hi 0.7"}, + {24, "Hi 1"}, + {25, "Hi 2"}, + }; + + _shutterTable = new Dictionary + { + {0x00011f40, "1/8000"}, + {0x00011900, "1/6400"}, + {0x00011770, "1/6000"}, + {0x00011388, "1/5000"}, + {0x00010FA0, "1/4000"}, + {0x00010C80, "1/3200"}, + {0x000109C4, "1/2500"}, + {0x000107d0, "1/2000"}, + {0x00010640, "1/1600"}, + {0x000104e2, "1/1250"}, + {0x000103e8, "1/1000"}, + {0x00010320, "1/800"}, + {0x000102ee, "1/750"}, + {0x00010280, "1/640"}, + {0x000101f4, "1/500"}, + {0x00010190, "1/400"}, + {0x0001015e, "1/350"}, + {0x00010140, "1/320"}, + {0x000100fa, "1/250"}, + {0x000100c8, "1/200"}, + {0x000100b4, "1/180"}, + {0x000100a0, "1/160"}, + {0x0001007d, "1/125"}, + {0x00010064, "1/100"}, + {0x0001005a, "1/90"}, + {0x00010050, "1/80"}, + {0x0001003c, "1/60"}, + {0x00010032, "1/50"}, + {0x0001002d, "1/45"}, + {0x00010028, "1/40"}, + {0x0001001e, "1/30"}, + {0x00010019, "1/25"}, + {0x00010014, "1/20"}, + {0x0001000f, "1/15"}, + {0x0001000d, "1/13"}, + {0x0001000a, "1/10"}, + {0x00010008, "1/8"}, + {0x00010006, "1/6"}, + {0x00010005, "1/5"}, + {0x00010004, "1/4"}, + {0x00010003, "1/3"}, + {0x000a0019, "1/2.5"}, + {0x00010002, "1/2"}, + {0x000a0010, "1/1.6"}, + {0x000a000f, "1/1.5"}, + {0x000a000d, "1/1.3"}, + {0x00010001, "1s"}, + {0x000d000a, "1.3s"}, + {0x000f000a, "1.5s"}, + {0x0010000a, "1.6s"}, + {0x00020001, "2s"}, + {0x0019000a, "2.5s"}, + {0x00030001, "3s"}, + {0x00040001, "4s"}, + {0x00050001, "5s"}, + {0x00060001, "6s"}, + {0x00080001, "8s"}, + {0x000a0001, "10s"}, + {0x000d0001, "13s"}, + {0x000f0001, "15s"}, + {0x00140001, "20s"}, + {0x00190001, "25s"}, + {0x001e0001, "30s"}, + {0xFFFFFFFF, "Bulb"}, + {0xFFFFFFFD, "Time"}, + {0xFFFFFFFE, "Flash Sync"}, + }; + } + + public const int CONST_CMD_TerminateCapture = 0x920C; + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.Bulb); + Capabilities.Add(CapabilityEnum.RecordMovie); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + return res; + } + + public override void StartBulbMode() + { + DeviceReady(); + ExecuteWithNoData(CONST_CMD_EndLiveView); + DeviceReady(); + ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 1); + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) 0x0001), + CONST_PROP_ExposureProgramMode); + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ExposureTime); + + ErrorCodes.GetException(CaptureInSdRam + ? ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInMedia, 0xFFFFFFFF, + 0x0001) + : ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInMedia, 0xFFFFFFFF, + 0x0000)); + } + + public override void EndBulbMode() + { + lock (Locker) + { + DeviceReady(); + ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_TerminateCapture, 0, 0)); + DeviceReady(); + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 0); + } + } + + public override void LockCamera() + { + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 1); + } + + public override void UnLockCamera() + { + StillImageDevice.ExecuteWithNoData(CONST_CMD_ChangeCameraMode, 0); + } + + public override void StartRecordMovie() + { + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 1}, CONST_PROP_ApplicationMode); + base.StartRecordMovie(); + } + + public override void StopRecordMovie() + { + base.StopRecordMovie(); + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 0}, CONST_PROP_ApplicationMode); + } + + protected override void GetAdditionalLiveViewData(LiveViewData viewData, byte[] result) + { + viewData.LiveViewImageWidth = ToInt16(result, 8); + viewData.LiveViewImageHeight = ToInt16(result, 10); + + viewData.ImageWidth = ToInt16(result, 12); + viewData.ImageHeight = ToInt16(result, 14); + + viewData.FocusFrameXSize = ToInt16(result, 16); + viewData.FocusFrameYSize = ToInt16(result, 18); + + viewData.FocusX = ToInt16(result, 20); + viewData.FocusY = ToInt16(result, 22); + + viewData.Focused = result[40] != 1; + viewData.MovieIsRecording = result[60] == 1; + viewData.MovieTimeRemain = ToDeciaml(result, 56); + + if (result[29] == 1) + viewData.Rotation = -90; + if (result[29] == 2) + viewData.Rotation = 90; + + viewData.HaveLevelAngleData = true; + viewData.LevelAngleRolling = ToInt16(result, 44); + viewData.LevelAnglePitching = ToInt16(result, 48); + viewData.LevelAngleYawing = ToInt16(result, 52); + + viewData.PeakSoundL = (int)(result[344] / 14.0 * 100); + viewData.PeakSoundR = (int)(result[345] / 14.0 * 100); + viewData.SoundL = (int)(result[346] / 14.0 * 100); + viewData.SoundR = (int)(result[347] / 14.0 * 100); + viewData.HaveSoundData = true; + } + + protected override PropertyValue InitExposureDelay() + { + + PropertyValue res = new PropertyValue() + { + Name = "Exposure delay mode", + IsEnabled = true, + Code = 0xD06A + }; + res.AddValues("3 sec", 0); + res.AddValues("2 sec", 1); + res.AddValues("1 sec", 2); + res.AddValues("OFF", 3); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, new[] { (byte)val }, res.Code); + return res; + } + + protected override void InitShutterSpeed() + { + NormalShutterSpeed = new PropertyValue(); + NormalShutterSpeed.Name = "ShutterSpeed"; + NormalShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + MovieShutterSpeed = new PropertyValue(); + MovieShutterSpeed.Name = "ShutterSpeed"; + MovieShutterSpeed.ValueChanged += MovieShutterSpeed_ValueChanged; + ReInitShutterSpeed(); + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_ShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_ShutterSpeed); + } + + private void MovieShutterSpeed_ValueChanged(object sender, string key, long val) + { + UInt32 localValue = Convert.ToUInt32(val & 0x00000000FFFFFFFF); + + if (Mode != null && (Mode.Value == "M" || Mode.Value == "S")) + if (key == "Bulb") + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(0xFFFFFFFF), + CONST_PROP_MovieShutterSpeed); + else + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(localValue), + CONST_PROP_MovieShutterSpeed); + } + + protected override void ReInitShutterSpeed() + { + lock (Locker) + { + DeviceReady(); + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_ShutterSpeed); + if (result.Data == null) + return; + NormalShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb")) + NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + NormalShutterSpeed.ReloadValues(); + NormalShutterSpeed.SetValue(defval, false); + ShutterSpeed = NormalShutterSpeed; + } + catch (Exception) + { + } + try + { + byte datasize = 4; + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, + CONST_PROP_MovieShutterSpeed); + if (result.Data == null || result.Data.Length == 0) + return; + MovieShutterSpeed.Clear(); + int type = BitConverter.ToInt16(result.Data, 2); + byte formFlag = result.Data[(2 * datasize) + 5]; + UInt32 defval = BitConverter.ToUInt32(result.Data, datasize + 5); + for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize) + { + UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i); + MovieShutterSpeed.AddValues("1/" + (val - 0x10000), val); + } + // force to add Bulb mode for some cameras which not support it + if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb")) + MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF); + + MovieShutterSpeed.SetValue(defval, false); + } + catch (Exception) + { + } + } + } + + public override void ReadDeviceProperties(uint prop) + { + //lock (Locker) + //{ + try + { + HaveLiveView = true; + switch (prop) + { + case CONST_PROP_Fnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_MovieFnumber: + //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber)); + ReInitFNumber(false); + break; + case CONST_PROP_ExposureIndex: + NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndex), false); + break; + //case CONST_PROP_ExposureIndexEx: + // NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureIndexEx), false); + // break; + case CONST_PROP_MovieExposureIndex: + MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureIndex), false); + break; + //case CONST_PROP_ExposureTime: + // NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + // CONST_PROP_ExposureTime), false); + // break; + case CONST_PROP_ShutterSpeed: + NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ShutterSpeed), false); + break; + case CONST_PROP_MovieShutterSpeed: + MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieShutterSpeed), false); + break; + case CONST_PROP_WhiteBalance: + WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_WhiteBalance), false); + break; + case CONST_PROP_ExposureProgramMode: + Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureProgramMode), true); + break; + case CONST_PROP_ExposureBiasCompensation: + NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureBiasCompensation), + false); + break; + case CONST_PROP_MovieExposureBiasCompensation: + MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_MovieExposureBiasCompensation), + false); + break; + + case CONST_PROP_CompressionSetting: + CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_CompressionSetting), + false); + break; + case CONST_PROP_ExposureMeteringMode: + ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureMeteringMode), + false); + break; + case CONST_PROP_AFModeSelect: + NormalFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect), + false); + NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3; + break; + case CONST_PROP_AfModeAtLiveView: + LiveViewFocusMode.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView), + false); + LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3; + break; + case CONST_PROP_BatteryLevel: + { + var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel); + if (data.Data != null && data.Data.Length > 0) + Battery = data.Data[0]; + } + break; + case CONST_PROP_ExposureIndicateStatus: + { + var data = + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + CONST_PROP_ExposureIndicateStatus); + if (data.Data != null && data.Data.Length > 0) + { + sbyte i = + unchecked( + (sbyte)data.Data[0]); + ExposureStatus = Convert.ToInt32(i); + } + } + break; + case CONST_PROP_LiveViewStatus: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewOn = response.Data[0] == 1; + } + else + { + LiveViewOn = false; + } + break; + } + case CONST_PROP_LiveViewSelector: + { + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector); + if (response.Data != null && response.Data.Length > 0) + { + LiveViewMovieOn = response.Data[0] == 1; + } + else + { + LiveViewMovieOn = false; + } + break; + } + default: + // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs + foreach (PropertyValue advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop)) + { + if (advancedProperty.Name == "Image Size") + { + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code); + if (val.Data != null && val.Data.Length > 0) + { + advancedProperty.SetValue( + Encoding.Unicode.GetString(val.Data, 1, 20), false); + } + } + else + { + advancedProperty.SetValue( + StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + advancedProperty.Code), false); + } + } + break; + } + } + catch (Exception ex) + { + Log.Error("ReadDeviceProperties error", ex); + } + //} + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD810.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD810.cs new file mode 100644 index 0000000..c3c8b01 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD810.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD810 : NikonD600 + { + public NikonD810() + { + _isoTable = new Dictionary() + { + {0x0020, "Lo 1.0"}, + {0x0028, "Lo 0.7"}, + {0x002d, "Lo 0.5"}, + {0x0032, "Lo 0.3"}, + {0x0040, "64"}, + {0x0048, "72"}, + {0x0050, "80"}, + {0x0064, "100"}, + {0x007D, "125"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "Hi 0.3"}, + {0x4650, "Hi 0.5"}, + {0x4e20, "Hi 0.7"}, + {0x6400, "Hi 1.0"}, + {0xC800, "Hi 2.0"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "72"}, + {1, "80"}, + {2, "100"}, + {3, "125"}, + {4, "140"}, + {5, "160"}, + {6, "200"}, + {7, "250"}, + {8, "280"}, + {9, "320"}, + {10, "400"}, + {11, "500"}, + {12, "560"}, + {13, "640"}, + {14, "800"}, + {15, "1000"}, + {16, "1100"}, + {17, "1250"}, + {18, "1600"}, + {19, "2000"}, + {20, "2200"}, + {21, "2500"}, + {22, "3200"}, + {23, "4000"}, + {24, "4500"}, + {25, "5000"}, + {26, "6400"}, + {27, "8000"}, + {28, "9000"}, + {29, "10000"}, + {30, "12800"}, + {31, "Hi 0.3"}, + {32, "Hi 0.5"}, + {33, "Hi 0.7"}, + {34, "Hi 1"}, + {35, "Hi 2"}, + }; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD850.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD850.cs new file mode 100644 index 0000000..9eab528 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD850.cs @@ -0,0 +1,101 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonD850: NikonD500 + { + public NikonD850() + { + _isoTable = new Dictionary() + { + {0x0020, "Lo 1.0"}, + {0x0028, "Lo 0.7"}, + {0x002d, "Lo 0.5"}, + {0x0032, "Lo 0.3"}, + {0x0040, "64"}, + {0x0048, "72"}, + {0x0050, "80"}, + {0x0064, "100"}, + {0x007D, "125"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "Hi 0.3"}, + {0x9c40, "Hi 0.7"}, + {0xC800, "Hi 1.0"}, + {0x19000, "Hi 2.0"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "72"}, + {1, "80"}, + {2, "100"}, + {3, "125"}, + {4, "140"}, + {5, "160"}, + {6, "200"}, + {7, "250"}, + {8, "280"}, + {9, "320"}, + {10, "400"}, + {11, "500"}, + {12, "560"}, + {13, "640"}, + {14, "800"}, + {15, "1000"}, + {16, "1100"}, + {17, "1250"}, + {18, "1600"}, + {19, "2000"}, + {20, "2200"}, + {21, "2500"}, + {22, "3200"}, + {23, "4000"}, + {24, "4500"}, + {25, "5000"}, + {26, "6500"}, + {27, "8000"}, + {28, "9000"}, + {29, "10000"}, + {30, "12800"}, + {31, "16000"}, + {32, "18000"}, + {33, "20000"}, + {34, "25600"}, + {35, "Hi 0.3"}, + {36, "Hi 0.5"}, + {37, "Hi 0.7"}, + {38, "Hi 1"}, + {39, "Hi 2"}, + }; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonD90.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonD90.cs new file mode 100644 index 0000000..c5ae687 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonD90.cs @@ -0,0 +1,133 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.IO; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices.Nikon +{ + public class NikonD90 : NikonBase + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + bool res = base.Init(deviceDescriptor); + Capabilities.Clear(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.CaptureInRam); + Capabilities.Add(CapabilityEnum.CaptureNoAf); + return res; + } + + public override LiveViewData GetLiveViewImage() + { + LiveViewData viewData = new LiveViewData(); + viewData.HaveFocusData = true; + + const int headerSize = 128; + + var result = StillImageDevice.ExecuteReadData(CONST_CMD_GetLiveViewImage); + if (result.ErrorCode == ErrorCodes.MTP_Not_LiveView) + { + _timer.Start(); + viewData.IsLiveViewRunning = false; + viewData.ImageData = null; + return viewData; + } + if (result.Data == null || result.Data.Length <= headerSize) + return null; + int cbBytesRead = result.Data.Length; + GetAdditionalLiveViewData(viewData, result.Data); + + MemoryStream copy = new MemoryStream(cbBytesRead - headerSize); + copy.Write(result.Data, headerSize, cbBytesRead - headerSize); + copy.Close(); + viewData.ImageData = copy.GetBuffer(); + + return viewData; + } + + /// + /// Take picture with no autofocus + /// If live view runnig the live view is stoped after done restarted + /// + public override void CapturePhotoNoAf() + { + lock (Locker) + { + try + { + IsBusy = true; + MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus); + ErrorCodes.GetException(response.ErrorCode); + // test if live view is on + if (response.Data != null && response.Data.Length > 0 && response.Data[0] > 0) + { + if (CaptureInSdRam) + { + DeviceReady(); + ErrorCodes.GetException(ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF)); + return; + } + StopLiveView(); + } + // the focus mode can be sett only in host mode + LockCamera(); + byte oldval = 0; + var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect); + if (val.Data != null && val.Data.Length > 0) + oldval = val.Data[0]; + + SetProperty(CONST_CMD_SetDevicePropValue, new[] {(byte) 4}, CONST_PROP_AFModeSelect); + + ErrorCodes.GetException(CaptureInSdRam + ? ExecuteWithNoData(CONST_CMD_InitiateCaptureRecInSdram, 0xFFFFFFFF) + : ExecuteWithNoData(CONST_CMD_InitiateCapture)); + + if (val.Data != null && val.Data.Length > 0) + SetProperty(CONST_CMD_SetDevicePropValue, new[] {oldval}, CONST_PROP_AFModeSelect); + + UnLockCamera(); + } + catch (Exception) + { + IsBusy = false; + throw; + } + + //if (live != null && live.Length > 0 && live[0] == 1) + // StartLiveView(); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonL830.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonL830.cs new file mode 100644 index 0000000..1cdad73 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonL830.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +namespace CameraControl.Devices.Nikon +{ + public class NikonL830 : BaseMTPCamera + { + public override bool Init(DeviceDescriptor deviceDescriptor) + { + base.Init(deviceDescriptor); + Properties.Add(InitFocalLength()); + ExposureCompensation = new PropertyValue {Available = false}; + ExposureMeteringMode = new PropertyValue {Available = false}; + FNumber = new PropertyValue {Available = false}; + IsoNumber = new PropertyValue {Available = false}; + CompressionSetting = new PropertyValue {Available = false}; + Mode = new PropertyValue() {Available = false}; + ShutterSpeed = new PropertyValue() {Available = false}; + WhiteBalance = new PropertyValue() {Available = false}; + FocusMode = new PropertyValue() {Available = false}; + + StillImageDevice imageDevice = StillImageDevice as StillImageDevice; + if (imageDevice != null) + imageDevice.DeviceEvent += StillImageDevice_DeviceEvent; + return true; + } + + protected virtual PropertyValue InitFocalLength() + { + PropertyValue res = new PropertyValue() + { + Name = "Focal Length", + IsEnabled = true, + Code = 0x5008, + SubType = typeof(UInt32) + }; + res.AddValues("3500", 0x0DAC); + res.AddValues("4600", 0x11F8); + res.AddValues("5300", 0x14B4); + res.AddValues("6100", 0x17D4); + res.AddValues("7300", 0x1C84); + res.AddValues("8600", 0x2198); + res.AddValues("10500", 0x2904); + res.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, + res.Code), false); + res.ReloadValues(); + res.ValueChanged += + (sender, key, val) => SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(val), res.Code); + return res; + } + + private void StillImageDevice_DeviceEvent(object sender, PortableDeviceEventArgs e) + { + if (e.EventType.EventGuid == PortableDeviceGuids.WPD_EVENT_OBJECT_ADDED) + { + var id = e.EventType.DeviceObject.ID; + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + CameraDevice = this, + FileName = e.EventType.DeviceObject.Name, + Handle = e.EventType.DeviceObject.ID + }; + OnPhotoCapture(this, args); + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonZ6.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonZ6.cs new file mode 100644 index 0000000..dcfe25c --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonZ6.cs @@ -0,0 +1,135 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonZ6 : NikonD500 + { + public NikonZ6() + { + _isoTable = new Dictionary() + { + {0x0032, "Lo 1.0"}, + {0x0040, "Lo 0.7"}, + {0x0048, "Lo 0.5"}, + {0x0050, "Lo 0.3"}, + {0x0064, "100"}, + {0x007d, "125"}, + {0x008c, "140"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0118, "280"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0230, "560"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x0898, "2200"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1194, "4500"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4650, "18000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "32000"}, + {0x8ca0, "36000"}, + {0x9c40, "40000"}, + {0xC800, "51200"}, + {0xFA00, "Hi 0.3"}, + {0x11940, "Hi 0.5"}, + {0x13d30, "Hi 0.7"}, + {0x19000, "Hi 1"}, + {0x32000, "Hi 2"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "200"}, + {1, "250"}, + {2, "280"}, + {3, "320"}, + {4, "400"}, + {5, "500"}, + {6, "560"}, + {7, "640"}, + {8, "800"}, + {9, "1000"}, + {10, "1100"}, + {11, "1250"}, + {12, "1600"}, + {13, "2000"}, + {14, "2200"}, + {15, "2500"}, + {16, "3200"}, + {17, "4000"}, + {18, "4500"}, + {19, "5000"}, + {20, "6400"}, + {21, "8000"}, + {22, "9000"}, + {23, "10000"}, + {24, "12800"}, + {25, "16000"}, + {26, "18000"}, + {27, "20000"}, + {28, "25600"}, + {29, "32000"}, + {30, "36000"}, + {31, "40000"}, + {32, "51200"}, + {33, "Hi 0.3"}, + {34, "Hi 0.5"}, + {35, "Hi 0.7"}, + {36, "Hi 1"}, + {37, "Hi 2"}, + }; + + } + + protected virtual void InitFNumber() + { + NormalFNumber = new PropertyValue {IsEnabled = true, Name = "FNumber"}; + NormalFNumber.ValueChanged += NormalFNumber_ValueChanged; + NormalFNumber.SubType = typeof(UInt16); + MovieFNumber = new PropertyValue {IsEnabled = true, Name = "FNumber"}; + MovieFNumber.ValueChanged += MovieFNumber_ValueChanged; + MovieFNumber.SubType = typeof(UInt16); + ReInitFNumber(false); + } + + private void MovieFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) val), + CONST_PROP_MovieFnumber); + } + + private void NormalFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16) val), + CONST_PROP_Fnumber); + } + + } + +} diff --git a/DigiCamControl/CameraControl.Devices/Nikon/NikonZ7.cs b/DigiCamControl/CameraControl.Devices/Nikon/NikonZ7.cs new file mode 100644 index 0000000..a0ade3d --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Nikon/NikonZ7.cs @@ -0,0 +1,123 @@ +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Nikon +{ + public class NikonZ7 : NikonD500 + { + public NikonZ7() + { + _isoTable = new Dictionary() + { + {0x0020, "Lo 1.0"}, + {0x0028, "Lo 0.7"}, + {0x002d, "Lo 0.5"}, + {0x0032, "Lo 0.3"}, + {0x0040, "64"}, + {0x0048, "72"}, + {0x0050, "80"}, + {0x0064, "100"}, + {0x007D, "125"}, + {0x00A0, "160"}, + {0x00C8, "200"}, + {0x00FA, "250"}, + {0x0140, "320"}, + {0x0190, "400"}, + {0x01F4, "500"}, + {0x0280, "640"}, + {0x0320, "800"}, + {0x03E8, "1000"}, + {0x04E2, "1250"}, + {0x0640, "1600"}, + {0x07D0, "2000"}, + {0x09C4, "2500"}, + {0x0C80, "3200"}, + {0x0FA0, "4000"}, + {0x1388, "5000"}, + {0x1900, "6400"}, + {0x1F40, "8000"}, + {0x2710, "10000"}, + {0x3200, "12800"}, + {0x3e80, "16000"}, + {0x4e20, "20000"}, + {0x6400, "25600"}, + {0x7d00, "Hi 0.3"}, + {0x9c40, "Hi 0.7"}, + {0xC800, "Hi 1.0"}, + {0x19000, "Hi 2.0"}, + }; + + _autoIsoTable = new Dictionary() + { + {0, "100"}, + {1, "125"}, + {2, "140"}, + {3, "160"}, + {4, "200"}, + {5, "250"}, + {6, "280"}, + {7, "320"}, + {8, "400"}, + {9, "500"}, + {10, "560"}, + {11, "640"}, + {12, "800"}, + {13, "1000"}, + {14, "1100"}, + {15, "1250"}, + {16, "1600"}, + {17, "2000"}, + {18, "2200"}, + {19, "2500"}, + {20, "3200"}, + {21, "4000"}, + {22, "4500"}, + {23, "5000"}, + {24, "6400"}, + {25, "8000"}, + {26, "9000"}, + {27, "10000"}, + {28, "12800"}, + {29, "16000"}, + {30, "18000"}, + {31, "20000"}, + {32, "25600"}, + {33, "Hi 0.3"}, + {34, "Hi 0.5"}, + {35, "Hi 0.7"}, + {36, "Hi 1"}, + {37, "Hi 2"}, + }; + } + protected virtual void InitFNumber() + { + NormalFNumber = new PropertyValue { IsEnabled = true, Name = "FNumber" }; + NormalFNumber.ValueChanged += NormalFNumber_ValueChanged; + NormalFNumber.SubType = typeof(UInt16); + MovieFNumber = new PropertyValue { IsEnabled = true, Name = "FNumber" }; + MovieFNumber.ValueChanged += MovieFNumber_ValueChanged; + MovieFNumber.SubType = typeof(UInt16); + ReInitFNumber(false); + } + + private void MovieFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((UInt16)val), + CONST_PROP_MovieFnumber); + } + + private void NormalFNumber_ValueChanged(object sender, string key, long val) + { + if (Mode != null && (Mode.Value == "A" || Mode.Value == "M")) + SetProperty(CONST_CMD_SetDevicePropValue, BitConverter.GetBytes((ushort)val), + CONST_PROP_Fnumber); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Others/FakeCameraDevice.cs b/DigiCamControl/CameraControl.Devices/Others/FakeCameraDevice.cs new file mode 100644 index 0000000..42bfda3 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/FakeCameraDevice.cs @@ -0,0 +1,201 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Others +{ + public class FakeCameraDevice : BaseCameraDevice + { + #region Implementation of ICameraDevice + + + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + return true; + } + + public override void CapturePhoto() + { + List files = new List( + Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "*."+ CompressionSetting.Value)); + if (files.Count > 0) + { + Random rnd1 = new Random(); + var file = files[rnd1.Next(files.Count - 1)]; + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = null, + CameraDevice = this, + FileName = file, + Handle = file + }; + Task.Factory.StartNew(() => OnPhotoCapture(this, args)); + } + else + { + throw new Exception("No file in the MyPictures folder with extension " + CompressionSetting.Value); + } + } + + public override void CapturePhotoNoAf() + { + CapturePhoto(); + } + + public override void TransferFile(object o, string filename) + { + File.Copy((string) o, filename); + } + + #endregion + + private LiveViewData _liveViewData = new LiveViewData(); + + public FakeCameraDevice() + { + HaveLiveView = false; + IsBusy = false; + DeviceName = "Fake camera"; + SerialNumber = "00000000"; + IsConnected = true; + HaveLiveView = false; + ExposureStatus = 1; + ExposureCompensation = new PropertyValue() {IsEnabled = false}; + Mode = new PropertyValue {IsEnabled = false}; + FNumber = new PropertyValue {IsEnabled = false}; + ShutterSpeed = new PropertyValue {IsEnabled = false}; + WhiteBalance = new PropertyValue {IsEnabled = false}; + FocusMode = new PropertyValue {IsEnabled = false}; + + CompressionSetting = new PropertyValue {IsEnabled = true}; + CompressionSetting.AddValues("jpg",0); + CompressionSetting.AddValues("cr2", 1); + CompressionSetting.AddValues("nef", 2); + CompressionSetting.Value = "jpg"; + CompressionSetting.ReloadValues(); + + IsoNumber = new PropertyValue {IsEnabled = true}; + ExposureMeteringMode = new PropertyValue {IsEnabled = false}; + Battery = 100; + Capabilities.Add(CapabilityEnum.CaptureNoAf); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.LiveViewStream); + LiveViewImageZoomRatio = new PropertyValue(); + LiveViewImageZoomRatio.AddValues("All", 0); + LiveViewImageZoomRatio.Value = "All"; + + IsoNumber.AddValues("100", 100); + IsoNumber.AddValues("200", 200); + IsoNumber.AddValues("300", 300); + IsoNumber.Value = "100"; + IsoNumber.ReloadValues(); + + var val = new PropertyValue() {Name = "Test Test"}; + val.AddValues("Val 1", 1); + val.AddValues("Val 2", 2); + val.AddValues("Val 3", 3); + val.Value = "Val 1"; + val.ReloadValues(); + AdvancedProperties.Add(val); + } + + public override void StartLiveView() + { + _liveViewData.ImageData = File.ReadAllBytes("logo_big.jpg"); + _liveViewData.FocusFrameXSize = 100; + _liveViewData.FocusFrameYSize = 100; + _liveViewData.HaveFocusData = true; + _liveViewData.IsLiveViewRunning = true; + _liveViewData.LiveViewImageHeight = 639; + _liveViewData.LiveViewImageWidth = 639; + _liveViewData.ImageWidth = 639; + _liveViewData.ImageHeight = 639; + _liveViewData.FocusX = 639/2; + _liveViewData.FocusY = 639 / 2; + } + + public override void StopLiveView() + { + + } + + public override string GetLiveViewStream() + { + return "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"; + } + + public override LiveViewData GetLiveViewImage() + { + _liveViewData.SoundL++; + if (_liveViewData.SoundL > 99) + _liveViewData.SoundL = 0; + + _liveViewData.SoundR++; + if (_liveViewData.SoundR > 99) + _liveViewData.SoundR = 0; + + return _liveViewData; + } + + public override void Focus(int x, int y) + { + _liveViewData.FocusX = x; + _liveViewData.FocusY = y; + } + + public override int Focus(int step) + { + return step; + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + return true; + } + + //public override string ToString() + //{ + + // StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................Fake"); + // return c.ToString(); + //} + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Others/FileTransferDevice.cs b/DigiCamControl/CameraControl.Devices/Others/FileTransferDevice.cs new file mode 100644 index 0000000..afa0a2c --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/FileTransferDevice.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CameraControl.Devices.Others +{ + public class FileTransferDevice: FakeCameraDevice + { + + public FileTransferDevice():base() + { + DeviceName = "FileTransfer"; + } + + public override void TransferFile(object o, string filename) + { + File.WriteAllBytes(filename,(byte[])o); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Others/NotConnectedCameraDevice.cs b/DigiCamControl/CameraControl.Devices/Others/NotConnectedCameraDevice.cs new file mode 100644 index 0000000..0f761ed --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/NotConnectedCameraDevice.cs @@ -0,0 +1,65 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Text; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Others +{ + public class NotConnectedCameraDevice : BaseCameraDevice + { + #region Implementation of ICameraDevice + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + HaveLiveView = false; + IsBusy = false; + return true; + } + + #endregion + + public NotConnectedCameraDevice() + { + IsConnected = false; + HaveLiveView = false; + ExposureStatus = 1; + } + + public override string ToString() + { + + StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................Fake"); + return c.ToString(); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Others/OscCamera.cs b/DigiCamControl/CameraControl.Devices/Others/OscCamera.cs new file mode 100644 index 0000000..60215cc --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/OscCamera.cs @@ -0,0 +1,359 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using CameraControl.Devices; +using CameraControl.Devices.Classes; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace CameraControl.Devices.Others +{ + public class OscCamera : BaseCameraDevice + { + private string ExecuteEndPoint = "/osc/commands/execute"; + private string InfoEndPoint = "/osc/info"; + private string StatusEndPoint = "/osc/commands/status"; + + + public string Address { get; set; } + public string SessionId { get; set; } + + public void Init(string address) + { + + LiveViewImageZoomRatio = new PropertyValue(); + IsConnected = true; + IsoNumber = new PropertyValue {Available = true}; + FNumber = new PropertyValue {Available = false}; + ExposureCompensation = new PropertyValue {Available = true}; + FocusMode = new PropertyValue {Available = false}; + ShutterSpeed = new PropertyValue {Available = false}; + WhiteBalance = new PropertyValue {Available = false}; + Mode = new PropertyValue() {Available = true}; + SessionId = null; + Address = address; + GetInfo(); + GetSessionId(GetExecute(CreateJson("camera.startSession"))); + //SetProperty("clientVersion", 2); + InitIso(); + InitExposureCompensation(); + InitMode(); + } + + + private void InitIso() + { + try + { + IsoNumber = new PropertyValue { Available = true, IsEnabled = true}; + string property = "iso"; + var response = GetProperty(property); +// response = + //"{\"name\":\"camera.getOptions\",\"state\":\"done\",\"results\":{\"options\":{\"iso\":100,\"isoSupport\":[100,125,160,200,250,320,400,500,640,800,1000,1250,1600]}}}"; + var json = Initialize(response); + var val = json["results"]["options"][property].Value(); + var vals = json["results"]["options"][property + "Support"].Values().ToList(); + foreach (int i in vals) + { + IsoNumber.AddValues(i == 0 ? "Auto" : i.ToString(), i); + } + if (val == "0") + { + if (!vals.Contains(0)) + IsoNumber.AddValues("Auto", 0); + IsoNumber.Value = "Auto"; + IsoNumber.IsEnabled = false; + } + else + IsoNumber.Value = val; + IsoNumber.ReloadValues(); + IsoNumber.ValueChanged += (o, s, i) => SetProperty(property, i); + } + catch (Exception ex) + { + Log.Debug("Unable to get ISO", ex); + throw; + } + } + + private void InitExposureCompensation() + { + try + { + string property = "exposureCompensation"; + var response = GetProperty(property); +// response = +// "{\"name\":\"camera.getOptions\",\"state\":\"done\",\"results\":{\"options\":{\"exposureCompensation\":0.0,\"exposureCompensationSupport\":[-2.0,-1.7,-1.3,-1.0,-0.7,-0.3,0.0,0.3,0.7,1.0,1.3,1.7,2.0]}}}"; + var json = Initialize(response); + var val = json["results"]["options"][property].Value(); + var vals = json["results"]["options"][property + "Support"].Values(); + foreach (string s in vals) + { + ExposureCompensation.AddValues(s, 0); + } + ExposureCompensation.Value = val; + ExposureCompensation.ReloadValues(); + ExposureCompensation.ValueChanged += (o, s, i) => SetProperty(property, double.Parse(s,CultureInfo.InvariantCulture)); + } + catch (Exception ex) + { + Log.Debug("Unable to get exposureCompensation", ex); + + } + + } + + private void InitMode() + { + try + { + string property = "exposureProgram"; + var response = GetProperty(property); + var json = Initialize(response); + var val = json["results"]["options"][property].Value(); + //var vals = json["results"]["options"][property + "Support"].Values(); + // Mode.AddValues("Manual program", 1); + Mode.AddValues("Auto", 2); + // Mode.AddValues("Shutter priority program", 4); + Mode.AddValues("ISO priority program", 9); + + Mode.ReloadValues(); + Mode.ValueChanged += (o, s, i) => + { + SetProperty(property, i); + InitIso(); + }; + Mode.SetValue(val); + } + catch (Exception ex) + { + Log.Debug("Unable to get exposureProgram", ex); + + } + + } + + private string GetProperty(string name) + { + var param = new JArray(); + param.Add(name); + param.Add(name + "Support"); + var s = CreateJson("camera.getOptions", new JProperty("optionNames", param)); + return GetExecute(s); + } + + public void SetProperty(string name, object val) + { + try + { + var p = new JObject(); + p.Add(new JProperty(name, val)); + var s = CreateJson("camera.setOptions", new JProperty("options", p)); + // Log.Debug(s); + var res = GetExecute(s); + //Log.Debug(res); + Initialize(res); + } + catch (Exception ex) + { + Log.Error("Unable to set property " + name+" "+val.ToString(), ex); + } + } + + private void GetInfo() + { + var response = Get(InfoEndPoint); + var json = Initialize(response); + Manufacturer = json["manufacturer"].Value(); + DeviceName = json["model"].Value(); + SerialNumber = json["serialNumber"].Value(); + } + + private void GetSessionId(string response) + { + //response = "{\"name\":\"camera.startSession\",\"state\":\"done\",\"results\":{ \"sessionId\":\"SID_0001\",\"timeout\":180}}"; + var json = Initialize(response); + SessionId = json["results"]["sessionId"].Value(); + } + + public override void CapturePhoto() + { + var json = Initialize(GetExecute(CreateJson("camera.takePicture"))); + string id = json["id"].Value(); + string url = null; + do + { + var jsonStatus = Initialize(GetStatus(id)); + if (jsonStatus["state"].Value() == "done") + { + url = jsonStatus["results"]["fileUri"].Value(); + } + else + { + Thread.Sleep(150); + } + } while (string.IsNullOrEmpty(url)); + Log.Debug("Url to process " + url); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = null, + CameraDevice = this, + FileName = url.Replace('/', '\\'), + Handle = url + }; + OnPhotoCapture(this, args); + } + + public override void TransferFile(object o, string filename) + { + string url = ((string) o); + if (!url.StartsWith("http")) + { + url = Address + "/" + url; + } + TransferProgress = 0; + HttpHelper.DownLoadFileByWebRequest(url, filename, this); + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + try + { + string url = ((string)deviceObject.Handle); + var array = new JArray {url}; + var s = CreateJson("camera.delete", new JProperty("fileUrls", array)); + GetExecute(s); + } + catch (Exception ex) + { + Log.Error("Unable to set property ", ex); + } + return true; + } + + internal static JObject Initialize(string response) + { + var json = JObject.Parse(response); + if (json == null) + { + //throw new RemoteApiException(StatusCode.IllegalResponse); + } + if (json["error"] != null) + { + throw new DeviceException(json["error"]["code"].Value(), json["error"]["message"].Value()); + //throw new RemoteApiException((StatusCode)json["error"].Value(0)); + } + return json; + } + + + private string CreateJson(string name, params object[] prms) + { + var param = new JObject(); + if (!string.IsNullOrEmpty(SessionId)) + { + param.Add(new JProperty("sessionId", SessionId)); + } + + if (prms != null) + { + foreach (var p in prms) + { + param.Add(p); + } + } + var json = new JObject( + new JProperty("name", name), + new JProperty("parameters", param)); + + return json.ToString(Formatting.Indented); + } + + private string GetUrl(string command) + { + return Address + command; + } + + public string GetStatus(string id) + { + return Get(StatusEndPoint, new JObject(new JProperty("id", id)).ToString(Formatting.None)); + } + + public string GetExecute( string postData = null) + { + return Get(ExecuteEndPoint, postData); + } + + public string Get(string command, string postData=null) + { + try + { + if (string.IsNullOrEmpty(postData)) + { + using (var client = new WebClient()) + { + return client.DownloadString(GetUrl(command)); + } + } + // Create a request using a URL that can receive a post. + WebRequest request = WebRequest.Create(GetUrl(command)); + // Set the Method property of the request to POST. + request.Method = "POST"; + // Create POST data and convert it to a byte array. + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + // Set the ContentType property of the WebRequest. + request.ContentType = "application/json;charset=utf-8"; + // Set the ContentLength property of the WebRequest. + request.ContentLength = byteArray.Length; + Stream dataStream = null; + + // Get the request stream. + dataStream = request.GetRequestStream(); + // Write the data to the request stream. + dataStream.Write(byteArray, 0, byteArray.Length); + // Close the Stream object. + dataStream.Close(); + // Get the response. + WebResponse response = request.GetResponse(); + // Display the status. + Console.WriteLine(((HttpWebResponse)response).StatusDescription); + // Get the stream containing content returned by the server. + dataStream = response.GetResponseStream(); + // Open the stream using a StreamReader for easy access. + StreamReader reader = new StreamReader(dataStream); + // Read the content. + var res = reader.ReadToEnd(); + // Display the content. + // Clean up the streams. + reader.Close(); + dataStream.Close(); + response.Close(); + return res; + } + catch (WebException exx) + { + using (WebResponse response = exx.Response) + { + HttpWebResponse httpResponse = (HttpWebResponse)response; + if (httpResponse != null) + { + using (Stream data = httpResponse.GetResponseStream()) + using (var reader = new StreamReader(data)) + { + return reader.ReadToEnd(); + } + } + } + } + return ""; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Others/PanonoCamera.cs b/DigiCamControl/CameraControl.Devices/Others/PanonoCamera.cs new file mode 100644 index 0000000..46b8574 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/PanonoCamera.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading; +using CameraControl.Devices; +using CameraControl.Devices.Classes; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using WebSocketSharp; +using Timer = System.Timers.Timer; + +namespace PanonoTest +{ + public class PanonoCamera : BaseCameraDevice + { + private WebSocket _ws; + private static int request_id = 0; + private Timer _timer = new Timer(500); + + + public bool Init(string endpoint) + { + + _ws = new WebSocket(endpoint); + _ws.WaitTime = new TimeSpan(0, 0, 4); + _ws.OnMessage += Ws_OnMessage; + _ws.OnClose += _ws_OnClose; + _ws.OnError += _ws_OnError; + _ws.Connect(); + LiveViewImageZoomRatio = new PropertyValue(); + Auth(); + IsConnected = true; + IsoNumber = new PropertyValue {Available = true}; + FNumber = new PropertyValue {Available = false}; + ExposureCompensation = new PropertyValue {Available = false}; + FocusMode = new PropertyValue {Available = false}; + ShutterSpeed = new PropertyValue {Available = false}; + WhiteBalance = new PropertyValue {Available = false}; + InitIso(); + InitMode(); + _timer.Elapsed += _timer_Elapsed; + _timer.AutoReset = true; + // _timer.Start(); + return true; + } + + private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + try + { + //using (WebClient client = new WebClient()) + //{ + // var s = client.DownloadString("http://" + _ws.Url.Host + "/update_image"); + //} + } + catch (WebException ex) + { + if ((uint)ex.HResult != 0x80131515) + Log.Error("Ping error ", ex); + } + } + + private void _ws_OnError(object sender, ErrorEventArgs e) + { + StaticHelper.Instance.SystemMessage = e.Message; + } + + private void _ws_OnClose(object sender, CloseEventArgs e) + { + Close(); + OnCameraDisconnected(this, new DisconnectCameraEventArgs {}); + } + + public override void Close() + { + _timer.Stop(); + try + { + _ws.OnMessage -= Ws_OnMessage; + _ws.OnClose -= _ws_OnClose; + _ws.OnError -= _ws_OnError; + _ws.Close(); + } + catch (Exception e) + { + Log.Error("Camera close error", e); + } + } + + private void InitIso() + { + IsoNumber.Tag = "ISO"; + IsoNumber.AddValues("50", 50); + IsoNumber.AddValues("100", 100); + IsoNumber.AddValues("200", 200); + IsoNumber.AddValues("400", 400); + IsoNumber.AddValues("800", 800); + IsoNumber.AddValues("1600", 1600); + IsoNumber.ReloadValues(); + IsoNumber.ValueChanged += IsoNumber_ValueChanged; + ExecuteMethod("get_options", IsoNumber.Tag); + } + + private void InitMode() + { + Mode = new PropertyValue {Tag = "ImageType"}; + Mode.AddValues("Default", 0); + Mode.AddValues("HDR", 1); + Mode.ReloadValues(); + Mode.ValueChanged += Mode_ValueChanged; + ExecuteMethod("get_options", Mode.Tag); + } + + + private void SetProperty(string key, string value) + { + _ws.Send("{ \"id\":3,\"method\":\"set_options\",\"params\":{ \"" + key + "\":\"" + value + + "\"},\"jsonrpc\":\"2.0\"}"); + } + + private void Mode_ValueChanged(object sender, string key, long val) + { + SetProperty(Mode.Tag, key); + } + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + SetProperty(IsoNumber.Tag, key); + } + + public void Auth() + { + ExecuteMethod("auth", "{\"device\":\"test\",\"force\":\"test\"}"); + } + + public override void CapturePhoto() + { + IsBusy = true; + ExecuteMethod("capture"); + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + return true; + } + + private void Ws_OnMessage(object sender, MessageEventArgs e) + { + try + { + var json = JObject.Parse(e.Data); + if (json["result"] != null) + { + var values = json["result"].ToObject>(); + if (values.ContainsKey("serial_number")) + SerialNumber = (string)values["serial_number"]; + if (values.ContainsKey(IsoNumber.Tag)) + IsoNumber.SetValue((string)values[IsoNumber.Tag], false); + + if (values.ContainsKey(Mode.Tag)) + Mode.SetValue((string)values[Mode.Tag], false); + } + if ((string)json["method"] == "status_update") + { + if (json["params"]["battery_value"] != null) + { + Battery = json["params"]["battery_value"].Value(); + } + if (json["params"]["capture_available"] != null) + { + IsBusy = json["params"]["capture_available"].Value(); + } + } + if ((string)json["method"] == "upf_infos_update") + { + if (json["params"] != null) + { + var values = json["params"]["upf_infos"][0].ToObject>(); + if (values.ContainsKey("upf_status") && (string)values["upf_status"] == "ready") + { + string url = (string)values["upf_url"]; + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = null, + CameraDevice = this, + FileName = url.Replace('/', '\\'), + Handle = new List() { url, (long)values["upf_size"] } + }; + OnPhotoCapture(this, args); + } + } + } + } + catch (Exception ex) + { + + } + } + + public override void TransferFile(object o, string filename) + { + _timer.Stop(); + Thread.Sleep(100); + TransferProgress = 0; + var param = o as List; + HttpHelper.DownLoadFileByWebRequest((string) param[0], filename, this, (long) param[1]); + _timer.Start(); + } + + public override void TransferFileThumb(object o, string filename) + { + _timer.Stop(); + Thread.Sleep(100); + TransferProgress = 0; + var param = o as List; + HttpHelper.DownLoadFileByWebRequest(((string)param[0]).Replace("panoramas", "previews"), filename, + this); + _timer.Start(); + } + + private void ExecuteMethod(string method, params object[] prms) + { + _ws.Send(CreateJson(method, prms)); + } + + + private int GetId() + { + var id = Interlocked.Increment(ref request_id); + if (request_id > 1000000000) + { + request_id = 0; + } + return id; + } + + private string CreateJson(string name, params object[] prms) + { + return CreateJson(name, "2.0", prms); + } + + private string CreateJson(string name, string version, params object[] prms) + { + var param = new JArray(); + JObject json; + if (prms != null && prms.Length > 0) + { + foreach (var p in prms) + { + param.Add(p); + } + json = new JObject( + new JProperty("id", GetId()), + new JProperty("method", name), + new JProperty("params", param), + new JProperty("jsonrpc", version)); + } + else + { + json = new JObject( + new JProperty("id", GetId()), + new JProperty("method", name), + new JProperty("jsonrpc", version)); + } + + + return json.ToString(Formatting.None); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Others/WebCameraDevice.cs b/DigiCamControl/CameraControl.Devices/Others/WebCameraDevice.cs new file mode 100644 index 0000000..36251e1 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/WebCameraDevice.cs @@ -0,0 +1,210 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Threading; +using Accord.Video; +using Accord.Video.DirectShow; +using CameraControl.Devices.Classes; + +namespace CameraControl.Devices.Others +{ + public class WebCameraDevice: BaseCameraDevice + { + private VideoCaptureDevice _captureDevice; + + private LiveViewData _liveViewData = new LiveViewData(); + + private volatile bool _operationInProgress; + private Object _lock = new Object(); + private volatile bool _processLiveView = false; + + + public WebCameraDevice() + { + Capabilities.Add(CapabilityEnum.LiveView); + } + + public void Init(string id) + { + PortName = id; + _captureDevice = new VideoCaptureDevice(id); + _captureDevice.NewFrame += _localWebCam_NewFrame; + _captureDevice.SnapshotFrame += _localWebCam_SnapshotFrame; + _captureDevice.ProvideSnapshots = true; + IsConnected = true; + LiveViewImageZoomRatio = new PropertyValue(); + + IsoNumber = new PropertyValue { Available = false }; + FNumber = new PropertyValue { Available = false }; + ExposureCompensation = new PropertyValue { Available = false }; + FocusMode = new PropertyValue { Available = false }; + ShutterSpeed = new PropertyValue { Available = false }; + WhiteBalance = new PropertyValue { Available = false }; + Mode = new PropertyValue { Available = false }; + ExposureMeteringMode = new PropertyValue { Available = false }; + CompressionSetting =new PropertyValue(); + VideoCapabilities[] capabilities = _captureDevice.VideoCapabilities; + for (int i = 0; i < capabilities.Length; i++) + { + CompressionSetting.AddValues(capabilities[i].ToString(),i); + } + CompressionSetting.ReloadValues(); + StartLiveView(); + if (_captureDevice.VideoResolution != null) + CompressionSetting.Value = _captureDevice.VideoResolution.ToString(); + else + { + if (_captureDevice.VideoCapabilities.Length > 0) + { + _captureDevice.VideoResolution = _captureDevice.VideoCapabilities.First(); + CompressionSetting.Value = _captureDevice.VideoResolution.ToString(); + } + } + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + + } + + private void CompressionSetting_ValueChanged(object sender, string key, long val) + { + StopLiveView(); + VideoCapabilities[] capabilities = _captureDevice.VideoCapabilities; + _captureDevice.VideoResolution = capabilities[val]; + StartLiveView(); + } + + private void _localWebCam_NewFrame(object sender, NewFrameEventArgs eventargs) + { + if (_operationInProgress || !_processLiveView) + return; + try + { + _operationInProgress = true; + Image img = (Bitmap)eventargs.Frame.Clone(); + MemoryStream ms = new MemoryStream(); + img.Save(ms, ImageFormat.Jpeg); + ms.Seek(0, SeekOrigin.Begin); + _liveViewData.ImageData = ms.ToArray(); + } + catch (Exception ex) + { + Log.Error("Error get webcam frame ", ex); + } + } + + public override void TransferFile(object o, string filename) + { + byte[] data = (byte[])o; + File.WriteAllBytes(filename, data); + } + + public override void CapturePhotoNoAf() + { + CapturePhoto(); + } + + public override void CapturePhoto() + { + StartLiveView(); + + _processLiveView = true; + GetLiveViewImage(); + if (_liveViewData.ImageData != null) + { + PhotoCaptureEvent(_liveViewData.ImageData); + _liveViewData.ImageData = null; + } + else + { + throw new Exception("Could not capture photo from webcam."); + } + + + //StopLiveView(); + } + + public override void StartLiveView() + { + lock (_lock) + { + if (!_captureDevice.IsRunning) + { + _captureDevice.Start(); + Thread.Sleep(500); + } + _operationInProgress = false; + _processLiveView = true; + } + } + + public override void StopLiveView() + { + lock (_lock) + { + _captureDevice.SignalToStop(); + _captureDevice.WaitForStop(); + _operationInProgress = false; + _processLiveView = false; + } + } + + public override LiveViewData GetLiveViewImage() + { + _operationInProgress = false; + return _liveViewData; + } + + private void PhotoCaptureEvent(byte[] data) + { + try + { + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = null, + CameraDevice = this, + FileName = "img0000.jpg", + Handle = data + }; + OnPhotoCapture(this, args); + + } + catch (Exception e) + { + Log.Error("Photo capture error", e); + } + + } + + private void _localWebCam_SnapshotFrame(object sender, NewFrameEventArgs eventargs) + { + try + { + System.Drawing.Image img = (Bitmap)eventargs.Frame.Clone(); + using (MemoryStream ms = new MemoryStream()) + { + img.Save(ms, ImageFormat.Jpeg); + ms.Seek(0, SeekOrigin.Begin); + PhotoCaptureEvent(ms.ToArray()); + } + } + catch (Exception ex) + { + Log.Error("Unable to execute event", ex); + } + } + + public override void Close() + { + if (_captureDevice != null) + { + _captureDevice.SignalToStop(); + _captureDevice.SnapshotFrame -= _localWebCam_SnapshotFrame; + _captureDevice.NewFrame -= _localWebCam_NewFrame; + _captureDevice.WaitForStop(); + _captureDevice = null; + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Others/WiaCameraDevice.cs b/DigiCamControl/CameraControl.Devices/Others/WiaCameraDevice.cs new file mode 100644 index 0000000..f4e7d3e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/WiaCameraDevice.cs @@ -0,0 +1,733 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using CameraControl.Devices.Classes; +using WIA; + +#endregion + +namespace CameraControl.Devices.Others +{ + public class WiaCameraDevice : BaseCameraDevice + { + private Dictionary ShutterTable = new Dictionary + { + {1, "1/6400"}, + {2, "1/4000"}, + {3, "1/3200"}, + {4, "1/2500"}, + {5, "1/2000"}, + {6, "1/1600"}, + {8, "1/1250"}, + {10, "1/1000"}, + {12, "1/800"}, + {15, "1/640"}, + {20, "1/500"}, + {25, "1/400"}, + {31, "1/320"}, + {40, "1/250"}, + {50, "1/200"}, + {62, "1/160"}, + {80, "1/125"}, + {100, "1/100"}, + {125, "1/80"}, + {166, "1/60"}, + {200, "1/50"}, + {250, "1/40"}, + {333, "1/30"}, + {400, "1/25"}, + {500, "1/20"}, + {666, "1/15"}, + {769, "1/13"}, + {1000, "1/10"}, + {1250, "1/8"}, + {1666, "1/6"}, + {2000, "1/5"}, + {2500, "1/4"}, + {3333, "1/3"}, + {4000, "1/2.5"}, + {5000, "1/2"}, + {6250, "1/1.6"}, + {7692, "1/1.3"}, + {10000, "1s"}, + {13000, "1.3s"}, + {16000, "1.6s"}, + {20000, "2s"}, + {25000, "2.5s"}, + {30000, "3s"}, + {40000, "4s"}, + {50000, "5s"}, + {60000, "6s"}, + {80000, "8s"}, + {100000, "10s"}, + {130000, "13s"}, + {150000, "15s"}, + {200000, "20s"}, + {250000, "25s"}, + {300000, "30s"}, + {-1, "Bulb"}, + }; + + private Dictionary ExposureModeTable = new Dictionary() + { + {1, "M"}, + {2, "P"}, + {3, "A"}, + {4, "S"}, + {0x8010, "[Scene mode] AUTO"}, + {0x8011, "[Scene mode] Portrait"}, + {0x8012, "[Scene mode] Landscape"}, + {0x8013, "[Scene mode] Close up"}, + {0x8014, "[Scene mode] Sports"}, + {0x8016, "[Scene mode] Flash prohibition AUTO"}, + {0x8017, "[Scene mode] Child"}, + {0x8018, "[Scene mode] SCENE"}, + {0x8019, "[EffectMode] EFFECTS"}, + }; + + private Dictionary WbTable = new Dictionary() + { + {2, "Auto"}, + {4, "Daylight"}, + {5, "Fluorescent "}, + {6, "Incandescent"}, + {7, "Flash"}, + {32784, "Cloudy"}, + {32785, "Shade"}, + {32786, "Kelvin"}, + {32787, "Custom"} + }; + + private Dictionary CSTable = new Dictionary() + { + {0, "JPEG (BASIC)"}, + {1, "JPEG (NORMAL)"}, + {2, "JPEG (FINE)"}, + {3, "TIFF (RGB)"}, + {4, "RAW"}, + {5, "RAW + JPEG (BASIC)"}, + {6, "RAW + JPEG (NORMAL)"}, + {7, "RAW + JPEG (FINE)"} + }; + + private Dictionary EMMTable = new Dictionary + { + {2, "Center-weighted metering"}, + {3, "Multi-pattern metering"}, + {4, "Spot metering"} + }; + + private Dictionary FMTable = new Dictionary() + { + {1, "[M] Manual focus"}, + {0x8010, "[S] Single AF servo"}, + {0x8011, "[C] Continuous AF servo"}, + {0x8012, "[A] AF servo mode automatic switching"}, + {0x8013, "[F] Constant AF servo"}, + }; + + #region Implementation of ICameraDevice + + private string _displayName; + + public override string DisplayName + { + get + { + if (string.IsNullOrEmpty(_displayName)) + return DeviceName + " (" + SerialNumber + ")" + "(WIA)"; + return _displayName; + } + set + { + _displayName = value; + NotifyPropertyChanged("DisplayName"); + } + } + + + //public override bool GetCapability(CapabilityEnum capabilityEnum) + //{ + // return false; + //} + + + private Device Device { get; set; } + internal new object Locker = new object(); // object used to lock multi + public DeviceManager DeviceManager { get; set; } + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + IsBusy = false; + //the device not connected + try + { + ConnectToWiaDevice(deviceDescriptor); + } + catch (Exception exception) + { + Log.Error("Unable to connect camera using wia driver", exception); + return false; + } + DeviceManager = new DeviceManager(); + DeviceManager.RegisterEvent(Conts.wiaEventItemCreated, deviceDescriptor.WiaId); + DeviceManager.OnEvent += DeviceManager_OnEvent; + + try + { + Device = deviceDescriptor.WiaDevice; + DeviceName = Device.Properties["Description"].get_Value(); + Manufacturer = Device.Properties["Manufacturer"].get_Value(); + SerialNumber = StaticHelper.GetSerial(Device.Properties["PnP ID String"].get_Value()); + } + catch (Exception ex) + { + Log.Debug("Init error", ex); + } + IsConnected = true; + try + { + try + { + Property apertureProperty = Device.Properties[Conts.CONST_PROP_F_Number]; + if (apertureProperty != null) + { + foreach (var subTypeValue in apertureProperty.SubTypeValues) + { + double d = (int) subTypeValue; + string s = (d/100).ToString("0.0"); + FNumber.AddValues(s, (int) d); + FNumber.ReloadValues(); + if ((int) subTypeValue == (int) apertureProperty.get_Value()) + FNumber.SetValue((int) d); + } + } + } + catch (COMException) + { + FNumber.IsEnabled = false; + } + + try + { + Property isoProperty = Device.Properties[Conts.CONST_PROP_ISO_Number]; + if (isoProperty != null) + { + foreach (var subTypeValue in isoProperty.SubTypeValues) + { + IsoNumber.AddValues(subTypeValue.ToString(), (int) subTypeValue); + IsoNumber.ReloadValues(); + if ((int) subTypeValue == (int) isoProperty.get_Value()) + IsoNumber.SetValue((int) subTypeValue); + } + } + } + catch (COMException) + { + IsoNumber.IsEnabled = false; + } + + try + { + Property shutterProperty = Device.Properties[Conts.CONST_PROP_Exposure_Time]; + if (shutterProperty != null) + { + foreach (int subTypeValue in shutterProperty.SubTypeValues) + { + if (ShutterTable.ContainsKey((int) subTypeValue)) + ShutterSpeed.AddValues(ShutterTable[(int) subTypeValue], (int) subTypeValue); + } + ShutterSpeed.ReloadValues(); + ShutterSpeed.SetValue(shutterProperty.get_Value()); + } + } + catch (COMException) + { + ShutterSpeed.IsEnabled = false; + } + + try + { + Property wbProperty = Device.Properties[Conts.CONST_PROP_WhiteBalance]; + if (wbProperty != null) + { + foreach (var subTypeValue in wbProperty.SubTypeValues) + { + if (WbTable.ContainsKey((int) subTypeValue)) + WhiteBalance.AddValues(WbTable[(int) subTypeValue], (int) subTypeValue); + } + WhiteBalance.ReloadValues(); + WhiteBalance.SetValue(wbProperty.get_Value()); + } + } + catch (COMException) + { + WhiteBalance.IsEnabled = false; + } + + try + { + Property modeProperty = Device.Properties[Conts.CONST_PROP_ExposureMode]; + if (modeProperty != null) + { + foreach (var subTypeValue in modeProperty.SubTypeValues) + { + if (ExposureModeTable.ContainsKey((int) subTypeValue)) + Mode.AddValues(ExposureModeTable[(int) subTypeValue], Convert.ToUInt32(subTypeValue)); + } + Mode.ReloadValues(); + Mode.SetValue(Convert.ToUInt32(modeProperty.get_Value())); + } + Mode.IsEnabled = false; + } + catch (COMException) + { + Mode.IsEnabled = false; + } + + try + { + Property ecProperty = Device.Properties[Conts.CONST_PROP_ExposureCompensation]; + if (ecProperty != null) + { + foreach (var subTypeValue in ecProperty.SubTypeValues) + { + decimal d = (int) subTypeValue; + string s = decimal.Round(d/1000, 1).ToString(); + if (d > 0) + s = "+" + s; + ExposureCompensation.AddValues(s, (int) subTypeValue); + } + ExposureCompensation.ReloadValues(); + ExposureCompensation.SetValue(ecProperty.get_Value()); + } + } + catch (COMException) + { + ExposureCompensation.IsEnabled = false; + } + + try + { + Property csProperty = Device.Properties[Conts.CONST_PROP_CompressionSetting]; + if (csProperty != null) + { + foreach (var subTypeValue in csProperty.SubTypeValues) + { + if (CSTable.ContainsKey((int) subTypeValue)) + CompressionSetting.AddValues(CSTable[(int) subTypeValue], (int) subTypeValue); + } + CompressionSetting.ReloadValues(); + CompressionSetting.SetValue(csProperty.get_Value()); + } + } + catch (COMException) + { + CompressionSetting.IsEnabled = false; + } + + try + { + Property emmProperty = Device.Properties[Conts.CONST_PROP_ExposureMeteringMode]; + if (emmProperty != null) + { + foreach (var subTypeValue in emmProperty.SubTypeValues) + { + if (EMMTable.ContainsKey((int) subTypeValue)) + ExposureMeteringMode.AddValues(EMMTable[(int) subTypeValue], (int) subTypeValue); + } + ExposureMeteringMode.ReloadValues(); + ExposureMeteringMode.SetValue(emmProperty.get_Value()); + } + } + catch (COMException) + { + CompressionSetting.IsEnabled = false; + } + + try + { + Property fmProperty = Device.Properties[Conts.CONST_PROP_FocusMode]; + if (fmProperty != null) + { + foreach (int subTypeValue in fmProperty.SubTypeValues) + { + uint subval = Convert.ToUInt16(subTypeValue); + if (FMTable.ContainsKey(subval)) + FocusMode.AddValues(FMTable[subval], subval); + } + FocusMode.ReloadValues(); + FocusMode.SetValue(Convert.ToUInt16((int) fmProperty.get_Value())); + } + } + catch (COMException) + { + FocusMode.IsEnabled = false; + } + + try + { + Battery = Device.Properties[Conts.CONST_PROP_BatteryStatus].get_Value(); + } + catch (COMException) + { + Battery = 0; + } + IsConnected = true; + } + catch (Exception exception) + { + Log.Error(exception); + IsConnected = false; + } + HaveLiveView = true; + //Capabilities.Add(CapabilityEnum.LiveView); + return true; + } + + private void ConnectToWiaDevice(DeviceDescriptor deviceDescriptor, int retries_left = 6) + { + if (deviceDescriptor.WiaDevice == null) + { + Thread.Sleep(500); + try + { + deviceDescriptor.WiaDevice = deviceDescriptor.WiaDeviceInfo.Connect(); + deviceDescriptor.CameraDevice = this; + Thread.Sleep(250); + } + catch (COMException e) + { + if ((uint) e.ErrorCode == ErrorCodes.WIA_ERROR_BUSY && retries_left > 0) + { + int retry_in_secs = 2*(7 - retries_left); + Thread.Sleep(1000*retry_in_secs); + Log.Debug("Connection to wia failed, Retrying to connect in " + retry_in_secs + " seconds"); + ConnectToWiaDevice(deviceDescriptor, retries_left - 1); + } + else + { + Log.Error("Could not connect to wia device.", e); + throw e; + } + } + } + } + + private void DeviceManager_OnEvent(string eventId, string deviceId, string itemId) + { + Item tem = Device.GetItem(itemId); + ImageFile imageFile = (ImageFile) tem.Transfer("{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + EventArgs = imageFile, + CameraDevice = this, + FileName = "00000." + imageFile.FileExtension, + Handle = new object[] {imageFile, itemId} + }; + OnPhotoCapture(this, args); + OnCaptureCompleted(this, new EventArgs()); + } + + public WiaCameraDevice() + { + FNumber = new PropertyValue(); + FNumber.ValueChanged += FNumber_ValueChanged; + IsoNumber = new PropertyValue(); + IsoNumber.ValueChanged += IsoNumber_ValueChanged; + ShutterSpeed = new PropertyValue(); + ShutterSpeed.ValueChanged += ShutterSpeed_ValueChanged; + WhiteBalance = new PropertyValue(); + WhiteBalance.ValueChanged += WhiteBalance_ValueChanged; + Mode = new PropertyValue(); + Mode.ValueChanged += Mode_ValueChanged; + CompressionSetting = new PropertyValue(); + CompressionSetting.ValueChanged += CompressionSetting_ValueChanged; + ExposureCompensation = new PropertyValue(); + ExposureCompensation.ValueChanged += ExposureCompensation_ValueChanged; + ExposureMeteringMode = new PropertyValue(); + ExposureMeteringMode.ValueChanged += ExposureMeteringMode_ValueChanged; + FocusMode = new PropertyValue(); + FocusMode.IsEnabled = false; + } + + private void ExposureMeteringMode_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_ExposureMeteringMode].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void CompressionSetting_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_CompressionSetting].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void ExposureCompensation_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_ExposureCompensation].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void Mode_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + switch (key) + { + case "M": + ShutterSpeed.IsEnabled = true; + FNumber.IsEnabled = true; + break; + case "P": + ShutterSpeed.IsEnabled = false; + FNumber.IsEnabled = false; + break; + case "A": + ShutterSpeed.IsEnabled = false; + FNumber.IsEnabled = true; + break; + case "S": + ShutterSpeed.IsEnabled = true; + FNumber.IsEnabled = false; + break; + default: + ShutterSpeed.IsEnabled = false; + FNumber.IsEnabled = false; + break; + } + Device.Properties[Conts.CONST_PROP_ExposureMode].set_Value(val); + } + } + + private void WhiteBalance_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_WhiteBalance].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void ShutterSpeed_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_Exposure_Time].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void IsoNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_ISO_Number].set_Value(val); + } + catch (Exception) + { + } + } + } + + private void FNumber_ValueChanged(object sender, string key, long val) + { + lock (Locker) + { + try + { + Device.Properties[Conts.CONST_PROP_F_Number].set_Value(val); + } + catch (Exception) + { + } + } + } + + + public override void StartLiveView() + { + //throw new NotImplementedException(); + } + + public override void StopLiveView() + { + //throw new NotImplementedException(); + } + + public override LiveViewData GetLiveViewImage() + { + //throw new NotImplementedException(); + return new LiveViewData(); + } + + public override void AutoFocus() + { + //throw new NotImplementedException(); + } + + public override int Focus(int step) + { + return 0; + } + + public override void Focus(int x, int y) + { + //throw new NotImplementedException(); + } + + public override void CapturePhotoNoAf() + { + lock (Locker) + { + CapturePhoto(); + } + } + + public override void CapturePhoto() + { + Monitor.Enter(Locker); + try + { + IsBusy = true; + Device.ExecuteCommand(Conts.wiaCommandTakePicture); + } + catch (COMException comException) + { + IsBusy = false; + ErrorCodes.GetException(comException); + } + catch + { + IsBusy = false; + throw; + } + finally + { + Monitor.Exit(Locker); + } + } + + public override void Close() + { + if (Device != null) + Marshal.ReleaseComObject(Device); + Device = null; + HaveLiveView = false; + if (DeviceName != null) + DeviceManager.OnEvent -= DeviceManager_OnEvent; + } + + public override void ReadDeviceProperties(uint o) + { + HaveLiveView = true; + } + + public override void TransferFile(object o, string filename) + { + ImageFile deviceEventArgs = ((object[])(o))[0] as ImageFile; + if (deviceEventArgs != null) + { + deviceEventArgs.SaveFile(filename); + } + } + + //public override event PhotoCapturedEventHandler PhotoCaptured; + + public override bool DeleteObject(DeviceObject deviceObject) + { + string id = (string)((object[]) (deviceObject.Handle))[1]; + for (int j = 1; j <= Device.Items.Count; j++) + { + if (Device.Items[j].ItemID == id) + { + Device.Items.Remove(j); + break; + } + + } + return true; + } + + #endregion + + public override string ToStringCameraData() + { + StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................WIA"); + + if (Device != null) + c.AppendFormat("\n\tDevice ID.............{0}", Device.DeviceID); + + return c.ToString(); + + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Others/YiCamera.cs b/DigiCamControl/CameraControl.Devices/Others/YiCamera.cs new file mode 100644 index 0000000..fb5cf89 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Others/YiCamera.cs @@ -0,0 +1,448 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading; +using CameraControl.Devices.Classes; +using CameraControl.Devices.TransferProtocol; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PortableDeviceLib; + +namespace CameraControl.Devices.Others +{ + public class YiCamera : BaseCameraDevice + { + public YiCameraProtocol Protocol { get; set; } + public Dictionary CurrentValues { get; set; } + + private static AutoResetEvent _resetEvent = new AutoResetEvent(false); + private static AutoResetEvent _listingEvent = new AutoResetEvent(false); + private string _lastData = ""; + private bool _timelapse_running = false; + + + + public override bool Init(DeviceDescriptor deviceDescriptor) + { + CurrentValues = new Dictionary(); + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.LiveViewStream); + Capabilities.Add(CapabilityEnum.RecordMovie); + Protocol = deviceDescriptor.StillImageDevice as YiCameraProtocol; + Protocol.DataReceiverd += Protocol_DataReceiverd; + + DeviceName = Protocol.Model; + Manufacturer = Protocol.Manufacturer; + IsConnected = true; + CompressionSetting = new PropertyValue { Tag = "photo_quality" }; + + Mode = new PropertyValue { Tag = "capture_mode" }; + Mode.AddValues("Single", 0); + Mode.AddValues("Burst", 1); + Mode.AddValues("Delayed", 2); + //Mode.AddValues("TimeLapse", 3); + Mode.ReloadValues(); + + ExposureMeteringMode = new PropertyValue() { Tag = "meter_mode" }; + + LiveViewImageZoomRatio = new PropertyValue(); + LiveViewImageZoomRatio.AddValues("All", 0); + LiveViewImageZoomRatio.Value = "All"; + SendCommand(3); + Thread.Sleep(500); + + SerialNumber = GetValue("serial_number"); + SetProperty(Mode.Tag, GetValue(Mode.Tag)); + + + var thread = new Thread(LoadProperties) { Priority = ThreadPriority.Lowest }; + thread.Start(); + return true; + } + + private void LoadProperties() + { + try + { + IsoNumber = new PropertyValue {Available = false}; + FNumber = new PropertyValue {Available = false}; + ExposureCompensation = new PropertyValue {Available = false}; + FocusMode = new PropertyValue {Available = false}; + ShutterSpeed = new PropertyValue {Available = false}; + WhiteBalance = new PropertyValue {Available = false}; + + Properties.Add(AddNames("photo_size", "Photo size")); + Properties.Add(AddNames("precise_selftime", "Capture delay")); + Properties.Add(AddNames("burst_capture_number", "Burst capture number")); + Properties.Add(AddNames("auto_low_light", "Auto low light")); + + AdvancedProperties.Add(AddNames("video_resolution", "Video resolution")); + AdvancedProperties.Add(AddNames("led_mode", "Led mode")); + AdvancedProperties.Add(AddNames("auto_power_off", "Auto power off")); + AdvancedProperties.Add(AddNames("loop_record", "Loop record")); + AdvancedProperties.Add(AddNames("warp_enable", "Lens correction")); + AdvancedProperties.Add(AddNames("buzzer_ring", "Find device")); + + CompressionSetting.ValueChanged += + (sender, key, val) => { Protocol.SendValue(CompressionSetting.Tag, key); }; + SendCommand(9, CompressionSetting.Tag); + + Mode.ValueChanged += Mode_ValueChanged; + SendCommand(9, Mode.Tag); + + ExposureMeteringMode.ValueChanged += + (sender, key, val) => { Protocol.SendValue(ExposureMeteringMode.Tag, key); }; + SendCommand(9, ExposureMeteringMode.Tag); + + foreach (var property in Properties) + { + SendCommand(9, property.Tag); + } + foreach (var property in AdvancedProperties) + { + SendCommand(9, property.Tag); + } + } + catch (Exception ex) + { + Log.Error("Unable to load data", ex); + } + } + + void Mode_ValueChanged(object sender, string key, long val) + { + switch (val) + { + case 0: + Protocol.SendValue("capture_mode", "precise quality"); + break; + case 1: + Protocol.SendValue("capture_mode", "burst quality"); + break; + case 2: + Protocol.SendValue("capture_mode", "precise self quality"); + break; + case 3: + Protocol.SendValue("capture_mode", "precise quality cont."); + break; + } + } + + public void SendCommand(int command) + { + _resetEvent.Reset(); + Protocol.SendCommand(command); + _resetEvent.WaitOne(500); + } + + public void SendCommand(int command, string param) + { + _resetEvent.Reset(); + Protocol.SendCommand(command, param); + _resetEvent.WaitOne(1000); + } + + private PropertyValue AddNames(string keyname, string name) + { + var res = new PropertyValue + { + Tag = keyname, + Name = name + }; + res.ValueChanged += (sender, key, val) => { Protocol.SendValue(res.Tag, key); }; + return res; + } + + private string GetValue(string key) + { + return CurrentValues.ContainsKey(key) ? CurrentValues[key] : ""; + } + + void Protocol_DataReceiverd(object sender, string data) + { + try + { + if (data.Contains("msg_id")) + { + dynamic resp = JsonConvert.DeserializeObject(data); + switch ((string)resp.msg_id) + { + case "3": // allproperties + CurrentValues.Clear(); + foreach (JObject o in resp.param) + { + var k = o.ToObject>(); + CurrentValues.Add(k.First().Key, k.First().Value); + } + break; + case "7": + switch ((string)resp.type) + { + case "burst_complete": + case "photo_taken": + string filename = Path.GetFileName(((string)resp.param).Replace('/', '\\')); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs =new PortableDeviceEventArgs(), + CameraDevice = this, + FileName = filename, + Handle = filename + }; + OnPhotoCapture(this, args); + break; + default: + SetProperty((string)resp.type, (string)resp.param); + break; + } + break; + case "9": + SetValues(data); + break; + } + _lastData = data; + if (data.Contains("listing")) + _listingEvent.Set(); + } + } + catch (Exception) + { + + } + _resetEvent.Set(); + } + + public override AsyncObservableCollection GetObjects(object storageId, bool loadThumbs) + { + var res = new AsyncObservableCollection(); + SendCommand(1283, "\\/var\\/www\\/DCIM\\/100MEDIA/"); + _listingEvent.Reset(); + SendCommand(1282, " -D -S"); + _listingEvent.WaitOne(2500); + dynamic resp = JsonConvert.DeserializeObject(_lastData); + WebClient client = new WebClient(); + foreach (JObject o in resp.listing) + { + var k = o.ToObject>(); + string v = k.First().Value; + var file = new DeviceObject(); + file.FileName = k.First().Key; + if (file.FileName.ToLower().Contains("thm")) + continue; + file.Handle = file.FileName; + try + { + if (loadThumbs) + { + if (file.FileName.Contains(".jpg")) + file.ThumbData = + client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip, + file.FileName)); + if (file.FileName.Contains(".mp4")) + file.ThumbData = + client.DownloadData(string.Format("http://{0}/DCIM/100MEDIA/{1}?type=thumb", Protocol.Ip, + file.FileName.Replace("mp4", "THM"))); + } + if (v.Contains("|")) + file.FileDate = DateTime.ParseExact(v.Split('|')[1], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); + } + catch (Exception) + { + + } + res.Add(file); + } + return res; + } + + public override void FormatStorage(object storageId) + { + var o = GetObjects(storageId, false); + foreach (var deviceObject in o) + { + DeleteObject(deviceObject); + } + } + + public override void CapturePhotoNoAf() + { + CapturePhoto(); + } + + public override void CapturePhoto() + { + IsBusy = true; + if (Mode.NumericValue == 3) + _timelapse_running = !_timelapse_running; + else + _timelapse_running = false; + Mode.IsEnabled = !_timelapse_running; + Protocol.SendCommand(_timelapse_running ? 770 : 769); + } + + + public override void StartRecordMovie() + { + Protocol.SendCommand(513); + } + + public override void StopRecordMovie() + { + Protocol.SendCommand(514); + } + + public override bool DeleteObject(DeviceObject deviceObject) + { + SendCommand(1283, "\\/var\\/www\\/DCIM\\/100MEDIA/"); + SendCommand(1281, (string) deviceObject.Handle); + return true; + } + + public override void TransferFile(object o, string filename) + { + TransferProgress = 0; + HttpHelper.DownLoadFileByWebRequest(String.Format("http://{0}/DCIM/100MEDIA/{1}", Protocol.Ip, o), filename, this); + } + + public override void TransferFileThumb(object o, string filename) + { + TransferProgress = 0; + HttpHelper.DownLoadFileByWebRequest(String.Format("http://{0}/DCIM/100MEDIA/{1}?type=screen", Protocol.Ip, o), filename, + this); + } + + private void SetProperty(string prop, string val) + { + switch (prop) + { + case "battery": + int i; + if (int.TryParse(val, out i)) + Battery = i; + break; + case "photo_quality": + CompressionSetting.Value = val; + break; + case "capture_mode": + switch (val) + { + case "precise quality": + Mode.SetValue(0); + break; + case "burst quality": + Mode.SetValue(1); + break; + case "precise self quality": + Mode.SetValue(2); + break; + case "precise quality cont.": + Mode.SetValue(3); + break; + } + break; + case "meter_mode": + ExposureMeteringMode.Value = val; + break; + default: + foreach (var property in Properties) + { + if (property.Tag == prop) + property.Value = val; + } + foreach (var property in AdvancedProperties) + { + if (property.Tag == prop) + property.Value = val; + } + break; + } + } + + private void SetValues(string data) + { + List values=new List(); + dynamic a = JsonConvert.DeserializeObject(data); + foreach (string o in a.options) + { + values.Add(o); + } + string param = (string) a.param; + switch (param) + { + case "photo_quality": + CompressionSetting.Clear(); + for (int i = 0; i < values.Count; i++) + { + CompressionSetting.AddValues(values[i], i); + } + CompressionSetting.IsEnabled = a.permission == "settable"; + CompressionSetting.ReloadValues(); + CompressionSetting.Value = GetValue(param); + break; + case "meter_mode": + ExposureMeteringMode.Clear(); + for (int i = 0; i < values.Count; i++) + { + ExposureMeteringMode.AddValues(values[i], i); + } + ExposureMeteringMode.ReloadValues(); + ExposureMeteringMode.IsEnabled = a.permission == "settable"; + ExposureMeteringMode.Value = GetValue(param); + break; + default: + foreach (var property in Properties) + { + if (property.Tag == param) + { + property.Clear(); + for (int i = 0; i < values.Count; i++) + { + property.AddValues(values[i], i); + } + property.IsEnabled = a.permission == "settable"; + property.ReloadValues(); + property.Value = GetValue(param); + } + } + foreach (var property in AdvancedProperties) + { + if (property.Tag == param) + { + property.Clear(); + for (int i = 0; i < values.Count; i++) + { + property.AddValues(values[i], i); + } + property.IsEnabled = a.permission == "settable"; + property.ReloadValues(); + property.Value = GetValue(param); + } + } + break; + } + + } + + + public override string GetLiveViewStream() + { + return String.Format("rtsp://{0}/live",Protocol.Ip); + } + + public override void StartLiveView() + { + Protocol.SendCommand(259, "none_force"); + } + + public override string ToString() + { + + StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................YiA"); + return c.ToString(); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Properties/AssemblyInfo.cs b/DigiCamControl/CameraControl.Devices/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a349bbb --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Properties/AssemblyInfo.cs @@ -0,0 +1,72 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("CameraControl.Devices")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CameraControl.Devices")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(true)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("5035533e-afa3-4601-b47f-49c2b0d2f36f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] + +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Sony/CameraDiscovery.cs b/DigiCamControl/CameraControl.Devices/Sony/CameraDiscovery.cs new file mode 100644 index 0000000..0e9abde --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Sony/CameraDiscovery.cs @@ -0,0 +1,185 @@ +using Kazyx.DeviceDiscovery; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace SonyCameraCommunication +{ + public class CameraDiscovery + { + + IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("128.0.0.1"), 60000); + IPEndPoint multicastEndpoint = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 1900); + + Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + + public static string response; + + public bool UDPSocketSetup() + { + string udpStatus; + bool binded = false; + try + { + udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); + //udpSocket.Bind(localEndPoint); + udpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(multicastEndpoint.Address, IPAddress.Any)); + udpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 2); + udpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, true); + + NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); + foreach (NetworkInterface adapter in nics) + { + IPInterfaceProperties ip_properties = adapter.GetIPProperties(); + if (!adapter.GetIPProperties().MulticastAddresses.Any()) + continue; // most of VPN adapters will be skipped + if (!adapter.SupportsMulticast) + continue; // multicast is meaningless for this type of connection + if (OperationalStatus.Up != adapter.OperationalStatus) + continue; // this adapter is off or not connected + if (adapter.NetworkInterfaceType != NetworkInterfaceType.Wireless80211) + continue; + + IPv4InterfaceProperties p = adapter.GetIPProperties().GetIPv4Properties(); + if (null == p) + continue; // IPv4 is not configured on this adapter + + foreach (UnicastIPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses) + { + if (ip.Address.AddressFamily == AddressFamily.InterNetwork) + { + udpSocket.Bind(new IPEndPoint(ip.Address, 60000)); + binded = true; + break; + } + } + + // now we have adapter index as p.Index, let put it to socket option + udpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, (int)IPAddress.HostToNetworkOrder(p.Index)); + } + + if(!binded) + throw new Exception("Camea not connected !"); + return true; + } + catch (Exception exc) + { + return false; + } + } + + public bool MSearch() + { + string searchString = "M-SEARCH * HTTP/1.1\r\nHOST:239.255.255.250:1900\r\nMAN:\"ssdp:discover\"\r\nMX:1\r\nST:urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n"; + + + byte[] receiveBuffer = new byte[64000]; + + int receivedBytes = 0; + DateTime starTime = DateTime.Now; + + while (true) + { + try + { + udpSocket.SendTo(Encoding.UTF8.GetBytes(searchString), SocketFlags.None, multicastEndpoint); + if (udpSocket.Available > 0) + { + receivedBytes = udpSocket.Receive(receiveBuffer, SocketFlags.None); + + if (receivedBytes > 0) + { + response = Encoding.UTF8.GetString(receiveBuffer, 0, receivedBytes); + return true; + } + } + } + catch (Exception exc) + { + return false; + } + if ((DateTime.Now - starTime).TotalSeconds > 4000) + { + return false; + } + Thread.Sleep(150); + } + } + + public string DeviceDescription() + { + string[] responseStrings = response.Split('\n'); + string cameraIP = ""; + foreach (string resp in responseStrings) + { + if (resp.StartsWith("LOCATION: ")) + { + cameraIP = resp.Substring(resp.LastIndexOf(" ")); + } + } + HttpWebRequest descriptionReq = (HttpWebRequest)WebRequest.Create(cameraIP); + descriptionReq.Method = "GET"; + WebResponse descriptionResp = descriptionReq.GetResponse(); + Stream descriptionStream = descriptionResp.GetResponseStream(); + StreamReader descriptionRead = new StreamReader(descriptionStream); + string readDescription = descriptionRead.ReadToEnd(); + return readDescription; + } + + private const string upnp_ns = "{urn:schemas-upnp-org:device-1-0}"; + private const string sony_ns = "{urn:schemas-sony-com:av}"; + + public SonyCameraDeviceInfo AnalyzeDescription(string response) + { + //Log(response); + var endpoints = new Dictionary(); + + var xml = XDocument.Parse(response); + var device = xml.Root.Element(upnp_ns + "device"); + if (device == null) + { + return null; + } + var f_name = device.Element(upnp_ns + "friendlyName").Value; + var m_name = device.Element(upnp_ns + "modelName").Value; + var udn = device.Element(upnp_ns + "UDN").Value; + var info = device.Element(sony_ns + "X_ScalarWebAPI_DeviceInfo"); + if (info == null) + { + return null; + } + var list = info.Element(sony_ns + "X_ScalarWebAPI_ServiceList"); + + foreach (var service in list.Elements()) + { + var name = service.Element(sony_ns + "X_ScalarWebAPI_ServiceType").Value; + var url = service.Element(sony_ns + "X_ScalarWebAPI_ActionList_URL").Value; + if (name == null || url == null) + continue; + + string endpoint; + if (url.EndsWith("/")) + endpoint = url + name; + else + endpoint = url + "/" + name; + + endpoints.Add(name, endpoint); + } + + if (endpoints.Count == 0) + { + return null; + } + + return new SonyCameraDeviceInfo(udn, m_name, f_name, endpoints); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Sony/SonyCameraDeviceInfo.cs b/DigiCamControl/CameraControl.Devices/Sony/SonyCameraDeviceInfo.cs new file mode 100644 index 0000000..0c59bf5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Sony/SonyCameraDeviceInfo.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; + +namespace Kazyx.DeviceDiscovery +{ + public class SonyCameraDeviceInfo + { + internal SonyCameraDeviceInfo(string udn, string mname, string fname, Dictionary ep) + { + UDN = udn; + ModelName = mname; + FriendlyName = fname; + Endpoints = ep; + } + + private Dictionary _Endpoints; + + /// + /// K-V pairs of service name and its endpoint URL + /// + public Dictionary Endpoints + { + private set { _Endpoints = value; } + get { return new Dictionary(_Endpoints); } + } + + public string FriendlyName { private set; get; } + + public string ModelName { private set; get; } + + public string UDN { private set; get; } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Sony/SonyWifiCamera.cs b/DigiCamControl/CameraControl.Devices/Sony/SonyWifiCamera.cs new file mode 100644 index 0000000..779b64b --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Sony/SonyWifiCamera.cs @@ -0,0 +1,733 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Timers; +using CameraControl.Devices.Classes; +using PortableDeviceLib; +using Timer = System.Timers.Timer; + +namespace CameraControl.Devices.Sony +{ + public class SonyWifiCamera : BaseCameraDevice + { + private LiveViewData _liveViewData = new LiveViewData(); + private bool _shoulStopLiveView; + + + [StructLayout(LayoutKind.Sequential)] + struct CommonHeader + { + public byte StartByte; + public byte Type; + public Int16 SequenceNo; + public Int32 TimeStamp; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct PayloadHeader + { + public Int32 StartCode; + public UInt16 JpgDataSize; + //public byte Dummy; + public byte PadingSize; + public Int32 Reserved; + public byte Flag; + } + + private static int request_id = 0; + public string EndPoint { get; set; } + private readonly HttpClient mClient = new HttpClient(); + List AvailableMethods; + private Timer _timer = new Timer(100); + private string _liveViewUrl = ""; + private long _lastZoomPos = 0; + public SonyWifiCamera() + { + + } + + public bool Init(string endpoint) + { + Capabilities.Add(CapabilityEnum.LiveView); + Capabilities.Add(CapabilityEnum.Zoom); + _timer.Elapsed += _timer_Elapsed; + _timer.AutoReset = true; + IsBusy = true; + EndPoint = endpoint; + AvailableMethods = GetMethodTypes(); + ExecuteMethod("startRecMode"); + IsConnected = true; + ExposureMeteringMode = new PropertyValue(); + ExposureMeteringMode.Available = false; + LiveViewImageZoomRatio = new PropertyValue(); + for (int i = 0; i < 101; i++) + { + LiveViewImageZoomRatio.AddValues(i.ToString(), i); + } + LiveViewImageZoomRatio.ReloadValues(); + LiveViewImageZoomRatio.IsEnabled = false; + LiveViewImageZoomRatio.ValueChanged += LiveViewImageZoomRatio_ValueChanged; + Task.Factory.StartNew(InitProps); + return true; + } + + void LiveViewImageZoomRatio_ValueChanged(object sender, string key, long val) + { + var dif = Math.Abs(_lastZoomPos - val); + if (val > _lastZoomPos) + { + //ExecuteMethod("actZoom", "out", "1shot"); + ExecuteMethod("actZoom", "out", dif < 25 ? "1shot" : "start"); + } + else + { + //ExecuteMethod("actZoom", "in", "1shot"); + ExecuteMethod("actZoom", "in", dif < 25 ? "1shot" : "start"); + } + _lastZoomPos = val; + } + + private void InitProps() + { + Thread.Sleep(3500); + try + { + InitMode(); + InitIso(); + InitShutterSpeed(); + InitFNumber(); + InitFocusMode(); + InitWhitebalce(); + InitCompressionSetting(); + } + catch (Exception ex) + { + Log.Error("Sony prop init error", ex); + } + IsBusy = false; + _timer.Start(); + } + + private void InitIso() + { + try + { + IsoNumber = new PropertyValue(); + var prop = IsoNumber; + var cap = AsCapability(Post(CreateJson("getAvailableIsoSpeedRate"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setIsoSpeedRate", "1.0", key))); + } + catch (Exception e) + { + } + } + + private void InitFNumber() + { + FNumber = new PropertyValue(); + var prop = FNumber; + var cap = AsCapability(Post(CreateJson("getAvailableFNumber"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setFNumber", "1.0", key))); + } + + private void InitShutterSpeed() + { + ShutterSpeed = new PropertyValue(); + var prop = ShutterSpeed; + var cap = AsCapability(Post(CreateJson("getAvailableShutterSpeed"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setShutterSpeed", "1.0", key))); + } + + private void InitFocusMode() + { + FocusMode = new PropertyValue(); + //var prop = FocusMode; + //var cap = AsCapability(Post(CreateJson("getAvailableFocusMode"))); + //SetCapability(prop, cap); + //prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setFocusMode", "1.0", key))); + } + + private void InitWhitebalce() + { + //TODO:fix me + WhiteBalance = new PropertyValue(); + try + { + var prop = WhiteBalance; + var cap = AsCapability(Post(CreateJson("getAvailableWhiteBalance"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setWhiteBalance", "1.0", key))); + } + catch (Exception) + { + WhiteBalance.Available = false; + } + } + + private void InitCompressionSetting() + { + CompressionSetting = new PropertyValue(); + try + { + var prop = CompressionSetting; + var cap = AsCapability(Post(CreateJson("getAvailableStillQuality"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setStillQuality", "1.0", key))); + } + catch (Exception) + { + CompressionSetting.Available = false; + } + } + + private void InitMode() + { + try + { + Mode = new PropertyValue(); + var prop = Mode; + var cap = AsCapability(Post(CreateJson("getAvailableExposureMode"))); + SetCapability(prop, cap); + prop.ValueChanged += (sender, key, val) => CheckError(Post(CreateJson("setExposureMode", "1.0", key))); + } + catch (Exception) + { + + } + } + + void _timer_Elapsed(object sender, ElapsedEventArgs e) + { + _timer.Stop(); + Task.Factory.StartNew(GetEvent); + } + + private void GetEvent() + { + try + { + var jString = Post(CreateJson("getEvent","1.0",false)); + var json = Initialize(jString); + var jResult = json["result"] as JArray; + + if (jResult == null) return; + var elem = jResult[2]; + if (elem.HasValues) + { + LiveViewImageZoomRatio.SetValue(elem.Value("zoomPositionCurrentBox").ToString(), false); + } + elem = jResult[5]; + if (elem.HasValues) + { + foreach (var obj in elem.Children()) + { + foreach (var u in obj["takePictureUrl"].Values()) + { + var url = u; + if (url.Contains("?")) + url = url.Split('?')[0]; + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = new PortableDeviceEventArgs(), + CameraDevice = this, + FileName = url.Replace('/', '\\'), + Handle = url + }; + OnPhotoCapture(this, args); + } + } + } + + elem = jResult[18]; + if (elem.HasValues) + { + SetCapability(Mode, new Capability + { + Current = elem.Value("currentExposureMode"), + Candidates = elem["exposureModeCandidates"].Values().ToList() + }); + } + + elem = jResult[27]; + if (elem.HasValues) + { + SetCapability(FNumber, new Capability + { + Current = elem.Value("currentFNumber"), + Candidates = elem["fNumberCandidates"].Values().ToList() + }); + } + elem = jResult[28]; + if (elem.HasValues) + { + SetCapability(FocusMode, new Capability + { + Current = elem.Value("currentFocusMode"), + Candidates = elem["focusModeCandidates"].Values().ToList() + }); + } + + elem = jResult[29]; + if (elem.HasValues) + { + SetCapability(IsoNumber, new Capability + { + Current = elem.Value("currentIsoSpeedRate"), + Candidates = elem["isoSpeedRateCandidates"].Values().ToList() + }); + } + elem = jResult[32]; + if (elem.HasValues) + { + SetCapability(ShutterSpeed, new Capability + { + Current = elem.Value("currentShutterSpeed"), + Candidates = elem["shutterSpeedCandidates"].Values().ToList() + }); + } + elem = jResult[33]; + if (elem.HasValues) + { + WhiteBalance.SetValue(elem.Value("currentWhiteBalanceMode"), false); + } + if (jResult.Count > 36) // GetEvent version 1.2 + { + elem = jResult[37]; + if (elem.HasValues) + { + SetCapability(CompressionSetting, new Capability + { + Current = elem.Value("stillQuality"), + Candidates = elem["candidate"].Values().ToList() + }); + } + } + } + catch (Exception ex) + { + Log.Debug("Sony get error ", ex); + } + _timer.Start(); + } + + public override void CapturePhotoNoAf() + { + CapturePhoto(); + } + + public override void CapturePhoto() + { + IsBusy = true; + List urls; + bool firstRun = true; + while (true) + { + try + { + urls = AsPrimitiveList(firstRun ? Post(CreateJson("actTakePicture")) : Post(CreateJson("awaitTakePicture"))); + break; + } + catch (DeviceException exception) + { + if (exception.ErrorCode == 40403) + { + firstRun = false; + } + else + { + IsBusy = false; + Log.Error("Sony capture error ", exception); + throw; + } + } + catch(Exception ex) + { + IsBusy = false; + Log.Error("Sony capture error ", ex); + throw; + } + } + + foreach (var u in urls) + { + var url = u; + if (url.Contains("?")) + url = url.Split('?')[0]; + Log.Debug("Url to process " + url); + PhotoCapturedEventArgs args = new PhotoCapturedEventArgs + { + WiaImageItem = null, + EventArgs = new PortableDeviceEventArgs(), + CameraDevice = this, + FileName = url.Replace('/', '\\'), + Handle = url + }; + OnPhotoCapture(this, args); + } + } + + public override void StartLiveView() + { + string cmd = "{" + + "\"method\": \"setLiveviewFrameInfo\"," + + "\"params\": [" + + "{" + + "\"frameInfo\": false" + + "}" + + "]," + + "\"id\": 1," + + "\"version\": \"1.0\"" + + "}\""; + //CheckError(Post(cmd)); + _shoulStopLiveView = false; + _liveViewUrl = AsPrimitive(Post(CreateJson("startLiveview"))); + BeginGetStream(new Uri(_liveViewUrl)); + } + + public override void StopLiveView() + { + _shoulStopLiveView = true; + Post(CreateJson("stopLiveview")); + } + + public override LiveViewData GetLiveViewImage() + { + return _liveViewData; + } + + public override void TransferFile(object o, string filename) + { + TransferProgress = 0; + HttpHelper.DownLoadFileByWebRequest(((string)o) + "?size=Origin", filename, this); + } + + public override void TransferFileThumb(object o, string filename) + { + TransferProgress = 0; + HttpHelper.DownLoadFileByWebRequest(((string)o) + "?size=Scn", filename, + this); + } + + private static void SetCapability(PropertyValue prop, Capability cap) + { + if (prop == null) + return; + + // refresh properties only if the collection or value was changed + if (prop?.Value == cap.Current && prop.Values.Count == cap.Candidates.Count) + return; + //prop.Clear(false); + foreach (string val in cap.Candidates) + { + prop.AddValues(val, default(T)); + } + + if (cap.Candidates.Count == 0 && !string.IsNullOrEmpty(cap.Current)) + { + prop.AddValues(cap.Current, default(T)); + prop.IsEnabled = false; + } + else + { + prop.IsEnabled = true; + } + prop.ReloadValues(); + prop.SetValue(cap.Current, false); + } + + private void ExecuteMethod(string method, params object[] prms) + { + var res = Post(CreateJson(method, prms)); + } + + private List GetMethodTypes() + { + var methodTypes = new List(); + var res = Post(CreateJson("getMethodTypes", "1.0", "")); + var json = Initialize(res); + + foreach (var token in json["results"]) + { + methodTypes.Add(token.Value(0)); + } + return methodTypes; + } + + private static string CreateJson(string name, params object[] prms) + { + return CreateJson(name, "1.0", prms); + } + + private static string CreateJson(string name, string version, params object[] prms) + { + var param = new JArray(); + if (prms != null) + { + foreach (var p in prms) + { + param.Add(p); + } + } + var json = new JObject( + new JProperty("method", name), + new JProperty("version", version), + new JProperty("id", GetID()), + new JProperty("params", param)); + + return json.ToString(Formatting.None); + } + + private static int GetID() + { + var id = Interlocked.Increment(ref request_id); + if (request_id > 1000000000) + { + request_id = 0; + } + return id; + } + + internal string Post(string body) + { + if (EndPoint == null || body == null) + { + throw new ArgumentNullException(); + } + + var content = new StringContent(body); + content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + + try + { + Task task; + + var response = mClient.PostAsync(EndPoint, content).Result; + return Encoding.UTF8.GetString(response.Content.ReadAsByteArrayAsync().Result); + + //if (response.IsSuccessStatusCode) + //{ + // // ReadAsString fails in case of charset=utf-8 + // return Encoding.UTF8.GetString(response.Content.ReadAsByteArrayAsync().Result); + //} + //else + //{ + // //Debug.WriteLine("Http Status Error: " + response.StatusCode); + // //throw new RemoteApiException((int)response.StatusCode); + //} + } + //catch (RemoteApiException e) + //{ + // Debug.WriteLine("Request error: " + e.Message); + // Debug.WriteLine("Request error: " + e.StackTrace); + // throw e; + //} + catch (Exception e) + { + throw e; + //if (e is TaskCanceledException || e is OperationCanceledException) + //{ + // Debug.WriteLine("Request cancelled: " + e.StackTrace); + // throw new RemoteApiException(StatusCode.Cancelled); + //} + //else + //{ + // Debug.WriteLine("HttpPost Exception: " + e.StackTrace); + // throw new RemoteApiException(StatusCode.NetworkError); + //} + } + } + + internal static void CheckError(string jString) + { + var json = Initialize(jString); + } + + internal static JObject Initialize(string response) + { + var json = JObject.Parse(response); + if (json == null) + { + //throw new RemoteApiException(StatusCode.IllegalResponse); + } + if (json["error"] != null) + { + throw new DeviceException(json["error"].Value(1), json["error"].Value(0)); + //throw new RemoteApiException((StatusCode)json["error"].Value(0)); + } + return json; + } + + /// + /// For response which has a single Array consists of a single type. + /// + /// Type of the value + /// + internal static List AsPrimitiveList(string jString) + { + var json = Initialize(jString); + + return json["result"][0].Values().ToList(); + } + + internal static T AsPrimitive(string jString) + { + var json = Initialize(jString); + + return json["result"].Value(0); + } + + internal static Capability AsCapability(string jString) + { + var json = Initialize(jString); + + return new Capability + { + Current = json["result"].Value(0), + Candidates = json["result"][1].Values().ToList() + }; + } + + public void BeginGetStream(Uri uri) + { + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); + + // asynchronously get a response + request.BeginGetResponse(OnGetResponse, request); + } + + private void OnGetResponse(IAsyncResult asyncResult) + { + // get the response + HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState; + + try + { + HttpWebResponse resp = (HttpWebResponse)req.EndGetResponse(asyncResult); + Stream s = resp.GetResponseStream(); + + + while (true) + { + CommonHeader heder = new CommonHeader(); + //ByteArrayToStructure(s, ref heder); + var buff = ReadBytes(s, 8); + heder.StartByte = buff[0]; + heder.Type = buff[1]; + heder.SequenceNo = BitConverter.ToInt16(buff,2); ; + heder.TimeStamp = BitConverter.ToInt32(buff, 4); ; + PayloadHeader playload = new PayloadHeader(); + //ByteArrayToStructure(s, ref playload); + buff = ReadBytes(s, 128); + + playload.StartCode = BitConverter.ToInt32(buff, 0); + playload.JpgDataSize = BitConverter.ToUInt16(new byte[] { buff[6], buff[5], buff[4], 0 }, 0); + playload.PadingSize = buff[7]; + + if (((CommonHeader) heder).Type == 0x02) + { + if (playload.JpgDataSize > 0) + { + var data = ReadBytes(s, playload.JpgDataSize); + _liveViewData.FocusX = BitConverter.ToInt16(new byte[] { data[1], data[0]}, 0); + _liveViewData.FocusY = BitConverter.ToInt16(new byte[] { data[3], data[2] }, 0); ; + _liveViewData.FocusFrameXSize = BitConverter.ToInt16(new byte[] { data[5], data[4] }, 0) - _liveViewData.FocusX; + _liveViewData.FocusFrameYSize = BitConverter.ToInt16(new byte[] { data[7], data[6] }, 0) - _liveViewData.FocusY ; + _liveViewData.HaveFocusData = true; + _liveViewData.Focused = data[9] != 0; + _liveViewData.ImageWidth = 10000; + _liveViewData.ImageHeight = 10000; + _liveViewData.IsLiveViewRunning = true; + Console.WriteLine(playload.JpgDataSize); + } + } + else + { + _liveViewData.ImageData = ReadBytes(s, playload.JpgDataSize); + } + + if (playload.PadingSize > 0) + ReadBytes(s, playload.PadingSize); + if (_shoulStopLiveView) + break; + } + resp.Close(); + } + catch (Exception ex) + { + Log.Error("Unable to download stream ", ex); + } + } + + void ByteArrayToStructure(Stream br, ref object obj) + { + int len = Marshal.SizeOf(obj); + var bytearray = ReadBytes(br, len); + IntPtr i = Marshal.AllocHGlobal(len); + Marshal.Copy(bytearray, 0, i, len); + obj = Marshal.PtrToStructure(i, obj.GetType()); + Marshal.FreeHGlobal(i); + } + + private byte[] ReadBytes(Stream s, int length) + { + var payload = new byte[length]; + int numBytes = 0; + while (numBytes != length) + { + numBytes += s.Read(payload, numBytes, length - numBytes); + } + return payload; + } + + public override string ToString() + { + StringBuilder c = new StringBuilder(base.ToString() + "\n\tType..................Sony WiFi"); + return c.ToString(); + } + + public override void StartZoom(ZoomDirection direction) + { + switch (direction) + { + case ZoomDirection.In: + ExecuteMethod("actZoom", "in", "start"); + break; + case ZoomDirection.Out: + ExecuteMethod("actZoom", "out", "start"); + break; + default: + throw new ArgumentOutOfRangeException(nameof(direction), direction, null); + } + } + + public override void StopZoom(ZoomDirection direction) + { + switch (direction) + { + case ZoomDirection.In: + ExecuteMethod("actZoom", "in", "stop"); + break; + case ZoomDirection.Out: + ExecuteMethod("actZoom", "out", "stop"); + break; + default: + throw new ArgumentOutOfRangeException(nameof(direction), direction, null); + } + + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/StaticHelper.cs b/DigiCamControl/CameraControl.Devices/StaticHelper.cs new file mode 100644 index 0000000..e33fd6f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/StaticHelper.cs @@ -0,0 +1,282 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.IO; +using System.Timers; +using CameraControl.Devices.Classes; +using PortableDeviceLib; + +#endregion + +namespace CameraControl.Devices +{ + public class StaticHelper : BaseFieldClass + { + private static StaticHelper _instance; + + private Timer _timer = new Timer(5*1000); + + public AsyncObservableCollection Messages { get; set; } + + public static StaticHelper Instance + { + get + { + if (_instance == null) + _instance = new StaticHelper(); + return _instance; + } + set { _instance = value; } + } + + public StaticHelper() + { + SystemMessage = ""; + _timer.Elapsed += _timer_Elapsed; + _timer.Start(); + Messages = new AsyncObservableCollection(); + } + + void _timer_Elapsed(object sender, ElapsedEventArgs e) + { + SystemMessage = ""; + } + + public bool IsActive + { + get { return _isActive; } + set + { + _isActive = value; + NotifyPropertyChanged("IsActive"); + } + } + + private string _systemMessage; + + public string SystemMessage + { + get { return _systemMessage; } + set + { + _systemMessage = value; + IsActive = !string.IsNullOrWhiteSpace(_systemMessage); + NotifyPropertyChanged("SystemMessage"); + if (!String.IsNullOrWhiteSpace(_systemMessage)) + Messages.Add(DateTime.Now.ToShortTimeString() + " - " + _systemMessage); + _timer.Stop(); + _timer.Start(); + } + } + + + + private int _loadingProgress; + private bool _isActive; + + public int LoadingProgress + { + get { return _loadingProgress; } + set + { + _loadingProgress = value; + NotifyPropertyChanged("LoadingProgress"); + } + } + + public static bool GetBit(Int32 b, int bitNumber) + { + return (b & (1 << bitNumber)) != 0; + } + + public static bool GetBit(byte b, int bitNumber) + { + return (b & (1 << bitNumber)) != 0; + } + + public static bool GetBit(long b, int bitNumber) + { + return (b & (1 << bitNumber)) != 0; + } + + /// + /// Return serial number component from a pnp id string + /// + /// + /// + public static string GetSerial(string pnpstring) + { + if (pnpstring == null) + return ""; + string ret = ""; + if (pnpstring.Contains("#")) + { + string[] s = pnpstring.Split('#'); + if (s.Length > 2) + { + ret = s[2]; + } + } + return ret; + } + + /// + /// Generate a unique file name + /// + /// First part of file name including full path + /// The counter. + /// The last part of file name most cases the file extension. + /// + public static string GetUniqueFilename(string prefix, int counter, string sufix) + { + string file = prefix + counter + sufix; + if (File.Exists(file)) + { + return GetUniqueFilename(prefix, counter + 1, sufix); + } + return file; + } + + public static int GetDataLength(uint dataType) + { + int dataLength = 0; + switch (dataType) + { + //0x0001 INT8 Signed 8-bit integer + case 0x0001: + dataLength = 1; + break; + //0x0002 UINT8 Unsigned 8-bit integer + case 0x0002: + dataLength = 1; + break; + //0x0003 INT16 Signed 16-bit integer + case 0x0003: + dataLength = 2; + break; + //0x0004 UINT16 Unsigned 16-bit integer + case 0x0004: + dataLength = 2; + break; + //0x0005 INT32 Signed 32-bit integer + case 0x0005: + dataLength = 4; + break; + //0x0006 UINT32 Unsigned 32-bit integer + case 0x0006: + dataLength = 4; + break; + //0x0007 INT64 Signed 64-bit integer + case 0x0007: + dataLength = 8; + break; + //0x0008 UINT64 Unsigned 64-bit integer + case 0x0008: + dataLength = 8; + break; + //0x0009 INT128 Signed 128-bit integer + case 0x0009: + dataLength = 16; + break; + //0x000A UINT128 Unsigned 128-bit integer + case 0x000A: + dataLength = 16; + break; + //0x4001 AINT8 Signed 8-bit integer array + case 0x4001: + dataLength = 1; + break; + //0x4002 AUINT8 Unsigned 8-bit integer array + case 0x4002: + dataLength = 1; + break; + //0x4003 AINT16 Signed 16-bit integer array + case 0x4003: + dataLength = 2; + break; + //0x4004 AUINT16 Unsigned 16-bit integer array + case 0x4004: + dataLength = 2; + break; + //0x4005 AINT32 Signed 32-bit integer array + case 0x4005: + dataLength = 4; + break; + //0x4006 AUINT32 Unsigned 32-bit integer array + case 0x4006: + dataLength = 4; + break; + //0x4007 AINT64 Signed 64-bit integer array + case 0x4007: + dataLength = 8; + break; + //0x4008 AUINT64 Unsigned 64-bit integer array + case 0x4008: + dataLength = 8; + break; + //0x4009 AINT128 Signed 128-bit integer array + case 0x4009: + dataLength = 16; + break; + //0x400A AUINT128 Unsigned 128-bit integer array + case 0x400A: + dataLength = 16; + break; + //0xFFFF STR Variable length Unicode character string + case 0xFFFF: + dataLength = -1; + break; + } + return dataLength; + } + + public static long GetValue(MTPDataResponse result, int index, int dataLength) + { + long val = 0; + switch (dataLength) + { + case 1: + val = result.Data[index]; + break; + case 2: + val = BitConverter.ToUInt16(result.Data, index); + break; + case 4: + val = BitConverter.ToUInt32(result.Data, index); + break; + default: + val = (long) BitConverter.ToUInt64(result.Data, index); + break; + } + return val; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/CommandBlockContainer.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/CommandBlockContainer.cs new file mode 100644 index 0000000..e7f999d --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/CommandBlockContainer.cs @@ -0,0 +1,14 @@ +using CameraControl.Devices.TransferProtocol.DDServer; + +namespace ddserverTest +{ + public class CommandBlockContainer : ParameterContainer + { + public CommandBlockContainer(int commandCode, params uint[] parameters) + : base(parameters) + { + Header.Code = commandCode; + Header.ContainerType = ContainerType.CommandBlock; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/Container.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/Container.cs new file mode 100644 index 0000000..b7f4957 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/Container.cs @@ -0,0 +1,30 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public abstract class Container + { + public ContainerHeader Header; + + protected Container() + { + } + + protected Container(ContainerHeader header) + { + Header = header; + } + + /// + /// Write all bytes of this container to stream. + /// + /// + public void Write(Stream s) + { + Header.Write(s); + WritePayload(s); + } + + public abstract void WritePayload(Stream s); + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerHeader.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerHeader.cs new file mode 100644 index 0000000..9f62052 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerHeader.cs @@ -0,0 +1,81 @@ +using System; +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public class ContainerHeader + { + /// + /// Header length in bytes + /// + public const int HeaderLength = 12; + + /// + /// USB Still Image Capture Device Definition: This field contains the PIMA 15740 OperationCode, ResponseCode, or EventCode. + /// + public int Code; + + /// + /// This field describes the type of the container + /// + public ContainerType ContainerType = ContainerType.Undefined; + + /// + /// Container Length (including payload length) + /// + public int Length; + + /// + /// USB Still Image Capture Device Definition: This is a host generated number that associates all phases of an PIMA15740 operation + /// + public int TransactionID; + + public ContainerHeader() + { + } + + public ContainerHeader(Stream stream) + { + if (stream == null) + throw new ArgumentNullException("stream"); + + Length = readByte(stream) | (readByte(stream) << 8) | (readByte(stream) << 16) | (readByte(stream) << 24); + ContainerType = (ContainerType) readByte(stream); + //byte 5 skipped + readByte(stream); + Code = readByte(stream) | (readByte(stream) << 8); + TransactionID = readByte(stream) | (readByte(stream) << 8) | (readByte(stream) << 16) | + (readByte(stream) << 24); + } + + public int PayloadLength + { + get { return Length - HeaderLength; } + set { Length = HeaderLength + value; } + } + + private static int readByte(Stream s) + { + int result = s.ReadByte(); + if (result == -1) + throw new InvalidContainerException("Unexpected end of stream"); + return result; + } + + public void Write(Stream s) + { + s.WriteByte((byte) (0xff & Length)); + s.WriteByte((byte) (0xff & (Length >> 8))); + s.WriteByte((byte) (0xff & (Length >> 16))); + s.WriteByte((byte) (0xff & (Length >> 24))); + s.WriteByte((byte) (0xff & (int) ContainerType)); + s.WriteByte(0); + s.WriteByte((byte) (0xff & Code)); + s.WriteByte((byte) (0xff & (Code >> 8))); + s.WriteByte((byte) (0xff & TransactionID)); + s.WriteByte((byte) (0xff & (TransactionID >> 8))); + s.WriteByte((byte) (0xff & (TransactionID >> 16))); + s.WriteByte((byte) (0xff & (TransactionID >> 24))); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerType.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerType.cs new file mode 100644 index 0000000..b18fae2 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ContainerType.cs @@ -0,0 +1,39 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public enum ContainerType + { + Undefined = 0, + CommandBlock = 1, + DataBlock = 2, + ResponseBlock = 3, + EventBlock = 4 + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DataBlockContainer.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DataBlockContainer.cs new file mode 100644 index 0000000..f63a10e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DataBlockContainer.cs @@ -0,0 +1,42 @@ +using System; +using System.IO; +using System.Net.Sockets; +using PortableDeviceLib; +using ddserverTest; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public class DataBlockContainer : Container + { + public byte[] Payload; + + public DataBlockContainer(ContainerHeader header, Stream payload, StillImageDevice.TransferCallback callback) + { + Header = header; + Payload = new byte[Header.PayloadLength]; +// int readnum = payload.Read(Payload, 0, Header.PayloadLength); + int numBytes = 0; + while (numBytes != Header.PayloadLength) + { + numBytes += payload.Read(Payload, numBytes, Header.PayloadLength - numBytes); + if (callback != null) + callback((uint)Header.PayloadLength, (uint)numBytes); + } + } + + + public DataBlockContainer(int commandCode, byte[] data) + { + Header = new ContainerHeader(); + Header.Code = commandCode; + Header.ContainerType = ContainerType.DataBlock; + Header.PayloadLength = data.Length; + Payload = data; + } + + public override void WritePayload(Stream s) + { + s.Write(Payload, 0, Payload.Length); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdClient.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdClient.cs new file mode 100644 index 0000000..ac5fba5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdClient.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using PortableDeviceLib; +using ddserverTest; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public class DdClient + { + private readonly object _commandLock = new object(); + private TcpClient _client; + private Stream _inerStream; + private DdServerDevice _lastdevice; + private string _ip; + private int _port; + + public bool Open(string ip, int port) + { + try + { + _ip = ip; + _port = port; + _client = new TcpClient(ip, port); + _inerStream = _client.GetStream(); + string server = Encoding.ASCII.GetString(ReadPacket()); + } + catch (Exception) + { + return false; + } + return true; + } + + public int ReadInt() + { + return _inerStream.ReadByte() | (_inerStream.ReadByte() << 8) | (_inerStream.ReadByte() << 16) | + (_inerStream.ReadByte() << 24); + } + + + private byte[] ReadPacket() + { + int length = ReadInt(); + var buff = new byte[length - 4]; + _inerStream.Read(buff, 0, length - 4); + return buff; + } + + public void Write(Container container) + { + using (var ms = new MemoryStream()) + { + int totalsize = container.Header.Length + 4; + ms.WriteByte((byte)(0xff & totalsize)); + ms.WriteByte((byte)(0xff & (totalsize >> 8))); + ms.WriteByte((byte)(0xff & (totalsize >> 16))); + ms.WriteByte((byte)(0xff & (totalsize >> 24))); + container.Write(ms); + _inerStream.Write(ms.ToArray(), 0, (int) ms.Length); + } + } + + public void Write(Container container1, Container container2) + { + using (var ms = new MemoryStream()) + { + int totalsize = container1.Header.Length + container2.Header.Length + 4; + ms.WriteByte((byte)(0xff & totalsize)); + ms.WriteByte((byte)(0xff & (totalsize >> 8))); + ms.WriteByte((byte)(0xff & (totalsize >> 16))); + ms.WriteByte((byte)(0xff & (totalsize >> 24))); + container1.Write(ms); + container2.Write(ms); + _inerStream.Write(ms.ToArray(), 0, (int)ms.Length); + _inerStream.Flush(); + } + } + + public virtual Container ReadContainer(StillImageDevice.TransferCallback callback = null) + { + Container result = getContainer(false, callback); + return result; + } + + protected Container getContainer(bool synchronized, StillImageDevice.TransferCallback callback) + { + var header = new ContainerHeader(_inerStream); + + switch (header.ContainerType) + { + case ContainerType.DataBlock: + return new DataBlockContainer(header, _inerStream, callback); + case ContainerType.ResponseBlock: + if (synchronized) + Monitor.Exit(_commandLock); + return new ResponseBlockContainer(header, _inerStream); + //Give current instance as stream, because we need keep track on the distance to next header + case ContainerType.CommandBlock: + case ContainerType.EventBlock: + throw new Exception("Invalid container type. " + header.ContainerType); + } + throw new Exception("Unkown container type"); + } + + public List GetDevices() + { + var res = new List(); + Write(new CommandBlockContainer(0002)); + var buff = new byte[6]; + _inerStream.Read(buff, 0, 4); + + int totallegth = buff[3]; + Container c = ReadContainer(); + var dataBlockContainer = c as DataBlockContainer; + if (dataBlockContainer != null) + { + int index = 0; + int devcount = (dataBlockContainer.Payload[index] | (dataBlockContainer.Payload[index + 1] << 8)); + for (int i = 0; i < devcount; i++) + { + res.Add(new DdServerDevice(dataBlockContainer.Payload, index + 2)); + } + Container cc = ReadContainer(); + _inerStream.Read(buff, 0, 4); + } + return res; + } + + public bool Connect(DdServerDevice device) + { + _lastdevice = device; + Write(new CommandBlockContainer(0001, (uint) device.VendorId, (uint) device.ProductId)); + int len = ReadInt(); + //Write(new CommandBlockContainer(0x1001)); + Container c = ReadContainer(); + Container resp = ReadContainer(); + return true; + } + + public void Reconnect() + { + Open(_ip, _port); + Connect(_lastdevice); + } + + public bool IsConnected() + { + return _client.Connected; + } + + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdServerDevice.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdServerDevice.cs new file mode 100644 index 0000000..932f392 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/DdServerDevice.cs @@ -0,0 +1,28 @@ +using System.Text; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public class DdServerDevice + { + public DdServerDevice(byte[] data, int offset) + { + int index = offset; + VendorId = (data[index] | (data[index + 1] << 8)); + index += 2; + ProductId = (data[index] | (data[index + 1] << 8)); + index += 2; + string[] s = Encoding.ASCII.GetString(data, index, data.Length - index).Split('\0'); + if (s.Length > 1) + { + VendorName = s[0]; + ProductName = s[1]; + } + } + + public int VendorId { get; set; } + public int ProductId { get; set; } + + public string VendorName { get; set; } + public string ProductName { get; set; } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/InvalidContainerException.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/InvalidContainerException.cs new file mode 100644 index 0000000..eeffde7 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/InvalidContainerException.cs @@ -0,0 +1,11 @@ +using System; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + internal class InvalidContainerException : Exception + { + public InvalidContainerException(string msg) : base(msg) + { + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ParameterContainer.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ParameterContainer.cs new file mode 100644 index 0000000..c769b13 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ParameterContainer.cs @@ -0,0 +1,40 @@ +using System.IO; +using ddserverTest; + +namespace CameraControl.Devices.TransferProtocol.DDServer +{ + public class ParameterContainer : Container + { + public uint[] Parameters; + + public ParameterContainer() + { + } + + public ParameterContainer(uint[] parameters) + { + Header = new ContainerHeader(); + Parameters = parameters; + Header.PayloadLength = payloadLength; + } + + protected int payloadLength + { + get { return (Parameters == null) ? 0 : Parameters.Length*4; } + } + + public override void WritePayload(Stream s) + { + if (payloadLength > 0) + { + for (int i = 0; i < Parameters.Length; i++) + { + s.WriteByte((byte) (0xff & Parameters[i])); + s.WriteByte((byte) (0xff & (Parameters[i] >> 8))); + s.WriteByte((byte) (0xff & (Parameters[i] >> 16))); + s.WriteByte((byte) (0xff & (Parameters[i] >> 24))); + } + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ResponseBlockContainer.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ResponseBlockContainer.cs new file mode 100644 index 0000000..86fbb7f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DDServer/ResponseBlockContainer.cs @@ -0,0 +1,59 @@ +using System; +using System.IO; +using CameraControl.Devices.TransferProtocol.DDServer; + +namespace ddserverTest +{ + public class ResponseBlockContainer : ParameterContainer + { + /// + /// This constructor is used mainly for testing, because response blocks are + /// usually read from stream + /// + /// + /// + public ResponseBlockContainer(int responseCode, params uint[] parameters) + : base(parameters) + { + Header.Code = responseCode; + Header.ContainerType = ContainerType.ResponseBlock; + } + + /// + /// Read response block from stream + /// + /// the container header + /// data after header + public ResponseBlockContainer(ContainerHeader header, Stream payload) + { + if (payload == null) + throw new ArgumentNullException("payload"); + + Header = header; + readParameters(payload); + } + + protected void readParameters(Stream stream) + { + //PIMA 15740:2000: Response datasets may have at most five parameters + //-> this operation doesn't use too much memory + int pLength = Header.PayloadLength; + if (pLength < 0) + throw new InvalidContainerException("Invalid container length"); + if ((pLength%4) != 0) + throw new InvalidContainerException("Response payload length must by multiplier of 4"); + if (pLength > 20) + throw new InvalidContainerException("Response datasets may have at most five parameters"); + + int i = 0; + Parameters = new uint[pLength/4]; + while (i < Parameters.Length) + { + Parameters[i++] = + (uint) + (stream.ReadByte() | (stream.ReadByte() << 8) | (stream.ReadByte() << 16) | + (stream.ReadByte() << 24)); + } + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/DdServerProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/DdServerProtocol.cs new file mode 100644 index 0000000..74a2631 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/DdServerProtocol.cs @@ -0,0 +1,201 @@ +using System; +using System.IO; +using System.Text; +using CameraControl.Devices.TransferProtocol.DDServer; +using PortableDeviceLib; +using ddserverTest; + +namespace CameraControl.Devices.TransferProtocol +{ + public class DdServerProtocol : ITransferProtocol + { + private DdClient _client; + private uint _sessionId; + private readonly object _syncRoot = new object(); + + + #region Implementation of ITransferProtocol + public string Model { get; private set; } + public string Manufacturer { get; private set; } + public string SerialNumber { get; private set; } + public bool IsConnected { get; set; } + public string DeviceId { get; private set; } + + + public MTPDataResponse ExecuteReadBigData(uint code,Stream stream ,StillImageDevice.TransferCallback callback, params uint[] parameters) + { + lock (_syncRoot) + { + ReconnectIfNeeded(); + DataBlockContainer data; + var res = new MTPDataResponse(); + _client.Write(new CommandBlockContainer((int)code, parameters)); + int len = _client.ReadInt(); + Container resp = _client.ReadContainer(callback); + if (resp.Header.Length >= len - 4) + { + return new MTPDataResponse() { ErrorCode = (uint)resp.Header.Code }; + } + + data = (DataBlockContainer)resp; + resp = _client.ReadContainer(); + return new MTPDataResponse() { Data = data.Payload, ErrorCode = (uint)data.Header.Code }; + } + + } + + public MTPDataResponse ExecuteReadData(uint code, params uint[] parameters) + { + lock (_syncRoot) + { + ReconnectIfNeeded(); + DataBlockContainer data; + var res = new MTPDataResponse(); + _client.Write(new CommandBlockContainer((int) code, parameters)); + int len = _client.ReadInt(); + Container resp = _client.ReadContainer(); + if (resp.Header.Length >= len - 4) + { + return new MTPDataResponse() {ErrorCode = (uint) resp.Header.Code}; + } + + data = (DataBlockContainer) resp; + resp = _client.ReadContainer(); + return new MTPDataResponse() {Data = data.Payload, ErrorCode = (uint) data.Header.Code}; + } + } + + public uint ExecuteWithNoData(uint code, params uint[] parameters) + { + lock (_syncRoot) + { + ReconnectIfNeeded(); + _client.Write(new CommandBlockContainer((int) code, parameters)); + int len = _client.ReadInt(); + Container resp = _client.ReadContainer(); + if (resp.Header.Length >= len - 4) + { + return (uint) resp.Header.Code; + } + + resp = _client.ReadContainer(); + return (uint) resp.Header.Code; + } + } + + public uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters) + { + lock (_syncRoot) + { + ReconnectIfNeeded(); + _client.Write(new CommandBlockContainer((int)code, parameters), new DataBlockContainer((int)code, data)); + int len = _client.ReadInt(); + Container resp = _client.ReadContainer(); + if (resp.Header.Length >= len - 4) + { + return (uint)resp.Header.Code; + } + + resp = _client.ReadContainer(); + return (uint)resp.Header.Code; + } + } + + public void Disconnect() + { + + } + + #endregion + + public DdServerProtocol(DdClient client) + { + Init(client); + } + + public void Init(DdClient client) + { + _client = client; + LoadDeviceInfo(); + OpenSession(); + } + + public void OpenSession() + { + _sessionId++; + ExecuteWithNoData(0x1002, _sessionId); + } + + private void LoadDeviceInfo() + { + var res = ExecuteReadData(0x1001); + int index = 2 + 4 + 2; + int vendorDescCount = res.Data[index]; + index += vendorDescCount * 2; + index += 3; + int comandsCount = res.Data[index]; + index += 2; + // load commands + for (int i = 0; i < comandsCount; i++) + { + index += 2; + } + index += 2; + int eventcount = res.Data[index]; + index += 2; + // load events + for (int i = 0; i < eventcount; i++) + { + index += 2; + } + index += 2; + int propertycount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < propertycount; i++) + { + index += 2; + } + index += 2; + int formatscount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < formatscount; i++) + { + index += 2; + } + index += 2; + int imageformatscount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < imageformatscount; i++) + { + index += 2; + } + index += 2; + int strlen1 = res.Data[index]*2; + index += 1; + Manufacturer = Encoding.Unicode.GetString(res.Data, index, strlen1-2); + index += strlen1; + int strlen2 = res.Data[index] * 2; + index += 1; + Model = Encoding.Unicode.GetString(res.Data, index, strlen2-2); + index += strlen2; + int strlen3 = res.Data[index] * 2; + index += 1; + index += strlen3; + int strlen4 = res.Data[index] * 2; + index += 1; + SerialNumber = Encoding.Unicode.GetString(res.Data, index, strlen4-2); + } + + private void ReconnectIfNeeded() + { + if(!_client.IsConnected()) + { + _client.Reconnect(); + Init(_client); + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/ITransferProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/ITransferProtocol.cs new file mode 100644 index 0000000..a7eff6a --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/ITransferProtocol.cs @@ -0,0 +1,51 @@ +#region Licence +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#endregion + +using System.IO; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol +{ + public interface ITransferProtocol + { + string Model { get; } + string Manufacturer { get; } + string SerialNumber { get; } + bool IsConnected { get; set; } + string DeviceId { get; } + + + MTPDataResponse ExecuteReadBigData(uint code, Stream stream, StillImageDevice.TransferCallback callback, + params uint[] parameters); + + MTPDataResponse ExecuteReadData(uint code, params uint[] parameters); + uint ExecuteWithNoData(uint code, params uint[] parameters); + uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters); + + void Disconnect(); + + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/MtpProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/MtpProtocol.cs new file mode 100644 index 0000000..4071153 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/MtpProtocol.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol +{ + public class MtpProtocol : StillImageDevice, ITransferProtocol + { + public MtpProtocol(string deviceId) + : base(deviceId) + { + + } + + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/BaseCmd.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/BaseCmd.cs new file mode 100644 index 0000000..ede042e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/BaseCmd.cs @@ -0,0 +1,42 @@ +using System.IO; +using CameraControl.Devices.TransferProtocol.DDServer; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class BaseCmd : IPtpIpCommand + { + public PtpIpHeader Header { get; set; } + public uint TransactionID { get; set; } + + public BaseCmd() + { + Header = new PtpIpHeader(); + } + + public virtual void Write(Stream s) + { + + } + + public virtual void Read(Stream s) + { + + } + + public void WriteInt(uint val, Stream s) + { + s.WriteByte((byte)(0xff & val)); + s.WriteByte((byte)(0xff & (val >> 8))); + s.WriteByte((byte)(0xff & (val >> 16))); + s.WriteByte((byte)(0xff & (val >> 24))); + } + + public int readByte(Stream s) + { + int result = s.ReadByte(); + if (result == -1) + throw new InvalidContainerException("Unexpected end of stream"); + return result; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdRequest.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdRequest.cs new file mode 100644 index 0000000..d198d18 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdRequest.cs @@ -0,0 +1,52 @@ +using System.Drawing.Design; +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class CmdRequest : BaseCmd + { + public uint Code { get; set; } + public uint TransactionID { get; set; } + public uint[] Parameters { get; set; } + public uint DataType { get; set; } + + public CmdRequest(uint code, uint datatype = 1) + { + TransactionID = PtpIpProtocol.TransactionId++; + Header = new PtpIpHeader(); + Header.Type = (uint) PtpIpContainerType.Cmd_Request; + Code = code; + DataType = datatype; + } + + public override void Write(Stream s) + { + Header.Length = (uint) (8 + 4 + 2 + 4 + (Parameters != null ? (Parameters.Length*4) : 0)); + Header.Write(s); + // 4 byte unknown. set to 1 currently. + //s.Write(new byte[] {1, 0, 0, 0}, 0, 4); + WriteInt(DataType,s); + s.WriteByte((byte) (0xff & this.Code)); + s.WriteByte((byte) (0xff & (this.Code >> 8))); + + WriteInt(TransactionID, s); + + if (Parameters != null) + { + for (int i = 0; i < this.Parameters.Length; i++) + { + WriteInt(Parameters[i], s); + } + } + } + + public override void Read(Stream s) + { + Header.Read(s); + this.Code = (uint) (readByte(s) | (readByte(s) << 8)); + this.TransactionID = (uint) (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + byte[] b = new byte[Header.Length]; + s.Read(b, 0, (int) (Header.Length - (8 + 2 + 4))); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdResponse.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdResponse.cs new file mode 100644 index 0000000..d19cf68 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/CmdResponse.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class CmdResponse:BaseCmd + { + public int Code { get; set; } + public uint TransactionID { get; set; } + public uint[] Parameters { get; set; } + + public override void Read(Stream s) + { + this.Code = readByte(s) | (readByte(s) << 8); + this.TransactionID = (uint) (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + + if (Header.Length > 14) + { + List vals = new List(); + for (int i = 0; i < Header.Length - (8 + 2 + 4)/4; i++) + { + vals.Add((uint) (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24))); + } + Parameters = vals.ToArray(); + } + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/DataPacket.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/DataPacket.cs new file mode 100644 index 0000000..efc7505 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/DataPacket.cs @@ -0,0 +1,15 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class DataPacket : BaseCmd + { + public byte[] Data { get; set; } + public override void Read(Stream s) + { + TransactionID = (uint)(readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + Data = new byte[Header.Length - 8 - 4]; + s.Read(Data, 0, (int) (Header.Length - 8 - 4)); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/EndDataPacket.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/EndDataPacket.cs new file mode 100644 index 0000000..e11e6b8 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/EndDataPacket.cs @@ -0,0 +1,46 @@ +using System.IO; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class EndDataPacket : BaseCmd + { + + public byte[] Data { get; set; } + + public void Read(Stream s, StillImageDevice.TransferCallback callback) + { + this.TransactionID = (uint) (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + Data = new byte[Header.Length - 8 - 4]; + int numBytes = 0; + while (numBytes != Header.Length - 8 - 4) + { + numBytes += + s.Read(Data, numBytes, + (int) (Header.Length - 8 - 4 - + numBytes)); // payload.Read(Payload, numBytes, Header.PayloadLength - numBytes); + if (callback != null) + callback(Header.Length, (uint)numBytes); + } + + } + + public void Read(Stream s, StillImageDevice.TransferCallback callback, Stream outStream) + { + this.TransactionID = (uint) (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + //Data = new byte[Header.Length - 8 - 4]; + byte[] buff = new byte[102400]; + int numBytes = 0; + while (numBytes != Header.Length - 8 - 4) + { + var bytesRead = + s.Read(buff, 0, buff.Length); // payload.Read(Payload, numBytes, Header.PayloadLength - numBytes); + outStream.Write(buff, 0, bytesRead); + numBytes += bytesRead; + if (callback != null) + callback(Header.Length, (uint)numBytes); + } + } + + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/IPtpIpCommand.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/IPtpIpCommand.cs new file mode 100644 index 0000000..cf0da02 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/IPtpIpCommand.cs @@ -0,0 +1,11 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public interface IPtpIpCommand + { + PtpIpHeader Header { get; set; } + void Write(Stream s); + void Read(Stream s); + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandAck.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandAck.cs new file mode 100644 index 0000000..fecdb68 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandAck.cs @@ -0,0 +1,17 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + internal class InitCommandAck : BaseCmd + { + public int SessionId { get; set; } + + public override void Read(Stream s) + { + + byte[] b = new byte[Header.Length]; + SessionId = (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + s.Read(b, 0, (int) (Header.Length - (8 + 4))); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandRequest.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandRequest.cs new file mode 100644 index 0000000..6497a0a --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitCommandRequest.cs @@ -0,0 +1,32 @@ +using System; +using System.IO; +using System.Text; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class InitCommandRequest :BaseCmd + { + public Guid Guid { get; set; } + public string Name { get; set; } + + public override void Write(Stream s) + { + Guid = Guid.NewGuid(); + Name = "DCC V1.00"; + + Header = new PtpIpHeader(); + Header.Type = 1; + Header.Length = (uint) (8 + 16 + ((Name.Length + 1)*2)+4); + Header.Write(s); + s.Write(Guid.ToByteArray(), 0, 16); + s.Write(Encoding.Unicode.GetBytes(Name), 0, Name.Length*2); + s.WriteByte(0); + s.WriteByte(0); + //version 1.0 + s.WriteByte(0); + s.WriteByte(0); + s.WriteByte(1); + s.WriteByte(0); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitEventRequest.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitEventRequest.cs new file mode 100644 index 0000000..be13057 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/InitEventRequest.cs @@ -0,0 +1,24 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class InitEventRequest:BaseCmd + { + public int SessionId { get; set; } + + public InitEventRequest(int sessionId) + { + Header.Type = (uint) PtpIpContainerType.Init_Event_Request; + Header.Length = 8 + 4; + SessionId = sessionId; + } + + public override void Write(Stream s) + { + Header.Write(s); + WriteInt((uint) SessionId, s); + } + + + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpClient.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpClient.cs new file mode 100644 index 0000000..1f69e62 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpClient.cs @@ -0,0 +1,176 @@ +using System; +using System.IO; +using System.Net.Sockets; +using ddserverTest; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class PtpIpClient + { + private Stream _inerStream; + private TcpClient _client; + + private Stream _eventinerStream; + private TcpClient _eventclient; + + private object _commandLock = new object(); + + public bool Open(string ip, int port) + { + try + { + var header = new PtpIpHeader(); + + _client = new TcpClient(); + //_client.SendTimeout = 0; + //_client.ReceiveTimeout = 0; + _client.Connect(ip, port); + _client.ReceiveTimeout = 300000; + _client.SendTimeout = 300000; + _inerStream = _client.GetStream(); + + Write(new InitCommandRequest()); + InitCommandAck res = (InitCommandAck)Read(); + + _eventclient = new TcpClient(); + _eventclient.Connect(ip, port); + + _eventinerStream = _eventclient.GetStream(); + + WriteEvent(new InitEventRequest(res.SessionId)); + header.Read(_eventinerStream); + + header.Length = 8; + header.Type = (uint)PtpIpContainerType.Ping; + WriteEvent(header); + + header.Read(_eventinerStream); + + } + catch (Exception e) + { + Log.Error(e); + return false; + } + return true; + } + + public int ReadInt() + { + return _inerStream.ReadByte() | (_inerStream.ReadByte() << 8) | (_inerStream.ReadByte() << 16) | (_inerStream.ReadByte() << 24); + } + + + private byte[] ReadPacket() + { + int length = ReadInt(); + byte[] buff = new byte[length - 4]; + _inerStream.Read(buff, 0, length - 4); + return buff; + } + + public void Write(IPtpIpCommand container) + { + using (MemoryStream ms = new MemoryStream()) + { + container.Write(ms); + _inerStream.Write(ms.ToArray(), 0, (int)ms.Length); + //if(container.Header.Length!=ms.Length) + // throw new Exception("Wrong length"); + _inerStream.Flush(); + } + } + + public IPtpIpCommand Read(StillImageDevice.TransferCallback callback = null, Stream stream = null) + { + var header = new PtpIpHeader(); + header.Read(_inerStream); + switch ((PtpIpContainerType)header.Type) + { + case PtpIpContainerType.Init_Command_Request: + break; + case PtpIpContainerType.Init_Command_Ack: + var initcommand = new InitCommandAck() { Header = header }; + initcommand.Read(_inerStream); + return initcommand; + case PtpIpContainerType.Init_Event_Request: + break; + case PtpIpContainerType.Init_Event_Ack: + break; + case PtpIpContainerType.Init_Fail: + break; + case PtpIpContainerType.Cmd_Request: + break; + case PtpIpContainerType.Cmd_Response: + var cmdresp = new CmdResponse() { Header = header }; + cmdresp.Read(_inerStream); + return cmdresp; + case PtpIpContainerType.Event: + break; + case PtpIpContainerType.Start_Data_Packet: + var stardatares = new StartDataPacket() { Header = header }; + stardatares.Read(_inerStream); + return stardatares; + case PtpIpContainerType.Data_Packet: + var data = new DataPacket() { Header = header }; + data.Read(_inerStream); + return data; + case PtpIpContainerType.Cancel_Transaction: + break; + case PtpIpContainerType.End_Data_Packet: + var enddata = new EndDataPacket() { Header = header }; + if (stream != null) + enddata.Read(_inerStream, callback, stream); + else + enddata.Read(_inerStream, callback); + return enddata; + case PtpIpContainerType.Ping: + break; + case PtpIpContainerType.Pong: + break; + default: + throw new ArgumentOutOfRangeException(); + } + return null; + } + + public void Write(PtpIpHeader header) + { + using (MemoryStream ms = new MemoryStream()) + { + header.Write(ms); + _inerStream.Write(ms.ToArray(), 0, (int)ms.Length); + _inerStream.Flush(); + } + } + + public void WriteEvent(IPtpIpCommand container) + { + using (MemoryStream ms = new MemoryStream()) + { + container.Write(ms); + _eventinerStream.Write(ms.ToArray(), 0, (int)ms.Length); + if (container.Header.Length != ms.Length) + throw new Exception("Wrong length"); + } + } + + public void WriteEvent(PtpIpHeader container) + { + using (MemoryStream ms = new MemoryStream()) + { + container.Write(ms); + _eventinerStream.Write(ms.ToArray(), 0, (int)ms.Length); + } + } + + //public virtual Container ReadContainer() + //{ + // Container result = getContainer(false); + // return result; + //} + + + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainer.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainer.cs new file mode 100644 index 0000000..bbaeb9f --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainer.cs @@ -0,0 +1,7 @@ +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class PtpIpContainer + { + + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainerType.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainerType.cs new file mode 100644 index 0000000..29b195e --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpContainerType.cs @@ -0,0 +1,20 @@ +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public enum PtpIpContainerType + { + Init_Command_Request = 1, + Init_Command_Ack = 2, + Init_Event_Request = 3, + Init_Event_Ack = 4, + Init_Fail = 5, + Cmd_Request = 6, + Cmd_Response = 7, + Event = 8, + Start_Data_Packet = 9, + Data_Packet = 10, + Cancel_Transaction = 11, + End_Data_Packet = 12, + Ping = 13, + Pong = 14 + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpHeader.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpHeader.cs new file mode 100644 index 0000000..cf184a0 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/PtpIpHeader.cs @@ -0,0 +1,31 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class PtpIpHeader + { + public uint Length { get; set; } + + public uint Type { get; set; } + + + public void Write(Stream s) + { + s.WriteByte((byte)(0xff & this.Length )); + s.WriteByte((byte)(0xff & (this.Length >> 8))); + s.WriteByte((byte)(0xff & (this.Length >> 16))); + s.WriteByte((byte)(0xff & (this.Length >> 24))); + + s.WriteByte((byte)(0xff & this.Type )); + s.WriteByte((byte)(0xff & (this.Type >> 8))); + s.WriteByte((byte)(0xff & (this.Type >> 16))); + s.WriteByte((byte)(0xff & (this.Type >> 24))); + } + + public void Read(Stream s) + { + Length = (uint) (s.ReadByte() | (s.ReadByte() << 8) | (s.ReadByte() << 16) | (s.ReadByte() << 24)); + Type = (uint)(s.ReadByte() | (s.ReadByte() << 8) | (s.ReadByte() << 16) | (s.ReadByte() << 24)); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/StartDataPacket.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/StartDataPacket.cs new file mode 100644 index 0000000..9efd93a --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIp/StartDataPacket.cs @@ -0,0 +1,38 @@ +using System.IO; + +namespace CameraControl.Devices.TransferProtocol.PtpIp +{ + public class StartDataPacket:BaseCmd + { + + public int Size { get; set; } + + public byte[] Data { get; set; } + + + public override void Read(Stream s) + { + this.TransactionID = (uint)(readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + this.Size = (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + + int i = (readByte(s) | (readByte(s) << 8) | (readByte(s) << 16) | (readByte(s) << 24)); + } + + public override void Write(Stream s) + { + Header.Type = (uint) PtpIpContainerType.Start_Data_Packet; + Header.Length = (uint) (8 + 4 + 8 ); + Header.Write(s); + + WriteInt(TransactionID, s); + WriteInt((uint) Data.Length, s); + WriteInt(0, s); + + WriteInt((uint) (Data.Length+12), s); + WriteInt(12, s); + WriteInt(TransactionID, s); + s.Write(Data, 0, Data.Length); + + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIpProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIpProtocol.cs new file mode 100644 index 0000000..81d639d --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/PtpIpProtocol.cs @@ -0,0 +1,193 @@ +using System; +using System.IO; +using System.Text; +using CameraControl.Devices.TransferProtocol.PtpIp; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol +{ + public class PtpIpProtocol: ITransferProtocol + { + public static uint TransactionId { get; set; } + + private object _locker = new object(); + + public string Model { get; private set; } + public string Manufacturer { get; private set; } + public string SerialNumber { get; private set; } + public bool IsConnected { get; set; } + public string DeviceId { get; private set; } + + private PtpIpClient _client; + + public PtpIpProtocol(PtpIpClient client) + { + TransactionId = 1; + _client = client; + LoadDeviceInfo(); + IsConnected = true; + } + + private void LoadDeviceInfo() + { + var res = ExecuteReadData(0x1001); + int index = 2 + 4 + 2; + int vendorDescCount = res.Data[index]; + index += vendorDescCount * 2; + index += 3; + int comandsCount = res.Data[index]; + index += 2; + // load commands + for (int i = 0; i < comandsCount; i++) + { + index += 2; + } + index += 2; + int eventcount = res.Data[index]; + index += 2; + // load events + for (int i = 0; i < eventcount; i++) + { + index += 2; + } + index += 2; + int propertycount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < propertycount; i++) + { + index += 2; + } + index += 2; + int formatscount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < formatscount; i++) + { + index += 2; + } + index += 2; + int imageformatscount = res.Data[index]; + index += 2; + // load properties codes + for (int i = 0; i < imageformatscount; i++) + { + index += 2; + } + index += 2; + int strlen1 = res.Data[index] * 2; + index += 1; + Manufacturer = Encoding.Unicode.GetString(res.Data, index, strlen1 - 2); + index += strlen1; + int strlen2 = res.Data[index] * 2; + index += 1; + Model = Encoding.Unicode.GetString(res.Data, index, strlen2 - 2); + if (Model.Contains("\0")) + Model = Model.Substring(0, Model.IndexOf('\0')); + index += strlen2; + int strlen3 = res.Data[index] * 2; + index += 1; + index += strlen3; + int strlen4 = res.Data[index] * 2; + index += 1; + SerialNumber = Encoding.Unicode.GetString(res.Data, index, strlen4 - 2); + } + + public MTPDataResponse ExecuteReadBigData(uint code,Stream stream, StillImageDevice.TransferCallback callback, params uint[] parameters) + { + lock (_locker) + { + var cmd = new CmdRequest(code) { Parameters = parameters }; + _client.Write(cmd); + + var res1 = _client.Read(); + + + var response = res1 as CmdResponse; + if (response != null) + { + return new MTPDataResponse() { ErrorCode = (uint)response.Code }; + } + + var response1 = res1 as StartDataPacket; + var res2 = _client.Read(callback, stream); + var res3 = (EndDataPacket)res2; + + var res4 = _client.Read(); + return new MTPDataResponse() { Data = res3.Data }; + } + + } + + public MTPDataResponse ExecuteReadData(uint code, params uint[] parameters) + { + lock (_locker) + { + var cmd = new CmdRequest(code) {Parameters = parameters}; + _client.Write(cmd); + + var res1 = _client.Read(); + + + var response = res1 as CmdResponse; + if (response != null) + { + return new MTPDataResponse() {ErrorCode = (uint) response.Code}; + } + + var response1 = res1 as StartDataPacket; + var res2 = _client.Read(); + var res3 = (EndDataPacket) res2; + + var res4 = _client.Read(); + return new MTPDataResponse() {Data = res3.Data}; + } + } + + + public uint ExecuteWithNoData(uint code, params uint[] parameters) + { + lock (_locker) + { + _client.Write(new CmdRequest(code) {Parameters = parameters}); + + var res1 = _client.Read(); + + + var response = res1 as CmdResponse; + if (response != null) + { + return (uint) response.Code; + } + return 0; + } + } + + public uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters) + { + //6-> + //9-> + //7<- + lock (_locker) + { + var cmd = new CmdRequest(code,2) {Parameters = parameters}; + _client.Write(cmd); + _client.Write(new StartDataPacket() {Data = data, TransactionID = cmd.TransactionID}); + + var res1 = _client.Read(); + + var response = res1 as CmdResponse; + if (response != null) + { + return (uint) response.Code; + } + } + return 0; + } + + public void Disconnect() + { + //throw new NotImplementedException(); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/SonyTransferProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/SonyTransferProtocol.cs new file mode 100644 index 0000000..5bb3b53 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/SonyTransferProtocol.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol +{ + public class SonyTransferProtocol : ITransferProtocol + { + public string Model { get; private set; } + public string Manufacturer { get; private set; } + public string SerialNumber { get; private set; } + public bool IsConnected { get; set; } + public string DeviceId { get; private set; } + + + public MTPDataResponse ExecuteReadBigData(uint code, Stream stream, StillImageDevice.TransferCallback callback, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public MTPDataResponse ExecuteReadData(uint code, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public uint ExecuteWithNoData(uint code, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public void Disconnect() + { + throw new NotImplementedException(); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/TransferProtocol/YiCameraProtocol.cs b/DigiCamControl/CameraControl.Devices/TransferProtocol/YiCameraProtocol.cs new file mode 100644 index 0000000..099acf5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/TransferProtocol/YiCameraProtocol.cs @@ -0,0 +1,250 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PortableDeviceLib; + +namespace CameraControl.Devices.TransferProtocol +{ + public class YiCameraProtocol : ITransferProtocol + { + private object _locker = new object(); + public event DataReceiverdHandler DataReceiverd; + + public delegate void DataReceiverdHandler(object sender, string data); + + public string Token { get; set; } + + // My Attributes + private Socket m_sock; // Server connection + private byte[] m_byBuff = new byte[256]; // Recieved data buffer + private int bracker = 0; + private string data = ""; + + public string Ip { get; set; } + + public string Model { get; private set; } + public string Manufacturer { get; private set; } + public string SerialNumber { get; private set; } + public bool IsConnected { get; set; } + public string DeviceId { get; private set; } + + public YiCameraProtocol() + { + Manufacturer = "Xiaomi"; + Model = "Yi action camera"; + } + + public void Connect(string address, int port) + { + Ip = address; + // Close the socket if it is still open + if (m_sock != null && m_sock.Connected) + { + m_sock.Shutdown(SocketShutdown.Both); + Thread.Sleep(10); + m_sock.Close(); + } + + // Create the socket object + m_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + + IPAddress host = IPAddress.Parse(address); + IPEndPoint hostep = new IPEndPoint(host, port); + + // Connect to server non-Blocking method + m_sock.Blocking = false; + AsyncCallback onconnect = new AsyncCallback(OnConnect); + m_sock.BeginConnect(hostep, onconnect, m_sock); + var t = DateTime.Now; + while (!m_sock.Connected) + { + Thread.Sleep(50); + if ((DateTime.Now - t).TotalMilliseconds > 3000) + throw new Exception("Connection timeout."); + } + // get token + SendCommand(257); + t = DateTime.Now; + while (string.IsNullOrEmpty(Token)) + { + Thread.Sleep(50); + if ((DateTime.Now - t).TotalMilliseconds > 3000) + throw new Exception("Unable to get token."); + + } +// SendCommand(3); + } + + public void SendCommand(int command) + { + m_sock.Send( + Encoding.UTF8.GetBytes(String.Format("{{\"msg_id\":{0},\"token\":{1}}}", command, Token ?? "0"))); + } + + public void SendCommand(int command, string param) + { + var data = String.Format("{{\"msg_id\":{0},\"param\":\"{1}\",\"token\":{2}}}", command, param, + Token ?? "0"); + m_sock.Send(Encoding.UTF8.GetBytes(data)); + } + + public void SendValue(string param, string value) + { + var data = String.Format("{{\"type\":\"{0}\",\"msg_id\":2,\"param\":\"{1}\",\"token\":{2}}}", param, + value, + Token ?? "0"); + + m_sock.Send(Encoding.UTF8.GetBytes(data)); + } + + public void OnConnect(IAsyncResult ar) + { + // Socket was the passed in object + Socket sock = (Socket)ar.AsyncState; + + // Check if we were sucessfull + try + { + //sock.EndConnect( ar ); + if (sock.Connected) + SetupRecieveCallback(sock); + //else + // MessageBox.Show(this, "Unable to connect to remote machine", "Connect Failed!"); + } + catch (Exception ex) + { + Log.Error("OnRecievedData", ex); + } + } + + public void OnRecievedData(IAsyncResult ar) + { + // Socket was the passed in object + Socket sock = (Socket)ar.AsyncState; + + // Check if we got any data + try + { + int nBytesRec = sock.EndReceive(ar); + if (nBytesRec > 0) + { + // Wrote the data to the List + data += Encoding.ASCII.GetString(m_byBuff, 0, nBytesRec); + + // make sure the json string is valid + if (data.ToCharArray().Where((x) => x == '{').Count() == + data.ToCharArray().Where((x) => x == '}').Count()) + { + Console.WriteLine(data + "**************"); + // check if multile json strings + if (data.Contains("}{")) + { + data = data.Replace("}{", "}|{"); + var datas = data.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); + foreach (string s in datas) + { + ProcessData(s); + } + } + else + { + ProcessData(data); + } + data = ""; + } + // If the connection is still usable restablish the callback + SetupRecieveCallback(sock); + } + else + { + // If no data was recieved then the connection is probably dead + Console.WriteLine("Client {0}, disconnected", + sock.RemoteEndPoint); + sock.Shutdown(SocketShutdown.Both); + sock.Close(); + } + } + catch (Exception ex) + { + Log.Error("OnRecievedData", ex); + } + } + + private void ProcessData(string data) + { + try + { + dynamic resp = JsonConvert.DeserializeObject(data); + switch ((string) resp.msg_id) + { + case "257": // token + Token = resp.param; + break; + default: + OnDataReceiverd(data); + break; + } + } + catch (Exception ex) + { + Log.Error("SetupRecieveCallback", ex); + } + } + /// + /// Setup the callback for recieved data and loss of conneciton + /// + public void SetupRecieveCallback(Socket sock) + { + try + { + AsyncCallback recieveData = new AsyncCallback(OnRecievedData); + sock.BeginReceive(m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData, sock); + } + catch (Exception ex) + { + Log.Error("SetupRecieveCallback", ex); + } + } + + + public MTPDataResponse ExecuteReadBigData(uint code, Stream stream, StillImageDevice.TransferCallback callback, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public MTPDataResponse ExecuteReadData(uint code, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public uint ExecuteWithNoData(uint code, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters) + { + throw new NotImplementedException(); + } + + public void Disconnect() + { + + } + + protected virtual void OnDataReceiverd(string data) + { + var handler = DataReceiverd; + if (handler != null) handler(this, data); + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/DDServerProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/DDServerProvider.cs new file mode 100644 index 0000000..add84d5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/DDServerProvider.cs @@ -0,0 +1,55 @@ +using System; +using CameraControl.Devices.Classes; +using CameraControl.Devices.TransferProtocol; +using CameraControl.Devices.TransferProtocol.DDServer; + +namespace CameraControl.Devices.Wifi +{ + public class DDServerProvider:IWifiDeviceProvider + { + public string Name { get; set; } + public string DefaultIp { get; set; } + + public DeviceDescriptor Connect(string address) + { + int port = 4757; + string ip = address; + if (address.Contains(":")) + { + ip = address.Split(':')[0]; + int.TryParse(address.Split(':')[1], out port); + } + DdClient client = new DdClient(); + if (!client.Open(ip, port)) + throw new Exception("No server was found!"); + var devices = client.GetDevices(); + if (devices.Count == 0) + throw new Exception("No connected device was found!"); + + client.Connect(devices[0]); + DdServerProtocol protocol = new DdServerProtocol(client); + + if (CameraDeviceManager.GetNativeDriver(protocol.Model) != null) + { + DeviceDescriptor descriptor = new DeviceDescriptor { WpdId = "ddserver" }; + var cameraDevice = (ICameraDevice)Activator.CreateInstance(CameraDeviceManager.GetNativeDriver(protocol.Model)); + descriptor.StillImageDevice = protocol; + + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + descriptor.CameraDevice = cameraDevice; + return descriptor; + } + else + { + throw new Exception("Not Supported device " + protocol.Model); + } + } + + public DDServerProvider() + { + Name = "DSLRDASHBOARDSERVER (Nikon only)"; + DefaultIp = "192.168.1.1"; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/OscProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/OscProvider.cs new file mode 100644 index 0000000..4d4e7c2 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/OscProvider.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CameraControl.Devices; +using CameraControl.Devices.Classes; +using CameraControl.Devices.Others; + +namespace CameraControl.Devices.Wifi +{ + public class OscProvider: IWifiDeviceProvider + { + public DeviceDescriptor Connect(string address) + { + + DeviceDescriptor descriptor = new DeviceDescriptor { WpdId = "OscCamera" }; + var cameraDevice = new OscCamera(); + descriptor.CameraDevice = cameraDevice; + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init($"http://{address}"); + return descriptor; + } + + public string Name { get; set; } + public string DefaultIp { get; set; } + + public OscProvider() + { + Name = "OSC Protocol"; + DefaultIp = "192.168.1.1"; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/PanonoDiscovery.cs b/DigiCamControl/CameraControl.Devices/Wifi/PanonoDiscovery.cs new file mode 100644 index 0000000..0f94350 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/PanonoDiscovery.cs @@ -0,0 +1,94 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Windows; +using Rssdp; +using Rssdp.Infrastructure; + +namespace CameraControl.Devices.Wifi +{ + public class PanonoDiscovery + { + + + public string EndPoint { get; set; } + + public bool UDPSocketSetup() + { + try + { + SsdpDeviceLocator _DeviceLocator = null; + NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); + foreach (NetworkInterface adapter in nics) + { + IPInterfaceProperties ip_properties = adapter.GetIPProperties(); + if (!adapter.GetIPProperties().MulticastAddresses.Any()) + continue; // most of VPN adapters will be skipped + if (!adapter.SupportsMulticast) + continue; // multicast is meaningless for this type of connection + if (OperationalStatus.Up != adapter.OperationalStatus) + continue; // this adapter is off or not connected + if (adapter.NetworkInterfaceType != NetworkInterfaceType.Wireless80211) + continue; + + IPv4InterfaceProperties p = adapter.GetIPProperties().GetIPv4Properties(); + if (null == p) + continue; // IPv4 is not configured on this adapter + + foreach (UnicastIPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses) + { + if (ip.Address.AddressFamily == AddressFamily.InterNetwork) + { + + _DeviceLocator = + new SsdpDeviceLocator(new SsdpCommunicationsServer(new SocketFactory(ip.Address.ToString()))); + break; + } + } + + + } + + if (_DeviceLocator == null) + throw new Exception("Camea not connected !"); + + // (Optional) Set the filter so we only see notifications for devices we care about + // (can be any search target value i.e device type, uuid value etc - any value that appears in the + // DiscoverdSsdpDevice.NotificationType property or that is used with the searchTarget parameter of the Search method). + _DeviceLocator.NotificationFilter = "ssdp:all"; + + // Connect our event handler so we process devices as they are found + //_DeviceLocator.DeviceAvailable += deviceLocator_DeviceAvailable; + + // Enable listening for notifications (optional) + _DeviceLocator.StartListeningForNotifications(); + + // Perform a search so we don't have to wait for devices to broadcast notifications + // again to get any results right away (notifications are broadcast periodically). + var s = _DeviceLocator.SearchAsync(new TimeSpan(0, 0, 15)).Result.ToList(); + if (s.Any()) + { + foreach (var device in s) + { + if (device.NotificationType == "panono:ball-camera") + { + EndPoint = device.DescriptionLocation.ToString(); + return true; + } + } + } + return false; + } + catch (Exception exc) + { + Log.Debug("Camera discovery fail", exc); + return false; + } + } + + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/PanonoProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/PanonoProvider.cs new file mode 100644 index 0000000..278141b --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/PanonoProvider.cs @@ -0,0 +1,54 @@ +using System; +using CameraControl.Devices.Classes; +using PanonoTest; + +namespace CameraControl.Devices.Wifi +{ + public class PanonoProvider:IWifiDeviceProvider + { + public DeviceDescriptor Connect(string address) + { + if (string.IsNullOrEmpty(address) || address == DefaultIp) + { + PanonoDiscovery cameraDiscover = new PanonoDiscovery(); + + if (cameraDiscover.UDPSocketSetup()) + { + return ConnectCamera(cameraDiscover.EndPoint); + } + throw new Exception("No camera was found !"); + } + else + { + return ConnectCamera(address); + } + } + + public DeviceDescriptor ConnectCamera(string endpoint) + { + var camera = new PanonoCamera(); + camera.Init(endpoint); + Log.Debug("Camera found at " + endpoint); + camera.DeviceName = "Panono"; + camera.Manufacturer = "Panono"; + DeviceDescriptor descriptor = new DeviceDescriptor + { + WpdId = "PanonoCamera", + CameraDevice = camera + }; + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + return descriptor; + //ws://192.168.80.80:42345/ + } + + + public string Name { get; set; } + public string DefaultIp { get; set; } + + public PanonoProvider() + { + Name = "Panono"; + DefaultIp = ""; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/PtpIpProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/PtpIpProvider.cs new file mode 100644 index 0000000..83b7345 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/PtpIpProvider.cs @@ -0,0 +1,50 @@ +using System; +using CameraControl.Devices.Classes; +using CameraControl.Devices.TransferProtocol; +using CameraControl.Devices.TransferProtocol.PtpIp; + +namespace CameraControl.Devices.Wifi +{ + public class PtpIpProvider:IWifiDeviceProvider + { + public string Name { get; set; } + public string DefaultIp { get; set; } + + public DeviceDescriptor Connect(string address) + { + string ip = address; + if (address.Contains(":")) + { + ip = address.Split(':')[0]; + int port; + int.TryParse(address.Split(':')[1], out port); + } + PtpIpClient client = new PtpIpClient(); + if (!client.Open(ip, 15740)) + throw new Exception("No server was found!"); + PtpIpProtocol protocol = new PtpIpProtocol(client); + protocol.ExecuteWithNoData(0x1002, 1); + + if (CameraDeviceManager.GetNativeDriver(protocol.Model) != null) + { + DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = "ptpip"}; + var cameraDevice = (ICameraDevice)Activator.CreateInstance(CameraDeviceManager.GetNativeDriver(protocol.Model)); + descriptor.StillImageDevice = protocol; + descriptor.CameraDevice = cameraDevice; + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + return descriptor; + } + else + { + throw new Exception("Not Supported device " + protocol.Model); + } + } + + public PtpIpProvider() + { + Name = "WU 1a/1b,Nikon camera"; + DefaultIp = "192.168.1.1"; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/SonyProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/SonyProvider.cs new file mode 100644 index 0000000..4c2f997 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/SonyProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CameraControl.Devices.Classes; +using CameraControl.Devices.Sony; +using SonyCameraCommunication; + +namespace CameraControl.Devices.Wifi +{ + public class SonyProvider : IWifiDeviceProvider + { + public string Name { get; set; } + public string DefaultIp { get; set; } + public DeviceDescriptor Connect(string address) + { + CameraDiscovery cameraDiscover = new CameraDiscovery(); + + if (cameraDiscover.UDPSocketSetup()) + { + if (cameraDiscover.MSearch()) + { + + var cameraResp = cameraDiscover.DeviceDescription(); + var info = cameraDiscover.AnalyzeDescription(cameraResp); + var camera = new SonyWifiCamera(); + camera.Init(info.Endpoints["camera"]); + camera.DeviceName = info.FriendlyName; + camera.SerialNumber = info.UDN; + DeviceDescriptor descriptor = new DeviceDescriptor { WpdId = "SonyWifiCamera" }; + descriptor.CameraDevice = camera; + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + return descriptor; + } + } + throw new Exception("No camera was found !"); + } + + public SonyProvider() + { + Name = "Sony"; + DefaultIp = ""; + } + } +} diff --git a/DigiCamControl/CameraControl.Devices/Wifi/YiCameraProvider.cs b/DigiCamControl/CameraControl.Devices/Wifi/YiCameraProvider.cs new file mode 100644 index 0000000..f22bd9c --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Wifi/YiCameraProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CameraControl.Devices.Classes; +using CameraControl.Devices.Custom; +using CameraControl.Devices.Others; +using CameraControl.Devices.TransferProtocol; +using CameraControl.Devices.TransferProtocol.PtpIp; + +namespace CameraControl.Devices.Wifi +{ + public class YiCameraProvider : IWifiDeviceProvider + { + public string Name { get; set; } + public string DefaultIp { get; set; } + public DeviceDescriptor Connect(string address) + { + int port = 7878; + string ip = address; + if (address.Contains(":")) + { + ip = address.Split(':')[0]; + int.TryParse(address.Split(':')[1], out port); + } + YiCameraProtocol protocol = new YiCameraProtocol(); + protocol.Connect(ip, port); + + DeviceDescriptor descriptor = new DeviceDescriptor { WpdId = "YiCamera" }; + var cameraDevice = new YiCamera(); + descriptor.StillImageDevice = protocol; + descriptor.CameraDevice = cameraDevice; + //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId); + cameraDevice.Init(descriptor); + return descriptor; + } + + public YiCameraProvider() + { + Name = "Xiaomi Yi action camera"; + DefaultIp = "192.168.42.1"; + } + + } +} diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlCommandDescriptor.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlCommandDescriptor.cs new file mode 100644 index 0000000..d87fb75 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlCommandDescriptor.cs @@ -0,0 +1,92 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlCommandDescriptor : BaseFieldClass + { + [XmlAttribute] + public uint Code { get; set; } + + private string _name; + + [XmlAttribute] + public string Name + { + get { return _name; } + set + { + _name = value; + NotifyPropertyChanged("Name"); + NotifyPropertyChanged("DisplayName"); + } + } + + [XmlAttribute] + public string Description { get; set; } + + private string _hexCode; + + [XmlAttribute] + public string HexCode + { + get + { + _hexCode = Code.ToString("X"); + return _hexCode; + } + set { _hexCode = value; } + } + + [XmlIgnore] + public string DisplayName + { + get + { + return HexCode + " - " + Name; + ; + } + } + + public override string ToString() + { + return HexCode + Name; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlDataManager.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlDataManager.cs new file mode 100644 index 0000000..6299aa4 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlDataManager.cs @@ -0,0 +1,85 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlDataManager : BaseFieldClass + { + public const string PM_MODE = "Mode"; + public const string PM_ISO = "Iso"; + public const string PM_Shutter_Speed = "Shutter speed"; + public const string PM_Aperture = "Aperture"; + public const string PM_WhiteBalance = "White balance"; + public const string PM_ExposureComp = "Exposure Comp"; + public const string PM_Compression = "Compression"; + public const string PM_MeteringMode = "Metering mode"; + public const string PM_FocusMode = "Focus mode"; + public const string PM_BATERY = "Battery"; + public const string PM_Advanced = "Advanced properties"; + + private AsyncObservableCollection _propertyMapping; + + public AsyncObservableCollection PropertyMapping + { + get { return _propertyMapping; } + set + { + _propertyMapping = value; + NotifyPropertyChanged("PropertyMapping"); + } + } + + public XmlDataManager() + { + PropertyMapping = new AsyncObservableCollection + { + PM_MODE, + PM_ISO, + PM_Shutter_Speed, + PM_Aperture, + PM_WhiteBalance, + PM_ExposureComp, + PM_Compression, + PM_MeteringMode, + PM_FocusMode, + PM_BATERY, + PM_Advanced + }; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlDeviceData.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlDeviceData.cs new file mode 100644 index 0000000..e4c28e6 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlDeviceData.cs @@ -0,0 +1,108 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml.Serialization; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlDeviceData + { + public List AvaiableCommands { get; set; } + public List AvaiableEvents { get; set; } + public List AvaiableProperties { get; set; } + + public string Model { get; set; } + public string Manufacturer { get; set; } + + + public XmlDeviceData() + { + AvaiableCommands = new List(); + AvaiableEvents = new List(); + AvaiableProperties = new List(); + } + + public static XmlDeviceData Load(string filename) + { + XmlDeviceData photoSession = new XmlDeviceData(); + if (File.Exists(filename)) + { + XmlSerializer mySerializer = + new XmlSerializer(typeof (XmlDeviceData)); + FileStream myFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read); + photoSession = (XmlDeviceData) mySerializer.Deserialize(myFileStream); + myFileStream.Close(); + } + return photoSession; + } + + public string GetCommandName(uint code) + { + foreach (XmlCommandDescriptor xmlCommandDescriptor in AvaiableCommands) + { + if (xmlCommandDescriptor.Code == code) + return xmlCommandDescriptor.Name; + } + return ""; + } + + public string GetEventName(uint code) + { + foreach (XmlEventDescriptor xmlEventDescriptor in AvaiableEvents) + { + if (xmlEventDescriptor.Code == code) + return xmlEventDescriptor.Name; + } + return ""; + } + + public string GetPropName(uint code) + { + foreach (XmlPropertyDescriptor xmlPropertyDescriptor in AvaiableProperties) + { + if (xmlPropertyDescriptor.Code == code) + return xmlPropertyDescriptor.Name; + } + return ""; + } + + public bool PropertyExist(uint code) + { + return AvaiableProperties.Any(xmlPropertyDescriptor => xmlPropertyDescriptor.Code == code); + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlEventDescriptor.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlEventDescriptor.cs new file mode 100644 index 0000000..4c3e6a5 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlEventDescriptor.cs @@ -0,0 +1,70 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlEventDescriptor + { + [XmlAttribute] + public uint Code { get; set; } + + [XmlAttribute] + public string Name { get; set; } + + [XmlAttribute] + public string Description { get; set; } + + private string _hexCode; + + [XmlAttribute] + public string HexCode + { + get + { + _hexCode = Code.ToString("X"); + return _hexCode; + } + set { _hexCode = value; } + } + + public override string ToString() + { + return HexCode + Name; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyDescriptor.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyDescriptor.cs new file mode 100644 index 0000000..63f8a18 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyDescriptor.cs @@ -0,0 +1,115 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlPropertyDescriptor : BaseFieldClass + { + [XmlAttribute] + public uint Code { get; set; } + + private string _name; + + [XmlAttribute] + public string Name + { + get { return _name; } + set + { + _name = value; + NotifyPropertyChanged("Name"); + NotifyPropertyChanged("DisplayName"); + } + } + + [XmlIgnore] + public string DisplayName + { + get + { + return HexCode + " - " + Name; + ; + } + } + + [XmlAttribute] + public string Description { get; set; } + + [XmlAttribute] + public uint DataType { get; set; } + + [XmlAttribute] + public uint DataForm { get; set; } + + [XmlAttribute] + public long MinVal { get; set; } + + [XmlAttribute] + public long MaxVal { get; set; } + + [XmlAttribute] + public long Inc { get; set; } + + + private string _hexCode; + + [XmlAttribute] + public string HexCode + { + get + { + _hexCode = Code.ToString("X"); + return _hexCode; + } + set { _hexCode = value; } + } + + public List Values { get; set; } + + public XmlPropertyDescriptor() + { + Values = new List(); + } + + public override string ToString() + { + return HexCode + Name; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyValue.cs b/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyValue.cs new file mode 100644 index 0000000..94f5ae9 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/Xml/XmlPropertyValue.cs @@ -0,0 +1,89 @@ +#region Licence + +// Distributed under MIT License +// =========================================================== +// +// digiCamControl - DSLR camera remote control open source software +// Copyright (C) 2014 Duka Istvan +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#endregion + +#region + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using CameraControl.Devices.Classes; + +#endregion + +namespace CameraControl.Devices.Xml +{ + public class XmlPropertyValue : BaseFieldClass + { + [XmlAttribute] + public long Value { get; set; } + + private string _name; + + [XmlAttribute] + public string Name + { + get { return _name; } + set + { + _name = value; + NotifyPropertyChanged("Name"); + NotifyPropertyChanged("DisplayName"); + } + } + + private string _hexCode; + + [XmlAttribute] + public string HexValue + { + get + { + _hexCode = Value.ToString("X"); + return _hexCode; + } + set { _hexCode = value; } + } + + [XmlIgnore] + public string DisplayName + { + get + { + return Value + " - " + HexValue + " - " + Name; + ; + } + } + + public override string ToString() + { + return HexValue + Name; + } + } +} \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/app.config b/DigiCamControl/CameraControl.Devices/app.config new file mode 100644 index 0000000..01d1b13 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/DigiCamControl/CameraControl.Devices/packages.config b/DigiCamControl/CameraControl.Devices/packages.config new file mode 100644 index 0000000..59316d7 --- /dev/null +++ b/DigiCamControl/CameraControl.Devices/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.csproj b/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.csproj new file mode 100644 index 0000000..75a684a --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.csproj @@ -0,0 +1,191 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {F809DBB6-E0E8-47A8-92ED-C24575576A5D} + Library + Properties + Canon.Eos.Framework + Canon.Eos.Framework + v4.6 + 512 + + + + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + false + false + bin\x86\Debug\Canon.Eos.Framework.XML + + + bin\Release\ + TRACE + true + pdbonly + x86 + prompt + true + true + false + + + true + bin\Debug\ + DEBUG;TRACE + full + x64 + prompt + false + false + false + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + true + true + false + + + true + bin\Capture.Workflow\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + true + bin\x86\Capture.Workflow\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + false + + + true + bin\x64\Capture.Workflow\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + false + false + + + false + + + Canon.Eos.Framework.snk + + + + + + + + + + + EosCamera.cs + + + EosCamera.cs + + + + EosCamera.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.snk b/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.snk new file mode 100644 index 0000000..d9398ec Binary files /dev/null and b/DigiCamControl/Canon.Eos.Framework/Canon.Eos.Framework.snk differ diff --git a/DigiCamControl/Canon.Eos.Framework/EosBatteryQuality.cs b/DigiCamControl/Canon.Eos.Framework/EosBatteryQuality.cs new file mode 100644 index 0000000..2e0ba99 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosBatteryQuality.cs @@ -0,0 +1,10 @@ +namespace Canon.Eos.Framework +{ + public enum EosBatteryQuality : long + { + Low = 0, + Half, + High, + Full, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeObjectEvents.cs b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeObjectEvents.cs new file mode 100644 index 0000000..07ffb54 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeObjectEvents.cs @@ -0,0 +1,170 @@ +using System; +using System.Threading.Tasks; +using Canon.Eos.Framework.Eventing; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + partial class EosCamera + { + public readonly EosImageTransporter _transporter = new EosImageTransporter(); + + private void OnPictureTaken(EosMemoryImageEventArgs eventArgs) + { + var directoryItemInfo = EosImageTransporter.GetDirectoryItemInfo(eventArgs.Pointer); + eventArgs.FileName = directoryItemInfo.szFileName; + if (this.PictureTaken != null) + Task.Factory.StartNew(() => this.PictureTaken(this, eventArgs)); + } + + private void OnVolumeInfoChanged(EosVolumeInfoEventArgs eventArgs) + { + if (this.VolumeInfoChanged != null) + this.VolumeInfoChanged(this, eventArgs); + } + + private void OnObjectEventVolumeInfoChanged(IntPtr sender) + { + Edsdk.EdsVolumeInfo volumeInfo; + Util.Assert(Edsdk.EdsGetVolumeInfo(sender, out volumeInfo), "Failed to get volume info."); + + this.OnVolumeInfoChanged(new EosVolumeInfoEventArgs(new EosVolumeInfo + { + Access = volumeInfo.Access, + FreeSpaceInBytes = volumeInfo.FreeSpaceInBytes, + MaxCapacityInBytes = volumeInfo.MaxCapacity, + StorageType = volumeInfo.StorageType, + VolumeLabel = volumeInfo.szVolumeLabel + })); + } + + private void OnObjectEventVolumeUpdateItems(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventFolderUpdateItems(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventDirItemCreated(IntPtr sender, IntPtr context) + { + //LiveViewqueue.Enqueue(() => + //{ + // this.OnPictureTaken(new EosMemoryImageEventArgs(null){Pointer = sender}); + //}); + this.OnPictureTaken(new EosMemoryImageEventArgs(null) { Pointer = sender }); + } + + private void OnObjectEventDirItemRemoved(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventDirItemInfoChanged(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventDirItemContentChanged(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventDirItemRequestTransfer(IntPtr sender) + { + //LiveViewqueue.Enqueue(() => + //{ + // this.OnPictureTaken(new EosMemoryImageEventArgs(null) { Pointer = sender }); + // this.OnPictureTaken(_transporter.TransportInMemory(sender)); + // Edsdk.EdsRelease(sender); + //}); + this.OnPictureTaken(new EosMemoryImageEventArgs(null) { Pointer = sender }); + } + + private void OnObjectEventDirItemRequestTransferDt(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventDirItemCancelTransferDt(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventVolumeAdded(IntPtr sender, IntPtr context) + { + } + + private void OnObjectEventVolumeRemoved(IntPtr sender, IntPtr context) + { + } + + private uint HandleObjectEvent(uint objectEvent, IntPtr sender, IntPtr context) + { + try + { + EosFramework.LogInstance.Debug("HandleObjectEvent fired: " + objectEvent); + Console.WriteLine("Canon event {0}", objectEvent); + switch (objectEvent) + { + case Edsdk.ObjectEvent_VolumeInfoChanged: + //this.OnObjectEventVolumeInfoChanged(sender); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_VolumeUpdateItems: + this.OnObjectEventVolumeUpdateItems(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_FolderUpdateItems: + this.OnObjectEventFolderUpdateItems(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_DirItemCreated: + this.OnObjectEventDirItemCreated(sender, context); + break; + case Edsdk.ObjectEvent_DirItemRemoved: + this.OnObjectEventDirItemRemoved(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_DirItemInfoChanged: + this.OnObjectEventDirItemInfoChanged(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_DirItemContentChanged: + this.OnObjectEventDirItemContentChanged(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_DirItemRequestTransfer: + this.OnObjectEventDirItemRequestTransfer(sender); + break; + case Edsdk.ObjectEvent_DirItemRequestTransferDT: + this.OnObjectEventDirItemRequestTransferDt(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_DirItemCancelTransferDT: + this.OnObjectEventDirItemCancelTransferDt(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_VolumeAdded: + this.OnObjectEventVolumeAdded(sender, context); + Edsdk.EdsRelease(sender); + break; + case Edsdk.ObjectEvent_VolumeRemoved: + this.OnObjectEventVolumeRemoved(sender, context); + Edsdk.EdsRelease(sender); + break; + default: + Edsdk.EdsRelease(sender); + break; + } + } + catch (Exception ex) + { + EosFramework.LogInstance.Error("Handing HandleObjectEvent: {0}", ex); + } + finally + { + + } + + return Edsdk.EDS_ERR_OK; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCamera.HandePropertyEvents.cs b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandePropertyEvents.cs new file mode 100644 index 0000000..6170442 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandePropertyEvents.cs @@ -0,0 +1,187 @@ +using System; +using System.Threading; +using Canon.Eos.Framework.Eventing; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal; +using Canon.Eos.Framework.Internal.SDK; +using Canon.Eos.Framework.Threading; + +namespace Canon.Eos.Framework +{ + partial class EosCamera + { + private bool _liveMode; + private bool _cancelLiveViewRequested; + private bool _pauseLiveViewRequested; + private bool _liveViewRunning; + + private void OnLiveViewStarted(EventArgs eventArgs) + { + if (this.LiveViewStarted != null) + this.LiveViewStarted(this, eventArgs); + } + + private void OnLiveViewStopped(EventArgs eventArgs) + { + if (this.LiveViewStopped != null) + this.LiveViewStopped(this, eventArgs); + } + + private void OnLiveViewPaused(EventArgs eventArgs) + { + if (this.LiveViewPaused != null) + this.LiveViewPaused(this, eventArgs); + } + + private void OnLiveViewUpdate(EosLiveImageEventArgs eventArgs) + { + if (this.LiveViewUpdate != null) + this.LiveViewUpdate(this, eventArgs); + } + + public bool DownloadEvf() + { + lock (_locker) + { + + // Do not download if pauseUpdate requested + if (_pauseLiveViewRequested) + return true; + + if ((this.LiveViewDevice & EosLiveViewDevice.Host) == EosLiveViewDevice.None || _cancelLiveViewRequested) + return false; + + //lock (_locker) + //{ + _liveViewRunning = true; + DownloadEvfInternal(); + if (LiveViewqueue.Count > 0) + { + try + { + LiveViewqueue.Dequeue().Invoke(); + } + catch (Exception) + { + } + } + _liveViewRunning = false; + //} + return true; + } + } + + public bool DownloadEvfInternal() + { + var memoryStream = IntPtr.Zero; + try + { + Edsdk.EdsCreateMemoryStream(0, out memoryStream); + using (var image = EosLiveImage.CreateFromStream(memoryStream)) + { + Edsdk.EdsDownloadEvfImage(this.Handle, image.Handle); + + var converter = new EosConverter(); + this.OnLiveViewUpdate( + new EosLiveImageEventArgs(converter.ConvertImageStreamToBytes(memoryStream)) + { + Zoom = image.Zoom, + ZommBounds = image.ZoomBounds, + ImagePosition = image.ImagePosition, + ImageSize = image.Size, + + //Histogram = image.Histogram, + + }); + + } + } + catch (EosException eosEx) + { + //if (eosEx.EosErrorCode != EosErrorCode.DeviceBusy && eosEx.EosErrorCode != EosErrorCode.ObjectNotReady) + // throw; + } + finally + { + if (memoryStream != IntPtr.Zero) + Edsdk.EdsRelease(memoryStream); + } + return true; + } + + + private void StartDownloadEvfInBackGround() + { + var backgroundWorker = new BackgroundWorker(); + backgroundWorker.Work(() => + { + + while (this.DownloadEvf()) + { + // Take Picture requested? + if (this._pauseLiveViewRequested) + { + this.OnLiveViewPaused(EventArgs.Empty); + while (this._pauseLiveViewRequested) + { + //Wait until picture processing is finished + Thread.Sleep(EosCamera.WaitTimeoutForNextLiveDownload); + } + } + Thread.Sleep(EosCamera.WaitTimeoutForNextLiveDownload); + } + + this.LiveViewDevice = EosLiveViewDevice.None; + }); + } + + private void OnPropertyEventPropertyEvfOutputDeviceChanged(uint param, IntPtr context) + { + if (!_liveMode && (this.LiveViewDevice & EosLiveViewDevice.Host) != EosLiveViewDevice.None) + { + _liveMode = true; + this.OnLiveViewStarted(EventArgs.Empty); + //this.StartDownloadEvfInBackGround(); + } + else if (_liveMode && (this.LiveViewDevice & EosLiveViewDevice.Host) == EosLiveViewDevice.None) + { + _liveMode = false; + this.OnLiveViewStopped(EventArgs.Empty); + } + } + + private void OnPropertyEventPropertyChanged(uint propertyId, uint param, IntPtr context) + { + EosFramework.LogInstance.Debug("OnPropertyEventPropertyChanged: " + propertyId); + switch (propertyId) + { + case Edsdk.PropID_Evf_OutputDevice: + this.OnPropertyEventPropertyEvfOutputDeviceChanged(param, context); + break; + } + if (PropertyChanged != null) + PropertyChanged(this, new EosPropertyEventArgs() {PropertyId = propertyId}); + } + + private void OnPropertyEventPropertyDescChanged(uint propertyId, uint param, IntPtr context) + { + EosFramework.LogInstance.Debug("OnPropertyEventPropertyDescChanged: " + propertyId); + } + + private uint HandlePropertyEvent(uint propertyEvent, uint propertyId, uint param, IntPtr context) + { + EosFramework.LogInstance.Debug("HandlePropertyEvent fired: " + propertyEvent + ", id: " + propertyId); + switch (propertyEvent) + { + case Edsdk.PropertyEvent_PropertyChanged: + this.OnPropertyEventPropertyChanged(propertyId, param, context); + break; + + case Edsdk.PropertyEvent_PropertyDescChanged: + this.OnPropertyEventPropertyDescChanged(propertyId, param, context); + break; + } + return Edsdk.EDS_ERR_OK; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeStateEvents.cs b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeStateEvents.cs new file mode 100644 index 0000000..4ad5b1e --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCamera.HandeStateEvents.cs @@ -0,0 +1,35 @@ +using System; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + partial class EosCamera + { + private void OnStateEventShutdown(EventArgs eventArgs) + { + if (this.Shutdown != null) + this.Shutdown.BeginInvoke(this, eventArgs, null, null); + } + private void OnStateEventWillShutdown(EventArgs eventArgs) + { + if (this.WillShutdown != null) + this.WillShutdown.BeginInvoke(this, eventArgs, null, null); + } + + private uint HandleStateEvent(uint stateEvent, uint param, IntPtr context) + { + EosFramework.LogInstance.Debug("HandleStateEvent fired: " + stateEvent); + switch (stateEvent) + { + case Edsdk.StateEvent_Shutdown: + this.OnStateEventShutdown(EventArgs.Empty); + break; + + case Edsdk.StateEvent_WillSoonShutDown: + this.OnStateEventWillShutdown(EventArgs.Empty); + break; + } + return Edsdk.EDS_ERR_OK; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCamera.cs b/DigiCamControl/Canon.Eos.Framework/EosCamera.cs new file mode 100644 index 0000000..fcae3a7 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCamera.cs @@ -0,0 +1,765 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading; +using Canon.Eos.Framework.Eventing; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public sealed partial class EosCamera : EosObject + { + + private object _lock = new object(); + public Queue LiveViewqueue = new Queue(); + + const int WaitTimeoutForNextLiveDownload = 125; + const int MaximumCopyrightLengthInBytes = 64; + const int MaximumArtistLengthInBytes = 64; + const int MaximumOwnerNameLengthInBytes = 32; + + private Edsdk.EdsDeviceInfo _deviceInfo; + private Edsdk.EdsObjectEventHandler _edsObjectEventHandler; + private Edsdk.EdsPropertyEventHandler _edsPropertyEventHandler; + private Edsdk.EdsStateEventHandler _edsStateEventHandler; + + public event EventHandler LiveViewStarted; + public event EventHandler LiveViewStopped; + public event EventHandler LiveViewUpdate; + public event EventHandler LiveViewPaused; + public event EventHandler PictureTaken; + public event EventHandler Shutdown; + public event EventHandler WillShutdown; + public event EventHandler VolumeInfoChanged; + public event EventHandler PropertyChanged; + public event EventHandler Error; + + + internal EosCamera(IntPtr camera) + : base(camera) + { + Util.Assert(Edsdk.EdsGetDeviceInfo(this.Handle, out _deviceInfo), + "Failed to get device info."); + //this.SetEventHandlers(); + //this.EnsureOpenSession(); + } + + /// + /// Gets or sets the artist. + /// + /// + /// The artist. + /// + public new string Artist + { + get { return base.Artist; } + set { this.SetPropertyStringData(Edsdk.PropID_Artist, value, + EosCamera.MaximumArtistLengthInBytes); } + } + + /// + /// Gets or sets the battery level. + /// + /// + /// The battery level. + /// + [EosProperty(Edsdk.PropID_BatteryQuality)] + public long BatteryLevel + { + get { return this.GetPropertyIntegerData(Edsdk.PropID_BatteryLevel); } + set { this.SetPropertyIntegerData(Edsdk.PropID_BatteryLevel, value); } + } + + /// + /// Gets or sets the battery quality. + /// + /// + /// The battery quality. + /// + public EosBatteryQuality BatteryQuality + { + get { return (EosBatteryQuality)this.GetPropertyIntegerData(Edsdk.PropID_BatteryQuality); } + set { this.SetPropertyIntegerData(Edsdk.PropID_BatteryQuality, (long)value); } + } + + /// + /// Gets or sets the copyright. + /// + /// + /// The copyright. + /// + public new string Copyright + { + get { return base.Copyright; } + set { this.SetPropertyStringData(Edsdk.PropID_Copyright, value, + EosCamera.MaximumCopyrightLengthInBytes); } + } + + /// + /// Gets or sets a value indicating whether depth of field preview is enabled. + /// + /// + /// true if depth of field preview is enabled; otherwise, false. + /// + [EosProperty(Edsdk.PropID_Evf_DepthOfFieldPreview)] + public bool DepthOfFieldPreview + { + get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_DepthOfFieldPreview) != 0; } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_DepthOfFieldPreview, value ? 1 : 0); } + } + + /// + /// Gets the device description. + /// + public string DeviceDescription + { + get { return _deviceInfo.szDeviceDescription; } + } + + /// + /// Gets or sets the image quality. + /// + /// + /// The image quality. + /// + [EosProperty(Edsdk.PropID_ImageQuality)] + public EosImageQuality ImageQuality + { + get { return EosImageQuality.Create(this.GetPropertyIntegerData(Edsdk.PropID_ImageQuality)); } + set { this.SetPropertyIntegerData(Edsdk.PropID_ImageQuality, value.ToBitMask()); } + } + + + public bool IsErrorTolerantMode { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is in live view mode. + /// + /// + /// true if this instance is in live view mode; otherwise, false. + /// + [EosProperty(Edsdk.PropID_Evf_Mode)] + public bool IsInLiveViewMode + { + get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_Mode) != 0; } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_Mode, value ? 1 : 0); } + } + + /// + /// Gets a value indicating whether this instance is in host live view mode. + /// + /// + /// true if this instance is in host live view mode; otherwise, false. + /// + public bool IsInHostLiveViewMode + { + get { return this.IsInLiveViewMode && this.LiveViewDevice.HasFlag(EosLiveViewDevice.Host); } + } + + /// + /// Gets a value indicating whether session to the camera is open. + /// + /// + /// true if the session is open; otherwise, false. + /// + public bool IsSessionOpen { get; private set; } + + /// + /// Gets or sets the live view auto focus. + /// + /// + /// The live view auto focus. + /// + [EosProperty(Edsdk.PropID_Evf_AFMode)] + public EosLiveViewAutoFocus LiveViewAutoFocus + { + get { return (EosLiveViewAutoFocus)this.GetPropertyIntegerData(Edsdk.PropID_Evf_AFMode); } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_AFMode, (long)value); } + } + + /// + /// Gets or sets the live view color temperature. + /// + /// + /// The live view color temperature. + /// + [EosProperty(Edsdk.PropID_Evf_ColorTemperature)] + public long LiveViewColorTemperature + { + get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_ColorTemperature); } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_ColorTemperature, value); } + } + + /// + /// Gets or sets the live view device. + /// + /// + /// The live view device. + /// + [EosProperty(Edsdk.PropID_Evf_OutputDevice)] + public EosLiveViewDevice LiveViewDevice + { + get { return (EosLiveViewDevice)this.GetPropertyIntegerData(Edsdk.PropID_Evf_OutputDevice); } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_OutputDevice, (long)value); } + } + + /// + /// Gets or sets the live view white balance. + /// + /// + /// The live view white balance. + /// + [EosProperty(Edsdk.PropID_Evf_WhiteBalance)] + public EosWhiteBalance LiveViewWhiteBalance + { + get { return (EosWhiteBalance)this.GetPropertyIntegerData(Edsdk.PropID_Evf_WhiteBalance); } + set { this.SetPropertyIntegerData(Edsdk.PropID_Evf_WhiteBalance, (long)value); } + } + + /// + /// Gets a value indicating whether this instance is legacy. + /// + /// + /// true if this instance is legacy; otherwise, false. + /// + public bool IsLegacy + { + get { return _deviceInfo.DeviceSubType == 0; } + } + + /// + /// Gets a value indicating whether this instance is locked. + /// + /// + /// true if this instance is locked; otherwise, false. + /// + public bool IsLocked { get; private set; } + + /// + /// Gets or sets the name of the owner. + /// + /// + /// The name of the owner. + /// + public new string OwnerName + { + get { return base.OwnerName; } + set { this.SetPropertyStringData(Edsdk.PropID_OwnerName, value, + EosCamera.MaximumOwnerNameLengthInBytes); } + } + + /// + /// Gets the name of the port. + /// + /// + /// The name of the port. + /// + public string PortName + { + get { return _deviceInfo.szPortName; } + } + + [Flags] + private enum SaveLocation { Camera = 1, Host = 2 }; + + private void ChangePicturesSaveLocation(SaveLocation saveLocation) + { + this.CheckDisposed(); + + this.EnsureOpenSession(); + + Util.Assert(Edsdk.EdsSetPropertyData(this.Handle, Edsdk.PropID_SaveTo, 0, Marshal.SizeOf(typeof(int)), + (int)saveLocation), "Failed to set SaveTo location."); + + if(!this.IsLegacy) + { + this.LockAndExceute(() => + { + var capacity = new Edsdk.EdsCapacity { NumberOfFreeClusters = 0x7FFFFFFF, BytesPerSector = 0x1000, Reset = 1 }; + Util.Assert(Edsdk.EdsSetCapacity(this.Handle, capacity), "Failed to set capacity."); + }); + } + } + + protected internal override void DisposeUnmanaged() + { + if (this.IsSessionOpen) + Edsdk.EdsCloseSession(this.Handle); + base.DisposeUnmanaged(); + } + + public void EnsureOpenSession() + { + this.CheckDisposed(); + if (!this.IsSessionOpen) + { + Util.Assert(Edsdk.EdsOpenSession(this.Handle), "Failed to open session."); + this.IsSessionOpen = true; + } + } + + protected override TResult ExecuteGetter(Func function) + { + try + { + if (this.IsLegacy && !this.IsLocked) + return this.LockAndExceute(function); + return base.ExecuteGetter(function); + } + catch (Exception ex) + { + this.OnError(ex); + return default(TResult); + } + } + + protected override void ExecuteSetter(Action action) + { + lock (_locker) + { + + try + { + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(action); + return; + } + + base.ExecuteSetter(action); + } + catch (Exception ex) + { + this.OnError(ex); + } + } + } + + public void Lock() + { + lock (_locker) + { + this.CheckDisposed(); + + if (!this.IsLocked) + { + Util.Assert(Edsdk.EdsSendStatusCommand(this.Handle, Edsdk.CameraState_UILock,0), + "Failed to lock camera."); + this.IsLocked = true; + } + } + } + + public void DeleteItem(IntPtr itemInfo) + { + LockAndExceute(() => { Edsdk.EdsDeleteDirectoryItem(itemInfo); }); + } + + private void LockAndExceute(Action action) + { + this.Lock(); + try { action(); } + finally { this.Unlock(); } + } + + private TResult LockAndExceute(Func function) + { + this.Lock(); + try { return function(); } + finally { this.Unlock(); } + } + + private void OnError(Exception exception) + { + if (!this.IsErrorTolerantMode) + throw exception; + this.OnError(new EosExceptionEventArgs { Exception = exception }); + } + + private void OnError(EosExceptionEventArgs args) + { + if (this.Error != null) + this.Error(this, args); + } + + public void SetProperty(uint propertyId, long val) + { + lock (_locker) + { + SendCommand(Edsdk.CameraCommand_DoEvfAf, 0); + bool retry = false; + int retrynum = 0; + //DeviceReady(); + do + { + if (retrynum > 10) + { + return; + } + try + { + this.SetPropertyIntegerData(propertyId, val); + } + catch (EosPropertyException) + { + Thread.Sleep(50); + retry = true; + retrynum++; + } + } while (retry); + } + } + + public long GetProperty(uint propertyId) + { + lock (_locker) + { + return (long) this.GetPropertyIntegerData(propertyId); + } + } + + public DateTime GetDate() + { + lock (_locker) + { + //return (long)this.GetPropertyIntegerData(propertyId); + var v = this.GetPropertyStruct(Edsdk.PropID_DateTime, Edsdk.EdsDataType.Time); + return new DateTime(v.Year, v.Month, v.Day, v.Hour, v.Minute, v.Second); + } + } + + public void SetDate(DateTime time) + { + + lock (_locker) + { + //return (long)this.GetPropertyIntegerData(propertyId); +// var v = this.GetPropertyStruct(Edsdk.PropID_DateTime, Edsdk.EdsDataType.Time); + Edsdk.EdsTime edsTime = new Edsdk.EdsTime() + { + Day = time.Day, Hour = time.Hour, Year = time.Year, Minute = time.Minute, Month = time.Month, + Second = time.Second + }; + this.SetPropertyStruct(Edsdk.PropID_DateTime, edsTime); + } + } + + + + /// + /// Saves the pictures to camera. + /// + public void SavePicturesToCamera() + { + this.CheckDisposed(); + this.ChangePicturesSaveLocation(SaveLocation.Camera); + } + + /// + /// Saves the pictures to host. + /// + /// The path folder. + public void SavePicturesToHost(string pathFolder) + { + this.SavePicturesToHost(pathFolder, SaveLocation.Host); + } + + /// + /// Saves the pictures to host and camera. + /// + /// The path folder. + public void SavePicturesToHostAndCamera(string pathFolder) + { + this.SavePicturesToHost(pathFolder, SaveLocation.Camera); + } + + private void SavePicturesToHost(string pathFolder, SaveLocation saveLocation) + { + if (string.IsNullOrWhiteSpace(pathFolder)) + throw new ArgumentException("Cannot be null or white space.", "pathFolder"); + + this.CheckDisposed(); + + this.ChangePicturesSaveLocation(saveLocation | SaveLocation.Host); + } + + public uint SendCommand(uint command, int parameter = 0) + { + lock (_locker) + { + this.EnsureOpenSession(); + return Edsdk.EdsSendCommand(this.Handle, command, parameter); + } + } + + public void SetEventHandlers() + { + _edsStateEventHandler = this.HandleStateEvent; + Util.Assert(Edsdk.EdsSetCameraStateEventHandler(this.Handle, Edsdk.StateEvent_All, + _edsStateEventHandler, IntPtr.Zero), "Failed to set state handler."); + + _edsObjectEventHandler = this.HandleObjectEvent; + Util.Assert(Edsdk.EdsSetObjectEventHandler(this.Handle, Edsdk.ObjectEvent_All, + _edsObjectEventHandler, IntPtr.Zero), "Failed to set object handler."); + + _edsPropertyEventHandler = this.HandlePropertyEvent; + Util.Assert(Edsdk.EdsSetPropertyEventHandler(this.Handle, Edsdk.PropertyEvent_All, + _edsPropertyEventHandler, IntPtr.Zero), "Failed to set object handler."); + } + + /// + /// Starts the live view. + /// + /// + public EosLiveViewAutoFocus StartLiveView() + { + if (!this.IsInLiveViewMode) + this.IsInLiveViewMode = true; + this._cancelLiveViewRequested = false; + this._pauseLiveViewRequested = false; + var device = this.LiveViewDevice; + device = device | EosLiveViewDevice.Host; + this.LiveViewDevice = device; + return this.LiveViewAutoFocus; + } + + public EosLiveViewAutoFocus StartLiveViewCamera() + { + if (!this.IsInLiveViewMode) + this.IsInLiveViewMode = true; + this._cancelLiveViewRequested = false; + this._pauseLiveViewRequested = false; + var device = this.LiveViewDevice; + device = device| EosLiveViewDevice.Camera | EosLiveViewDevice.Host; + this.LiveViewDevice = device; + this.LiveViewAutoFocus = EosLiveViewAutoFocus.LiveMode; + return this.LiveViewAutoFocus; + } + + /// + /// Starts the live view with special auto focus. + /// + /// The auto focus. + /// + public EosLiveViewAutoFocus StartLiveView(EosLiveViewAutoFocus autoFocus) + { + this.StartLiveView(); + this.LiveViewAutoFocus = autoFocus; + return this.LiveViewAutoFocus; + } + + /// + /// Stops the live view. + /// + public void StopLiveView() + { + this.LiveViewDevice = EosLiveViewDevice.None; + } + + public void StartRecord() + { + LiveViewqueue.Enqueue(() => + { + StopLiveView(); + SavePicturesToCamera(); + this.SendCommand(Edsdk.CameraCommand_MovieSelectSwON); + StartLiveView(); + this.SendCommand(Edsdk.CameraCommand_DoEvfAf, 0); + SetPropertyIntegerData(Edsdk.PropID_Record, (long)4); + }); + } + + public void StopRecord() + { + //LiveViewqueue.Enqueue(() => + //{ + this.SendCommand(Edsdk.CameraCommand_DoEvfAf, 0); + SetPropertyIntegerData(Edsdk.PropID_Record, (long)0); + this.SendCommand(Edsdk.CameraCommand_MovieSelectSwOFF); + //}); + } + + public bool IsOldCanon() + { + if (string.IsNullOrEmpty(ProductName)) + return false; + string[] models = + { + " 1000D", " 40D", " 450D", " 50D", " 400D", " 500D", "Rebel XSi", "Rebel XTi", + "Rebel XS", "Rebel T1i", "1Ds Mark III" + }; + return models.Any(model => DeviceDescription.ToLower().Contains(model.ToLower())); + } + + /// + /// Takes the picture. + /// + + public void TakePicture() + { + lock (_locker) + { + if (IsOldCanon()) + { + Util.Assert(this.SendCommand(Edsdk.CameraCommand_TakePicture), "Failed to capture picture with CameraCommand_TakePicture."); + return; + } + + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(this.TakePicture); + return; + } + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Completely), + "Failed to press fully."); + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF), + "Failed to release."); + } + } + + public void TakePictureNoAf() + { + //_photoCounter = ImageQuality.SecondaryCompressLevel != EosCompressLevel.Unknown ? 0 : 1; + if (IsOldCanon()) + { + Util.Assert(this.SendCommand(Edsdk.CameraCommand_TakePicture), "Failed to capture picture with CameraCommand_TakePicture."); + return; + } + + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(this.TakePictureNoAf); + return; + } + + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int) Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Completely_NonAF), + "Failed to take picture no AF."); + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF), + "Failed to release."); + } + + public void ResetShutterButton() + { + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(this.ResetShutterButton); + return; + } + + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, (int)Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF), + "Failed to take picture no AF."); + } + + public void AutoFocus() + { + lock (_locker) + { + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(this.AutoFocus); + return; + } + + Util.Assert( + this.SendCommand(Edsdk.CameraCommand_PressShutterButton, + (int) Edsdk.EdsShutterButton.CameraCommand_ShutterButton_OFF), + "Failed to take picture no AF."); + Util.Assert( + this.SendCommand(Edsdk.CameraCommand_PressShutterButton, + (int) Edsdk.EdsShutterButton.CameraCommand_ShutterButton_Halfway), + "Failed to take picture no AF."); + } + } + + + public void BulbStart() + { + //this.Lock(); + //Thread.Sleep(120); + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, 65539), + "Failed to start bulb mode"); + } + + public void BulbEnd() + { + try + { + Util.Assert(this.SendCommand(Edsdk.CameraCommand_PressShutterButton, 0), + "Failed to start bulb mode"); + } + finally + { + if (this.IsLocked) + this.Unlock(); + } + } + + public void FocusInLiveView(uint focus) + { + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(() => this.FocusInLiveView(focus)); + return; + } + + Util.Assert(this.SendCommand(Edsdk.CameraCommand_DriveLensEvf, (int) focus), + "Failed to focus"); + } + + public void FocusModeLiveView(uint focus) + { + if (this.IsLegacy && !this.IsLocked) + { + this.LockAndExceute(() => this.FocusModeLiveView(focus)); + return; + } + + Util.Assert(this.SendCommand(Edsdk.CameraCommand_DoEvfAf, (int)focus), + "Failed to focus"); + } + + public void TakePictureInLiveview() + { + //_photoCounter = ImageQuality.SecondaryCompressLevel != EosCompressLevel.Unknown ? 0 : 1; + this._pauseLiveViewRequested = true; + } + + public void ResumeLiveview() + { + //has to be called if Taking photo fails + this._pauseLiveViewRequested = false; + + } + + public void PauseLiveview() + { + //has to be called if Taking photo fails + this._pauseLiveViewRequested = true; + Thread.Sleep(150); + //while (_liveViewRunning) + //{ + + //} + } + + public override string ToString() + { + return this.DeviceDescription ?? string.Empty; + } + + public void Unlock() + { + lock (_locker) + { + if (this.IsLocked) + { + Edsdk.EdsSendStatusCommand(this.Handle, Edsdk.CameraState_UIUnLock,0); + this.IsLocked = false; + } + } + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCameraCollection.cs b/DigiCamControl/Canon.Eos.Framework/EosCameraCollection.cs new file mode 100644 index 0000000..f127484 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCameraCollection.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public sealed class EosCameraCollection : EosDisposable, IEnumerable + { + private readonly IntPtr _cameraList; + private int _count = -1; + + internal EosCameraCollection() + { + Util.Assert(Edsdk.EdsGetCameraList(out _cameraList), "Failed to get cameras."); + } + + protected internal override void DisposeUnmanaged() + { + if (_cameraList != IntPtr.Zero) + Edsdk.EdsRelease(_cameraList); + base.DisposeUnmanaged(); + } + + /// + /// Gets the number of cameras in this instance. + /// + public int Count + { + get + { + this.CheckDisposed(); + if(_count < 0) + Edsdk.EdsGetChildCount(_cameraList, out _count); + return _count; + } + } + + /// + /// Gets the at the specified index. + /// + public EosCamera this[int index] + { + get + { + this.CheckDisposed(); + if (index < 0 || index >= this.Count) + throw new IndexOutOfRangeException(); + + IntPtr camera; + Util.Assert(Edsdk.EdsGetChildAtIndex(_cameraList, index, out camera), string.Format("Failed to get camera #{0}.", index+1)); + if (camera == IntPtr.Zero) + throw new EosException(Edsdk.EDS_ERR_DEVICE_NOT_FOUND, string.Format("Failed to get camera #{0}.", index+1)); + return new EosCamera(camera); + } + } + + /// + /// Gets the enumerator. + /// + /// + public IEnumerator GetEnumerator() + { + for (var i = 0; i < this.Count; ++i) + { + this.CheckDisposed(); + EosCamera camera = null; + try + { + camera = this[i]; + } + catch (EosException ex) + { + if(ex.EosErrorCode != EosErrorCode.CommDisconnected) + throw; + } + if(camera != null) + yield return camera; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + this.CheckDisposed(); + return this.GetEnumerator(); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosCompressLevel.cs b/DigiCamControl/Canon.Eos.Framework/EosCompressLevel.cs new file mode 100644 index 0000000..46edf6f --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosCompressLevel.cs @@ -0,0 +1,18 @@ +namespace Canon.Eos.Framework +{ + public enum EosCompressLevel : byte + { + Unknown = 0xF, + JpegUncompressed = 0, + JpegCompression1 = 1, + Normal = 2, + Fine = 3, + Lossless = 4, + SuperFine = 5, + JpegCompression6 = 6, + JpegCompression7 = 7, + JpegCompression8 = 8, + JpegCompression9 = 9, + JpegCompression10 = 10, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosDisposable.cs b/DigiCamControl/Canon.Eos.Framework/EosDisposable.cs new file mode 100644 index 0000000..4908f4e --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosDisposable.cs @@ -0,0 +1,42 @@ +using System; +using Canon.Eos.Framework.Interfaces; + +namespace Canon.Eos.Framework +{ + public abstract class EosDisposable : IDisposable, IEosAssertable + { + ~EosDisposable() + { + this.Dispose(false); + } + + internal protected void CheckDisposed() + { + if (this.IsDisposed) + throw new ObjectDisposedException(this.GetType().Name); + } + + internal protected bool IsDisposed { get; private set; } + + internal protected virtual void DisposeManaged() { } + + internal protected virtual void DisposeUnmanaged() { } + + private void Dispose(bool disposing) + { + if (!this.IsDisposed) + { + if (disposing) + this.DisposeManaged(); + this.DisposeUnmanaged(); + this.IsDisposed = true; + } + } + + public void Dispose() + { + this.Dispose(true); + //GC.SuppressFinalize(this); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosErrorCode.cs b/DigiCamControl/Canon.Eos.Framework/EosErrorCode.cs new file mode 100644 index 0000000..e0951f3 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosErrorCode.cs @@ -0,0 +1,151 @@ + +namespace Canon.Eos.Framework +{ + public enum EosErrorCode : long + { + Ok = 0x00000000, + Unimplemented = 0x00000001, + InternalError = 0x00000002, + MemAllocFailed = 0x00000003, + MemFreeFailed = 0x00000004, + OperationCancelled = 0x00000005, + IncompatibleVersion = 0x00000006, + NotSupported = 0x00000007, + UnexpectedException = 0x00000008, + ProtectionViolation = 0x00000009, + MissingSubcomponent = 0x0000000A, + SelectionUnavailable = 0x0000000B, + + /* File errors */ + FileIoError = 0x00000020, + FileTooManyOpen = 0x00000021, + FileNotFound = 0x00000022, + FileOpenError = 0x00000023, + FileCloseError = 0x00000024, + FileSeekError = 0x00000025, + FileTellError = 0x00000026, + FileReadError = 0x00000027, + FileWriteError = 0x00000028, + FilePermissionError = 0x00000029, + FileDiskFullError = 0x0000002A, + FileAlreadyExists = 0x0000002B, + FileFormatUnrecognized = 0x0000002C, + FileDataCorrupt = 0x0000002D, + FileNamingNa = 0x0000002E, + + /* Directory errors */ + DirNotFound = 0x00000040, + DirIoError = 0x00000041, + DirEntryNotFound = 0x00000042, + DirEntryExists = 0x00000043, + DirNotEmpty = 0x00000044, + + /* Property errors */ + PropertiesUnavailable = 0x00000050, + PropertiesMismatch = 0x00000051, + PropertiesNotLoaded = 0x00000053, + + /* Function Parameter errors */ + InvalidParameter = 0x00000060, + InvalidHandle = 0x00000061, + InvalidPointer = 0x00000062, + InvalidIndex = 0x00000063, + InvalidLength = 0x00000064, + InvalidFunctionPointer = 0x00000065, + InvalidSortFunction = 0x00000066, + + /* Device errors */ + DeviceNotFound = 0x00000080, + DeviceBusy = 0x00000081, + DeviceInvalid = 0x00000082, + DeviceEmergency = 0x00000083, + DeviceMemoryFull = 0x00000084, + DeviceInternalError = 0x00000085, + DeviceInvalidParameter = 0x00000086, + DeviceNoDisk = 0x00000087, + DeviceDiskError = 0x00000088, + DeviceCfGateChanged = 0x00000089, + DeviceDialChanged = 0x0000008A, + DeviceNotInstalled = 0x0000008B, + DeviceStayAwake = 0x0000008C, + DeviceNotReleased = 0x0000008D, + + /* Stream errors */ + StreamIoError = 0x000000A0, + StreamNotOpen = 0x000000A1, + StreamAlreadyOpen = 0x000000A2, + StreamOpenError = 0x000000A3, + StreamCloseError = 0x000000A4, + StreamSeekError = 0x000000A5, + StreamTellError = 0x000000A6, + StreamReadError = 0x000000A7, + StreamWriteError = 0x000000A8, + StreamPermissionError = 0x000000A9, + StreamCouldntBeginThread = 0x000000AA, + StreamBadOptions = 0x000000AB, + StreamEndOfStream = 0x000000AC, + + /* Communications errors */ + CommPortIsInUse = 0x000000C0, + CommDisconnected = 0x000000C1, + CommDeviceIncompatible = 0x000000C2, + CommBufferFull = 0x000000C3, + CommUsbBusError = 0x000000C4, + + /* Lock/Unlock */ + UsbDeviceLockError = 0x000000D0, + UsbDeviceUnlockError = 0x000000D1, + + /* STI/WIA */ + StiUnknownError = 0x000000E0, + StiInternalError = 0x000000E1, + StiDeviceCreateError = 0x000000E2, + StiDeviceReleaseError = 0x000000E3, + DeviceNotLaunched = 0x000000E4, + + EnumNa = 0x000000F0, + InvalidFunctionCall = 0x000000F1, + HandleNotFound = 0x000000F2, + InvalidId = 0x000000F3, + WaitTimeoutError = 0x000000F4, + + /* PTP */ + SessionNotOpen = 0x00002003, + InvalidTransactionid = 0x00002004, + IncompleteTransfer = 0x00002007, + InvalidStrageid = 0x00002008, + DevicepropNotSupported = 0x0000200A, + InvalidObjectformatcode = 0x0000200B, + SelfTestFailed = 0x00002011, + PartialDeletion = 0x00002012, + SpecificationByFormatUnsupported = 0x00002014, + NoValidObjectinfo = 0x00002015, + InvalidCodeFormat = 0x00002016, + UnknownVenderCode = 0x00002017, + CaptureAlreadyTerminated = 0x00002018, + InvalidParentobject = 0x0000201A, + InvalidDevicepropFormat = 0x0000201B, + InvalidDevicepropValue = 0x0000201C, + SessionAlreadyOpen = 0x0000201E, + TransactionCancelled = 0x0000201F, + SpecificationOfDestinationUnsupported = 0x00002020, + UnknownCommand = 0x0000A001, + OperationRefused = 0x0000A005, + LensCoverClose = 0x0000A006, + LowBattery = 0x0000A101, + ObjectNotReady = 0x0000A102, + + /* Capture Error */ + TakePictureAutoFocusFailed = 0x00008D01, + TakePictureReserved = 0x00008D02, + TakePictureMirrorUp = 0x00008D03, + TakePictureSensorCleaning = 0x00008D04, + TakePictureSilence = 0x00008D05, + TakePictureNoCard = 0x00008D06, + TakePictureCard = 0x00008D07, + TakePictureCardProtect = 0x00008D08, + + + LastGenericErrorPlusOne = 0x000000F5, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosException.cs b/DigiCamControl/Canon.Eos.Framework/EosException.cs new file mode 100644 index 0000000..a9561fb --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosException.cs @@ -0,0 +1,38 @@ +using System; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal; + +namespace Canon.Eos.Framework +{ + public class EosException : Exception + { + internal EosException(long eosErrorCode) + { + this.EosErrorCode = (EosErrorCode)eosErrorCode; + } + + internal EosException(long eosErrorCode, string message) + : base(message) + { + this.EosErrorCode = (EosErrorCode)eosErrorCode; + } + + internal EosException(long eosErrorCode, string message, Exception innerException) + : base(message, innerException) + { + this.EosErrorCode = (EosErrorCode)eosErrorCode; + } + + public EosErrorCode EosErrorCode { get; private set; } + + public string EosErrorCodeMessage + { + get { return Util.ConvertCamelCasedStringToFriendlyString(this.EosErrorCode.ToString()) + "."; } + } + + public override string Message + { + get { return string.Format("{0}{1}{2}", this.EosErrorCodeMessage, Environment.NewLine, base.Message); } + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosFocus.cs b/DigiCamControl/Canon.Eos.Framework/EosFocus.cs new file mode 100644 index 0000000..a03fb24 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosFocus.cs @@ -0,0 +1,51 @@ +using System.Drawing; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public struct EosFocus + { + internal static EosFocus Create(Edsdk.EdsFocusInfo focus) + { + var focusPoints = new EosFocusPoint[focus.pointNumber]; + for (var i = 0; i < focusPoints.Length; ++i) + focusPoints[i] = EosFocusPoint.Create(focus.focusPoint[i]); + + return new EosFocus + { + Bounds = new Rectangle { + X = focus.imageRect.x, + Y = focus.imageRect.y, + Height = focus.imageRect.height, + Width = focus.imageRect.width, + }, + ExecuteMode = focus.executeMode, + FocusPoints = focusPoints + }; + } + + /// + /// Gets or sets the bounds. + /// + /// + /// The bounds. + /// + public Rectangle Bounds { get; private set; } + + /// + /// Gets or sets the execute mode. + /// + /// + /// The execute mode. + /// + public long ExecuteMode { get; private set; } + + /// + /// Gets or sets the focus points. + /// + /// + /// The focus points. + /// + public EosFocusPoint[] FocusPoints { get; private set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosFocusPoint.cs b/DigiCamControl/Canon.Eos.Framework/EosFocusPoint.cs new file mode 100644 index 0000000..a20a741 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosFocusPoint.cs @@ -0,0 +1,56 @@ +using System.Drawing; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public struct EosFocusPoint + { + internal static EosFocusPoint Create(Edsdk.EdsFocusPoint focusPoint) + { + return new EosFocusPoint + { + Bounds = new Rectangle { + X = focusPoint.rect.x, + Y = focusPoint.rect.y, + Height = focusPoint.rect.height, + Width = focusPoint.rect.width, + }, + IsInFocus = focusPoint.justFocus != 0, + IsSelected = focusPoint.selected != 0, + IsValid = focusPoint.valid != 0, + }; + } + + /// + /// Gets or sets the bounds. + /// + /// + /// The bounds. + /// + public Rectangle Bounds { get; private set; } + + /// + /// Gets or sets a value indicating whether this instance is in focus. + /// + /// + /// true if this instance is in focus; otherwise, false. + /// + public bool IsInFocus { get; private set; } + + /// + /// Gets or sets a value indicating whether this instance is valid. + /// + /// + /// true if this instance is valid; otherwise, false. + /// + public bool IsValid { get; private set; } + + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + /// + /// true if this instance is selected; otherwise, false. + /// + public bool IsSelected { get; private set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosFramework.cs b/DigiCamControl/Canon.Eos.Framework/EosFramework.cs new file mode 100644 index 0000000..ac688af --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosFramework.cs @@ -0,0 +1,122 @@ +using System; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Interfaces; +using Canon.Eos.Framework.Internal.SDK; + + +namespace Canon.Eos.Framework +{ + public sealed class EosFramework : EosDisposable + { + private static readonly object __referenceLock = new object(); + private static readonly object __eventLock = new object(); + private static int __referenceCount; + private static Edsdk.EdsCameraAddedHandler __edsCameraAddedHandler; + private static event EventHandler GlobalCameraAdded; + + static EosFramework() + { + EosFramework.LogInstance = new ConsoleLog(); + } + + /// + /// Gets or sets the log instance. + /// + /// + /// The log instance. + /// + public static IEosLog LogInstance { get; set; } + + /// + /// Occurs when a camera is added to the host, + /// + public event EventHandler CameraAdded + { + add + { + lock (__eventLock) + { + EosFramework.GlobalCameraAdded += value; + } + } + remove + { + lock (__eventLock) + { + EosFramework.GlobalCameraAdded -= value; + } + } + } + + public EosFramework() + { + lock (__referenceLock) + { + if (__referenceCount == 0) + { + try + { + Util.Assert(Edsdk.EdsInitializeSDK(), "Failed to initialize the SDK."); + __edsCameraAddedHandler = EosFramework.HandleCameraAddedEvent; + Edsdk.EdsSetCameraAddedHandler(__edsCameraAddedHandler, IntPtr.Zero); + } + catch (EosException) + { + throw; + } + catch (Exception ex) + { + Util.Assert(0xFFFFFFFF, "Failed to initialize the SDK.", ex); + } + } + ++__referenceCount; + } + } + + private static uint HandleCameraAddedEvent(IntPtr context) + { + lock (__eventLock) + { + if (EosFramework.GlobalCameraAdded != null) + { + // TODO: find something better than null to pass as sender! + EosFramework.GlobalCameraAdded(null, EventArgs.Empty); + } + } + return Edsdk.EDS_ERR_OK; + } + + /// + /// Gets a collection of cameras currenly connected to the host. + /// + /// + public EosCameraCollection GetCameraCollection() + { + this.CheckDisposed(); + return new EosCameraCollection(); + } + + /// + /// Gets the first camera available. + /// + /// + public EosCamera GetCamera() + { + using (var cameras = this.GetCameraCollection()) + return cameras.Count > 0 ? cameras[0] : null; + } + + protected internal override void DisposeUnmanaged() + { + lock (__referenceLock) + { + if (__referenceCount > 0) + { + if(--__referenceCount == 0) + Edsdk.EdsTerminateSDK(); + } + } + base.DisposeUnmanaged(); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosImageFormat.cs b/DigiCamControl/Canon.Eos.Framework/EosImageFormat.cs new file mode 100644 index 0000000..8bc2be0 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosImageFormat.cs @@ -0,0 +1,11 @@ +namespace Canon.Eos.Framework +{ + public enum EosImageFormat : byte + { + Unknown = 0x0, + Jpeg = 0x1, + Crw = 0x2, + Raw = 0x4, + Cr2 = 0x6, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosImageQuality.cs b/DigiCamControl/Canon.Eos.Framework/EosImageQuality.cs new file mode 100644 index 0000000..868f6c0 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosImageQuality.cs @@ -0,0 +1,96 @@ +namespace Canon.Eos.Framework +{ + public struct EosImageQuality + { + private EosImageSize _secondaryImageSize; + + /// + /// Gets or sets the size of the primary image. + /// + /// + /// The size of the primary image. + /// + public EosImageSize PrimaryImageSize { get; set; } + + /// + /// Gets or sets the primary image format. + /// + /// + /// The primary image format. + /// + public EosImageFormat PrimaryImageFormat { get; set; } + + /// + /// Gets or sets the primary compress level. + /// + /// + /// The primary compress level. + /// + public EosCompressLevel PrimaryCompressLevel { get; set; } + + /// + /// Gets or sets the size of the secondary image. + /// + /// + /// The size of the secondary image. + /// + public EosImageSize SecondaryImageSize + { + get { return (byte)_secondaryImageSize >= 0xF ? EosImageSize.Unknown : _secondaryImageSize; } + set { _secondaryImageSize = value; } + } + + /// + /// Gets or sets the secondary image format. + /// + /// + /// The secondary image format. + /// + public EosImageFormat SecondaryImageFormat { get; set; } + + /// + /// Gets or sets the secondary compress level. + /// + /// + /// The secondary compress level. + /// + public EosCompressLevel SecondaryCompressLevel { get; set; } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return string.Format("Primary Image: Size <{0}>, Format <{1}>, CompressLevel <{2}>\n" + + "Secondary Image: Size <{3}>, Format <{4}>, CompressLevel <{5}>", + this.PrimaryImageSize, this.PrimaryImageFormat, this.PrimaryCompressLevel, + this.SecondaryImageSize, this.SecondaryImageFormat, this.SecondaryCompressLevel); + } + + public static EosImageQuality Create(long bitMask) + { + var quality = new EosImageQuality { + PrimaryImageSize = (EosImageSize)((bitMask >> 24) & 0xFF), + PrimaryImageFormat = (EosImageFormat)((bitMask >> 20) & 0xF), + PrimaryCompressLevel = (EosCompressLevel)((bitMask >> 16) & 0xF), + SecondaryImageSize = (EosImageSize)((bitMask >> 8) & 0xF), + SecondaryImageFormat = (EosImageFormat)((bitMask >> 4) & 0xF), + SecondaryCompressLevel = (EosCompressLevel)(bitMask & 0xF), + }; + return quality; + } + + public long ToBitMask() + { + return (uint)this.PrimaryImageSize << 24 | + (uint)this.PrimaryImageFormat << 20 | + (uint)this.PrimaryCompressLevel << 16 | + (uint)this.SecondaryImageSize << 8 | + (uint)this.SecondaryImageFormat << 4 | + (uint)this.SecondaryCompressLevel; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosImageSize.cs b/DigiCamControl/Canon.Eos.Framework/EosImageSize.cs new file mode 100644 index 0000000..63340bb --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosImageSize.cs @@ -0,0 +1,15 @@ +namespace Canon.Eos.Framework +{ + public enum EosImageSize : uint + { + Unknown = 0xFF, + Large = 0, + Middle = 1, + Small = 2, + Middle2 = 5, + Middle3 = 6, + Small2 = 14, + Small3 = 15, + Small4 = 16, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosLiveImage.cs b/DigiCamControl/Canon.Eos.Framework/EosLiveImage.cs new file mode 100644 index 0000000..1c8d1ea --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosLiveImage.cs @@ -0,0 +1,56 @@ +using System; +using System.Drawing; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public class EosLiveImage : EosObject + { + internal static EosLiveImage CreateFromStream(IntPtr stream) + { + IntPtr imagePtr; + Util.Assert(Edsdk.EdsCreateEvfImageRef(stream, out imagePtr), "Failed to create evf image."); + return new EosLiveImage(imagePtr); + } + + internal EosLiveImage(IntPtr imagePtr) + : base(imagePtr) { } + + [EosProperty(Edsdk.PropID_Evf_ImagePosition)] + public Point ImagePosition + { + get { return this.GetPropertyPointData(Edsdk.PropID_Evf_ImagePosition); } + } + + [EosProperty(Edsdk.PropID_Evf_Zoom)] + public long[] Histogram + { + get { return this.GetPropertyIntegerArrayData(Edsdk.PropID_Evf_Histogram); } + } + + [EosProperty(Edsdk.PropID_Evf_Zoom)] + public long Zoom + { + get { return this.GetPropertyIntegerData(Edsdk.PropID_Evf_Zoom); } + } + + [EosProperty(Edsdk.PropID_Evf_ZoomRect)] + public Rectangle ZoomBounds + { + get { return this.GetPropertyRectangleData(Edsdk.PropID_Evf_ZoomRect); } + } + + [EosProperty(Edsdk.PropID_Evf_ZoomPosition)] + public Point ZoomPosition + { + get { return this.GetPropertyPointData(Edsdk.PropID_Evf_ZoomPosition); } + } + + [EosProperty(Edsdk.PropID_Evf_CoordinateSystem)] + public Size Size + { + get { return this.GetPropertySizeData(Edsdk.PropID_Evf_CoordinateSystem); } + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosLiveViewAutoFocus.cs b/DigiCamControl/Canon.Eos.Framework/EosLiveViewAutoFocus.cs new file mode 100644 index 0000000..7c18edf --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosLiveViewAutoFocus.cs @@ -0,0 +1,9 @@ +namespace Canon.Eos.Framework +{ + public enum EosLiveViewAutoFocus + { + QuickMode = 0, + LiveMode = 1, + LiveFaceMode = 2, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosLiveViewDevice.cs b/DigiCamControl/Canon.Eos.Framework/EosLiveViewDevice.cs new file mode 100644 index 0000000..7be0327 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosLiveViewDevice.cs @@ -0,0 +1,12 @@ +using System; + +namespace Canon.Eos.Framework +{ + [Flags] + public enum EosLiveViewDevice : int + { + None = 0, + Camera = 1, + Host = 2 + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosObject.cs b/DigiCamControl/Canon.Eos.Framework/EosObject.cs new file mode 100644 index 0000000..0989b4a --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosObject.cs @@ -0,0 +1,281 @@ +using System; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework +{ + public abstract class EosObject : EosDisposable + { + private readonly IntPtr _handle; + protected object _locker = new object(); + + internal EosObject(IntPtr handle) + { + _handle = handle; + } + + public IntPtr Handle + { + get { return _handle; } + } + + /// + /// Gets the artist. + /// + [EosProperty(Edsdk.PropID_Artist)] + public string Artist + { + get { return this.GetPropertyStringData(Edsdk.PropID_Artist); } + } + + /// + /// Gets the copyright. + /// + [EosProperty(Edsdk.PropID_Copyright)] + public string Copyright + { + get { return this.GetPropertyStringData(Edsdk.PropID_Copyright); } + } + + /// + /// Gets the focus. + /// + [EosProperty(Edsdk.PropID_FocusInfo)] + public EosFocus Focus + { + get + { return EosFocus.Create(this.GetPropertyStruct(Edsdk.PropID_FocusInfo, + Edsdk.EdsDataType.FocusInfo)); + } + } + + /// + /// Gets the firmware version. + /// + [EosProperty(Edsdk.PropID_FirmwareVersion)] + public string FirmwareVersion + { + get { return this.GetPropertyStringData(Edsdk.PropID_FirmwareVersion); } + } + + /// + /// Gets the name of the owner. + /// + /// + /// The name of the owner. + /// + [EosProperty(Edsdk.PropID_OwnerName)] + public string OwnerName + { + get { return this.GetPropertyStringData(Edsdk.PropID_OwnerName); } + } + + /// + /// Gets the name of the product. + /// + /// + /// The name of the product. + /// + [EosProperty(Edsdk.PropID_ProductName)] + public string ProductName + { + get { return this.GetPropertyStringData(Edsdk.PropID_ProductName); } + } + + /// + /// Gets the serial number. + /// + [EosProperty(Edsdk.PropID_BodyIDEx)] + public string SerialNumber + { + get { return this.GetPropertyStringData(Edsdk.PropID_BodyIDEx); } + } + + /// + /// Gets or sets the white balance. + /// + /// + /// The white balance. + /// + [EosProperty(Edsdk.PropID_WhiteBalance)] + public EosWhiteBalance WhiteBalance + { + get { return (EosWhiteBalance)this.GetPropertyIntegerData(Edsdk.PropID_WhiteBalance); } + set { this.SetPropertyIntegerData(Edsdk.PropID_WhiteBalance, (long)value); } + } + + protected internal override void DisposeUnmanaged() + { + if(_handle != IntPtr.Zero) + Edsdk.EdsRelease(_handle); + base.DisposeUnmanaged(); + } + + protected virtual void ExecuteSetter(Action action) + { + lock (_locker) + { + action(); + } + } + + protected virtual TResult ExecuteGetter(Func function) + { + return function(); + } + + + internal int GetPropertyDataSize(uint propertyId, Edsdk.EdsDataType expectedDataType) + { + return this.ExecuteGetter(() => + { + int dataSize; + Edsdk.EdsDataType dataType; + Util.Assert(Edsdk.EdsGetPropertySize(this.Handle, propertyId, 0, out dataType, out dataSize), + "Failed to get property size.", propertyId); + //Util.AssertIf(expectedDataType != dataType, "DataType mismatch: Expected <{0}>, Actual <{1}>", expectedDataType, dataType); + return dataSize; + }); + } + + internal T GetPropertyStruct(uint propertyId, Edsdk.EdsDataType expectedDataType) where T: struct + { + return this.ExecuteGetter(() => + { + var dataSize = this.GetPropertyDataSize(propertyId, expectedDataType); + var ptr = Marshal.AllocHGlobal(dataSize); + try + { + Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, dataSize, ptr), + "Failed to get required struct.", propertyId); + return (T)Marshal.PtrToStructure(ptr, typeof(T)); + } + finally + { + Marshal.FreeHGlobal(ptr); + } + }); + } + + internal void SetPropertyStruct(uint propertyId,T data) where T : struct + { + this.ExecuteSetter(() => + { + try + { + Util.Assert(Edsdk.EdsSetPropertyData(this.Handle, propertyId, 0, Marshal.SizeOf((object)data), (object)data), + string.Format("Failed to set property string data: propertyId {0}, data {1}", propertyId, data), + propertyId, data); + } + finally + { + + } + }); + } + public Edsdk.EdsPropertyDesc GetPropertyDescription(uint propertyId) + { + return this.ExecuteGetter(() => + { + Edsdk.EdsPropertyDesc desc; + Util.Assert(Edsdk.EdsGetPropertyDesc(this.Handle, propertyId, out desc), + string.Format("Failed to get property description for data: propertyId {0}", propertyId), propertyId); + return desc; + }); + } + + protected long GetPropertyIntegerData(uint propertyId) + { + return this.ExecuteGetter(() => + { + uint data; + Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, out data), + string.Format("Failed to get property integer data: propertyId {0}", propertyId), propertyId); + return data; + }); + } + + protected Point GetPropertyPointData(uint propertyId) + { + var point = this.GetPropertyStruct(propertyId, Edsdk.EdsDataType.Point); + return new Point { X = point.x, Y = point.y }; + } + + protected Size GetPropertySizeData(uint propertyId) + { + var point = this.GetPropertyStruct(propertyId, Edsdk.EdsDataType.Point); + return new Size { Width = point.width, Height = point.height }; + } + + protected Rectangle GetPropertyRectangleData(uint propertyId) + { + var rect = this.GetPropertyStruct(propertyId, Edsdk.EdsDataType.Rect); + return new Rectangle { X = rect.x, Y = rect.y, Height = rect.height, Width = rect.width }; + } + + protected long[] GetPropertyIntegerArrayData(uint propertyId) + { + return this.ExecuteGetter(() => + { + var dataSize = this.GetPropertyDataSize(propertyId, Edsdk.EdsDataType.UInt32_Array); + var ptr = Marshal.AllocHGlobal(dataSize); + try + { + Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, dataSize, ptr), + "Failed to get required struct.", propertyId); + + var signed = new int[dataSize / Marshal.SizeOf(typeof(uint))]; + Marshal.Copy(ptr, signed, 0, signed.Length); + return signed.Select(i => (long)(uint)i).ToArray(); + } + finally + { + Marshal.FreeHGlobal(ptr); + } + }); + } + + protected string GetPropertyStringData(uint propertyId) + { + return this.ExecuteGetter(() => + { + string data; + Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, out data), + string.Format("Failed to get property string data: propertyId {0}", propertyId), propertyId); + return data; + }); + } + + protected void SetPropertyIntegerData(uint propertyId, long data) + { + this.ExecuteSetter(() => Util.Assert(Edsdk.EdsSetPropertyData(this.Handle, propertyId, 0, Marshal.SizeOf(typeof(uint)), (uint)data), + string.Format("Failed to set property integer data: propertyId {0}, data {1}", propertyId, data), + propertyId, data)); + } + + public void SetPropertyIntegerArrayData(uint propertyId, uint[] data) + { + this.ExecuteSetter(() => Util.Assert(Edsdk.EdsSetPropertyData(this.Handle, propertyId, 0, Marshal.SizeOf(typeof(uint)) * data.Length, data), + string.Format("Failed to set property integer array data: propertyId {0}, data {1}", propertyId, data), + propertyId, data)); + } + + protected void SetPropertyStringData(uint propertyId, string data, int maxByteLength) + { + this.ExecuteSetter(() => + { + var bytes = Util.ConvertStringToBytesWithNullByteAtEnd(data); + if (bytes.Length > maxByteLength) + throw new ArgumentException(string.Format("'{0}' converted to bytes is longer than {1}.", data, maxByteLength), "data"); + + Util.Assert(Edsdk.EdsSetPropertyData(this.Handle, propertyId, 0, bytes.Length, bytes), + string.Format("Failed to set property string data: propertyId {0}, data {1}", propertyId, data), + propertyId, data); + }); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosPropertyAttribute.cs b/DigiCamControl/Canon.Eos.Framework/EosPropertyAttribute.cs new file mode 100644 index 0000000..4e0fc64 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosPropertyAttribute.cs @@ -0,0 +1,17 @@ +using System; + +namespace Canon.Eos.Framework +{ + public class EosPropertyAttribute : Attribute + { + public EosPropertyAttribute(uint propertyId) + { + this.PropertyId = propertyId; + } + + /// + /// Gets the property id. + /// + public uint PropertyId { get; private set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosPropertyException.cs b/DigiCamControl/Canon.Eos.Framework/EosPropertyException.cs new file mode 100644 index 0000000..5f92420 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosPropertyException.cs @@ -0,0 +1,30 @@ +using System; + +namespace Canon.Eos.Framework +{ + public class EosPropertyException : EosException + { + internal EosPropertyException(long eosErrorCode) + : base(eosErrorCode) + { + } + + internal EosPropertyException(long eosErrorCode, string message) + : base(eosErrorCode, message) + { + } + + internal EosPropertyException(long eosErrorCode, string message, Exception innerException) + : base(eosErrorCode, message, innerException) { } + + /// + /// Gets the property id. + /// + public uint PropertyId { get; internal set; } + + /// + /// Gets the property value. + /// + public object PropertyValue { get; internal set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosVolumeInfo.cs b/DigiCamControl/Canon.Eos.Framework/EosVolumeInfo.cs new file mode 100644 index 0000000..481d3f5 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosVolumeInfo.cs @@ -0,0 +1,35 @@ +namespace Canon.Eos.Framework +{ + public class EosVolumeInfo + { + internal EosVolumeInfo() { } + + /// + /// Gets the access. + /// + public long Access { get; internal set; } + + /// + /// Gets the free space in bytes. + /// + public ulong FreeSpaceInBytes { get; internal set; } + + /// + /// Gets the max capacity in bytes. + /// + public ulong MaxCapacityInBytes { get; internal set; } + + /// + /// Gets the type of the storage. + /// + /// + /// The type of the storage. + /// + public long StorageType { get; internal set; } + + /// + /// Gets the volume label. + /// + public string VolumeLabel { get; internal set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/EosWhiteBalance.cs b/DigiCamControl/Canon.Eos.Framework/EosWhiteBalance.cs new file mode 100644 index 0000000..64040df --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/EosWhiteBalance.cs @@ -0,0 +1,26 @@ +namespace Canon.Eos.Framework +{ + public enum EosWhiteBalance : long + { + Pasted = -2, + Click = -1, + Auto = 0, + Daylight = 1, + Cloudy = 2, + Tungsten = 3, + Fluorescent = 4, + Flash = 5, + Manual = 6, + Shade = 8, + ColorTemperature = 9, + Custom = 10, + Custom2 = 11, + Custom3 = 12, + Manual2 = 15, + Manual3 = 16, + Manual4 = 18, + Manual5 = 19, + Custom4 = 20, + Custom5 = 21, + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosExceptionEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosExceptionEventArgs.cs new file mode 100644 index 0000000..271a9b9 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosExceptionEventArgs.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosExceptionEventArgs : EventArgs + { + public Exception Exception { get; internal set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosFileImageEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosFileImageEventArgs.cs new file mode 100644 index 0000000..a1fdac0 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosFileImageEventArgs.cs @@ -0,0 +1,20 @@ +using System.IO; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosFileImageEventArgs : EosImageEventArgs + { + internal EosFileImageEventArgs(string imageFilePath) + { + this.ImageFilePath = imageFilePath; + } + + public string ImageFilePath { get; private set; } + + public override Stream GetStream() + { + return new FileStream(this.ImageFilePath, FileMode.Open, + FileAccess.Read, FileShare.Read); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosImageEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosImageEventArgs.cs new file mode 100644 index 0000000..bda8868 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosImageEventArgs.cs @@ -0,0 +1,25 @@ +using System; +using System.Drawing; +using System.IO; + +namespace Canon.Eos.Framework.Eventing +{ + public abstract class EosImageEventArgs : EventArgs + { + public virtual Image GetImage() + { + using (var stream = this.GetStream()) + return Image.FromStream(stream); + } + + public virtual Bitmap GetBitmap() + { + using (var stream = this.GetStream()) + return new Bitmap(stream); + } + + public abstract Stream GetStream(); + + public IntPtr Pointer { get; set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosLiveImageEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosLiveImageEventArgs.cs new file mode 100644 index 0000000..5b28ff8 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosLiveImageEventArgs.cs @@ -0,0 +1,20 @@ +using System.Drawing; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosLiveImageEventArgs : EosMemoryImageEventArgs + { + internal EosLiveImageEventArgs(byte[] imageData) + : base(imageData) { } + + public Point ImagePosition { get; internal set; } + + public long[] Histogram { get; internal set; } + + public long Zoom { get; internal set; } + + public Rectangle ZommBounds { get; set; } + + public Size ImageSize { get; set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosMemoryImageEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosMemoryImageEventArgs.cs new file mode 100644 index 0000000..4e630e2 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosMemoryImageEventArgs.cs @@ -0,0 +1,21 @@ +using System.IO; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosMemoryImageEventArgs : EosImageEventArgs + { + internal EosMemoryImageEventArgs(byte[] imageData) + { + this.ImageData = imageData; + } + + public byte[] ImageData { get; private set; } + + public string FileName { get; set; } + + public override Stream GetStream() + { + return new MemoryStream(this.ImageData); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosPropertyEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosPropertyEventArgs.cs new file mode 100644 index 0000000..5baab22 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosPropertyEventArgs.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosPropertyEventArgs: EventArgs + { + public uint PropertyId { get; set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Eventing/EosVolumeInfoEventArgs.cs b/DigiCamControl/Canon.Eos.Framework/Eventing/EosVolumeInfoEventArgs.cs new file mode 100644 index 0000000..b56d234 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Eventing/EosVolumeInfoEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace Canon.Eos.Framework.Eventing +{ + public class EosVolumeInfoEventArgs : EventArgs + { + internal EosVolumeInfoEventArgs(EosVolumeInfo volumeInfo) + { + this.VolumeInfo = volumeInfo; + } + + public EosVolumeInfo VolumeInfo { get; private set; } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Helper/ConsoleLog.cs b/DigiCamControl/Canon.Eos.Framework/Helper/ConsoleLog.cs new file mode 100644 index 0000000..556a005 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Helper/ConsoleLog.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using Canon.Eos.Framework.Interfaces; + +namespace Canon.Eos.Framework.Helper +{ + internal class ConsoleLog : IEosLog + { + public bool IsDebugEnabled { get; set; } + + public bool IsErrorEnabled { get; set; } + + public bool IsWarningEnabled { get; set; } + + public string LogProviderName + { + get { return this.GetType().FullName; } + } + + public void Debug(string format, params object[] parameters) + { + if(this.IsDebugEnabled) + Print(LogType.Debug, format, parameters); + } + + public void Error(string format, params object[] parameters) + { + if(this.IsErrorEnabled || this.IsWarningEnabled || this.IsDebugEnabled) + Print(LogType.Error, format, parameters); + } + + public void Warn(string format, params object[] parameters) + { + if (this.IsWarningEnabled || this.IsDebugEnabled) + Print(LogType.Warn, format, parameters); + } + + private enum LogType { Debug, Error, Warn } + + private static void Print(LogType logType, string format, params object[] parameters) + { + var stringBuilder = new StringBuilder(); + stringBuilder.Append(logType); + stringBuilder.Append("::"); + stringBuilder.AppendFormat(format, parameters); + Console.Error.WriteLine(stringBuilder); + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Helper/Util.cs b/DigiCamControl/Canon.Eos.Framework/Helper/Util.cs new file mode 100644 index 0000000..77a8cfa --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Helper/Util.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework.Helper +{ + internal static class Util + { + public static string ConvertCamelCasedStringToFriendlyString(string camelCase) + { + return Regex.Replace(camelCase, @"(?(? + /// + /// + public interface IEosLog + { + /// + /// Gets or sets a value indicating whether to enable debug logging + /// + /// + /// true to enable log debug messages; otherwise, false. + /// + bool IsDebugEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether to enable error logging + /// + /// + /// true to enable log error messages; otherwise, false. + /// + bool IsErrorEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether to enable warning logging + /// + /// + /// true to enable log warning messages; otherwise, false. + /// + bool IsWarningEnabled { get; set; } + + /// + /// Gets the name of the log provider. + /// + /// + /// The name of the log provider. + /// + string LogProviderName { get; } + + /// + /// Writes a debug message to the log. + /// + /// The format. + /// The parameters. + void Debug(string format, params object[] parameters); + + /// + /// Writes a error message to the log. + /// + /// The format. + /// The parameters. + void Error(string format, params object[] parameters); + + /// + /// Writes a warning message to the log. + /// + /// The format. + /// The parameters. + void Warn(string format, params object[] parameters); + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Internal/EosConverter.cs b/DigiCamControl/Canon.Eos.Framework/Internal/EosConverter.cs new file mode 100644 index 0000000..b2bfdb2 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Internal/EosConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Interfaces; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework.Internal +{ + public class EosConverter : IEosAssertable + { + public byte[] ConvertImageStreamToBytes(IntPtr imageStream) + { + IntPtr imagePtr; + Util.Assert(Edsdk.EdsGetPointer(imageStream, out imagePtr), "Failed to get image pointer."); + + UInt64 imageLen; + Util.Assert(Edsdk.EdsGetLength(imageStream, out imageLen), "Failed to get image pointer length."); + + var bytes = new byte[imageLen]; + Marshal.Copy(imagePtr, bytes, 0, bytes.Length); + return bytes; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Internal/EosImageTransporter.cs b/DigiCamControl/Canon.Eos.Framework/Internal/EosImageTransporter.cs new file mode 100644 index 0000000..dbaf731 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Internal/EosImageTransporter.cs @@ -0,0 +1,130 @@ +using System; +using System.IO; +using Canon.Eos.Framework.Eventing; +using Canon.Eos.Framework.Helper; +using Canon.Eos.Framework.Interfaces; +using Canon.Eos.Framework.Internal.SDK; + +namespace Canon.Eos.Framework.Internal +{ + public class EosImageTransporter : IEosAssertable + { + public delegate void ProgressEventHandler(int progress); + public event ProgressEventHandler ProgressEvent; + + + public static Edsdk.EdsDirectoryItemInfo GetDirectoryItemInfo(IntPtr directoryItem) + { + Edsdk.EdsDirectoryItemInfo directoryItemInfo; + Util.Assert(Edsdk.EdsGetDirectoryItemInfo(directoryItem, out directoryItemInfo), "Failed to get directory item info."); + return directoryItemInfo; + } + + private static IntPtr CreateFileStream(string imageFilePath) + { + IntPtr stream; + Util.Assert(Edsdk.EdsCreateFileStream(imageFilePath, Edsdk.EdsFileCreateDisposition.CreateAlways, + Edsdk.EdsAccess.ReadWrite, out stream), "Failed to create file stream"); + return stream; + } + + private static IntPtr CreateMemoryStream(UInt64 size) + { + IntPtr stream; + Util.Assert(Edsdk.EdsCreateMemoryStream(size, out stream), "Failed to create memory stream"); + return stream; + } + + private static void DestroyStream(ref IntPtr stream) + { + if(stream != IntPtr.Zero) + { + Util.Assert(Edsdk.EdsRelease(stream), "Failed to release stream"); + stream = IntPtr.Zero; + } + } + + private static void Download(IntPtr directoryItem, UInt64 size, IntPtr stream) + { + if (stream == IntPtr.Zero) + return; + try + { + Util.Assert(Edsdk.EdsDownload(directoryItem, size, stream), "Failed to download to stream"); + Util.Assert(Edsdk.EdsDownloadComplete(directoryItem), "Failed to complete download"); + } + catch (EosException) + { + throw; + } + catch (Exception ex) + { + throw new EosException(-1, "Unexpected exception while downloading.", ex); + } + } + + private static void Transport(IntPtr directoryItem, UInt64 size, IntPtr stream, bool destroyStream) + { + try + { + Download(directoryItem, size, stream); + } + catch (EosException) + { + throw; + } + catch (Exception ex) + { + throw new EosException(-1, "Unexpected exception while transporting.", ex); + } + finally + { + if (destroyStream) DestroyStream(ref stream); + } + } + + public EosImageEventArgs TransportAsFile(IntPtr directoryItem, string imageBasePath) + { + var directoryItemInfo = GetDirectoryItemInfo(directoryItem); + var imageFilePath = Path.Combine(imageBasePath ?? Environment.CurrentDirectory, directoryItemInfo.szFileName); + var stream = CreateFileStream(imageFilePath); + Transport(directoryItem, directoryItemInfo.Size, stream, true); + + return new EosFileImageEventArgs(imageFilePath); + } + + public EosImageEventArgs TransportAsFileName(IntPtr directoryItem, string imagePath, IntPtr context) + { + var directoryItemInfo = GetDirectoryItemInfo(directoryItem); + var stream = CreateFileStream(imagePath); + Edsdk.EdsSetProgressCallback(stream, progress, Edsdk.EdsProgressOption.Periodically, context); + Transport(directoryItem, directoryItemInfo.Size, stream, true); + + return new EosFileImageEventArgs(imagePath); + } + + public EosMemoryImageEventArgs TransportInMemory(IntPtr directoryItem, IntPtr context) + { + var directoryItemInfo = GetDirectoryItemInfo(directoryItem); + var stream = CreateMemoryStream(directoryItemInfo.Size); + try + { + Edsdk.EdsSetProgressCallback(stream, progress, Edsdk.EdsProgressOption.Periodically, context); + Transport(directoryItem, directoryItemInfo.Size, stream, false); + var converter = new EosConverter(); + return new EosMemoryImageEventArgs(converter.ConvertImageStreamToBytes(stream)){FileName = directoryItemInfo.szFileName}; + } + finally + { + DestroyStream(ref stream); + } + } + + private uint progress(uint inpercent, IntPtr incontext, ref bool outcancel) + { + if (ProgressEvent != null) + ProgressEvent((int) inpercent); + return Edsdk.EDS_ERR_OK; + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDK.cs b/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDK.cs new file mode 100644 index 0000000..3b25fe2 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDK.cs @@ -0,0 +1,2787 @@ +using System; +using System.Runtime.InteropServices; + +namespace Canon.Eos.Framework.Internal.SDK +{ + + public partial class Edsdk + { + public const string DllPath32 = "SDK/X86/EDSDK"; + + public const string DllPath64 = "SDK/X64/EDSDK"; + + + #region Callback Functions + + public delegate uint EdsProgressCallback( uint inPercent, IntPtr inContext, ref bool outCancel); + public delegate uint EdsCameraAddedHandler(IntPtr inContext); + public delegate uint EdsPropertyEventHandler(uint inEvent, uint inPropertyID, uint inParam, IntPtr inContext); + public delegate uint EdsObjectEventHandler( uint inEvent, IntPtr inRef, IntPtr inContext); + public delegate uint EdsStateEventHandler( uint inEvent, uint inParameter, IntPtr inContext); + + #endregion + + #region Data Types + + public enum EdsDataType : uint + { + Unknown = 0, + Bool = 1, + String = 2, + Int8 = 3, + UInt8 = 6, + Int16 = 4, + UInt16 = 7, + Int32 = 8, + UInt32 = 9, + Int64 = 10, + UInt64 = 11, + Float = 12, + Double = 13, + ByteBlock = 14, + Rational = 20, + Point = 21, + Rect = 22, + Time = 23, + + Bool_Array = 30, + Int8_Array = 31, + Int16_Array = 32, + Int32_Array = 33, + UInt8_Array = 34, + UInt16_Array = 35, + UInt32_Array = 36, + Rational_Array = 37, + + FocusInfo = 101, + PictureStyleDesc, + } + + #endregion + + + #region Property IDs + + /*---------------------------------- + Camera Setting Properties + ----------------------------------*/ + public const uint PropID_Unknown = 0x0000ffff; + + public const uint PropID_ProductName = 0x00000002; + public const uint PropID_BodyIDEx = 0x00000015; + public const uint PropID_OwnerName = 0x00000004; + public const uint PropID_MakerName = 0x00000005; + public const uint PropID_DateTime = 0x00000006; + public const uint PropID_FirmwareVersion = 0x00000007; + public const uint PropID_BatteryLevel = 0x00000008; + public const uint PropID_CFn = 0x00000009; + public const uint PropID_SaveTo = 0x0000000b; + public const uint kEdsPropID_CurrentStorage = 0x0000000c; + public const uint kEdsPropID_CurrentFolder = 0x0000000d; + public const uint kEdsPropID_MyMenu = 0x0000000e; + + public const uint PropID_BatteryQuality = 0x00000010; + + public const uint PropID_HDDirectoryStructure = 0x00000020; + + /*---------------------------------- + Image Properties + ----------------------------------*/ + public const uint PropID_ImageQuality = 0x00000100; + public const uint PropID_JpegQuality = 0x00000101; + public const uint PropID_Orientation = 0x00000102; + public const uint PropID_ICCProfile = 0x00000103; + public const uint PropID_FocusInfo = 0x00000104; + public const uint PropID_DigitalExposure = 0x00000105; + public const uint PropID_WhiteBalance = 0x00000106; + public const uint PropID_ColorTemperature = 0x00000107; + public const uint PropID_WhiteBalanceShift = 0x00000108; + public const uint PropID_Contrast = 0x00000109; + public const uint PropID_ColorSaturation = 0x0000010a; + public const uint PropID_ColorTone = 0x0000010b; + public const uint PropID_Sharpness = 0x0000010c; + public const uint PropID_ColorSpace = 0x0000010d; + public const uint PropID_ToneCurve = 0x0000010e; + public const uint PropID_PhotoEffect = 0x0000010f; + public const uint PropID_FilterEffect = 0x00000110; + public const uint PropID_ToningEffect = 0x00000111; + public const uint PropID_ParameterSet = 0x00000112; + public const uint PropID_ColorMatrix = 0x00000113; + public const uint PropID_PictureStyle = 0x00000114; + public const uint PropID_PictureStyleDesc = 0x00000115; + public const uint PropID_PictureStyleCaption = 0x00000200; + + /*---------------------------------- + Image Processing Properties + ----------------------------------*/ + public const uint PropID_Linear = 0x00000300; + public const uint PropID_ClickWBPoint = 0x00000301; + public const uint PropID_WBCoeffs = 0x00000302; + + /*---------------------------------- + Property Mask + ----------------------------------*/ + public const uint PropID_AtCapture_Flag = 0x80000000; + + /*---------------------------------- + Capture Properties + ----------------------------------*/ + public const uint PropID_AEMode = 0x00000400; + public const uint PropID_AEModeSelect = 0x00000436; + public const uint PropID_DriveMode = 0x00000401; + public const uint PropID_ISOSpeed = 0x00000402; + public const uint PropID_MeteringMode = 0x00000403; + public const uint PropID_AFMode = 0x00000404; + public const uint PropID_Av = 0x00000405; + public const uint PropID_Tv = 0x00000406; + public const uint PropID_ExposureCompensation = 0x00000407; + public const uint PropID_FlashCompensation = 0x00000408; + public const uint PropID_FocalLength = 0x00000409; + public const uint PropID_AvailableShots = 0x0000040a; + public const uint PropID_Bracket = 0x0000040b; + public const uint PropID_WhiteBalanceBracket = 0x0000040c; + public const uint PropID_LensName = 0x0000040d; + public const uint PropID_AEBracket = 0x0000040e; + public const uint PropID_AEBracketType = 16778300; + public const uint PropID_FEBracket = 0x0000040f; + public const uint PropID_ISOBracket = 0x00000410; + public const uint PropID_NoiseReduction = 0x00000411; + public const uint PropID_FlashOn = 0x00000412; + public const uint PropID_RedEye = 0x00000413; + public const uint PropID_FlashMode = 0x00000414; + public const uint PropID_LensStatus = 0x00000416; + + public const uint PropID_Artist = 0x00000418; + public const uint PropID_Copyright = 0x00000419; + public const uint PropID_DepthOfField = 0x0000041b; + public const uint PropID_EFCompensation = 0x0000041e; + + /*---------------------------------- + EVF Properties + ----------------------------------*/ + public const uint PropID_Evf_OutputDevice = 0x00000500; + public const uint PropID_Evf_Mode = 0x00000501; + public const uint PropID_Evf_WhiteBalance = 0x00000502; + public const uint PropID_Evf_ColorTemperature = 0x00000503; + public const uint PropID_Evf_DepthOfFieldPreview = 0x00000504; + + // EVF IMAGE DATA Properties + public const uint PropID_Evf_Zoom = 0x00000507; + public const uint PropID_Evf_ZoomPosition = 0x00000508; + public const uint PropID_Evf_FocusAid = 0x00000509; + public const uint PropID_Evf_Histogram = 0x0000050A; + public const uint PropID_Evf_ImagePosition = 0x0000050B; + public const uint PropID_Evf_ZoomRect = 0x00000541; + public const uint PropID_Evf_HistogramStatus = 0x0000050C; + public const uint PropID_Evf_AFMode = 0x0000050E; + public const uint PropID_Evf_CoordinateSystem = 0x00000540; + public const uint PropID_Record = 0x00000510; + + /*---------------------------------- + Image GPS Properties + ----------------------------------*/ + public const uint PropID_GPSVersionID = 0x00000800; + public const uint PropID_GPSLatitudeRef = 0x00000801; + public const uint PropID_GPSLatitude = 0x00000802; + public const uint PropID_GPSLongitudeRef = 0x00000803; + public const uint PropID_GPSLongitude = 0x00000804; + public const uint PropID_GPSAltitudeRef = 0x00000805; + public const uint PropID_GPSAltitude = 0x00000806; + public const uint PropID_GPSTimeStamp = 0x00000807; + public const uint PropID_GPSSatellites = 0x00000808; + public const uint PropID_GPSStatus = 0x00000809; + public const uint PropID_GPSMapDatum = 0x00000812; + public const uint PropID_GPSDateStamp = 0x0000081D; + #endregion + + #region Camera commands + + /*----------------------------------------------------------------------------- + Send Commands + -----------------------------------------------------------------------------*/ + public const uint CameraCommand_TakePicture = 0x00000000; + public const uint CameraCommand_ExtendShutDownTimer = 0x00000001; + public const uint CameraCommand_BulbStart = 0x00000002; + public const uint CameraCommand_BulbEnd = 0x00000003; + public const uint CameraCommand_DoEvfAf = 0x00000102; + public const uint CameraCommand_DriveLensEvf = 0x00000103; + public const uint CameraCommand_DoClickWBEvf = 0x00000104; + + public const uint CameraCommand_PressShutterButton = 0x00000004; + public const uint CameraCommand_MovieSelectSwON = 0x00000107; + public const uint CameraCommand_MovieSelectSwOFF = 0x00000108; + + public enum EdsEvfAf : uint + { + CameraCommand_EvfAf_OFF = 0, + CameraCommand_EvfAf_ON = 1, + } + + public enum EdsShutterButton : uint + { + CameraCommand_ShutterButton_OFF = 0x00000000, + CameraCommand_ShutterButton_Halfway = 0x00000001, + CameraCommand_ShutterButton_Completely = 0x00000003, + CameraCommand_ShutterButton_Halfway_NonAF = 0x00010001, + CameraCommand_ShutterButton_Completely_NonAF = 0x00010003, + } + #endregion + + #region Camera status command + + /*---------------------------------- + Camera Status Commands + ----------------------------------*/ + public const uint CameraState_UILock = 0x00000000; + public const uint CameraState_UIUnLock = 0x00000001; + public const uint CameraState_EnterDirectTransfer = 0x00000002; + public const uint CameraState_ExitDirectTransfer = 0x00000003; + + #endregion + + + #region Enumeration of property value + + /*----------------------------------------------------------------------------- + Stream Seek Origins + -----------------------------------------------------------------------------*/ + public enum EdsSeekOrigin : uint + { + Cur = 0 , + Begin , + End , + } + + /*----------------------------------------------------------------------------- + File and Propaties Access + -----------------------------------------------------------------------------*/ + public enum EdsAccess : uint + { + Read = 0 , + Write , + ReadWrite , + Error = 0xFFFFFFFF, + } + + /*----------------------------------------------------------------------------- + File Create Disposition + -----------------------------------------------------------------------------*/ + public enum EdsFileCreateDisposition : uint + { + CreateNew = 0 , + CreateAlways , + OpenExisting , + OpenAlways , + TruncateExsisting, + } + + + /*----------------------------------------------------------------------------- + Target Image Types + -----------------------------------------------------------------------------*/ + public enum EdsTargetImageType : uint + { + Unknown = 0x00000000, + Jpeg = 0x00000001, + TIFF = 0x00000007, + TIFF16 = 0x00000008, + RGB = 0x00000009, + RGB16 = 0x0000000A, + } + + + /*----------------------------------------------------------------------------- + Image Source + -----------------------------------------------------------------------------*/ + public enum EdsImageSource : uint + { + FullView = 0 , + Thumbnail, + Preview, + } + + /*----------------------------------------------------------------------------- + Progress Option + -----------------------------------------------------------------------------*/ + public enum EdsProgressOption : uint + { + NoReport = 0 , + Done , + Periodically , + } + + + /*----------------------------------------------------------------------------- + file attribute + -----------------------------------------------------------------------------*/ + public enum EdsFileAttribute : uint + { + Normal = 0x00000000, + ReadOnly = 0x00000001, + Hidden = 0x00000002, + System = 0x00000004, + Archive = 0x00000020, + } + + /*----------------------------------------------------------------------------- + Save To + -----------------------------------------------------------------------------*/ + public enum EdsSaveTo : uint + { + Camera = 1, + Host = 2, + Both = 3, + } + + /*----------------------------------------------------------------------------- + StorageTypes + -----------------------------------------------------------------------------*/ + public enum EdsStorageType : uint + { + Non = 0, + CF = 1, + SD = 2, + } + + /*----------------------------------------------------------------------------- + Transfer Option + -----------------------------------------------------------------------------*/ + public enum EdsTransferOption : uint + { + ByDirectTransfer = 1, + ByRelease = 2, + ToDesktop = 0x00000100, + } + + /*----------------------------------------------------------------------------- + Drive Lens + -----------------------------------------------------------------------------*/ + public const uint EvfDriveLens_Near1 = 0x00000001; + public const uint EvfDriveLens_Near2 = 0x00000002; + public const uint EvfDriveLens_Near3 = 0x00000003; + public const uint EvfDriveLens_Far1 = 0x00008001; + public const uint EvfDriveLens_Far2 = 0x00008002; + public const uint EvfDriveLens_Far3 = 0x00008003; + + /*----------------------------------------------------------------------------- + Depth of Field Preview + -----------------------------------------------------------------------------*/ + public const uint EvfDepthOfFieldPreview_OFF = 0x00000000; + public const uint EvfDepthOfFieldPreview_ON = 0x00000001; + + + /*----------------------------------------------------------------------------- + Image Format + -----------------------------------------------------------------------------*/ + + public const int ImageFormat_Unknown = 0x00000000; + public const int ImageFormat_Jpeg = 0x00000001; + public const int ImageFormat_CRW = 0x00000002; + public const int ImageFormat_RAW = 0x00000004; + + public const int ImageFormat_CR2 = 0x00000006; + + + public const int ImageSize_Large = 0; + public const int ImageSize_Middle = 1; + public const int ImageSize_Small = 2; + public const int ImageSize_Middle1 = 5; + public const int ImageSize_Middle2 = 6; + public const int ImageSize_Unknown = -1; + + + + public const int CompressQuality_Normal = 2; + public const int CompressQuality_Fine = 3; + public const int CompressQuality_Lossless = 4; + public const int CompressQuality_SuperFine = 5; + public const int CompressQuality_Unknown = -1; + + + /*----------------------------------------------------------------------------- + Battery level + -----------------------------------------------------------------------------*/ + public const uint BatteryLevel_Empty = 1; + public const uint BatteryLevel_Low = 30; + public const uint BatteryLevel_Half = 50; + public const uint BatteryLevel_Normal = 80; + public const uint BatteryLevel_AC = 0xFFFFFFFF; + + /*----------------------------------------------------------------------------- + White Balance + -----------------------------------------------------------------------------*/ + public const int WhiteBalance_Click = -1; + public const int WhiteBalance_Auto = 0; + public const int WhiteBalance_Daylight = 1; + public const int WhiteBalance_Cloudy = 2; + public const int WhiteBalance_Tangsten = 3; + public const int WhiteBalance_Fluorescent = 4; + public const int WhiteBalance_Strobe = 5; + public const int WhiteBalance_WhitePaper = 6; + public const int WhiteBalance_Shade = 8; + public const int WhiteBalance_ColorTemp = 9; + public const int WhiteBalance_PCSet1 = 10; + public const int WhiteBalance_PCSet2 = 11; + public const int WhiteBalance_PCSet3 = 12; + + /*----------------------------------------------------------------------------- + Photo Effects + -----------------------------------------------------------------------------*/ + public const int PhotoEffect_Off = 0; + public const int PhotoEffect_Monochrome = 5; + + /*----------------------------------------------------------------------------- + Color Matrix + -----------------------------------------------------------------------------*/ + public const int ColorMatrix_Custom = 0; + public const int ColorMatrix_1 = 1; + public const int ColorMatrix_2 = 2; + public const int ColorMatrix_3 = 3; + public const int ColorMatrix_4 = 4; + public const int ColorMatrix_5 = 5; + public const int ColorMatrix_6 = 6; + public const int ColorMatrix_7 = 7; + + /*----------------------------------------------------------------------------- + Filter Effects + -----------------------------------------------------------------------------*/ + public const int FilterEffect_None = 0; + public const int FilterEffect_Yellow = 1; + public const int FilterEffect_Orange = 2; + public const int FilterEffect_Red = 3; + public const int FilterEffect_Green = 4; + + /*----------------------------------------------------------------------------- + Toning Effects + -----------------------------------------------------------------------------*/ + public const int TonigEffect_None = 0; + public const int TonigEffect_Sepia = 1; + public const int TonigEffect_Blue = 2; + public const int TonigEffect_Purple = 3; + public const int TonigEffect_Green = 4; + + /*----------------------------------------------------------------------------- + Color Space + -----------------------------------------------------------------------------*/ + public const uint ColorSpace_sRGB = 1; + public const uint ColorSpace_AdobeRGB = 2; + public const uint ColorSpace_Unknown = 0xffffffff; + + /*----------------------------------------------------------------------------- + PictureStyle + -----------------------------------------------------------------------------*/ + public const uint PictureStyle_Standard = 0x0081; + public const uint PictureStyle_Portrait = 0x0082; + public const uint PictureStyle_Landscape = 0x0083; + public const uint PictureStyle_Neutral = 0x0084; + public const uint PictureStyle_Faithful = 0x0085; + public const uint PictureStyle_Monochrome = 0x0086; + public const uint PictureStyle_Auto = 0x0087; + public const uint PictureStyle_FineDetail = 0x0088; + public const uint PictureStyle_User1 = 0x0021; + public const uint PictureStyle_User2 = 0x0022; + public const uint PictureStyle_User3 = 0x0023; + public const uint PictureStyle_PC1 = 0x0041; + public const uint PictureStyle_PC2 = 0x0042; + public const uint PictureStyle_PC3 = 0x0043; + + + /*----------------------------------------------------------------------------- + AE Mode + -----------------------------------------------------------------------------*/ + public const uint AEMode_Program = 0; + public const uint AEMode_Tv = 1; + public const uint AEMode_Av = 2; + public const uint AEMode_Mamual = 3; + public const uint AEMode_Bulb = 4; + public const uint AEMode_A_DEP = 5; + public const uint AEMode_DEP = 6; + public const uint AEMode_Custom = 7; + public const uint AEMode_Lock = 8; + public const uint AEMode_Green = 9; + public const uint AEMode_NigntPortrait = 10; + public const uint AEMode_Sports = 11; + public const uint AEMode_Portrait = 12; + public const uint AEMode_Landscape = 13; + public const uint AEMode_Closeup = 14; + public const uint AEMode_FlashOff = 15; + public const uint AEMode_CreativeAuto = 19; + public const uint AEMode_Movie = 20; + public const uint AEMode_PhotoInMovie = 21; + public const uint AEMode_SceneIntelligentAuto = 22; + public const uint AEMode_SCN = 25; + public const uint AEMode_Unknown = 0xffffffff; + + /*----------------------------------------------------------------------------- + Bracket + -----------------------------------------------------------------------------*/ + public const uint Bracket_AEB = 0x01; + public const uint Bracket_ISOB = 0x02; + public const uint Bracket_WBB = 0x04; + public const uint Bracket_FEB = 0x08; + public const uint Bracket_Unknown = 0xffffffff; + + + /*----------------------------------------------------------------------------- + EVF Output Device [Flag] + -----------------------------------------------------------------------------*/ + public const uint EvfOutputDevice_TFT = 1; + public const uint EvfOutputDevice_PC = 2; + + + /*----------------------------------------------------------------------------- + EVF Zoom + -----------------------------------------------------------------------------*/ + public const int EvfZoom_Fit = 1; + public const int EvfZoom_x5 = 5; + public const int EvfZoom_x10 = 10; + + public enum EdsEvfAFMode : uint + { + Evf_AFMode_Quick = 0, + Evf_AFMode_Live = 1, + Evf_AFMode_LiveFace = 2, + Evf_AFMode_LiveMulti = 3, + } + + /*----------------------------------------------------------------------------- + Strobo Mode + -----------------------------------------------------------------------------*/ + public enum EdsStroboMode + { + kEdsStroboModeInternal = 0, + kEdsStroboModeExternalETTL = 1, + kEdsStroboModeExternalATTL = 2, + kEdsStroboModeExternalTTL = 3, + kEdsStroboModeExternalAuto = 4, + kEdsStroboModeExternalManual = 5, + kEdsStroboModeManual = 6, + } + + public enum EdsETTL2Mode + { + kEdsETTL2ModeEvaluative = 0, + kEdsETTL2ModeAverage = 1, + } + + public enum ImageQuality : uint + { + /* Jpeg Only */ + EdsImageQuality_LJ = 0x0010ff0f, /* Jpeg Large */ + EdsImageQuality_M1J = 0x0510ff0f, /* Jpeg Middle1 */ + EdsImageQuality_M2J = 0x0610ff0f, /* Jpeg Middle2 */ + EdsImageQuality_SJ = 0x0210ff0f, /* Jpeg Small */ + EdsImageQuality_LJF = 0x0013ff0f, /* Jpeg Large Fine */ + EdsImageQuality_LJN = 0x0012ff0f, /* Jpeg Large Normal */ + EdsImageQuality_MJF = 0x0113ff0f, /* Jpeg Middle Fine */ + EdsImageQuality_MJN = 0x0112ff0f, /* Jpeg Middle Normal */ + EdsImageQuality_SJF = 0x0213ff0f, /* Jpeg Small Fine */ + EdsImageQuality_SJN = 0x0212ff0f, /* Jpeg Small Normal */ + EdsImageQuality_S1JF = 0x0E13ff0f, /* Jpeg Small1 Fine */ + EdsImageQuality_S1JN = 0x0E12ff0f, /* Jpeg Small1 Normal */ + EdsImageQuality_S2JF = 0x0F13ff0f, /* Jpeg Small2 */ + EdsImageQuality_S3JF = 0x1013ff0f, /* Jpeg Small3 */ + + /* RAW + Jpeg */ + EdsImageQuality_LR = 0x0064ff0f, /* RAW */ + EdsImageQuality_LRLJF = 0x00640013, /* RAW + Jpeg Large Fine */ + EdsImageQuality_LRLJN = 0x00640012, /* RAW + Jpeg Large Normal */ + EdsImageQuality_LRMJF = 0x00640113, /* RAW + Jpeg Middle Fine */ + EdsImageQuality_LRMJN = 0x00640112, /* RAW + Jpeg Middle Normal */ + EdsImageQuality_LRSJF = 0x00640213, /* RAW + Jpeg Small Fine */ + EdsImageQuality_LRSJN = 0x00640212, /* RAW + Jpeg Small Normal */ + EdsImageQuality_LRS1JF = 0x00640E13, /* RAW + Jpeg Small1 Fine */ + EdsImageQuality_LRS1JN = 0x00640E12, /* RAW + Jpeg Small1 Normal */ + EdsImageQuality_LRS2JF = 0x00640F13, /* RAW + Jpeg Small2 */ + EdsImageQuality_LRS3JF = 0x00641013, /* RAW + Jpeg Small3 */ + + EdsImageQuality_LRLJ = 0x00640010, /* RAW + Jpeg Large */ + EdsImageQuality_LRM1J = 0x00640510, /* RAW + Jpeg Middle1 */ + EdsImageQuality_LRM2J = 0x00640610, /* RAW + Jpeg Middle2 */ + EdsImageQuality_LRSJ = 0x00640210, /* RAW + Jpeg Small */ + + /* MRAW(SRAW1) + Jpeg */ + EdsImageQuality_MR = 0x0164ff0f, /* MRAW(SRAW1) */ + EdsImageQuality_MRLJF = 0x01640013, /* MRAW(SRAW1) + Jpeg Large Fine */ + EdsImageQuality_MRLJN = 0x01640012, /* MRAW(SRAW1) + Jpeg Large Normal */ + EdsImageQuality_MRMJF = 0x01640113, /* MRAW(SRAW1) + Jpeg Middle Fine */ + EdsImageQuality_MRMJN = 0x01640112, /* MRAW(SRAW1) + Jpeg Middle Normal */ + EdsImageQuality_MRSJF = 0x01640213, /* MRAW(SRAW1) + Jpeg Small Fine */ + EdsImageQuality_MRSJN = 0x01640212, /* MRAW(SRAW1) + Jpeg Small Normal */ + EdsImageQuality_MRS1JF = 0x01640E13, /* MRAW(SRAW1) + Jpeg Small1 Fine */ + EdsImageQuality_MRS1JN = 0x01640E12, /* MRAW(SRAW1) + Jpeg Small1 Normal */ + EdsImageQuality_MRS2JF = 0x01640F13, /* MRAW(SRAW1) + Jpeg Small2 */ + EdsImageQuality_MRS3JF = 0x01641013, /* MRAW(SRAW1) + Jpeg Small3 */ + + EdsImageQuality_MRLJ = 0x01640010, /* MRAW(SRAW1) + Jpeg Large */ + EdsImageQuality_MRM1J = 0x01640510, /* MRAW(SRAW1) + Jpeg Middle1 */ + EdsImageQuality_MRM2J = 0x01640610, /* MRAW(SRAW1) + Jpeg Middle2 */ + EdsImageQuality_MRSJ = 0x01640210, /* MRAW(SRAW1) + Jpeg Small */ + + /* SRAW(SRAW2) + Jpeg */ + EdsImageQuality_SR = 0x0264ff0f, /* SRAW(SRAW2) */ + EdsImageQuality_SRLJF = 0x02640013, /* SRAW(SRAW2) + Jpeg Large Fine */ + EdsImageQuality_SRLJN = 0x02640012, /* SRAW(SRAW2) + Jpeg Large Normal */ + EdsImageQuality_SRMJF = 0x02640113, /* SRAW(SRAW2) + Jpeg Middle Fine */ + EdsImageQuality_SRMJN = 0x02640112, /* SRAW(SRAW2) + Jpeg Middle Normal */ + EdsImageQuality_SRSJF = 0x02640213, /* SRAW(SRAW2) + Jpeg Small Fine */ + EdsImageQuality_SRSJN = 0x02640212, /* SRAW(SRAW2) + Jpeg Small Normal */ + EdsImageQuality_SRS1JF = 0x02640E13, /* SRAW(SRAW2) + Jpeg Small1 Fine */ + EdsImageQuality_SRS1JN = 0x02640E12, /* SRAW(SRAW2) + Jpeg Small1 Normal */ + EdsImageQuality_SRS2JF = 0x02640F13, /* SRAW(SRAW2) + Jpeg Small2 */ + EdsImageQuality_SRS3JF = 0x02641013, /* SRAW(SRAW2) + Jpeg Small3 */ + + EdsImageQuality_SRLJ = 0x02640010, /* SRAW(SRAW2) + Jpeg Large */ + EdsImageQuality_SRM1J = 0x02640510, /* SRAW(SRAW2) + Jpeg Middle1 */ + EdsImageQuality_SRM2J = 0x02640610, /* SRAW(SRAW2) + Jpeg Middle2 */ + EdsImageQuality_SRSJ = 0x02640210, /* SRAW(SRAW2) + Jpeg Small */ + + EdsImageQuality_Unknown = 0xffffffff, + } + + public enum ImageQualityForLegacy : uint + { + kEdsImageQualityForLegacy_LJ = 0x001f000f, /* Jpeg Large */ + kEdsImageQualityForLegacy_M1J = 0x051f000f, /* Jpeg Middle1 */ + kEdsImageQualityForLegacy_M2J = 0x061f000f, /* Jpeg Middle2 */ + kEdsImageQualityForLegacy_SJ = 0x021f000f, /* Jpeg Small */ + kEdsImageQualityForLegacy_LJF = 0x00130000, /* Jpeg Large Fine */ + kEdsImageQualityForLegacy_LJN = 0x00120000, /* Jpeg Large Normal */ + kEdsImageQualityForLegacy_MJF = 0x01130000, /* Jpeg Middle Fine */ + kEdsImageQualityForLegacy_MJN = 0x01120000, /* Jpeg Middle Normal */ + kEdsImageQualityForLegacy_SJF = 0x02130000, /* Jpeg Small Fine */ + kEdsImageQualityForLegacy_SJN = 0x02120000, /* Jpeg Small Normal */ + + kEdsImageQualityForLegacy_LR = 0x00240000, /* RAW */ + kEdsImageQualityForLegacy_LRLJF = 0x00240013, /* RAW + Jpeg Large Fine */ + kEdsImageQualityForLegacy_LRLJN = 0x00240012, /* RAW + Jpeg Large Normal */ + kEdsImageQualityForLegacy_LRMJF = 0x00240113, /* RAW + Jpeg Middle Fine */ + kEdsImageQualityForLegacy_LRMJN = 0x00240112, /* RAW + Jpeg Middle Normal */ + kEdsImageQualityForLegacy_LRSJF = 0x00240213, /* RAW + Jpeg Small Fine */ + kEdsImageQualityForLegacy_LRSJN = 0x00240212, /* RAW + Jpeg Small Normal */ + + kEdsImageQualityForLegacy_LR2 = 0x002f000f, /* RAW */ + kEdsImageQualityForLegacy_LR2LJ = 0x002f001f, /* RAW + Jpeg Large */ + kEdsImageQualityForLegacy_LR2M1J = 0x002f051f, /* RAW + Jpeg Middle1 */ + kEdsImageQualityForLegacy_LR2M2J = 0x002f061f, /* RAW + Jpeg Middle2 */ + kEdsImageQualityForLegacy_LR2SJ = 0x002f021f, /* RAW + Jpeg Small */ + + kEdsImageQualityForLegacy_Unknown = 0xffffffff, + } + + #endregion + + #region Event IDs + + /*----------------------------------------------------------------------------- + Camera Events + -----------------------------------------------------------------------------*/ + /*---------------------------------- + Property Event + ----------------------------------*/ + /* Notifies all property events. */ + public const uint PropertyEvent_All = 0x00000100; + + /* Notifies that a camera property value has been changed. + The changed property can be retrieved from event data. + The changed value can be retrieved by means of EdsGetPropertyData. + In the case of type 1 protocol standard cameras, + notification of changed properties can only be issued for custom functions (CFn). + If the property type is 0x0000FFFF, the changed property cannot be identified. + Thus, retrieve all required properties repeatedly. */ + public const uint PropertyEvent_PropertyChanged = 0x00000101; + + /* Notifies of changes in the list of camera properties with configurable values. + The list of configurable values for property IDs indicated in event data + can be retrieved by means of EdsGetPropertyDesc. + For type 1 protocol standard cameras, the property ID is identified as "Unknown" + during notification. + Thus, you must retrieve a list of configurable values for all properties and + retrieve the property values repeatedly. + (For details on properties for which you can retrieve a list of configurable + properties, + see the description of EdsGetPropertyDesc). */ + public const uint PropertyEvent_PropertyDescChanged = 0x00000102; + + /*---------------------------------- + Object Event + ----------------------------------*/ + /* Notifies all object events. */ + public const uint ObjectEvent_All = 0x00000200; + + /* Notifies that the volume object (memory card) state (VolumeInfo) + has been changed. + Changed objects are indicated by event data. + The changed value can be retrieved by means of EdsGetVolumeInfo. + Notification of this event is not issued for type 1 protocol standard cameras. */ + public const uint ObjectEvent_VolumeInfoChanged = 0x00000201; + + /* Notifies if the designated volume on a camera has been formatted. + If notification of this event is received, get sub-items of the designated + volume again as needed. + Changed volume objects can be retrieved from event data. + Objects cannot be identified on cameras earlier than the D30 + if files are added or deleted. + Thus, these events are subject to notification. */ + public const uint ObjectEvent_VolumeUpdateItems = 0x00000202; + + /* Notifies if many images are deleted in a designated folder on a camera. + If notification of this event is received, get sub-items of the designated + folder again as needed. + Changed folders (specifically, directory item objects) can be retrieved + from event data. */ + public const uint ObjectEvent_FolderUpdateItems = 0x00000203; + + /* Notifies of the creation of objects such as new folders or files + on a camera compact flash card or the like. + This event is generated if the camera has been set to store captured + images simultaneously on the camera and a computer, + for example, but not if the camera is set to store images + on the computer alone. + Newly created objects are indicated by event data. + Because objects are not indicated for type 1 protocol standard cameras, + (that is, objects are indicated as NULL), + you must again retrieve child objects under the camera object to + identify the new objects. */ + public const uint ObjectEvent_DirItemCreated = 0x00000204; + + /* Notifies of the deletion of objects such as folders or files on a camera + compact flash card or the like. + Deleted objects are indicated in event data. + Because objects are not indicated for type 1 protocol standard cameras, + you must again retrieve child objects under the camera object to + identify deleted objects. */ + public const uint ObjectEvent_DirItemRemoved = 0x00000205; + + /* Notifies that information of DirItem objects has been changed. + Changed objects are indicated by event data. + The changed value can be retrieved by means of EdsGetDirectoryItemInfo. + Notification of this event is not issued for type 1 protocol standard cameras. */ + public const uint ObjectEvent_DirItemInfoChanged = 0x00000206; + + /* Notifies that header information has been updated, as for rotation information + of image files on the camera. + If this event is received, get the file header information again, as needed. + This function is for type 2 protocol standard cameras only. */ + public const uint ObjectEvent_DirItemContentChanged = 0x00000207; + + /* Notifies that there are objects on a camera to be transferred to a computer. + This event is generated after remote release from a computer or local release + from a camera. + If this event is received, objects indicated in the event data must be downloaded. + Furthermore, if the application does not require the objects, instead + of downloading them, + execute EdsDownloadCancel and release resources held by the camera. + The order of downloading from type 1 protocol standard cameras must be the order + in which the events are received. */ + public const uint ObjectEvent_DirItemRequestTransfer = 0x00000208; + + /* Notifies if the camera's direct transfer button is pressed. + If this event is received, objects indicated in the event data must be downloaded. + Furthermore, if the application does not require the objects, instead of + downloading them, + execute EdsDownloadCancel and release resources held by the camera. + Notification of this event is not issued for type 1 protocol standard cameras. */ + public const uint ObjectEvent_DirItemRequestTransferDT = 0x00000209; + + /* Notifies of requests from a camera to cancel object transfer + if the button to cancel direct transfer is pressed on the camera. + If the parameter is 0, it means that cancellation of transfer is requested for + objects still not downloaded, + with these objects indicated by kEdsObjectEvent_DirItemRequestTransferDT. + Notification of this event is not issued for type 1 protocol standard cameras. */ + public const uint ObjectEvent_DirItemCancelTransferDT = 0x0000020a; + + public const uint ObjectEvent_VolumeAdded = 0x0000020c; + public const uint ObjectEvent_VolumeRemoved = 0x0000020d; + + /*---------------------------------- + State Event + ----------------------------------*/ + /* Notifies all state events. */ + public const uint StateEvent_All = 0x00000300; + + /* Indicates that a camera is no longer connected to a computer, + whether it was disconnected by unplugging a cord, opening + the compact flash compartment, + turning the camera off, auto shut-off, or by other means. */ + public const uint StateEvent_Shutdown = 0x00000301; + + /* Notifies of whether or not there are objects waiting to + be transferred to a host computer. + This is useful when ensuring all shot images have been transferred + when the application is closed. + Notification of this event is not issued for type 1 protocol + standard cameras. */ + public const uint StateEvent_JobStatusChanged = 0x00000302; + + /* Notifies that the camera will shut down after a specific period. + Generated only if auto shut-off is set. + Exactly when notification is issued (that is, the number of + seconds until shutdown) varies depending on the camera model. + To continue operation without having the camera shut down, + use EdsSendCommand to extend the auto shut-off timer. + The time in seconds until the camera shuts down is returned + as the initial value. */ + public const uint StateEvent_WillSoonShutDown = 0x00000303; + + /* As the counterpart event to kEdsStateEvent_WillSoonShutDown, + this event notifies of updates to the number of seconds until + a camera shuts down. + After the update, the period until shutdown is model-dependent. */ + public const uint StateEvent_ShutDownTimerUpdate = 0x00000304; + + /* Notifies that a requested release has failed, due to focus + failure or similar factors. */ + public const uint StateEvent_CaptureError = 0x00000305; + + /* Notifies of internal SDK errors. + If this error event is received, the issuing device will probably + not be able to continue working properly, + so cancel the remote connection. */ + public const uint StateEvent_InternalError = 0x00000306; + + public const uint StateEvent_AfResult = 0x00000309; + + + public const uint StateEvent_BulbExposureTime = 0x00000310; + + #endregion + + + #region Proto type defenition of EDSDK API + + /*---------------------------------- + Basic functions + ----------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsInitializeSDK + // + // Description: + // Initializes the libraries. + // When using the EDSDK libraries, you must call this API once + // before using EDSDK APIs. + // + // Parameters: + // In: None + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsInitializeSDK")] + public extern static uint EdsInitializeSDK_32(); + + [DllImport(DllPath64, EntryPoint = "EdsInitializeSDK")] + public extern static uint EdsInitializeSDK_64(); + + public static uint EdsInitializeSDK() + { + return IntPtr.Size == 4 /* 64bit */ ? EdsInitializeSDK_32() : EdsInitializeSDK_64(); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsTerminateSDK + // + // Description: + // Terminates use of the libraries. + // This function muse be called when ending the SDK. + // Calling this function releases all resources allocated by the libraries. + // + // Parameters: + // In: None + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsTerminateSDK")] + public extern static uint EdsTerminateSDK_32(); + + [DllImport(DllPath64, EntryPoint = "EdsTerminateSDK")] + public extern static uint EdsTerminateSDK_64(); + + public static uint EdsTerminateSDK() + { + return IntPtr.Size == 4 /* 64bit */ ? EdsTerminateSDK_32() : EdsTerminateSDK_64(); + } + + /*------------------------------------------- + Reference-counter operating functions + --------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsRetain + // + // Description: + // Increments the reference counter of existing objects. + // + // Parameters: + // In: inRef - The reference for the item. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsRetain")] + public extern static uint EdsRetain_32(IntPtr inRef); + + [DllImport(DllPath64, EntryPoint = "EdsRetain")] + public extern static uint EdsRetain_64(IntPtr inRef); + + public static uint EdsRetain(IntPtr inRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsRetain_32(inRef) : EdsRetain_64(inRef); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsRelease + // + // Description: + // Decrements the reference counter to an object. + // When the reference counter reaches 0, the object is released. + // + // Parameters: + // In: inRef - The reference of the item. + // Out: None + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsRelease")] + public extern static uint EdsRelease_32(IntPtr inRef); + + [DllImport(DllPath64, EntryPoint = "EdsRelease")] + public extern static uint EdsRelease_64(IntPtr inRef); + + public static uint EdsRelease(IntPtr inRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsRelease_32(inRef) : EdsRelease_64(inRef); + } + + /*---------------------------------- + Item-tree operating functions + ----------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetChildCount + // + // Description: + // Gets the number of child objects of the designated object. + // Example: Number of files in a directory + // + // Parameters: + // In: inRef - The reference of the list. + // Out: outCount - Number of elements in this list. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetChildCount")] + public extern static uint EdsGetChildCount_32(IntPtr inRef, out int outCount); + + [DllImport(DllPath64, EntryPoint = "EdsGetChildCount")] + public extern static uint EdsGetChildCount_64(IntPtr inRef, out int outCount); + + public static uint EdsGetChildCount(IntPtr inRef, out int outCount) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetChildCount_32(inRef, out outCount) : EdsGetChildCount_64(inRef, out outCount); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsGetChildAtIndex + // + // Description: + // Gets an indexed child object of the designated object. + // + // Parameters: + // In: inRef - The reference of the item. + // inIndex - The index that is passed in, is zero based. + // Out: outRef - The pointer which receives reference of the + // specified index . + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetChildAtIndex")] + public extern static uint EdsGetChildAtIndex_32(IntPtr inRef, int inIndex, out IntPtr outRef); + + [DllImport(DllPath64, EntryPoint = "EdsGetChildAtIndex")] + public extern static uint EdsGetChildAtIndex_64(IntPtr inRef, int inIndex, out IntPtr outRef); + + public static uint EdsGetChildAtIndex(IntPtr inRef, int inIndex, out IntPtr outRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetChildAtIndex_32(inRef, inIndex, out outRef) : EdsGetChildAtIndex_64(inRef, inIndex, out outRef); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsGetParent + // + // Description: + // Gets the parent object of the designated object. + // + // Parameters: + // In: inRef - The reference of the item. + // Out: outParentRef - The pointer which receives reference. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetParent")] + public extern static uint EdsGetParent_32(IntPtr inRef, out IntPtr outParentRef); + + [DllImport(DllPath64, EntryPoint = "EdsGetParent")] + public extern static uint EdsGetParent_64(IntPtr inRef, out IntPtr outParentRef); + + public static uint EdsGetParent(IntPtr inRef, out IntPtr outParentRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetParent_32(inRef, out outParentRef) : EdsGetParent_64(inRef, out outParentRef); + } + + /*---------------------------------- + Property operating functions + ----------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetPropertySize + // + // Description: + // Gets the byte size and data type of a designated property + // from a camera object or image object. + // + // Parameters: + // In: inRef - The reference of the item. + // inPropertyID - The ProprtyID + // inParam - Additional information of property. + // We use this parameter in order to specify an index + // in case there are two or more values over the same ID. + // Out: outDataType - Pointer to the buffer that is to receive the property + // type data. + // outSize - Pointer to the buffer that is to receive the property + // size. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetPropertySize")] + public extern static uint EdsGetPropertySize_32(IntPtr inRef, uint inPropertyID, int inParam, out EdsDataType outDataType, out int outSize); + + [DllImport(DllPath64, EntryPoint = "EdsGetPropertySize")] + public extern static uint EdsGetPropertySize_64(IntPtr inRef, uint inPropertyID, int inParam, out EdsDataType outDataType, out int outSize); + + public static uint EdsGetPropertySize(IntPtr inRef, uint inPropertyID, int inParam, out EdsDataType outDataType, out int outSize) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetPropertySize_32(inRef, inPropertyID, inParam, out outDataType, out outSize) : EdsGetPropertySize_64(inRef, inPropertyID, inParam, out outDataType, out outSize); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetPropertyData + // + // Description: + // Gets property information from the object designated in inRef. + // + // Parameters: + // In: inRef - The reference of the item. + // inPropertyID - The ProprtyID + // inParam - Additional information of property. + // We use this parameter in order to specify an index + // in case there are two or more values over the same ID. + // inPropertySize - The number of bytes of the prepared buffer + // for receive property-value. + // Out: outPropertyData - The buffer pointer to receive property-value. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetPropertyData")] + public extern static uint EdsGetPropertyData_32(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, IntPtr outPropertyData); + + [DllImport(DllPath64, EntryPoint = "EdsGetPropertyData")] + public extern static uint EdsGetPropertyData_64(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, IntPtr outPropertyData); + + + public static uint EdsGetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, IntPtr outPropertyData) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetPropertyData_32(inRef, inPropertyID, inParam, inPropertySize, outPropertyData) : EdsGetPropertyData_64(inRef, inPropertyID, inParam, inPropertySize, outPropertyData); + } + + #region GetPorpertyData Wrapper + + public static uint EdsGetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, out uint outPropertyData) + { + int size = Marshal.SizeOf(typeof(uint)); + IntPtr ptr = Marshal.AllocHGlobal(size); + uint err = EdsGetPropertyData(inRef, inPropertyID, inParam, size, ptr); + + outPropertyData = (uint)Marshal.PtrToStructure(ptr, typeof(uint)); + Marshal.FreeHGlobal(ptr); + return err; + } + + public static uint EdsGetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, + out Edsdk.EdsTime outPropertyData) + { + int size = Marshal.SizeOf(typeof(Edsdk.EdsTime)); + IntPtr ptr = Marshal.AllocHGlobal(size); + uint err = EdsGetPropertyData(inRef, inPropertyID, inParam, size, ptr); + + outPropertyData = (Edsdk.EdsTime)Marshal.PtrToStructure(ptr, typeof(Edsdk.EdsTime)); + Marshal.FreeHGlobal(ptr); + return err; + } + + public static uint EdsGetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, out string outPropertyData) + { + IntPtr ptr = Marshal.AllocHGlobal(256); + uint err = EdsGetPropertyData(inRef, inPropertyID, inParam, 256, ptr); + + outPropertyData = Marshal.PtrToStringAnsi(ptr); + Marshal.FreeHGlobal(ptr); + + return err; + } + #endregion + + /*----------------------------------------------------------------------------- + // + // Function: EdsSetPropertyData + // + // Description: + // Sets property data for the object designated in inRef. + // + // Parameters: + // In: inRef - The reference of the item. + // inPropertyID - The ProprtyID + // inParam - Additional information of property. + // inPropertySize - The number of bytes of the prepared buffer + // for set property-value. + // inPropertyData - The buffer pointer to set property-value. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetPropertyData")] + public extern static uint EdsSetPropertyData_32(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, [MarshalAs(UnmanagedType.AsAny), In] object inPropertyData); + + [DllImport(DllPath64, EntryPoint = "EdsSetPropertyData")] + public extern static uint EdsSetPropertyData_64(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, [MarshalAs(UnmanagedType.AsAny), In] object inPropertyData); + + public static uint EdsSetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, [MarshalAs(UnmanagedType.AsAny), In] object inPropertyData) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetPropertyData_32(inRef, inPropertyID, inParam, inPropertySize, inPropertyData) : EdsSetPropertyData_64(inRef, inPropertyID, inParam, inPropertySize, inPropertyData); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetPropertyDesc + // + // Description: + // Gets a list of property data that can be set for the object + // designated in inRef, as well as maximum and minimum values. + // This API is intended for only some shooting-related properties. + // + // Parameters: + // In: inRef - The reference of the camera. + // inPropertyID - The Property ID. + // Out: outPropertyDesc - Array of the value which can be set up. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetPropertyDesc")] + public extern static uint EdsGetPropertyDesc_32(IntPtr inRef, uint inPropertyID, out EdsPropertyDesc outPropertyDesc); + + [DllImport(DllPath64, EntryPoint = "EdsGetPropertyDesc")] + public extern static uint EdsGetPropertyDesc_64(IntPtr inRef, uint inPropertyID, out EdsPropertyDesc outPropertyDesc); + + public static uint EdsGetPropertyDesc(IntPtr inRef, uint inPropertyID, out EdsPropertyDesc outPropertyDesc) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetPropertyDesc_32(inRef, inPropertyID, out outPropertyDesc) : EdsGetPropertyDesc_64(inRef, inPropertyID, out outPropertyDesc); + } + /*-------------------------------------------- + Device-list and device operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetCameraList + // + // Description: + // Gets camera list objects. + // + // Parameters: + // In: None + // Out: outCameraListRef - Pointer to the camera-list. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetCameraList")] + public extern static uint EdsGetCameraList_32(out IntPtr outCameraListRef); + + [DllImport(DllPath64, EntryPoint = "EdsGetCameraList")] + public extern static uint EdsGetCameraList_64(out IntPtr outCameraListRef); + + public static uint EdsGetCameraList(out IntPtr outCameraListRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetCameraList_32(out outCameraListRef) : EdsGetCameraList_64(out outCameraListRef); + } + + /*-------------------------------------------- + Camera operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetDeviceInfo + // + // Description: + // Gets device information, such as the device name. + // Because device information of remote cameras is stored + // on the host computer, you can use this API + // before the camera object initiates communication + // (that is, before a session is opened). + // + // Parameters: + // In: inCameraRef - The reference of the camera. + // Out: outDeviceInfo - Information as device of camera. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetDeviceInfo")] + public extern static uint EdsGetDeviceInfo_32(IntPtr inCameraRef, out EdsDeviceInfo outDeviceInfo); + + [DllImport(DllPath64, EntryPoint = "EdsGetDeviceInfo")] + public extern static uint EdsGetDeviceInfo_64(IntPtr inCameraRef, out EdsDeviceInfo outDeviceInfo); + + public static uint EdsGetDeviceInfo(IntPtr inCameraRef, out EdsDeviceInfo outDeviceInfo) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetDeviceInfo_32(inCameraRef, out outDeviceInfo) : EdsGetDeviceInfo_64(inCameraRef, out outDeviceInfo); + } /*----------------------------------------------------------------------------- + // + // Function: EdsOpenSession + // + // Description: + // Establishes a logical connection with a remote camera. + // Use this API after getting the camera's EdsCamera object. + // + // Parameters: + // In: inCameraRef - The reference of the camera + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsOpenSession")] + public extern static uint EdsOpenSession_32(IntPtr inCameraRef); + + [DllImport(DllPath64, EntryPoint = "EdsOpenSession")] + public extern static uint EdsOpenSession_64(IntPtr inCameraRef); + + public static uint EdsOpenSession(IntPtr inCameraRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsOpenSession_32(inCameraRef) : EdsOpenSession_64(inCameraRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCloseSession + // + // Description: + // Closes a logical connection with a remote camera. + // + // Parameters: + // In: inCameraRef - The reference of the camera + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCloseSession")] + public extern static uint EdsCloseSession_32(IntPtr inCameraRef); + + [DllImport(DllPath64, EntryPoint = "EdsCloseSession")] + public extern static uint EdsCloseSession_64(IntPtr inCameraRef); + + public static uint EdsCloseSession(IntPtr inCameraRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCloseSession_32(inCameraRef) : EdsCloseSession_64(inCameraRef); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsSendCommand + // + // Description: + // Sends a command such as "Shoot" to a remote camera. + // + // Parameters: + // In: inCameraRef - The reference of the camera which will receive the + // command. + // inCommand - Specifies the command to be sent. + // inParam - Specifies additional command-specific information. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSendCommand")] + public extern static uint EdsSendCommand_32(IntPtr inCameraRef, uint inCommand, int inParam); + + [DllImport(DllPath64, EntryPoint = "EdsSendCommand")] + public extern static uint EdsSendCommand_64(IntPtr inCameraRef, uint inCommand, int inParam); + + public static uint EdsSendCommand(IntPtr inCameraRef, uint inCommand, int inParam) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSendCommand_32(inCameraRef, inCommand, inParam) : EdsSendCommand_64(inCameraRef, inCommand, inParam); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSendStatusCommand + // + // Description: + // Sets the remote camera state or mode. + // + // Parameters: + // In: inCameraRef - The reference of the camera which will receive the + // command. + // inStatusCommand - Specifies the command to be sent. + // inParam - Specifies additional command-specific information. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSendStatusCommand")] + public extern static uint EdsSendStatusCommand_32(IntPtr inCameraRef, uint inCameraState, int inParam); + + [DllImport(DllPath64, EntryPoint = "EdsSendStatusCommand")] + public extern static uint EdsSendStatusCommand_64(IntPtr inCameraRef, uint inCameraState, int inParam); + + + public static uint EdsSendStatusCommand(IntPtr inCameraRef, uint inCameraState, int inParam) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSendStatusCommand_32(inCameraRef, inCameraState, inParam) : EdsSendStatusCommand_64(inCameraRef, inCameraState, inParam); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetCapacity + // + // Description: + // Sets the remaining HDD capacity on the host computer + // (excluding the portion from image transfer), + // as calculated by subtracting the portion from the previous time. + // Set a reset flag initially and designate the cluster length + // and number of free clusters. + // Some type 2 protocol standard cameras can display the number of shots + // left on the camera based on the available disk capacity + // of the host computer. + // For these cameras, after the storage destination is set to the computer, + // use this API to notify the camera of the available disk capacity + // of the host computer. + // + // Parameters: + // In: inCameraRef - The reference of the camera which will receive the + // command. + // inCapacity - The remaining capacity of a transmission place. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetCapacity")] + public extern static uint EdsSetCapacity_32(IntPtr inCameraRef, EdsCapacity inCapacity); + + [DllImport(DllPath64, EntryPoint = "EdsSetCapacity")] + public extern static uint EdsSetCapacity_64(IntPtr inCameraRef, EdsCapacity inCapacity); + + public static uint EdsSetCapacity(IntPtr inCameraRef, EdsCapacity inCapacity) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetCapacity_32(inCameraRef, inCapacity) : EdsSetCapacity_64(inCameraRef, inCapacity); + } + + /*-------------------------------------------- + Volume operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetVolumeInfo + // + // Description: + // Gets volume information for a memory card in the camera. + // + // Parameters: + // In: inVolumeRef - The reference of the volume. + // Out: outVolumeInfo - information of the volume. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetVolumeInfo")] + public extern static uint EdsGetVolumeInfo_32(IntPtr inCameraRef, out EdsVolumeInfo outVolumeInfo); + + [DllImport(DllPath64, EntryPoint = "EdsGetVolumeInfo")] + public extern static uint EdsGetVolumeInfo_64(IntPtr inCameraRef, out EdsVolumeInfo outVolumeInfo); + + public static uint EdsGetVolumeInfo(IntPtr inCameraRef, out EdsVolumeInfo outVolumeInfo) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetVolumeInfo_32(inCameraRef, out outVolumeInfo) : EdsGetVolumeInfo_64(inCameraRef, out outVolumeInfo); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsFormatVolume + // + // Description: + // . + // + // Parameters: + // In: inVolumeRef - The reference of volume . + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsFormatVolume")] + public extern static uint EdsFormatVolume_32(IntPtr inVolumeRef); + + [DllImport(DllPath64, EntryPoint = "EdsFormatVolume")] + public extern static uint EdsFormatVolume_64(IntPtr inVolumeRef); + + public static uint EdsFormatVolume(IntPtr inVolumeRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsFormatVolume_32(inVolumeRef) : EdsFormatVolume_64(inVolumeRef); + } + + /*-------------------------------------------- + Directory-item operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsGetDirectoryItemInfo + // + // Description: + // Gets information about the directory or file objects + // on the memory card (volume) in a remote camera. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // Out: outDirItemInfo - information of the directory item. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetDirectoryItemInfo")] + public extern static uint EdsGetDirectoryItemInfo_32(IntPtr inDirItemRef, out EdsDirectoryItemInfo outDirItemInfo); + + [DllImport(DllPath64, EntryPoint = "EdsGetDirectoryItemInfo")] + public extern static uint EdsGetDirectoryItemInfo_64(IntPtr inDirItemRef, out EdsDirectoryItemInfo outDirItemInfo); + + public static uint EdsGetDirectoryItemInfo(IntPtr inDirItemRef, out EdsDirectoryItemInfo outDirItemInfo) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetDirectoryItemInfo_32(inDirItemRef, out outDirItemInfo) : EdsGetDirectoryItemInfo_64(inDirItemRef, out outDirItemInfo); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsDeleteDirectoryItem + // + // Description: + // Deletes a camera folder or file. + // If folders with subdirectories are designated, all files are deleted + // except protected files. + // EdsDirectoryItem objects deleted by means of this API are implicitly + // released by the EDSDK. Thus, there is no need to release them + // by means of EdsRelease. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDeleteDirectoryItem")] + public extern static uint EdsDeleteDirectoryItem_32(IntPtr inDirItemRef); + + [DllImport(DllPath64, EntryPoint = "EdsDeleteDirectoryItem")] + public extern static uint EdsDeleteDirectoryItem_64(IntPtr inDirItemRef); + + public static uint EdsDeleteDirectoryItem(IntPtr inDirItemRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDeleteDirectoryItem_32(inDirItemRef) : EdsDeleteDirectoryItem_64(inDirItemRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsDownload + // + // Description: + // Downloads a file on a remote camera + // (in the camera memory or on a memory card) to the host computer. + // The downloaded file is sent directly to a file stream created in advance. + // When dividing the file being retrieved, call this API repeatedly. + // Also in this case, make the data block size a multiple of 512 (bytes), + // excluding the final block. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // inReadSize - + // + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDownload")] + public extern static uint EdsDownload_32(IntPtr inDirItemRef, UInt64 inReadSize, IntPtr outStream); + + [DllImport(DllPath64, EntryPoint = "EdsDownload")] + public extern static uint EdsDownload_64(IntPtr inDirItemRef, UInt64 inReadSize, IntPtr outStream); + + public static uint EdsDownload(IntPtr inDirItemRef, UInt64 inReadSize, IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownload_32(inDirItemRef, inReadSize, outStream) : EdsDownload_64(inDirItemRef, inReadSize, outStream); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsDownloadCancel + // + // Description: + // Must be executed when downloading of a directory item is canceled. + // Calling this API makes the camera cancel file transmission. + // It also releases resources. + // This operation need not be executed when using EdsDownloadThumbnail. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDownloadCancel")] + public extern static uint EdsDownloadCancel_32(IntPtr inDirItemRef); + + [DllImport(DllPath64, EntryPoint = "EdsDownloadCancel")] + public extern static uint EdsDownloadCancel_64(IntPtr inDirItemRef); + + public static uint EdsDownloadCancel(IntPtr inDirItemRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownloadCancel_32(inDirItemRef) : EdsDownloadCancel_64(inDirItemRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsDownloadComplete + // + // Description: + // Must be called when downloading of directory items is complete. + // Executing this API makes the camera + // recognize that file transmission is complete. + // This operation need not be executed when using EdsDownloadThumbnail. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // + // Out: outStream - None. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDownloadComplete")] + public extern static uint EdsDownloadComplete_32(IntPtr inDirItemRef); + + [DllImport(DllPath64, EntryPoint = "EdsDownloadComplete")] + public extern static uint EdsDownloadComplete_64(IntPtr inDirItemRef); + + public static uint EdsDownloadComplete(IntPtr inDirItemRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownloadComplete_32(inDirItemRef) : EdsDownloadComplete_64(inDirItemRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsDownloadThumbnail + // + // Description: + // Extracts and downloads thumbnail information from image files in a camera. + // Thumbnail information in the camera's image files is downloaded + // to the host computer. + // Downloaded thumbnails are sent directly to a file stream created in advance. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDownloadThumbnail")] + public extern static uint EdsDownloadThumbnail_32(IntPtr inDirItemRef, IntPtr outStream); + + [DllImport(DllPath64, EntryPoint = "EdsDownloadThumbnail")] + public extern static uint EdsDownloadThumbnail_64(IntPtr inDirItemRef, IntPtr outStream); + + public static uint EdsDownloadThumbnail(IntPtr inDirItemRef, IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownloadThumbnail_32(inDirItemRef, outStream) : EdsDownloadThumbnail_64(inDirItemRef, outStream); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetAttribute + // + // Description: + // Gets attributes of files on a camera. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // Out: outFileAttribute - Indicates the file attributes. + // As for the file attributes, OR values of the value defined + // by enum EdsFileAttributes can be retrieved. Thus, when + // determining the file attributes, you must check + // if an attribute flag is set for target attributes. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetAttribute")] + public extern static uint EdsGetAttribute_32(IntPtr inDirItemRef, out EdsFileAttribute outFileAttribute); + + [DllImport(DllPath64, EntryPoint = "EdsGetAttribute")] + public extern static uint EdsGetAttribute_64(IntPtr inDirItemRef, out EdsFileAttribute outFileAttribute); + + public static uint EdsDeleteDirectoryItem(IntPtr inDirItemRef, out EdsFileAttribute outFileAttribute) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetAttribute_32(inDirItemRef, out outFileAttribute) : EdsGetAttribute_64(inDirItemRef, out outFileAttribute); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetAttribute + // + // Description: + // Changes attributes of files on a camera. + // + // Parameters: + // In: inDirItemRef - The reference of the directory item. + // inFileAttribute - Indicates the file attributes. + // As for the file attributes, OR values of the value + // defined by enum EdsFileAttributes can be retrieved. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetAttribute")] + public extern static uint EdsSetAttribute_32(IntPtr inDirItemRef, EdsFileAttribute inFileAttribute); + + [DllImport(DllPath64, EntryPoint = "EdsSetAttribute")] + public extern static uint EdsSetAttribute_64(IntPtr inDirItemRef, EdsFileAttribute inFileAttribute); + + public static uint EdsSetAttribute(IntPtr inDirItemRef, EdsFileAttribute inFileAttribute) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetAttribute_32(inDirItemRef, inFileAttribute) : EdsSetAttribute_64(inDirItemRef, inFileAttribute); + } + /*-------------------------------------------- + Stream operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateFileStream + // + // Description: + // Creates a new file on a host computer (or opens an existing file) + // and creates a file stream for access to the file. + // If a new file is designated before executing this API, + // the file is actually created following the timing of writing + // by means of EdsWrite or the like with respect to an open stream. + // + // Parameters: + // In: inFileName - Pointer to a null-terminated string that specifies + // the file name. + // inCreateDisposition - Action to take on files that exist, + // and which action to take when files do not exist. + // inDesiredAccess - Access to the stream (reading, writing, or both). + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateFileStream")] + public extern static uint EdsCreateFileStream_32(string inFileName, EdsFileCreateDisposition inCreateDisposition, EdsAccess inDesiredAccess, out IntPtr outStream); + + [DllImport(DllPath64, EntryPoint = "EdsCreateFileStream")] + public extern static uint EdsCreateFileStream_64(string inFileName, EdsFileCreateDisposition inCreateDisposition, EdsAccess inDesiredAccess, out IntPtr outStream); + + public static uint EdsCreateFileStream(string inFileName, EdsFileCreateDisposition inCreateDisposition, EdsAccess inDesiredAccess, out IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateFileStream_32(inFileName, inCreateDisposition, inDesiredAccess, out outStream) : EdsCreateFileStream_64(inFileName, inCreateDisposition, inDesiredAccess, out outStream); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateMemoryStream + // + // Description: + // Creates a stream in the memory of a host computer. + // In the case of writing in excess of the allocated buffer size, + // the memory is automatically extended. + // + // Parameters: + // In: inBufferSize - The number of bytes of the memory to allocate. + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateMemoryStream")] + public extern static uint EdsCreateMemoryStream_32(UInt64 inBufferSize, out IntPtr outStream); + + [DllImport(DllPath64, EntryPoint = "EdsCreateMemoryStream")] + public extern static uint EdsCreateMemoryStream_64(UInt64 inBufferSize, out IntPtr outStream); + + + public static uint EdsCreateMemoryStream(UInt64 inBufferSize, out IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateMemoryStream_32(inBufferSize, out outStream) : EdsCreateMemoryStream_64(inBufferSize, out outStream); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateStreamEx + // + // Description: + // An extended version of EdsCreateStreamFromFile. + // Use this function when working with Unicode file names. + // + // Parameters: + // In: inFileName - Designate the file name. + // inCreateDisposition - Action to take on files that exist, + // and which action to take when files do not exist. + // inDesiredAccess - Access to the stream (reading, writing, or both). + // + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateStreamEx")] + public extern static uint EdsCreateStreamEx_32( + string inFileName, + EdsFileCreateDisposition inCreateDisposition, + EdsAccess inDesiredAccess, + out IntPtr outStream + ); + [DllImport(DllPath64, EntryPoint = "EdsCreateStreamEx")] + public extern static uint EdsCreateStreamEx_64( + string inFileName, EdsFileCreateDisposition inCreateDisposition, EdsAccess inDesiredAccess, out IntPtr outStream + ); + + public static uint EdsCreateStreamEx(string inFileName, EdsFileCreateDisposition inCreateDisposition, EdsAccess inDesiredAccess, out IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateStreamEx_32(inFileName, inCreateDisposition, inDesiredAccess, out outStream) : EdsCreateStreamEx_64(inFileName, inCreateDisposition, inDesiredAccess, out outStream); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateMemoryStreamFromPointer + // + // Description: + // Creates a stream from the memory buffer you prepare. + // Unlike the buffer size of streams created by means of EdsCreateMemoryStream, + // the buffer size you prepare for streams created this way does not expand. + // + // Parameters: + // In: inBufferSize - The number of bytes of the memory to allocate. + // Out: outStream - The reference of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateMemoryStreamFromPointer")] + public extern static uint EdsCreateMemoryStreamFromPointer_32(byte[] inUserBuffer, UInt64 inBufferSize, out IntPtr outStream); + + [DllImport(DllPath64, EntryPoint = "EdsCreateMemoryStreamFromPointer")] + public extern static uint EdsCreateMemoryStreamFromPointer_64(byte[] inUserBuffer, UInt64 inBufferSize, out IntPtr outStream); + + public static uint EdsCreateMemoryStreamFromPointer(byte[] inUserBuffer, UInt64 inBufferSize, out IntPtr outStream) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateMemoryStreamFromPointer_32(inUserBuffer, inBufferSize, out outStream) : EdsCreateMemoryStreamFromPointer_64(inUserBuffer, inBufferSize, out outStream); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetPointer + // + // Description: + // Gets the pointer to the start address of memory managed by the memory stream. + // As the EDSDK automatically resizes the buffer, the memory stream provides + // you with the same access methods as for the file stream. + // If access is attempted that is excessive with regard to the buffer size + // for the stream, data before the required buffer size is allocated + // is copied internally, and new writing occurs. + // Thus, the buffer pointer might be switched on an unknown timing. + // Caution in use is therefore advised. + // + // Parameters: + // In: inStream - Designate the memory stream for the pointer to retrieve. + // Out: outPointer - If successful, returns the pointer to the buffer + // written in the memory stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetPointer")] + public extern static uint EdsGetPointer_32(IntPtr inStreamRef, out IntPtr outPointer); + + [DllImport(DllPath64, EntryPoint = "EdsGetPointer")] + public extern static uint EdsGetPointer_64(IntPtr inStreamRef, out IntPtr outPointer); + + + public static uint EdsGetPointer(IntPtr inStreamRef, out IntPtr outPointe) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetPointer_32(inStreamRef, out outPointe) : EdsGetPointer_64(inStreamRef, out outPointe); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsRead + // + // Description: + // Reads data the size of inReadSize into the outBuffer buffer, + // starting at the current read or write position of the stream. + // The size of data actually read can be designated in outReadSize. + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // inReadSize - The number of bytes to read. + // Out: outBuffer - Pointer to the user-supplied buffer that is to receive + // the data read from the stream. + // outReadSize - The actually read number of bytes. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsRead")] + public extern static uint EdsRead_32(IntPtr inStreamRef, UInt64 inReadSize, IntPtr outBuffer, out UInt64 outReadSize); + + [DllImport(DllPath64, EntryPoint = "EdsRead")] + public extern static uint EdsRead_64(IntPtr inStreamRef, UInt64 inReadSize, IntPtr outBuffer, out UInt64 outReadSize); + + public static uint EdsRead(IntPtr inStreamRef, UInt64 inReadSize, IntPtr outBuffer, out UInt64 outReadSize) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsRead_32(inStreamRef, inReadSize, outBuffer, out outReadSize) : EdsRead_64(inStreamRef, inReadSize, outBuffer, out outReadSize); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsWrite + // + // Description: + // Writes data of a designated buffer + // to the current read or write position of the stream. + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // inWriteSize - The number of bytes to write. + // inBuffer - A pointer to the user-supplied buffer that contains + // the data to be written to the stream. + // Out: outWrittenSize - The actually written-in number of bytes. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsWrite")] + public extern static uint EdsWrite_32(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr inBuffer, out uint outWrittenSize); + + [DllImport(DllPath64, EntryPoint = "EdsWrite")] + public extern static uint EdsWrite_64(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr inBuffer, out uint outWrittenSize); + + public static uint EdsWrite(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr inBuffer, out uint outWrittenSize) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsWrite_32(inStreamRef, inWriteSize, inBuffer, out outWrittenSize) : EdsWrite_64(inStreamRef, inWriteSize, inBuffer, out outWrittenSize); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSeek + // + // Description: + // Moves the read or write position of the stream + (that is, the file position indicator). + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // inSeekOffset - Number of bytes to move the pointer. + // inSeekOrigin - Pointer movement mode. Must be one of the following + // values. + // kEdsSeek_Cur Move the stream pointer inSeekOffset bytes + // from the current position in the stream. + // kEdsSeek_Begin Move the stream pointer inSeekOffset bytes + // forward from the beginning of the stream. + // kEdsSeek_End Move the stream pointer inSeekOffset bytes + // from the end of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSeek")] + public extern static uint EdsSeek_32(IntPtr inStreamRef, Int64 inSeekOffset, EdsSeekOrigin inSeekOrigin); + + [DllImport(DllPath64, EntryPoint = "EdsSeek")] + public extern static uint EdsSeek_64(IntPtr inStreamRef, Int64 inSeekOffset, EdsSeekOrigin inSeekOrigin); + + public static uint EdsSeek(IntPtr inStreamRef, Int64 inSeekOffset, EdsSeekOrigin inSeekOrigin) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSeek_32(inStreamRef, inSeekOffset, inSeekOrigin) : EdsSeek_64(inStreamRef, inSeekOffset, inSeekOrigin); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetPosition + // + // Description: + // Gets the current read or write position of the stream + // (that is, the file position indicator). + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // Out: outPosition - The current stream pointer. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetPosition")] + public extern static uint EdsGetPosition_32(IntPtr inStreamRef, out UInt64 outPosition); + + [DllImport(DllPath64, EntryPoint = "EdsGetPosition")] + public extern static uint EdsGetPosition_64(IntPtr inStreamRef, out UInt64 outPosition); + + public static uint EdsGetPosition(IntPtr inStreamRef, out UInt64 outPosition) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetPosition_32(inStreamRef, out outPosition) : EdsGetPosition_64(inStreamRef, out outPosition); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetLength + // + // Description: + // Gets the stream size. + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // Out: outLength - The length of the stream. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetLength")] + public extern static uint EdsGetLength_32(IntPtr inStreamRef, out UInt64 outLength); + + [DllImport(DllPath64, EntryPoint = "EdsGetLength")] + public extern static uint EdsGetLength_64(IntPtr inStreamRef, out UInt64 outLength); + + public static uint EdsGetLength(IntPtr inStreamRef, out UInt64 outLength) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetLength_32(inStreamRef, out outLength) : EdsGetLength_64(inStreamRef, out outLength); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCopyData + // + // Description: + // Copies data from the copy source stream to the copy destination stream. + // The read or write position of the data to copy is determined from + // the current file read or write position of the respective stream. + // After this API is executed, the read or write positions of the copy source + // and copy destination streams are moved an amount corresponding to + // inWriteSize in the positive direction. + // + // Parameters: + // In: inStreamRef - The reference of the stream or image. + // inWriteSize - The number of bytes to copy. + // Out: outStreamRef - The reference of the stream or image. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCopyData")] + public extern static uint EdsCopyData_32(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr outStreamRef); + + [DllImport(DllPath64, EntryPoint = "EdsCopyData")] + public extern static uint EdsCopyData_64(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr outStreamRef); + + public static uint EdsCopyData(IntPtr inStreamRef, UInt64 inWriteSize, IntPtr outStreamRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCopyData_32(inStreamRef, inWriteSize, outStreamRef) : EdsCopyData_64(inStreamRef, inWriteSize, outStreamRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetProgressCallback + // + // Description: + // Register a progress callback function. + // An event is received as notification of progress during processing that + // takes a relatively long time, such as downloading files from a + // remote camera. + // If you register the callback function, the EDSDK calls the callback + // function during execution or on completion of the following APIs. + // This timing can be used in updating on-screen progress bars, for example. + // + // Parameters: + // In: inRef - The reference of the stream or image. + // inProgressCallback - Pointer to a progress callback function. + // inProgressOption - The option about progress is specified. + // Must be one of the following values. + // kEdsProgressOption_Done + // When processing is completed,a callback function + // is called only at once. + // kEdsProgressOption_Periodically + // A callback function is performed periodically. + // inContext - Application information, passed in the argument + // when the callback function is called. Any information + // required for your program may be added. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetProgressCallback")] + public extern static uint EdsSetProgressCallback_32(IntPtr inRef, EdsProgressCallback inProgressFunc, EdsProgressOption inProgressOption, IntPtr inContext); + + [DllImport(DllPath64, EntryPoint = "EdsSetProgressCallback")] + public extern static uint EdsSetProgressCallback_64(IntPtr inRef, EdsProgressCallback inProgressFunc, EdsProgressOption inProgressOption, IntPtr inContext); + + public static uint EdsSetProgressCallback(IntPtr inRef, EdsProgressCallback inProgressFunc, EdsProgressOption inProgressOption, IntPtr inContext) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetProgressCallback_32(inRef, inProgressFunc, inProgressOption, inContext) : EdsSetProgressCallback_64(inRef, inProgressFunc, inProgressOption, inContext); + } + + /*-------------------------------------------- + Image operating functions + ---------------------------------------------*/ + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateImageRef + // + // Description: + // Creates an image object from an image file. + // Without modification, stream objects cannot be worked with as images. + // Thus, when extracting images from image files, + // you must use this API to create image objects. + // The image object created this way can be used to get image information + // (such as the height and width, number of color components, and + // resolution), thumbnail image data, and the image data itself. + // + // Parameters: + // In: inStreamRef - The reference of the stream. + // + // Out: outImageRef - The reference of the image. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateImageRef")] + public extern static uint EdsCreateImageRef_32(IntPtr inStreamRef, out IntPtr outImageRef); + + [DllImport(DllPath64, EntryPoint = "EdsCreateImageRef")] + public extern static uint EdsCreateImageRef_64(IntPtr inStreamRef, out IntPtr outImageRef); + + public static uint EdsCreateImageRef(IntPtr inStreamRef, out IntPtr outImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateImageRef_32(inStreamRef, out outImageRef) : EdsCreateImageRef_64(inStreamRef, out outImageRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetImageInfo + // + // Description: + // Gets image information from a designated image object. + // Here, image information means the image width and height, + // number of color components, resolution, and effective image area. + // + // Parameters: + // In: inStreamRef - Designate the object for which to get image information. + // inImageSource - Of the various image data items in the image file, + // designate the type of image data representing the + // information you want to get. Designate the image as + // defined in Enum EdsImageSource. + // + // kEdsImageSrc_FullView + // The image itself (a full-sized image) + // kEdsImageSrc_Thumbnail + // A thumbnail image + // kEdsImageSrc_Preview + // A preview image + // kEdsImageSrc_RAWThumbnail + // A RAW thumbnail image + // kEdsImageSrc_RAWFullView + // A RAW full-sized image + // Out: outImageInfo - Stores the image data information designated + // in inImageSource. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetImageInfo")] + public extern static uint EdsGetImageInfo_32(IntPtr inImageRef, EdsImageSource inImageSource, out EdsImageInfo outImageInfo); + + [DllImport(DllPath64, EntryPoint = "EdsGetImageInfo")] + public extern static uint EdsGetImageInfo_64(IntPtr inImageRef, EdsImageSource inImageSource, out EdsImageInfo outImageInfo); + + public static uint EdsGetImageInfo(IntPtr inImageRef, EdsImageSource inImageSource, out EdsImageInfo outImageInfo) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetImageInfo_32(inImageRef, inImageSource, out outImageInfo) : EdsGetImageInfo_64(inImageRef, inImageSource, out outImageInfo); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsGetImage + // + // Description: + // Gets designated image data from an image file, in the form of a + // designated rectangle. + // Returns uncompressed results for JPEGs and processed results + // in the designated pixel order (RGB, Top-down BGR, and so on) for + // RAW images. + // Additionally, by designating the input/output rectangle, + // it is possible to get reduced, enlarged, or partial images. + // However, because images corresponding to the designated output rectangle + // are always returned by the SDK, the SDK does not take the aspect + // ratio into account. + // To maintain the aspect ratio, you must keep the aspect ratio in mind + // when designating the rectangle. + // + // Parameters: + // In: + // inImageRef - Designate the image object for which to get + // the image data. + // inImageSource - Designate the type of image data to get from + // the image file (thumbnail, preview, and so on). + // Designate values as defined in Enum EdsImageSource. + // inImageType - Designate the output image type. Because + // the output format of EdGetImage may only be RGB, only + // kEdsTargetImageType_RGB or kEdsTargetImageType_RGB16 + // can be designated. + // However, image types exceeding the resolution of + // inImageSource cannot be designated. + // inSrcRect - Designate the coordinates and size of the rectangle + // to be retrieved (processed) from the source image. + // inDstSize - Designate the rectangle size for output. + // + // Out: + // outStreamRef - Designate the memory or file stream for output of + // the image. + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsGetImage")] + public extern static uint EdsGetImage_32(IntPtr inImageRef, EdsImageSource inImageSource, EdsTargetImageType inImageType, EdsRect inSrcRect, EdsSize inDstSize, IntPtr outStreamRef); + + [DllImport(DllPath64, EntryPoint = "EdsGetImage")] + public extern static uint EdsGetImage_64(IntPtr inImageRef, EdsImageSource inImageSource, EdsTargetImageType inImageType, EdsRect inSrcRect, EdsSize inDstSize, IntPtr outStreamRef); + + public static uint EdsGetImage(IntPtr inImageRef, EdsImageSource inImageSource, EdsTargetImageType inImageType, EdsRect inSrcRect, EdsSize inDstSize, IntPtr outStreamRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsGetImage_32(inImageRef, inImageSource, inImageType, inSrcRect, inDstSize, outStreamRef) : EdsGetImage_64(inImageRef, inImageSource, inImageType, inSrcRect, inDstSize, outStreamRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSaveImage + // + // Description: + // Saves as a designated image type after RAW processing. + // When saving with JPEG compression, + // the JPEG quality setting applies with respect to EdsOptionRef. + // + // Parameters: + // In: + // inImageRef - Designate the image object for which to produce the file. + // inImageType - Designate the image type to produce. Designate the + // following image types. + // + // kEdsTargetImageType - Jpeg JPEG + // kEdsTargetImageType - TIFF 8-bit TIFF + // kEdsTargetImageType - TIFF16 16-bit TIFF + // inSaveSetting - Designate saving options, such as JPEG image quality. + // Out: + // outStreamRef - Specifies the output file stream. The memory stream + // cannot be specified here. + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSaveImage")] + public extern static uint EdsSaveImage_32(IntPtr inImageRef, EdsTargetImageType inImageType, EdsSaveImageSetting inSaveSetting, IntPtr outStreamRef); + + [DllImport(DllPath64, EntryPoint = "EdsSaveImage")] + public extern static uint EdsSaveImage_64(IntPtr inImageRef, EdsTargetImageType inImageType, EdsSaveImageSetting inSaveSetting, IntPtr outStreamRef); + + public static uint EdsSaveImage(IntPtr inImageRef, EdsTargetImageType inImageType, EdsSaveImageSetting inSaveSetting, IntPtr outStreamRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSaveImage_32(inImageRef, inImageType, inSaveSetting, outStreamRef) : EdsSaveImage_64(inImageRef, inImageType, inSaveSetting, outStreamRef); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCacheImage + // + // Description: + // Switches a setting on and off for creation of an image cache in the SDK + // for a designated image object during extraction (processing) of + // the image data. + // Creating the cache increases the processing speed, starting from + // the second time. + // + // Parameters: + // In: inImageRef - The reference of the image. + // inUseCache - If cache image data or not + // If set to FALSE, the cached image data will released. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCacheImage")] + public extern static uint EdsCacheImage_32(IntPtr inImageRef, bool inUseCache); + + [DllImport(DllPath64, EntryPoint = "EdsCacheImage")] + public extern static uint EdsCacheImage_64(IntPtr inImageRef, bool inUseCache); + + public static uint EdsCacheImage(IntPtr inImageRef, bool inUseCache) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCacheImage_32(inImageRef, inUseCache) : EdsCacheImage_64(inImageRef, inUseCache); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsReflectImageProperty + // Description: + // Incorporates image object property changes + // (effected by means of EdsSetPropertyData) in the stream. + // + // Parameters: + // In: inImageRef - The reference of the image. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsReflectImageProperty")] + public extern static uint EdsReflectImageProperty_32(IntPtr inImageRef); + + [DllImport(DllPath64, EntryPoint = "EdsReflectImageProperty")] + public extern static uint EdsReflectImageProperty_64(IntPtr inImageRef); + + public static uint EdsReflectImageProperty(IntPtr inImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsReflectImageProperty_32(inImageRef) : EdsReflectImageProperty_64(inImageRef); + } + //---------------------------------------------- + // Event handler registering functions + //---------------------------------------------- + /*----------------------------------------------------------------------------- + // + // Function: EdsSetCameraAddedHandler + // + // Description: + // Registers a callback function for when a camera is detected. + // + // Parameters: + // In: inCameraAddedHandler - Pointer to a callback function + // called when a camera is connected physically + // inContext - Specifies an application-defined value to be sent to + // the callback function pointed to by CallBack parameter. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetCameraAddedHandler")] + public extern static uint EdsSetCameraAddedHandler_32(EdsCameraAddedHandler inCameraAddedHandler, IntPtr inContext); + + [DllImport(DllPath64, EntryPoint = "EdsSetCameraAddedHandler")] + public extern static uint EdsSetCameraAddedHandler_64(EdsCameraAddedHandler inCameraAddedHandler, IntPtr inContext); + + public static uint EdsSetCameraAddedHandler(EdsCameraAddedHandler inCameraAddedHandler, IntPtr inContext) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetCameraAddedHandler_32(inCameraAddedHandler, inContext) : EdsSetCameraAddedHandler_64(inCameraAddedHandler, inContext); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetPropertyEventHandler + // + // Description: + // Registers a callback function for receiving status + // change notification events for property states on a camera. + // + // Parameters: + // In: inCameraRef - Designate the camera object. + // inEvent - Designate one or all events to be supplemented. + // inPropertyEventHandler - Designate the pointer to the callback + // function for receiving property-related camera events. + // inContext - Designate application information to be passed by + // means of the callback function. Any data needed for + // your application can be passed. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetPropertyEventHandler")] + public extern static uint EdsSetPropertyEventHandler_32(IntPtr inCameraRef, uint inEvent, EdsPropertyEventHandler inPropertyEventHandler, IntPtr inContext); + + [DllImport(DllPath64, EntryPoint = "EdsSetPropertyEventHandler")] + public extern static uint EdsSetPropertyEventHandler_64(IntPtr inCameraRef, uint inEvent, EdsPropertyEventHandler inPropertyEventHandler, IntPtr inContext); + + public static uint EdsSetPropertyEventHandler(IntPtr inCameraRef, uint inEvent, EdsPropertyEventHandler inPropertyEventHandler, IntPtr inContext) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetPropertyEventHandler_32(inCameraRef, inEvent, inPropertyEventHandler, inContext) : EdsSetPropertyEventHandler_64(inCameraRef, inEvent, inPropertyEventHandler, inContext); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetObjectEventHandler + // + // Description: + // Registers a callback function for receiving status + // change notification events for objects on a remote camera. + // Here, object means volumes representing memory cards, files and directories, + // and shot images stored in memory, in particular. + // + // Parameters: + // In: inCameraRef - Designate the camera object. + // inEvent - Designate one or all events to be supplemented. + // To designate all events, use kEdsObjectEvent_All. + // inObjectEventHandler - Designate the pointer to the callback function + // for receiving object-related camera events. + // inContext - Passes inContext without modification, + // as designated as an EdsSetObjectEventHandler argument. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetObjectEventHandler")] + public extern static uint EdsSetObjectEventHandler_32(IntPtr inCameraRef, uint inEvent, EdsObjectEventHandler inObjectEventHandler, IntPtr inContext); + + [DllImport(DllPath64, EntryPoint = "EdsSetObjectEventHandler")] + public extern static uint EdsSetObjectEventHandler_64(IntPtr inCameraRef, uint inEvent, EdsObjectEventHandler inObjectEventHandler, IntPtr inContext); + + public static uint EdsSetObjectEventHandler(IntPtr inCameraRef, uint inEvent, EdsObjectEventHandler inObjectEventHandler, IntPtr inContext) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetObjectEventHandler_32(inCameraRef, inEvent, inObjectEventHandler, inContext) : EdsSetObjectEventHandler_64(inCameraRef, inEvent, inObjectEventHandler, inContext); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsSetCameraStateEventHandler + // + // Description: + // Registers a callback function for receiving status + // change notification events for property states on a camera. + // + // Parameters: + // In: inCameraRef - Designate the camera object. + // inEvent - Designate one or all events to be supplemented. + // To designate all events, use kEdsStateEvent_All. + // inStateEventHandler - Designate the pointer to the callback function + // for receiving events related to camera object states. + // inContext - Designate application information to be passed + // by means of the callback function. Any data needed for + // your application can be passed. + // Out: None + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsSetCameraStateEventHandler")] + public extern static uint EdsSetCameraStateEventHandler_32(IntPtr inCameraRef, uint inEvent, EdsStateEventHandler inStateEventHandler, IntPtr inContext); + + [DllImport(DllPath64, EntryPoint = "EdsSetCameraStateEventHandler")] + public extern static uint EdsSetCameraStateEventHandler_64(IntPtr inCameraRef, uint inEvent, EdsStateEventHandler inStateEventHandler, IntPtr inContext); + + public static uint EdsSetCameraStateEventHandler(IntPtr inCameraRef, uint inEvent, EdsStateEventHandler inStateEventHandler, IntPtr inContext) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetCameraStateEventHandler_32(inCameraRef, inEvent, inStateEventHandler, inContext) : EdsSetCameraStateEventHandler_64(inCameraRef, inEvent, inStateEventHandler, inContext); + } + /*----------------------------------------------------------------------------- + // + // Function: EdsCreateEvfImageRef + // Description: + // Creates an object used to get the live view image data set. + // + // Parameters: + // In: inStreamRef - The stream reference which opened to get EVF JPEG image. + // Out: outEvfImageRef - The EVFData reference. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsCreateEvfImageRef")] + public extern static uint EdsCreateEvfImageRef_32(IntPtr inStreamRef, out IntPtr outEvfImageRef); + + [DllImport(DllPath64, EntryPoint = "EdsCreateEvfImageRef")] + public extern static uint EdsCreateEvfImageRef_64(IntPtr inStreamRef, out IntPtr outEvfImageRef); + + public static uint EdsCreateEvfImageRef(IntPtr inStreamRef, out IntPtr outEvfImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateEvfImageRef_32(inStreamRef, out outEvfImageRef) : EdsCreateEvfImageRef_64(inStreamRef, out outEvfImageRef); + } + + /*----------------------------------------------------------------------------- + // + // Function: EdsDownloadEvfImage + // Description: + // Downloads the live view image data set for a camera currently in live view mode. + // Live view can be started by using the property ID:kEdsPropertyID_Evf_OutputDevice and + // data:EdsOutputDevice_PC to call EdsSetPropertyData. + // In addition to image data, information such as zoom, focus position, and histogram data + // is included in the image data set. Image data is saved in a stream maintained by EdsEvfImageRef. + // EdsGetPropertyData can be used to get information such as the zoom, focus position, etc. + // Although the information of the zoom and focus position can be obtained from EdsEvfImageRef, + // settings are applied to EdsCameraRef. + // + // Parameters: + // In: inCameraRef - The Camera reference. + // In: inEvfImageRef - The EVFData reference. + // + // Returns: Any of the sdk errors. + -----------------------------------------------------------------------------*/ + [DllImport(DllPath32, EntryPoint = "EdsDownloadEvfImage")] + public extern static uint EdsDownloadEvfImage_32(IntPtr inCameraRef, IntPtr outEvfImageRef); + + [DllImport(DllPath64, EntryPoint = "EdsDownloadEvfImage")] + public extern static uint EdsDownloadEvfImage_64(IntPtr inCameraRef, IntPtr outEvfImageRef); + + public static uint EdsDownloadEvfImage(IntPtr inCameraRef, IntPtr outEvfImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownloadEvfImage_32(inCameraRef, outEvfImageRef) : EdsDownloadEvfImage_64(inCameraRef, outEvfImageRef); + } + #endregion + + + #region Definition of base Structures + + public const int EDS_MAX_NAME = 256; + public const int EDS_TRANSFER_BLOCK_SIZE = 512; + + /*----------------------------------------------------------------------------- + Point + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsPoint + { + public int x; + public int y; + } + + /*----------------------------------------------------------------------------- + Rectangle + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsRect + { + public int x; + public int y; + public int width; + public int height; + } + + /*----------------------------------------------------------------------------- + Size + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsSize + { + public int width; + public int height; + } + + /*----------------------------------------------------------------------------- + Rational + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsRational + { + public int Numerator; + public uint Denominator; + } + + /*----------------------------------------------------------------------------- + Time + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsTime + { + public int Year; + public int Month; + public int Day; + public int Hour; + public int Minute; + public int Second; + public int Milliseconds; + } + + + /*----------------------------------------------------------------------------- + Device Info + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsDeviceInfo + { + [MarshalAs( UnmanagedType.ByValTStr, SizeConst = EDS_MAX_NAME)] + public string szPortName; + + [MarshalAs( UnmanagedType.ByValTStr, SizeConst = EDS_MAX_NAME)] + public string szDeviceDescription; + + public uint DeviceSubType; + + public uint reserved; + } + + /*----------------------------------------------------------------------------- + Volume Info + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsVolumeInfo + { + public uint StorageType; + public uint Access; + public ulong MaxCapacity; + public ulong FreeSpaceInBytes; + + [MarshalAs( UnmanagedType.ByValTStr, SizeConst = EDS_MAX_NAME)] + public string szVolumeLabel; + } + + + /*----------------------------------------------------------------------------- + DirectoryItem Info + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsDirectoryItemInfo + { + public UInt64 Size; + public int isFolder; + public uint GroupID; + public uint Option; + + [MarshalAs( UnmanagedType.ByValTStr, SizeConst=EDS_MAX_NAME)] + public string szFileName; + + public uint format; + public uint dateTime; + } + + + /*----------------------------------------------------------------------------- + Image Info + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsImageInfo + { + public uint Width; // image width + public uint Height; // image height + + public uint NumOfComponents; // number of color components in image. + public uint ComponentDepth; // bits per sample. 8 or 16. + + public EdsRect EffectiveRect; // Effective rectangles except + // a black line of the image. + // A black line might be in the top and bottom + // of the thumbnail image. + + public uint reserved1; + public uint reserved2; + + } + + /*----------------------------------------------------------------------------- + SaveImage Setting + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsSaveImageSetting + { + public uint JPEGQuality; + IntPtr iccProfileStream; + public uint reserved; + } + + /*----------------------------------------------------------------------------- + Property Desc + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsPropertyDesc + { + public int Form; + public uint Access; + public int NumElements; + + [MarshalAs( UnmanagedType.ByValArray, SizeConst=128)] + public int[ ] PropDesc; + } + + /*----------------------------------------------------------------------------- + Picture Style Desc + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsPictureStyleDesc + { + public int contrast; + public uint sharpness; + public int saturation; + public int colorTone; + public uint filterEffect; + public uint toningEffect; + public uint sharpFineness; + public uint sharpThreshold; + } + + /*----------------------------------------------------------------------------- + Focus Info + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential)] + public struct EdsFocusPoint + { + public uint valid; + public uint selected; + public uint justFocus; + public EdsRect rect; + public uint reserved; + } + + [StructLayout(LayoutKind.Sequential)] + public struct EdsFocusInfo + { + public EdsRect imageRect; + public uint pointNumber; + + [MarshalAs( UnmanagedType.ByValArray, SizeConst=128)] + public EdsFocusPoint[] focusPoint; + public uint executeMode; + } + + + /*----------------------------------------------------------------------------- + Capacity + -----------------------------------------------------------------------------*/ + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public struct EdsCapacity + { + public int NumberOfFreeClusters; + public int BytesPerSector; + public int Reset; + } + + #endregion + + + #region Definition of error Codes + + /*----------------------------------------------------------------------- + ED-SDK Error Code Masks + ------------------------------------------------------------------------*/ + public const uint EDS_ISSPECIFIC_MASK = 0x80000000; + public const uint EDS_COMPONENTID_MASK = 0x7F000000; + public const uint EDS_RESERVED_MASK = 0x00FF0000; + public const uint EDS_ERRORID_MASK = 0x0000FFFF; + + /*----------------------------------------------------------------------- + ED-SDK Base Component IDs + ------------------------------------------------------------------------*/ + public const uint EDS_CMP_ID_CLIENT_COMPONENTID = 0x01000000; + public const uint EDS_CMP_ID_LLSDK_COMPONENTID = 0x02000000; + public const uint EDS_CMP_ID_HLSDK_COMPONENTID = 0x03000000; + + /*----------------------------------------------------------------------- + ED-SDK Functin Success Code + ------------------------------------------------------------------------*/ + public const uint EDS_ERR_OK = 0x00000000; + + /*----------------------------------------------------------------------- + ED-SDK Generic Error IDs + ------------------------------------------------------------------------*/ + /* Miscellaneous errors */ + public const uint EDS_ERR_UNIMPLEMENTED = 0x00000001; + public const uint EDS_ERR_INTERNAL_ERROR = 0x00000002; + public const uint EDS_ERR_MEM_ALLOC_FAILED = 0x00000003; + public const uint EDS_ERR_MEM_FREE_FAILED = 0x00000004; + public const uint EDS_ERR_OPERATION_CANCELLED = 0x00000005; + public const uint EDS_ERR_INCOMPATIBLE_VERSION = 0x00000006; + public const uint EDS_ERR_NOT_SUPPORTED = 0x00000007; + public const uint EDS_ERR_UNEXPECTED_EXCEPTION = 0x00000008; + public const uint EDS_ERR_PROTECTION_VIOLATION = 0x00000009; + public const uint EDS_ERR_MISSING_SUBCOMPONENT = 0x0000000A; + public const uint EDS_ERR_SELECTION_UNAVAILABLE = 0x0000000B; + + /* File errors */ + public const uint EDS_ERR_FILE_IO_ERROR = 0x00000020; + public const uint EDS_ERR_FILE_TOO_MANY_OPEN = 0x00000021; + public const uint EDS_ERR_FILE_NOT_FOUND = 0x00000022; + public const uint EDS_ERR_FILE_OPEN_ERROR = 0x00000023; + public const uint EDS_ERR_FILE_CLOSE_ERROR = 0x00000024; + public const uint EDS_ERR_FILE_SEEK_ERROR = 0x00000025; + public const uint EDS_ERR_FILE_TELL_ERROR = 0x00000026; + public const uint EDS_ERR_FILE_READ_ERROR = 0x00000027; + public const uint EDS_ERR_FILE_WRITE_ERROR = 0x00000028; + public const uint EDS_ERR_FILE_PERMISSION_ERROR = 0x00000029; + public const uint EDS_ERR_FILE_DISK_FULL_ERROR = 0x0000002A; + public const uint EDS_ERR_FILE_ALREADY_EXISTS = 0x0000002B; + public const uint EDS_ERR_FILE_FORMAT_UNRECOGNIZED = 0x0000002C; + public const uint EDS_ERR_FILE_DATA_CORRUPT = 0x0000002D; + public const uint EDS_ERR_FILE_NAMING_NA = 0x0000002E; + + /* Directory errors */ + public const uint EDS_ERR_DIR_NOT_FOUND = 0x00000040; + public const uint EDS_ERR_DIR_IO_ERROR = 0x00000041; + public const uint EDS_ERR_DIR_ENTRY_NOT_FOUND = 0x00000042; + public const uint EDS_ERR_DIR_ENTRY_EXISTS = 0x00000043; + public const uint EDS_ERR_DIR_NOT_EMPTY = 0x00000044; + + /* Property errors */ + public const uint EDS_ERR_PROPERTIES_UNAVAILABLE = 0x00000050; + public const uint EDS_ERR_PROPERTIES_MISMATCH = 0x00000051; + public const uint EDS_ERR_PROPERTIES_NOT_LOADED = 0x00000053; + + /* Function Parameter errors */ + public const uint EDS_ERR_INVALID_PARAMETER = 0x00000060; + public const uint EDS_ERR_INVALID_HANDLE = 0x00000061; + public const uint EDS_ERR_INVALID_POINTER = 0x00000062; + public const uint EDS_ERR_INVALID_INDEX = 0x00000063; + public const uint EDS_ERR_INVALID_LENGTH = 0x00000064; + public const uint EDS_ERR_INVALID_FN_POINTER = 0x00000065; + public const uint EDS_ERR_INVALID_SORT_FN = 0x00000066; + + /* Device errors */ + public const uint EDS_ERR_DEVICE_NOT_FOUND = 0x00000080; + public const uint EDS_ERR_DEVICE_BUSY = 0x00000081; + public const uint EDS_ERR_DEVICE_INVALID = 0x00000082; + public const uint EDS_ERR_DEVICE_EMERGENCY = 0x00000083; + public const uint EDS_ERR_DEVICE_MEMORY_FULL = 0x00000084; + public const uint EDS_ERR_DEVICE_INTERNAL_ERROR = 0x00000085; + public const uint EDS_ERR_DEVICE_INVALID_PARAMETER = 0x00000086; + public const uint EDS_ERR_DEVICE_NO_DISK = 0x00000087; + public const uint EDS_ERR_DEVICE_DISK_ERROR = 0x00000088; + public const uint EDS_ERR_DEVICE_CF_GATE_CHANGED = 0x00000089; + public const uint EDS_ERR_DEVICE_DIAL_CHANGED = 0x0000008A; + public const uint EDS_ERR_DEVICE_NOT_INSTALLED = 0x0000008B; + public const uint EDS_ERR_DEVICE_STAY_AWAKE = 0x0000008C; + public const uint EDS_ERR_DEVICE_NOT_RELEASED = 0x0000008D; + + /* Stream errors */ + public const uint EDS_ERR_STREAM_IO_ERROR = 0x000000A0; + public const uint EDS_ERR_STREAM_NOT_OPEN = 0x000000A1; + public const uint EDS_ERR_STREAM_ALREADY_OPEN = 0x000000A2; + public const uint EDS_ERR_STREAM_OPEN_ERROR = 0x000000A3; + public const uint EDS_ERR_STREAM_CLOSE_ERROR = 0x000000A4; + public const uint EDS_ERR_STREAM_SEEK_ERROR = 0x000000A5; + public const uint EDS_ERR_STREAM_TELL_ERROR = 0x000000A6; + public const uint EDS_ERR_STREAM_READ_ERROR = 0x000000A7; + public const uint EDS_ERR_STREAM_WRITE_ERROR = 0x000000A8; + public const uint EDS_ERR_STREAM_PERMISSION_ERROR = 0x000000A9; + public const uint EDS_ERR_STREAM_COULDNT_BEGIN_THREAD = 0x000000AA; + public const uint EDS_ERR_STREAM_BAD_OPTIONS = 0x000000AB; + public const uint EDS_ERR_STREAM_END_OF_STREAM = 0x000000AC; + + /* Communications errors */ + public const uint EDS_ERR_COMM_PORT_IS_IN_USE = 0x000000C0; + public const uint EDS_ERR_COMM_DISCONNECTED = 0x000000C1; + public const uint EDS_ERR_COMM_DEVICE_INCOMPATIBLE = 0x000000C2; + public const uint EDS_ERR_COMM_BUFFER_FULL = 0x000000C3; + public const uint EDS_ERR_COMM_USB_BUS_ERR = 0x000000C4; + + /* Lock/Unlock */ + public const uint EDS_ERR_USB_DEVICE_LOCK_ERROR = 0x000000D0; + public const uint EDS_ERR_USB_DEVICE_UNLOCK_ERROR = 0x000000D1; + + /* STI/WIA */ + public const uint EDS_ERR_STI_UNKNOWN_ERROR = 0x000000E0; + public const uint EDS_ERR_STI_INTERNAL_ERROR = 0x000000E1; + public const uint EDS_ERR_STI_DEVICE_CREATE_ERROR = 0x000000E2; + public const uint EDS_ERR_STI_DEVICE_RELEASE_ERROR = 0x000000E3; + public const uint EDS_ERR_DEVICE_NOT_LAUNCHED = 0x000000E4; + + public const uint EDS_ERR_ENUM_NA = 0x000000F0; + public const uint EDS_ERR_INVALID_FN_CALL = 0x000000F1; + public const uint EDS_ERR_HANDLE_NOT_FOUND = 0x000000F2; + public const uint EDS_ERR_INVALID_ID = 0x000000F3; + public const uint EDS_ERR_WAIT_TIMEOUT_ERROR = 0x000000F4; + + /* PTP */ + public const uint EDS_ERR_SESSION_NOT_OPEN = 0x00002003; + public const uint EDS_ERR_INVALID_TRANSACTIONID = 0x00002004; + public const uint EDS_ERR_INCOMPLETE_TRANSFER = 0x00002007; + public const uint EDS_ERR_INVALID_STRAGEID = 0x00002008; + public const uint EDS_ERR_DEVICEPROP_NOT_SUPPORTED = 0x0000200A; + public const uint EDS_ERR_INVALID_OBJECTFORMATCODE = 0x0000200B; + public const uint EDS_ERR_SELF_TEST_FAILED = 0x00002011; + public const uint EDS_ERR_PARTIAL_DELETION = 0x00002012; + public const uint EDS_ERR_SPECIFICATION_BY_FORMAT_UNSUPPORTED = 0x00002014; + public const uint EDS_ERR_NO_VALID_OBJECTINFO = 0x00002015; + public const uint EDS_ERR_INVALID_CODE_FORMAT = 0x00002016; + public const uint EDS_ERR_UNKNOWN_VENDER_CODE = 0x00002017; + public const uint EDS_ERR_CAPTURE_ALREADY_TERMINATED = 0x00002018; + public const uint EDS_ERR_INVALID_PARENTOBJECT = 0x0000201A; + public const uint EDS_ERR_INVALID_DEVICEPROP_FORMAT = 0x0000201B; + public const uint EDS_ERR_INVALID_DEVICEPROP_VALUE = 0x0000201C; + public const uint EDS_ERR_SESSION_ALREADY_OPEN = 0x0000201E; + public const uint EDS_ERR_TRANSACTION_CANCELLED = 0x0000201F; + public const uint EDS_ERR_SPECIFICATION_OF_DESTINATION_UNSUPPORTED = 0x00002020; + public const uint EDS_ERR_UNKNOWN_COMMAND = 0x0000A001; + public const uint EDS_ERR_OPERATION_REFUSED = 0x0000A005; + public const uint EDS_ERR_LENS_COVER_CLOSE = 0x0000A006; + public const uint EDS_ERR_LOW_BATTERY = 0x0000A101; + public const uint EDS_ERR_OBJECT_NOTREADY = 0x0000A102; + + /* Capture Error */ + public const uint EDS_ERR_TAKE_PICTURE_AF_NG = 0x00008D01; + public const uint EDS_ERR_TAKE_PICTURE_RESERVED = 0x00008D02; + public const uint EDS_ERR_TAKE_PICTURE_MIRROR_UP_NG = 0x00008D03; + public const uint EDS_ERR_TAKE_PICTURE_SENSOR_CLEANING_NG = 0x00008D04; + public const uint EDS_ERR_TAKE_PICTURE_SILENCE_NG = 0x00008D05; + public const uint EDS_ERR_TAKE_PICTURE_NO_CARD_NG = 0x00008D06; + public const uint EDS_ERR_TAKE_PICTURE_CARD_NG = 0x00008D07; + public const uint EDS_ERR_TAKE_PICTURE_CARD_PROTECT_NG = 0x00008D08; + + + public const uint EDS_ERR_LAST_GENERIC_ERROR_PLUS_ONE = 0x000000F5; + + #endregion + + + } +} \ No newline at end of file diff --git a/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDKAddons.cs b/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDKAddons.cs new file mode 100644 index 0000000..5bf39dc --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Internal/SDK/EDSDKAddons.cs @@ -0,0 +1,41 @@ +using System; +using System.Runtime.InteropServices; + +namespace Canon.Eos.Framework.Internal.SDK +{ + public partial class Edsdk + { + + [DllImport(DllPath32, EntryPoint = "EdsSetPropertyData")] + public extern static uint EdsSetPropertyData_32(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, byte[] inPropertyData); + + [DllImport(DllPath64, EntryPoint = "EdsSetPropertyData")] + public extern static uint EdsSetPropertyData_64(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, byte[] inPropertyData); + + public static uint EdsSetPropertyData(IntPtr inRef, uint inPropertyID, int inParam, int inPropertySize, byte[] inPropertyData) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsSetPropertyData_32(inRef, inPropertyID, inParam, inPropertySize, inPropertyData) : EdsSetPropertyData_64(inRef, inPropertyID, inParam, inPropertySize, inPropertyData); + } + + [DllImport(DllPath32, EntryPoint = "EdsCreateEvfImageRef")] + public extern static uint EdsCreateEvfImageRefCdecl_32(IntPtr inStreamRef, out IntPtr outEvfImageRef); + [DllImport(DllPath64, EntryPoint = "EdsCreateEvfImageRef")] + public extern static uint EdsCreateEvfImageRefCdecl_64(IntPtr inStreamRef, out IntPtr outEvfImageRef); + + public static uint EdsCreateEvfImageRefCdecl(IntPtr inStreamRef, out IntPtr outEvfImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsCreateEvfImageRef_32(inStreamRef, out outEvfImageRef) : EdsCreateEvfImageRef_64(inStreamRef, out outEvfImageRef); + } + + [DllImport(DllPath32, EntryPoint = "EdsDownloadEvfImage")] + public extern static uint EdsDownloadEvfImageCdecl_32(IntPtr inCameraRef, IntPtr outEvfImageRef); + [DllImport(DllPath64, EntryPoint = "EdsDownloadEvfImage")] + public extern static uint EdsDownloadEvfImageCdecl_64(IntPtr inCameraRef, IntPtr outEvfImageRef); + + public static uint EdsDownloadEvfImageCdecl(IntPtr inCameraRef, IntPtr outEvfImageRef) + { + return IntPtr.Size == 4 /* 64bit */ ? EdsDownloadEvfImage_32(inCameraRef, outEvfImageRef) : EdsDownloadEvfImage_64(inCameraRef, outEvfImageRef); + } + + } +} \ No newline at end of file diff --git a/DigiCamControl/Canon.Eos.Framework/Properties/AssemblyInfo.cs b/DigiCamControl/Canon.Eos.Framework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ad3f655 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Canon.Eos.Framework")] +[assembly: AssemblyDescription("An open-source .NET framwork for the Canon EDSDK")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("20Three Ways - Sascha Kiefer")] +[assembly: AssemblyProduct("Canon.Eos.Framework")] +[assembly: AssemblyCopyright("Copyright © 2011-2012 20Three Ways - Sascha Kiefer")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("3a70507d-c50a-47ca-b920-303d687631ec")] +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] \ No newline at end of file diff --git a/DigiCamControl/Canon.Eos.Framework/Threading/BackgroundWorker.cs b/DigiCamControl/Canon.Eos.Framework/Threading/BackgroundWorker.cs new file mode 100644 index 0000000..8af6971 --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/Threading/BackgroundWorker.cs @@ -0,0 +1,49 @@ +using System; +using System.Threading; + +namespace Canon.Eos.Framework.Threading +{ + internal class BackgroundWorker + { + public void Work(Action callback) + { + var state = new State(false) { Callback = () => { callback(); return true; } }; + if (!ThreadPool.QueueUserWorkItem(BackgroundWorker.PerformUserWork, state)) + throw new ApplicationException("Unable to queue user work item."); + } + + public TResult WorkAndWait(Func callback, int millisecondsWaitTimeout = Timeout.Infinite) + { + var state = new State { Callback = callback }; + if (!ThreadPool.QueueUserWorkItem(BackgroundWorker.PerformUserWork, state)) + throw new ApplicationException("Unable to queue user work item."); + if (!state.WaitHandle.WaitOne(millisecondsWaitTimeout)) + throw new TimeoutException(); + return state.Result; + } + + private static void PerformUserWork(object workItem) + { + var state = (State)workItem; + state.Result = state.Callback(); + if(state.WaitHandle != null) + state.WaitHandle.Set(); + } + + private class State + { + public State(bool wait = true) + { + if(wait) + this.WaitHandle = new ManualResetEvent(false); + } + + public T Result { get; set; } + + public Func Callback { get; set; } + + public ManualResetEvent WaitHandle { get; private set; } + + } + } +} diff --git a/DigiCamControl/Canon.Eos.Framework/packages.config b/DigiCamControl/Canon.Eos.Framework/packages.config new file mode 100644 index 0000000..702580e --- /dev/null +++ b/DigiCamControl/Canon.Eos.Framework/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DigiCamControl/PortableDeviceLib/ClassDiagram1.cd b/DigiCamControl/PortableDeviceLib/ClassDiagram1.cd new file mode 100644 index 0000000..6c22a65 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/ClassDiagram1.cd @@ -0,0 +1,18 @@ + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + PortableDevice.cs + + + + + + AIAEAAAAAAAAABAAAAAAAAQAAAAAgAEAYAAAAAAAAAA= + PortableDeviceCollection.cs + + + + \ No newline at end of file diff --git a/DigiCamControl/PortableDeviceLib/ContentType.cs b/DigiCamControl/PortableDeviceLib/ContentType.cs new file mode 100644 index 0000000..8e6f49d --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/ContentType.cs @@ -0,0 +1,126 @@ +#region License +/* +ContentType.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceApiLib; + +namespace PortableDeviceLib +{ + /// + /// + /// + public class ContentType + { + + private Dictionary formats; + + /// + /// Initialize a new instance of the class + /// + /// + /// + /// + internal ContentType(PortableDeviceClass portableDeviceClass, Guid guid, string name) + { + if (guid == Guid.Empty) + throw new Exception("guid cann't be Guid.Empty"); + if (string.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); + + formats = new Dictionary(); + this.Guid = guid; + this.Name = name; + + this.ExtractSupportedFormat(portableDeviceClass, guid); + } + + /// + /// Gets or sets the guid of the content type + /// + public Guid Guid + { + get; + private set; + } + + /// + /// Gets or sets the name of the content type + /// + public string Name + { + get; + private set; + } + + /// + /// Gets or sets the supported format + /// + public IEnumerable SupportedFormats + { + get + { + return formats.Values; + } + } + + private void ExtractSupportedFormat(PortableDeviceClass portableDeviceClass, Guid contentType) + { + if (portableDeviceClass == null) + throw new PortableDeviceException(""); + + PortableDeviceApiLib.IPortableDeviceCapabilities capabilities; + portableDeviceClass.Capabilities(out capabilities); + + if (capabilities == null) + { + System.Diagnostics.Trace.WriteLine("Cannot extract capabilities from device"); + throw new PortableDeviceException("Cannot extract capabilities from device"); + } + + + PortableDeviceApiLib.IPortableDeviceValues pValues = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + + //Functional objects variables + IPortableDevicePropVariantCollection formats; + uint countObjects = 1; + tag_inner_PROPVARIANT values = new tag_inner_PROPVARIANT(); + string formatName; + Guid currentFormat; + capabilities.GetSupportedFormats(ref contentType, out formats); + + formats.GetCount(ref countObjects); + for (uint i = 0; i < countObjects; i++) + { + formats.GetAt(i, ref values); + + pValues.SetValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS, ref values); + pValues.GetStringValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS, out formatName); + currentFormat = new Guid(formatName); + this.formats.Add(currentFormat, PortableDeviceHelpers.GetKeyNameFromGuid(currentFormat)); + } + + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/DevicePortablePKeys.cs b/DigiCamControl/PortableDeviceLib/DevicePortablePKeys.cs new file mode 100644 index 0000000..d0d00ac --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/DevicePortablePKeys.cs @@ -0,0 +1,1840 @@ +#region License +/* +DevicePortablePKeys.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using PortableDeviceApiLib; + +namespace PortableDeviceLib +{ + /// + /// Regroup default item from WPD + /// + public class PortableDevicePKeys + { + /// + /// + /// + static PortableDevicePKeys() + { + WPD_RESOURCE_DEFAULT.fmtid = new Guid(0xE81E79BE, 0x34F0, 0x41BF, 0xB5, 0x3F, 0xF1, 0xA0, 0x6A, 0xE8, 0x78, 0x42); + WPD_RESOURCE_DEFAULT.pid = 0; + + WPD_RESOURCE_CONTACT_PHOTO.fmtid = new Guid(0x2C4D6803, 0x80EA, 0x4580, 0xAF, 0x9A, 0x5B, 0xE1, 0xA2, 0x3E, 0xDD, 0xCB); + WPD_RESOURCE_CONTACT_PHOTO.pid = 0; + + WPD_RESOURCE_THUMBNAIL.fmtid = new Guid(0xC7C407BA, 0x98FA, 0x46B5, 0x99, 0x60, 0x23, 0xFE, 0xC1, 0x24, 0xCF, 0xDE); + WPD_RESOURCE_THUMBNAIL.pid = 0; + + WPD_RESOURCE_ICON.fmtid = new Guid(0xF195FED8, 0xAA28, 0x4EE3, 0xB1, 0x53, 0xE1, 0x82, 0xDD, 0x5E, 0xDC, 0x39); + WPD_RESOURCE_ICON.pid = 0; + + WPD_RESOURCE_AUDIO_CLIP.fmtid = new Guid(0x3BC13982, 0x85B1, 0x48E0, 0x95, 0xA6, 0x8D, 0x3A, 0xD0, 0x6B, 0xE1, 0x17); + WPD_RESOURCE_AUDIO_CLIP.pid = 0; + + WPD_RESOURCE_ALBUM_ART.fmtid = new Guid(0xF02AA354, 0x2300, 0x4E2D, 0xA1, 0xB9, 0x3B, 0x67, 0x30, 0xF7, 0xFA, 0x21); + WPD_RESOURCE_ALBUM_ART.pid = 0; + + WPD_RESOURCE_GENERIC.fmtid = new Guid(0xB9B9F515, 0xBA70, 0x4647, 0x94, 0xDC, 0xFA, 0x49, 0x25, 0xE9, 0x5A, 0x07); + WPD_RESOURCE_GENERIC.pid = 0; + + WPD_RESOURCE_VIDEO_CLIP.fmtid = new Guid(0xB566EE42, 0x6368, 0x4290, 0x86, 0x62, 0x70, 0x18, 0x2F, 0xB7, 0x9F, 0x20); + WPD_RESOURCE_VIDEO_CLIP.pid = 0; + + WPD_RESOURCE_BRANDING_ART.fmtid = new Guid(0xB633B1AE, 0x6CAF, 0x4A87, 0x95, 0x89, 0x22, 0xDE, 0xD6, 0xDD, 0x58, 0x99); + WPD_RESOURCE_BRANDING_ART.pid = 0; + + WPD_PROPERTY_NULL.fmtid = new Guid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + WPD_PROPERTY_NULL.pid = 0; + + WPD_OBJECT_ID.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_ID.pid = 2; + + WPD_OBJECT_PARENT_ID.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_PARENT_ID.pid = 3; + + WPD_OBJECT_NAME.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_NAME.pid = 4; + + WPD_OBJECT_PERSISTENT_UNIQUE_ID.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_PERSISTENT_UNIQUE_ID.pid = 5; + + WPD_OBJECT_FORMAT.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_FORMAT.pid = 6; + + WPD_OBJECT_CONTENT_TYPE.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_CONTENT_TYPE.pid = 7; + + WPD_OBJECT_ISHIDDEN.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_ISHIDDEN.pid = 9; + + WPD_OBJECT_ISSYSTEM.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_ISSYSTEM.pid = 10; + + WPD_OBJECT_SIZE.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_SIZE.pid = 11; + + WPD_OBJECT_ORIGINAL_FILE_NAME.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_ORIGINAL_FILE_NAME.pid = 12; + + WPD_OBJECT_NON_CONSUMABLE.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_NON_CONSUMABLE.pid = 13; + + WPD_OBJECT_REFERENCES.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_REFERENCES.pid = 14; + + WPD_OBJECT_KEYWORDS.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_KEYWORDS.pid = 15; + + WPD_OBJECT_SYNC_ID.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_SYNC_ID.pid = 16; + + WPD_OBJECT_IS_DRM_PROTECTED.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_IS_DRM_PROTECTED.pid = 17; + + WPD_OBJECT_DATE_CREATED.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_DATE_CREATED.pid = 18; + + WPD_OBJECT_DATE_MODIFIED.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_DATE_MODIFIED.pid = 19; + + WPD_OBJECT_DATE_AUTHORED.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_DATE_AUTHORED.pid = 20; + + WPD_OBJECT_BACK_REFERENCES.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_BACK_REFERENCES.pid = 21; + + WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID.pid = 23; + + WPD_OBJECT_GENERATE_THUMBNAIL_FROM_RESOURCE.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_GENERATE_THUMBNAIL_FROM_RESOURCE.pid = 24; + + WPD_OBJECT_HINT_LOCATION_DISPLAY_NAME.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_HINT_LOCATION_DISPLAY_NAME.pid = 25; + + WPD_OBJECT_CAN_DELETE.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); + WPD_OBJECT_CAN_DELETE.pid = 26; + + WPD_FUNCTIONAL_OBJECT_CATEGORY.fmtid = new Guid(0x8F052D93, 0xABCA, 0x4FC5, 0xA5, 0xAC, 0xB0, 0x1D, 0xF4, 0xDB, 0xE5, 0x98); + WPD_FUNCTIONAL_OBJECT_CATEGORY.pid = 2; + + WPD_FOLDER_CONTENT_TYPES_ALLOWED.fmtid = new Guid(0x7E9A7ABF, 0xE568, 0x4B34, 0xAA, 0x2F, 0x13, 0xBB, 0x12, 0xAB, 0x17, 0x7D); + WPD_FOLDER_CONTENT_TYPES_ALLOWED.pid = 2; + + WPD_IMAGE_BITDEPTH.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_BITDEPTH.pid = 3; + + WPD_IMAGE_CROPPED_STATUS.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_CROPPED_STATUS.pid = 4; + + WPD_IMAGE_COLOR_CORRECTED_STATUS.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_COLOR_CORRECTED_STATUS.pid = 5; + + WPD_IMAGE_FNUMBER.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_FNUMBER.pid = 6; + + WPD_IMAGE_EXPOSURE_TIME.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_EXPOSURE_TIME.pid = 7; + + WPD_IMAGE_EXPOSURE_INDEX.fmtid = new Guid(0x63D64908, 0x9FA1, 0x479F, 0x85, 0xBA, 0x99, 0x52, 0x21, 0x64, 0x47, 0xDB); + WPD_IMAGE_EXPOSURE_INDEX.pid = 8; + + WPD_MEDIA_TOTAL_BITRATE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_TOTAL_BITRATE.pid = 2; + + WPD_MEDIA_BITRATE_TYPE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_BITRATE_TYPE.pid = 3; + + WPD_MEDIA_COPYRIGHT.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_COPYRIGHT.pid = 4; + + WPD_MEDIA_SUBSCRIPTION_CONTENT_ID.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SUBSCRIPTION_CONTENT_ID.pid = 5; + + WPD_MEDIA_USE_COUNT.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_USE_COUNT.pid = 6; + + WPD_MEDIA_SKIP_COUNT.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SKIP_COUNT.pid = 7; + + WPD_MEDIA_LAST_ACCESSED_TIME.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_LAST_ACCESSED_TIME.pid = 8; + + WPD_MEDIA_PARENTAL_RATING.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_PARENTAL_RATING.pid = 9; + + WPD_MEDIA_META_GENRE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_META_GENRE.pid = 10; + + WPD_MEDIA_COMPOSER.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_COMPOSER.pid = 11; + + WPD_MEDIA_EFFECTIVE_RATING.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_EFFECTIVE_RATING.pid = 12; + + WPD_MEDIA_SUB_TITLE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SUB_TITLE.pid = 13; + + WPD_MEDIA_RELEASE_DATE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_RELEASE_DATE.pid = 14; + + WPD_MEDIA_SAMPLE_RATE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SAMPLE_RATE.pid = 15; + + WPD_MEDIA_STAR_RATING.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_STAR_RATING.pid = 16; + + WPD_MEDIA_USER_EFFECTIVE_RATING.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_USER_EFFECTIVE_RATING.pid = 17; + + WPD_MEDIA_TITLE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_TITLE.pid = 18; + + WPD_MEDIA_DURATION.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_DURATION.pid = 19; + + WPD_MEDIA_BUY_NOW.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_BUY_NOW.pid = 20; + + WPD_MEDIA_ENCODING_PROFILE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_ENCODING_PROFILE.pid = 21; + + WPD_MEDIA_WIDTH.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_WIDTH.pid = 22; + + WPD_MEDIA_HEIGHT.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_HEIGHT.pid = 23; + + WPD_MEDIA_ARTIST.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_ARTIST.pid = 24; + + WPD_MEDIA_ALBUM_ARTIST.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_ALBUM_ARTIST.pid = 25; + + WPD_MEDIA_OWNER.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_OWNER.pid = 26; + + WPD_MEDIA_MANAGING_EDITOR.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_MANAGING_EDITOR.pid = 27; + + WPD_MEDIA_WEBMASTER.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_WEBMASTER.pid = 28; + + WPD_MEDIA_SOURCE_URL.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SOURCE_URL.pid = 29; + + WPD_MEDIA_DESTINATION_URL.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_DESTINATION_URL.pid = 30; + + WPD_MEDIA_DESCRIPTION.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_DESCRIPTION.pid = 31; + + WPD_MEDIA_GENRE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_GENRE.pid = 32; + + WPD_MEDIA_TIME_BOOKMARK.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_TIME_BOOKMARK.pid = 33; + + WPD_MEDIA_OBJECT_BOOKMARK.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_OBJECT_BOOKMARK.pid = 34; + + WPD_MEDIA_LAST_BUILD_DATE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_LAST_BUILD_DATE.pid = 35; + + WPD_MEDIA_BYTE_BOOKMARK.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_BYTE_BOOKMARK.pid = 36; + + WPD_MEDIA_TIME_TO_LIVE.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_TIME_TO_LIVE.pid = 37; + + WPD_MEDIA_GUID.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_GUID.pid = 38; + + WPD_MEDIA_SUB_DESCRIPTION.fmtid = new Guid(0x2ED8BA05, 0x0AD3, 0x42DC, 0xB0, 0xD0, 0xBC, 0x95, 0xAC, 0x39, 0x6A, 0xC8); + WPD_MEDIA_SUB_DESCRIPTION.pid = 39; + + WPD_CONTACT_DISPLAY_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_DISPLAY_NAME.pid = 2; + + WPD_CONTACT_FIRST_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_FIRST_NAME.pid = 3; + + WPD_CONTACT_MIDDLE_NAMES.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_MIDDLE_NAMES.pid = 4; + + WPD_CONTACT_LAST_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_LAST_NAME.pid = 5; + + WPD_CONTACT_PREFIX.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PREFIX.pid = 6; + + WPD_CONTACT_SUFFIX.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_SUFFIX.pid = 7; + + WPD_CONTACT_PHONETIC_FIRST_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PHONETIC_FIRST_NAME.pid = 8; + + WPD_CONTACT_PHONETIC_LAST_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PHONETIC_LAST_NAME.pid = 9; + + WPD_CONTACT_PERSONAL_FULL_POSTAL_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_FULL_POSTAL_ADDRESS.pid = 10; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE1.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE1.pid = 11; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE2.pid = 12; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_CITY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_CITY.pid = 13; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_REGION.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_REGION.pid = 14; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_POSTAL_CODE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_POSTAL_CODE.pid = 15; + + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_COUNTRY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_COUNTRY.pid = 16; + + WPD_CONTACT_BUSINESS_FULL_POSTAL_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_FULL_POSTAL_ADDRESS.pid = 17; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE1.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE1.pid = 18; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE2.pid = 19; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_CITY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_CITY.pid = 20; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_REGION.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_REGION.pid = 21; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_POSTAL_CODE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_POSTAL_CODE.pid = 22; + + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_COUNTRY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_COUNTRY.pid = 23; + + WPD_CONTACT_OTHER_FULL_POSTAL_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_FULL_POSTAL_ADDRESS.pid = 24; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE1.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE1.pid = 25; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE2.pid = 26; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_CITY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_CITY.pid = 27; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_REGION.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_REGION.pid = 28; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_CODE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_CODE.pid = 29; + + WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_COUNTRY.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_COUNTRY.pid = 30; + + WPD_CONTACT_PRIMARY_EMAIL_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PRIMARY_EMAIL_ADDRESS.pid = 31; + + WPD_CONTACT_PERSONAL_EMAIL.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_EMAIL.pid = 32; + + WPD_CONTACT_PERSONAL_EMAIL2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_EMAIL2.pid = 33; + + WPD_CONTACT_BUSINESS_EMAIL.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_EMAIL.pid = 34; + + WPD_CONTACT_BUSINESS_EMAIL2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_EMAIL2.pid = 35; + + WPD_CONTACT_OTHER_EMAILS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_EMAILS.pid = 36; + + WPD_CONTACT_PRIMARY_PHONE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PRIMARY_PHONE.pid = 37; + + WPD_CONTACT_PERSONAL_PHONE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_PHONE.pid = 38; + + WPD_CONTACT_PERSONAL_PHONE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_PHONE2.pid = 39; + + WPD_CONTACT_BUSINESS_PHONE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_PHONE.pid = 40; + + WPD_CONTACT_BUSINESS_PHONE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_PHONE2.pid = 41; + + WPD_CONTACT_MOBILE_PHONE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_MOBILE_PHONE.pid = 42; + + WPD_CONTACT_MOBILE_PHONE2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_MOBILE_PHONE2.pid = 43; + + WPD_CONTACT_PERSONAL_FAX.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_FAX.pid = 44; + + WPD_CONTACT_BUSINESS_FAX.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_FAX.pid = 45; + + WPD_CONTACT_PAGER.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PAGER.pid = 46; + + WPD_CONTACT_OTHER_PHONES.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_OTHER_PHONES.pid = 47; + + WPD_CONTACT_PRIMARY_WEB_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PRIMARY_WEB_ADDRESS.pid = 48; + + WPD_CONTACT_PERSONAL_WEB_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PERSONAL_WEB_ADDRESS.pid = 49; + + WPD_CONTACT_BUSINESS_WEB_ADDRESS.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BUSINESS_WEB_ADDRESS.pid = 50; + + WPD_CONTACT_INSTANT_MESSENGER.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_INSTANT_MESSENGER.pid = 51; + + WPD_CONTACT_INSTANT_MESSENGER2.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_INSTANT_MESSENGER2.pid = 52; + + WPD_CONTACT_INSTANT_MESSENGER3.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_INSTANT_MESSENGER3.pid = 53; + + WPD_CONTACT_COMPANY_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_COMPANY_NAME.pid = 54; + + WPD_CONTACT_PHONETIC_COMPANY_NAME.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PHONETIC_COMPANY_NAME.pid = 55; + + WPD_CONTACT_ROLE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_ROLE.pid = 56; + + WPD_CONTACT_BIRTHDATE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_BIRTHDATE.pid = 57; + + WPD_CONTACT_PRIMARY_FAX.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_PRIMARY_FAX.pid = 58; + + WPD_CONTACT_SPOUSE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_SPOUSE.pid = 59; + + WPD_CONTACT_CHILDREN.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_CHILDREN.pid = 60; + + WPD_CONTACT_ASSISTANT.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_ASSISTANT.pid = 61; + + WPD_CONTACT_ANNIVERSARY_DATE.fmtid = new Guid(0xFBD4FDAB, 0x987D, 0x4777, 0xB3, 0xF9, 0x72, 0x61, 0x85, 0xA9, 0x31, 0x2B); + WPD_CONTACT_ANNIVERSARY_DATE.pid = 62; + + WPD_MUSIC_ALBUM.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_MUSIC_ALBUM.pid = 3; + + WPD_MUSIC_TRACK.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_MUSIC_TRACK.pid = 4; + + WPD_MUSIC_LYRICS.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_MUSIC_LYRICS.pid = 6; + + WPD_MUSIC_MOOD.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_MUSIC_MOOD.pid = 8; + + WPD_AUDIO_BITRATE.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_AUDIO_BITRATE.pid = 9; + + WPD_AUDIO_CHANNEL_COUNT.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_AUDIO_CHANNEL_COUNT.pid = 10; + + WPD_AUDIO_FORMAT_CODE.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_AUDIO_FORMAT_CODE.pid = 11; + + WPD_AUDIO_BIT_DEPTH.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_AUDIO_BIT_DEPTH.pid = 12; + + WPD_AUDIO_BLOCK_ALIGNMENT.fmtid = new Guid(0xB324F56A, 0xDC5D, 0x46E5, 0xB6, 0xDF, 0xD2, 0xEA, 0x41, 0x48, 0x88, 0xC6); + WPD_AUDIO_BLOCK_ALIGNMENT.pid = 13; + + WPD_VIDEO_AUTHOR.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_AUTHOR.pid = 2; + + WPD_VIDEO_RECORDEDTV_STATION_NAME.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_RECORDEDTV_STATION_NAME.pid = 4; + + WPD_VIDEO_RECORDEDTV_CHANNEL_NUMBER.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_RECORDEDTV_CHANNEL_NUMBER.pid = 5; + + WPD_VIDEO_RECORDEDTV_REPEAT.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_RECORDEDTV_REPEAT.pid = 7; + + WPD_VIDEO_BUFFER_SIZE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_BUFFER_SIZE.pid = 8; + + WPD_VIDEO_CREDITS.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_CREDITS.pid = 9; + + WPD_VIDEO_KEY_FRAME_DISTANCE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_KEY_FRAME_DISTANCE.pid = 10; + + WPD_VIDEO_QUALITY_SETTING.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_QUALITY_SETTING.pid = 11; + + WPD_VIDEO_SCAN_TYPE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_SCAN_TYPE.pid = 12; + + WPD_VIDEO_BITRATE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_BITRATE.pid = 13; + + WPD_VIDEO_FOURCC_CODE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_FOURCC_CODE.pid = 14; + + WPD_VIDEO_FRAMERATE.fmtid = new Guid(0x346F2163, 0xF998, 0x4146, 0x8B, 0x01, 0xD1, 0x9B, 0x4C, 0x00, 0xDE, 0x9A); + WPD_VIDEO_FRAMERATE.pid = 15; + + WPD_COMMON_INFORMATION_SUBJECT.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_SUBJECT.pid = 2; + + WPD_COMMON_INFORMATION_BODY_TEXT.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_BODY_TEXT.pid = 3; + + WPD_COMMON_INFORMATION_PRIORITY.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_PRIORITY.pid = 4; + + WPD_COMMON_INFORMATION_START_DATETIME.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_START_DATETIME.pid = 5; + + WPD_COMMON_INFORMATION_END_DATETIME.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_END_DATETIME.pid = 6; + + WPD_COMMON_INFORMATION_NOTES.fmtid = new Guid(0xB28AE94B, 0x05A4, 0x4E8E, 0xBE, 0x01, 0x72, 0xCC, 0x7E, 0x09, 0x9D, 0x8F); + WPD_COMMON_INFORMATION_NOTES.pid = 7; + + WPD_EMAIL_TO_LINE.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_TO_LINE.pid = 2; + + WPD_EMAIL_CC_LINE.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_CC_LINE.pid = 3; + + WPD_EMAIL_BCC_LINE.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_BCC_LINE.pid = 4; + + WPD_EMAIL_HAS_BEEN_READ.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_HAS_BEEN_READ.pid = 7; + + WPD_EMAIL_RECEIVED_TIME.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_RECEIVED_TIME.pid = 8; + + WPD_EMAIL_HAS_ATTACHMENTS.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_HAS_ATTACHMENTS.pid = 9; + + WPD_EMAIL_SENDER_ADDRESS.fmtid = new Guid(0x41F8F65A, 0x5484, 0x4782, 0xB1, 0x3D, 0x47, 0x40, 0xDD, 0x7C, 0x37, 0xC5); + WPD_EMAIL_SENDER_ADDRESS.pid = 10; + + WPD_APPOINTMENT_LOCATION.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_LOCATION.pid = 3; + + WPD_APPOINTMENT_TYPE.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_TYPE.pid = 7; + + WPD_APPOINTMENT_REQUIRED_ATTENDEES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_REQUIRED_ATTENDEES.pid = 8; + + WPD_APPOINTMENT_OPTIONAL_ATTENDEES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_OPTIONAL_ATTENDEES.pid = 9; + + WPD_APPOINTMENT_ACCEPTED_ATTENDEES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_ACCEPTED_ATTENDEES.pid = 10; + + WPD_APPOINTMENT_RESOURCES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_RESOURCES.pid = 11; + + WPD_APPOINTMENT_TENTATIVE_ATTENDEES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_TENTATIVE_ATTENDEES.pid = 12; + + WPD_APPOINTMENT_DECLINED_ATTENDEES.fmtid = new Guid(0xF99EFD03, 0x431D, 0x40D8, 0xA1, 0xC9, 0x4E, 0x22, 0x0D, 0x9C, 0x88, 0xD3); + WPD_APPOINTMENT_DECLINED_ATTENDEES.pid = 13; + + WPD_TASK_STATUS.fmtid = new Guid(0xE354E95E, 0xD8A0, 0x4637, 0xA0, 0x3A, 0x0C, 0xB2, 0x68, 0x38, 0xDB, 0xC7); + WPD_TASK_STATUS.pid = 6; + + WPD_TASK_PERCENT_COMPLETE.fmtid = new Guid(0xE354E95E, 0xD8A0, 0x4637, 0xA0, 0x3A, 0x0C, 0xB2, 0x68, 0x38, 0xDB, 0xC7); + WPD_TASK_PERCENT_COMPLETE.pid = 8; + + WPD_TASK_REMINDER_DATE.fmtid = new Guid(0xE354E95E, 0xD8A0, 0x4637, 0xA0, 0x3A, 0x0C, 0xB2, 0x68, 0x38, 0xDB, 0xC7); + WPD_TASK_REMINDER_DATE.pid = 10; + + WPD_TASK_OWNER.fmtid = new Guid(0xE354E95E, 0xD8A0, 0x4637, 0xA0, 0x3A, 0x0C, 0xB2, 0x68, 0x38, 0xDB, 0xC7); + WPD_TASK_OWNER.pid = 11; + + WPD_STORAGE_TYPE.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_TYPE.pid = 2; + + WPD_STORAGE_FILE_SYSTEM_TYPE.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_FILE_SYSTEM_TYPE.pid = 3; + + WPD_STORAGE_CAPACITY.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_CAPACITY.pid = 4; + + WPD_STORAGE_FREE_SPACE_IN_BYTES.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_FREE_SPACE_IN_BYTES.pid = 5; + + WPD_STORAGE_FREE_SPACE_IN_OBJECTS.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_FREE_SPACE_IN_OBJECTS.pid = 6; + + WPD_STORAGE_DESCRIPTION.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_DESCRIPTION.pid = 7; + + WPD_STORAGE_SERIAL_NUMBER.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_SERIAL_NUMBER.pid = 8; + + WPD_STORAGE_MAX_OBJECT_SIZE.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_MAX_OBJECT_SIZE.pid = 9; + + WPD_STORAGE_CAPACITY_IN_OBJECTS.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_CAPACITY_IN_OBJECTS.pid = 10; + + WPD_STORAGE_ACCESS_CAPABILITY.fmtid = new Guid(0x01A3057A, 0x74D6, 0x4E80, 0xBE, 0xA7, 0xDC, 0x4C, 0x21, 0x2C, 0xE5, 0x0A); + WPD_STORAGE_ACCESS_CAPABILITY.pid = 11; + + WPD_NETWORK_ASSOCIATION_HOST_NETWORK_IDENTIFIERS.fmtid = new Guid(0xE4C93C1F, 0xB203, 0x43F1, 0xA1, 0x00, 0x5A, 0x07, 0xD1, 0x1B, 0x02, 0x74); + WPD_NETWORK_ASSOCIATION_HOST_NETWORK_IDENTIFIERS.pid = 2; + + WPD_NETWORK_ASSOCIATION_X509V3SEQUENCE.fmtid = new Guid(0xE4C93C1F, 0xB203, 0x43F1, 0xA1, 0x00, 0x5A, 0x07, 0xD1, 0x1B, 0x02, 0x74); + WPD_NETWORK_ASSOCIATION_X509V3SEQUENCE.pid = 3; + + WPD_STILL_IMAGE_CAPTURE_RESOLUTION.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_CAPTURE_RESOLUTION.pid = 2; + + WPD_STILL_IMAGE_CAPTURE_FORMAT.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_CAPTURE_FORMAT.pid = 3; + + WPD_STILL_IMAGE_COMPRESSION_SETTING.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_COMPRESSION_SETTING.pid = 4; + + WPD_STILL_IMAGE_WHITE_BALANCE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_WHITE_BALANCE.pid = 5; + + WPD_STILL_IMAGE_RGB_GAIN.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_RGB_GAIN.pid = 6; + + WPD_STILL_IMAGE_FNUMBER.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FNUMBER.pid = 7; + + WPD_STILL_IMAGE_FOCAL_LENGTH.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FOCAL_LENGTH.pid = 8; + + WPD_STILL_IMAGE_FOCUS_DISTANCE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FOCUS_DISTANCE.pid = 9; + + WPD_STILL_IMAGE_FOCUS_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FOCUS_MODE.pid = 10; + + WPD_STILL_IMAGE_EXPOSURE_METERING_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EXPOSURE_METERING_MODE.pid = 11; + + WPD_STILL_IMAGE_FLASH_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FLASH_MODE.pid = 12; + + WPD_STILL_IMAGE_EXPOSURE_TIME.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EXPOSURE_TIME.pid = 13; + + WPD_STILL_IMAGE_EXPOSURE_PROGRAM_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EXPOSURE_PROGRAM_MODE.pid = 14; + + WPD_STILL_IMAGE_EXPOSURE_INDEX.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EXPOSURE_INDEX.pid = 15; + + WPD_STILL_IMAGE_EXPOSURE_BIAS_COMPENSATION.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EXPOSURE_BIAS_COMPENSATION.pid = 16; + + WPD_STILL_IMAGE_CAPTURE_DELAY.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_CAPTURE_DELAY.pid = 17; + + WPD_STILL_IMAGE_CAPTURE_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_CAPTURE_MODE.pid = 18; + + WPD_STILL_IMAGE_CONTRAST.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_CONTRAST.pid = 19; + + WPD_STILL_IMAGE_SHARPNESS.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_SHARPNESS.pid = 20; + + WPD_STILL_IMAGE_DIGITAL_ZOOM.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_DIGITAL_ZOOM.pid = 21; + + WPD_STILL_IMAGE_EFFECT_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_EFFECT_MODE.pid = 22; + + WPD_STILL_IMAGE_BURST_NUMBER.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_BURST_NUMBER.pid = 23; + + WPD_STILL_IMAGE_BURST_INTERVAL.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_BURST_INTERVAL.pid = 24; + + WPD_STILL_IMAGE_TIMELAPSE_NUMBER.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_TIMELAPSE_NUMBER.pid = 25; + + WPD_STILL_IMAGE_TIMELAPSE_INTERVAL.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_TIMELAPSE_INTERVAL.pid = 26; + + WPD_STILL_IMAGE_FOCUS_METERING_MODE.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_FOCUS_METERING_MODE.pid = 27; + + WPD_STILL_IMAGE_UPLOAD_URL.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_UPLOAD_URL.pid = 28; + + WPD_STILL_IMAGE_ARTIST.fmtid = new Guid(0x58C571EC, 0x1BCB, 0x42A7, 0x8A, 0xC5, 0xBB, 0x29, 0x15, 0x73, 0xA2, 0x60); + WPD_STILL_IMAGE_ARTIST.pid = 29; + + WPD_SMS_PROVIDER.fmtid = new Guid(0x7E1074CC, 0x50FF, 0x4DD1, 0xA7, 0x42, 0x53, 0xBE, 0x6F, 0x09, 0x3A, 0x0D); + WPD_SMS_PROVIDER.pid = 2; + + WPD_SMS_TIMEOUT.fmtid = new Guid(0x7E1074CC, 0x50FF, 0x4DD1, 0xA7, 0x42, 0x53, 0xBE, 0x6F, 0x09, 0x3A, 0x0D); + WPD_SMS_TIMEOUT.pid = 3; + + WPD_SMS_MAX_PAYLOAD.fmtid = new Guid(0x7E1074CC, 0x50FF, 0x4DD1, 0xA7, 0x42, 0x53, 0xBE, 0x6F, 0x09, 0x3A, 0x0D); + WPD_SMS_MAX_PAYLOAD.pid = 4; + + WPD_SMS_ENCODING.fmtid = new Guid(0x7E1074CC, 0x50FF, 0x4DD1, 0xA7, 0x42, 0x53, 0xBE, 0x6F, 0x09, 0x3A, 0x0D); + WPD_SMS_ENCODING.pid = 5; + + WPD_SECTION_DATA_OFFSET.fmtid = new Guid(0x516AFD2B, 0xC64E, 0x44F0, 0x98, 0xDC, 0xBE, 0xE1, 0xC8, 0x8F, 0x7D, 0x66); + WPD_SECTION_DATA_OFFSET.pid = 2; + + WPD_SECTION_DATA_LENGTH.fmtid = new Guid(0x516AFD2B, 0xC64E, 0x44F0, 0x98, 0xDC, 0xBE, 0xE1, 0xC8, 0x8F, 0x7D, 0x66); + WPD_SECTION_DATA_LENGTH.pid = 3; + + WPD_SECTION_DATA_UNITS.fmtid = new Guid(0x516AFD2B, 0xC64E, 0x44F0, 0x98, 0xDC, 0xBE, 0xE1, 0xC8, 0x8F, 0x7D, 0x66); + WPD_SECTION_DATA_UNITS.pid = 4; + + WPD_SECTION_DATA_REFERENCED_OBJECT_RESOURCE.fmtid = new Guid(0x516AFD2B, 0xC64E, 0x44F0, 0x98, 0xDC, 0xBE, 0xE1, 0xC8, 0x8F, 0x7D, 0x66); + WPD_SECTION_DATA_REFERENCED_OBJECT_RESOURCE.pid = 5; + + WPD_RENDERING_INFORMATION_PROFILES.fmtid = new Guid(0xC53D039F, 0xEE23, 0x4A31, 0x85, 0x90, 0x76, 0x39, 0x87, 0x98, 0x70, 0xB4); + WPD_RENDERING_INFORMATION_PROFILES.pid = 2; + + WPD_RENDERING_INFORMATION_PROFILE_ENTRY_TYPE.fmtid = new Guid(0xC53D039F, 0xEE23, 0x4A31, 0x85, 0x90, 0x76, 0x39, 0x87, 0x98, 0x70, 0xB4); + WPD_RENDERING_INFORMATION_PROFILE_ENTRY_TYPE.pid = 3; + + WPD_RENDERING_INFORMATION_PROFILE_ENTRY_CREATABLE_RESOURCES.fmtid = new Guid(0xC53D039F, 0xEE23, 0x4A31, 0x85, 0x90, 0x76, 0x39, 0x87, 0x98, 0x70, 0xB4); + WPD_RENDERING_INFORMATION_PROFILE_ENTRY_CREATABLE_RESOURCES.pid = 4; + + WPD_CLIENT_NAME.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_NAME.pid = 2; + + WPD_CLIENT_MAJOR_VERSION.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_MAJOR_VERSION.pid = 3; + + WPD_CLIENT_MINOR_VERSION.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_MINOR_VERSION.pid = 4; + + WPD_CLIENT_REVISION.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_REVISION.pid = 5; + + WPD_CLIENT_WMDRM_APPLICATION_PRIVATE_KEY.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_WMDRM_APPLICATION_PRIVATE_KEY.pid = 6; + + WPD_CLIENT_WMDRM_APPLICATION_CERTIFICATE.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_WMDRM_APPLICATION_CERTIFICATE.pid = 7; + + WPD_CLIENT_SECURITY_QUALITY_OF_SERVICE.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_SECURITY_QUALITY_OF_SERVICE.pid = 8; + + WPD_CLIENT_DESIRED_ACCESS.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_DESIRED_ACCESS.pid = 9; + + WPD_CLIENT_SHARE_MODE.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_SHARE_MODE.pid = 10; + + WPD_CLIENT_EVENT_COOKIE.fmtid = new Guid(0x204D9F0C, 0x2292, 0x4080, 0x9F, 0x42, 0x40, 0x66, 0x4E, 0x70, 0xF8, 0x59); + WPD_CLIENT_EVENT_COOKIE.pid = 11; + + WPD_PROPERTY_ATTRIBUTE_FORM.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_FORM.pid = 2; + + WPD_PROPERTY_ATTRIBUTE_CAN_READ.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_CAN_READ.pid = 3; + + WPD_PROPERTY_ATTRIBUTE_CAN_WRITE.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_CAN_WRITE.pid = 4; + + WPD_PROPERTY_ATTRIBUTE_CAN_DELETE.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_CAN_DELETE.pid = 5; + + WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE.pid = 6; + + WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY.pid = 7; + + WPD_PROPERTY_ATTRIBUTE_RANGE_MIN.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_RANGE_MIN.pid = 8; + + WPD_PROPERTY_ATTRIBUTE_RANGE_MAX.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_RANGE_MAX.pid = 9; + + WPD_PROPERTY_ATTRIBUTE_RANGE_STEP.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_RANGE_STEP.pid = 10; + + WPD_PROPERTY_ATTRIBUTE_ENUMERATION_ELEMENTS.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_ENUMERATION_ELEMENTS.pid = 11; + + WPD_PROPERTY_ATTRIBUTE_REGULAR_EXPRESSION.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_REGULAR_EXPRESSION.pid = 12; + + WPD_PROPERTY_ATTRIBUTE_MAX_SIZE.fmtid = new Guid(0xAB7943D8, 0x6332, 0x445F, 0xA0, 0x0D, 0x8D, 0x5E, 0xF1, 0xE9, 0x6F, 0x37); + WPD_PROPERTY_ATTRIBUTE_MAX_SIZE.pid = 13; + + WPD_CLASS_EXTENSION_OPTIONS_SUPPORTED_CONTENT_TYPES.fmtid = new Guid(0x6309FFEF, 0xA87C, 0x4CA7, 0x84, 0x34, 0x79, 0x75, 0x76, 0xE4, 0x0A, 0x96); + WPD_CLASS_EXTENSION_OPTIONS_SUPPORTED_CONTENT_TYPES.pid = 2; + + WPD_CLASS_EXTENSION_OPTIONS_DONT_REGISTER_WPD_DEVICE_INTERFACE.fmtid = new Guid(0x6309FFEF, 0xA87C, 0x4CA7, 0x84, 0x34, 0x79, 0x75, 0x76, 0xE4, 0x0A, 0x96); + WPD_CLASS_EXTENSION_OPTIONS_DONT_REGISTER_WPD_DEVICE_INTERFACE.pid = 3; + + WPD_CLASS_EXTENSION_OPTIONS_REGISTER_WPD_PRIVATE_DEVICE_INTERFACE.fmtid = new Guid(0x6309FFEF, 0xA87C, 0x4CA7, 0x84, 0x34, 0x79, 0x75, 0x76, 0xE4, 0x0A, 0x96); + WPD_CLASS_EXTENSION_OPTIONS_REGISTER_WPD_PRIVATE_DEVICE_INTERFACE.pid = 4; + + WPD_RESOURCE_ATTRIBUTE_TOTAL_SIZE.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_TOTAL_SIZE.pid = 2; + + WPD_RESOURCE_ATTRIBUTE_CAN_READ.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_CAN_READ.pid = 3; + + WPD_RESOURCE_ATTRIBUTE_CAN_WRITE.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_CAN_WRITE.pid = 4; + + WPD_RESOURCE_ATTRIBUTE_CAN_DELETE.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_CAN_DELETE.pid = 5; + + WPD_RESOURCE_ATTRIBUTE_OPTIMAL_READ_BUFFER_SIZE.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_OPTIMAL_READ_BUFFER_SIZE.pid = 6; + + WPD_RESOURCE_ATTRIBUTE_OPTIMAL_WRITE_BUFFER_SIZE.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_OPTIMAL_WRITE_BUFFER_SIZE.pid = 7; + + WPD_RESOURCE_ATTRIBUTE_FORMAT.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_FORMAT.pid = 8; + + WPD_RESOURCE_ATTRIBUTE_RESOURCE_KEY.fmtid = new Guid(0x1EB6F604, 0x9278, 0x429F, 0x93, 0xCC, 0x5B, 0xB8, 0xC0, 0x66, 0x56, 0xB6); + WPD_RESOURCE_ATTRIBUTE_RESOURCE_KEY.pid = 9; + + WPD_DEVICE_SYNC_PARTNER.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_SYNC_PARTNER.pid = 2; + + WPD_DEVICE_FIRMWARE_VERSION.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_FIRMWARE_VERSION.pid = 3; + + WPD_DEVICE_POWER_LEVEL.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_POWER_LEVEL.pid = 4; + + WPD_DEVICE_POWER_SOURCE.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_POWER_SOURCE.pid = 5; + + WPD_DEVICE_PROTOCOL.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_PROTOCOL.pid = 6; + + WPD_DEVICE_MANUFACTURER.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_MANUFACTURER.pid = 7; + + WPD_DEVICE_MODEL.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_MODEL.pid = 8; + + WPD_DEVICE_SERIAL_NUMBER.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_SERIAL_NUMBER.pid = 9; + + WPD_DEVICE_SUPPORTS_NON_CONSUMABLE.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_SUPPORTS_NON_CONSUMABLE.pid = 10; + + WPD_DEVICE_DATETIME.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_DATETIME.pid = 11; + + WPD_DEVICE_FRIENDLY_NAME.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_FRIENDLY_NAME.pid = 12; + + WPD_DEVICE_SUPPORTED_DRM_SCHEMES.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_SUPPORTED_DRM_SCHEMES.pid = 13; + + WPD_DEVICE_SUPPORTED_FORMATS_ARE_ORDERED.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_SUPPORTED_FORMATS_ARE_ORDERED.pid = 14; + + WPD_DEVICE_TYPE.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_TYPE.pid = 15; + + WPD_DEVICE_NETWORK_IDENTIFIER.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC); + WPD_DEVICE_NETWORK_IDENTIFIER.pid = 16; + + WPD_EVENT_PARAMETER_PNP_DEVICE_ID.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_PNP_DEVICE_ID.pid = 2; + + WPD_EVENT_PARAMETER_EVENT_ID.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_EVENT_ID.pid = 3; + + WPD_EVENT_PARAMETER_OPERATION_STATE.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_OPERATION_STATE.pid = 4; + + WPD_EVENT_PARAMETER_OPERATION_PROGRESS.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_OPERATION_PROGRESS.pid = 5; + + WPD_EVENT_PARAMETER_OBJECT_PARENT_PERSISTENT_UNIQUE_ID.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_OBJECT_PARENT_PERSISTENT_UNIQUE_ID.pid = 6; + + WPD_EVENT_PARAMETER_OBJECT_CREATION_COOKIE.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_OBJECT_CREATION_COOKIE.pid = 7; + + WPD_EVENT_PARAMETER_CHILD_HIERARCHY_CHANGED.fmtid = new Guid(0x15AB1953, 0xF817, 0x4FEF, 0xA9, 0x21, 0x56, 0x76, 0xE8, 0x38, 0xF6, 0xE0); + WPD_EVENT_PARAMETER_CHILD_HIERARCHY_CHANGED.pid = 8; + + WPD_EVENT_OPTION_IS_BROADCAST_EVENT.fmtid = new Guid(0xB3D8DAD7, 0xA361, 0x4B83, 0x8A, 0x48, 0x5B, 0x02, 0xCE, 0x10, 0x71, 0x3B); + WPD_EVENT_OPTION_IS_BROADCAST_EVENT.pid = 2; + + WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT.fmtid = new Guid(0xB3D8DAD7, 0xA361, 0x4B83, 0x8A, 0x48, 0x5B, 0x02, 0xCE, 0x10, 0x71, 0x3B); + WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT.pid = 3; + + WPD_API_OPTION_USE_CLEAR_DATA_STREAM.fmtid = new Guid(0x10E54A3E, 0x052D, 0x4777, 0xA1, 0x3C, 0xDE, 0x76, 0x14, 0xBE, 0x2B, 0xC4); + WPD_API_OPTION_USE_CLEAR_DATA_STREAM.pid = 2; + + WPD_API_OPTION_IOCTL_ACCESS.fmtid = new Guid(0x10E54A3E, 0x052D, 0x4777, 0xA1, 0x3C, 0xDE, 0x76, 0x14, 0xBE, 0x2B, 0xC4); + WPD_API_OPTION_IOCTL_ACCESS.pid = 3; + + WPD_COMMAND_COMMON_RESET_DEVICE.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_COMMAND_COMMON_RESET_DEVICE.pid = 2; + + WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS.pid = 3; + + WPD_COMMAND_COMMON_SAVE_CLIENT_INFORMATION.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_COMMAND_COMMON_SAVE_CLIENT_INFORMATION.pid = 4; + + WPD_PROPERTY_COMMON_COMMAND_CATEGORY.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_COMMAND_CATEGORY.pid = 1001; + + WPD_PROPERTY_COMMON_COMMAND_ID.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_COMMAND_ID.pid = 1002; + + WPD_PROPERTY_COMMON_HRESULT.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_HRESULT.pid = 1003; + + WPD_PROPERTY_COMMON_DRIVER_ERROR_CODE.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_DRIVER_ERROR_CODE.pid = 1004; + + WPD_PROPERTY_COMMON_COMMAND_TARGET.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_COMMAND_TARGET.pid = 1006; + + WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS.pid = 1007; + + WPD_PROPERTY_COMMON_OBJECT_IDS.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_OBJECT_IDS.pid = 1008; + + WPD_PROPERTY_COMMON_CLIENT_INFORMATION.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_CLIENT_INFORMATION.pid = 1009; + + WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT.pid = 1010; + + WPD_OPTION_VALID_OBJECT_IDS.fmtid = new Guid(0xF0422A9C, 0x5DC8, 0x4440, 0xB5, 0xBD, 0x5D, 0xF2, 0x88, 0x35, 0x65, 0x8A); + WPD_OPTION_VALID_OBJECT_IDS.pid = 5001; + + WPD_COMMAND_OBJECT_ENUMERATION_START_FIND.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_COMMAND_OBJECT_ENUMERATION_START_FIND.pid = 2; + + WPD_COMMAND_OBJECT_ENUMERATION_FIND_NEXT.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_COMMAND_OBJECT_ENUMERATION_FIND_NEXT.pid = 3; + + WPD_COMMAND_OBJECT_ENUMERATION_END_FIND.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_COMMAND_OBJECT_ENUMERATION_END_FIND.pid = 4; + + WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID.pid = 1001; + + WPD_PROPERTY_OBJECT_ENUMERATION_FILTER.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_PROPERTY_OBJECT_ENUMERATION_FILTER.pid = 1002; + + WPD_PROPERTY_OBJECT_ENUMERATION_OBJECT_IDS.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_PROPERTY_OBJECT_ENUMERATION_OBJECT_IDS.pid = 1003; + + WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT.pid = 1004; + + WPD_PROPERTY_OBJECT_ENUMERATION_NUM_OBJECTS_REQUESTED.fmtid = new Guid(0xB7474E91, 0xE7F8, 0x4AD9, 0xB4, 0x00, 0xAD, 0x1A, 0x4B, 0x58, 0xEE, 0xEC); + WPD_PROPERTY_OBJECT_ENUMERATION_NUM_OBJECTS_REQUESTED.pid = 1005; + + WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED.pid = 2; + + WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES.pid = 3; + + WPD_COMMAND_OBJECT_PROPERTIES_GET.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_GET.pid = 4; + + WPD_COMMAND_OBJECT_PROPERTIES_SET.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_SET.pid = 5; + + WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL.pid = 6; + + WPD_COMMAND_OBJECT_PROPERTIES_DELETE.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_COMMAND_OBJECT_PROPERTIES_DELETE.pid = 7; + + WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID.pid = 1001; + + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS.pid = 1002; + + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES.pid = 1003; + + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES.pid = 1004; + + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS.fmtid = new Guid(0x9E5582E4, 0x0814, 0x44E6, 0x98, 0x1A, 0xB2, 0x99, 0x8D, 0x58, 0x38, 0x04); + WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS.pid = 1005; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_START.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_START.pid = 2; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_NEXT.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_NEXT.pid = 3; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_END.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_END.pid = 4; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_START.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_START.pid = 5; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_NEXT.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_NEXT.pid = 6; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_END.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_END.pid = 7; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_START.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_START.pid = 8; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_NEXT.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_NEXT.pid = 9; + + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_END.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_END.pid = 10; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_IDS.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_IDS.pid = 1001; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT.pid = 1002; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_VALUES.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_VALUES.pid = 1003; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PROPERTY_KEYS.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PROPERTY_KEYS.pid = 1004; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_DEPTH.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_DEPTH.pid = 1005; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PARENT_OBJECT_ID.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PARENT_OBJECT_ID.pid = 1006; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_FORMAT.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_FORMAT.pid = 1007; + + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_WRITE_RESULTS.fmtid = new Guid(0x11C824DD, 0x04CD, 0x4E4E, 0x8C, 0x7B, 0xF6, 0xEF, 0xB7, 0x94, 0xD8, 0x4E); + WPD_PROPERTY_OBJECT_PROPERTIES_BULK_WRITE_RESULTS.pid = 1008; + + WPD_COMMAND_OBJECT_RESOURCES_GET_SUPPORTED.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_GET_SUPPORTED.pid = 2; + + WPD_COMMAND_OBJECT_RESOURCES_GET_ATTRIBUTES.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_GET_ATTRIBUTES.pid = 3; + + WPD_COMMAND_OBJECT_RESOURCES_OPEN.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_OPEN.pid = 4; + + WPD_COMMAND_OBJECT_RESOURCES_READ.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_READ.pid = 5; + + WPD_COMMAND_OBJECT_RESOURCES_WRITE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_WRITE.pid = 6; + + WPD_COMMAND_OBJECT_RESOURCES_CLOSE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_CLOSE.pid = 7; + + WPD_COMMAND_OBJECT_RESOURCES_DELETE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_DELETE.pid = 8; + + WPD_COMMAND_OBJECT_RESOURCES_CREATE_RESOURCE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_CREATE_RESOURCE.pid = 9; + + WPD_COMMAND_OBJECT_RESOURCES_REVERT.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_REVERT.pid = 10; + + WPD_COMMAND_OBJECT_RESOURCES_SEEK.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_COMMAND_OBJECT_RESOURCES_SEEK.pid = 11; + + WPD_PROPERTY_OBJECT_RESOURCES_OBJECT_ID.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_OBJECT_ID.pid = 1001; + + WPD_PROPERTY_OBJECT_RESOURCES_ACCESS_MODE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_ACCESS_MODE.pid = 1002; + + WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_KEYS.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_KEYS.pid = 1003; + + WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_ATTRIBUTES.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_ATTRIBUTES.pid = 1004; + + WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT.pid = 1005; + + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ.pid = 1006; + + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ.pid = 1007; + + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_WRITE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_WRITE.pid = 1008; + + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_WRITTEN.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_WRITTEN.pid = 1009; + + WPD_PROPERTY_OBJECT_RESOURCES_DATA.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_DATA.pid = 1010; + + WPD_PROPERTY_OBJECT_RESOURCES_OPTIMAL_TRANSFER_BUFFER_SIZE.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_OPTIMAL_TRANSFER_BUFFER_SIZE.pid = 1011; + + WPD_PROPERTY_OBJECT_RESOURCES_SEEK_OFFSET.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_SEEK_OFFSET.pid = 1012; + + WPD_PROPERTY_OBJECT_RESOURCES_SEEK_ORIGIN_FLAG.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_SEEK_ORIGIN_FLAG.pid = 1013; + + WPD_PROPERTY_OBJECT_RESOURCES_POSITION_FROM_START.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_PROPERTY_OBJECT_RESOURCES_POSITION_FROM_START.pid = 1014; + + WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_READ_SUPPORTED.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_READ_SUPPORTED.pid = 5001; + + WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_WRITE_SUPPORTED.fmtid = new Guid(0xB3A2B22D, 0xA595, 0x4108, 0xBE, 0x0A, 0xFC, 0x3C, 0x96, 0x5F, 0x3D, 0x4A); + WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_WRITE_SUPPORTED.pid = 5002; + + WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY.pid = 2; + + WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_AND_DATA.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_AND_DATA.pid = 3; + + WPD_COMMAND_OBJECT_MANAGEMENT_WRITE_OBJECT_DATA.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_WRITE_OBJECT_DATA.pid = 4; + + WPD_COMMAND_OBJECT_MANAGEMENT_COMMIT_OBJECT.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_COMMIT_OBJECT.pid = 5; + + WPD_COMMAND_OBJECT_MANAGEMENT_REVERT_OBJECT.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_REVERT_OBJECT.pid = 6; + + WPD_COMMAND_OBJECT_MANAGEMENT_DELETE_OBJECTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_DELETE_OBJECTS.pid = 7; + + WPD_COMMAND_OBJECT_MANAGEMENT_MOVE_OBJECTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_MOVE_OBJECTS.pid = 8; + + WPD_COMMAND_OBJECT_MANAGEMENT_COPY_OBJECTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_COMMAND_OBJECT_MANAGEMENT_COPY_OBJECTS.pid = 9; + + WPD_PROPERTY_OBJECT_MANAGEMENT_CREATION_PROPERTIES.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_CREATION_PROPERTIES.pid = 1001; + + WPD_PROPERTY_OBJECT_MANAGEMENT_CONTEXT.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_CONTEXT.pid = 1002; + + WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_TO_WRITE.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_TO_WRITE.pid = 1003; + + WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_WRITTEN.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_WRITTEN.pid = 1004; + + WPD_PROPERTY_OBJECT_MANAGEMENT_DATA.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_DATA.pid = 1005; + + WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_ID.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_ID.pid = 1006; + + WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_OPTIONS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_OPTIONS.pid = 1007; + + WPD_PROPERTY_OBJECT_MANAGEMENT_OPTIMAL_TRANSFER_BUFFER_SIZE.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_OPTIMAL_TRANSFER_BUFFER_SIZE.pid = 1008; + + WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_IDS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_IDS.pid = 1009; + + WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_RESULTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_RESULTS.pid = 1010; + + WPD_PROPERTY_OBJECT_MANAGEMENT_DESTINATION_FOLDER_OBJECT_ID.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_DESTINATION_FOLDER_OBJECT_ID.pid = 1011; + + WPD_PROPERTY_OBJECT_MANAGEMENT_MOVE_RESULTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_MOVE_RESULTS.pid = 1012; + + WPD_PROPERTY_OBJECT_MANAGEMENT_COPY_RESULTS.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_PROPERTY_OBJECT_MANAGEMENT_COPY_RESULTS.pid = 1013; + + WPD_OPTION_OBJECT_MANAGEMENT_RECURSIVE_DELETE_SUPPORTED.fmtid = new Guid(0xEF1E43DD, 0xA9ED, 0x4341, 0x8B, 0xCC, 0x18, 0x61, 0x92, 0xAE, 0xA0, 0x89); + WPD_OPTION_OBJECT_MANAGEMENT_RECURSIVE_DELETE_SUPPORTED.pid = 5001; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS.pid = 2; + + WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS.pid = 3; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES.pid = 4; + + WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS.pid = 5; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES.pid = 6; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS.pid = 7; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMAT_PROPERTIES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMAT_PROPERTIES.pid = 8; + + WPD_COMMAND_CAPABILITIES_GET_FIXED_PROPERTY_ATTRIBUTES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_FIXED_PROPERTY_ATTRIBUTES.pid = 9; + + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS.pid = 10; + + WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS.pid = 11; + + WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS.pid = 1001; + + WPD_PROPERTY_CAPABILITIES_COMMAND.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_COMMAND.pid = 1002; + + WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS.pid = 1003; + + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES.pid = 1004; + + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY.pid = 1005; + + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS.pid = 1006; + + WPD_PROPERTY_CAPABILITIES_CONTENT_TYPES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_CONTENT_TYPES.pid = 1007; + + WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE.pid = 1008; + + WPD_PROPERTY_CAPABILITIES_FORMATS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_FORMATS.pid = 1009; + + WPD_PROPERTY_CAPABILITIES_FORMAT.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_FORMAT.pid = 1010; + + WPD_PROPERTY_CAPABILITIES_PROPERTY_KEYS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_PROPERTY_KEYS.pid = 1011; + + WPD_PROPERTY_CAPABILITIES_PROPERTY_ATTRIBUTES.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_PROPERTY_ATTRIBUTES.pid = 1012; + + WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS.pid = 1013; + + WPD_PROPERTY_CAPABILITIES_EVENT.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_EVENT.pid = 1014; + + WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS.fmtid = new Guid(0x0CABEC78, 0x6B74, 0x41C6, 0x92, 0x16, 0x26, 0x39, 0xD1, 0xFC, 0xE3, 0x56); + WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS.pid = 1015; + + WPD_COMMAND_STORAGE_FORMAT.fmtid = new Guid(0xD8F907A6, 0x34CC, 0x45FA, 0x97, 0xFB, 0xD0, 0x07, 0xFA, 0x47, 0xEC, 0x94); + WPD_COMMAND_STORAGE_FORMAT.pid = 2; + + WPD_COMMAND_STORAGE_EJECT.fmtid = new Guid(0xD8F907A6, 0x34CC, 0x45FA, 0x97, 0xFB, 0xD0, 0x07, 0xFA, 0x47, 0xEC, 0x94); + WPD_COMMAND_STORAGE_EJECT.pid = 4; + + WPD_PROPERTY_STORAGE_OBJECT_ID.fmtid = new Guid(0xD8F907A6, 0x34CC, 0x45FA, 0x97, 0xFB, 0xD0, 0x07, 0xFA, 0x47, 0xEC, 0x94); + WPD_PROPERTY_STORAGE_OBJECT_ID.pid = 1001; + + WPD_PROPERTY_STORAGE_DESTINATION_OBJECT_ID.fmtid = new Guid(0xD8F907A6, 0x34CC, 0x45FA, 0x97, 0xFB, 0xD0, 0x07, 0xFA, 0x47, 0xEC, 0x94); + WPD_PROPERTY_STORAGE_DESTINATION_OBJECT_ID.pid = 1002; + + WPD_COMMAND_SMS_SEND.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_COMMAND_SMS_SEND.pid = 2; + + WPD_PROPERTY_SMS_RECIPIENT.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_PROPERTY_SMS_RECIPIENT.pid = 1001; + + WPD_PROPERTY_SMS_MESSAGE_TYPE.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_PROPERTY_SMS_MESSAGE_TYPE.pid = 1002; + + WPD_PROPERTY_SMS_TEXT_MESSAGE.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_PROPERTY_SMS_TEXT_MESSAGE.pid = 1003; + + WPD_PROPERTY_SMS_BINARY_MESSAGE.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_PROPERTY_SMS_BINARY_MESSAGE.pid = 1004; + + WPD_OPTION_SMS_BINARY_MESSAGE_SUPPORTED.fmtid = new Guid(0xAFC25D66, 0xFE0D, 0x4114, 0x90, 0x97, 0x97, 0x0C, 0x93, 0xE9, 0x20, 0xD1); + WPD_OPTION_SMS_BINARY_MESSAGE_SUPPORTED.pid = 5001; + + WPD_COMMAND_STILL_IMAGE_CAPTURE_INITIATE.fmtid = new Guid(0x4FCD6982, 0x22A2, 0x4B05, 0xA4, 0x8B, 0x62, 0xD3, 0x8B, 0xF2, 0x7B, 0x32); + WPD_COMMAND_STILL_IMAGE_CAPTURE_INITIATE.pid = 2; + + WPD_COMMAND_MEDIA_CAPTURE_START.fmtid = new Guid(0x59B433BA, 0xFE44, 0x4D8D, 0x80, 0x8C, 0x6B, 0xCB, 0x9B, 0x0F, 0x15, 0xE8); + WPD_COMMAND_MEDIA_CAPTURE_START.pid = 2; + + WPD_COMMAND_MEDIA_CAPTURE_STOP.fmtid = new Guid(0x59B433BA, 0xFE44, 0x4D8D, 0x80, 0x8C, 0x6B, 0xCB, 0x9B, 0x0F, 0x15, 0xE8); + WPD_COMMAND_MEDIA_CAPTURE_STOP.pid = 3; + + WPD_COMMAND_MEDIA_CAPTURE_PAUSE.fmtid = new Guid(0x59B433BA, 0xFE44, 0x4D8D, 0x80, 0x8C, 0x6B, 0xCB, 0x9B, 0x0F, 0x15, 0xE8); + WPD_COMMAND_MEDIA_CAPTURE_PAUSE.pid = 4; + + WPD_COMMAND_DEVICE_HINTS_GET_CONTENT_LOCATION.fmtid = new Guid(0x0D5FB92B, 0xCB46, 0x4C4F, 0x83, 0x43, 0x0B, 0xC3, 0xD3, 0xF1, 0x7C, 0x84); + WPD_COMMAND_DEVICE_HINTS_GET_CONTENT_LOCATION.pid = 2; + + WPD_PROPERTY_DEVICE_HINTS_CONTENT_TYPE.fmtid = new Guid(0x0D5FB92B, 0xCB46, 0x4C4F, 0x83, 0x43, 0x0B, 0xC3, 0xD3, 0xF1, 0x7C, 0x84); + WPD_PROPERTY_DEVICE_HINTS_CONTENT_TYPE.pid = 1001; + + WPD_PROPERTY_DEVICE_HINTS_CONTENT_LOCATIONS.fmtid = new Guid(0x0D5FB92B, 0xCB46, 0x4C4F, 0x83, 0x43, 0x0B, 0xC3, 0xD3, 0xF1, 0x7C, 0x84); + WPD_PROPERTY_DEVICE_HINTS_CONTENT_LOCATIONS.pid = 1002; + + WPD_COMMAND_CLASS_EXTENSION_WRITE_DEVICE_INFORMATION.fmtid = new Guid(0x33FB0D11, 0x64A3, 0x4FAC, 0xB4, 0xC7, 0x3D, 0xFE, 0xAA, 0x99, 0xB0, 0x51); + WPD_COMMAND_CLASS_EXTENSION_WRITE_DEVICE_INFORMATION.pid = 2; + + WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES.fmtid = new Guid(0x33FB0D11, 0x64A3, 0x4FAC, 0xB4, 0xC7, 0x3D, 0xFE, 0xAA, 0x99, 0xB0, 0x51); + WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES.pid = 1001; + + WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_WRITE_RESULTS.fmtid = new Guid(0x33FB0D11, 0x64A3, 0x4FAC, 0xB4, 0xC7, 0x3D, 0xFE, 0xAA, 0x99, 0xB0, 0x51); + WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_WRITE_RESULTS.pid = 1002; + + WPD_COMMAND_GENERATE_KEYPAIR.fmtid = new Guid(0x78F9C6FC, 0x79B8, 0x473C, 0x90, 0x60, 0x6B, 0xD2, 0x3D, 0xD0, 0x72, 0xC4); + WPD_COMMAND_GENERATE_KEYPAIR.pid = 2; + + WPD_COMMAND_COMMIT_KEYPAIR.fmtid = new Guid(0x78F9C6FC, 0x79B8, 0x473C, 0x90, 0x60, 0x6B, 0xD2, 0x3D, 0xD0, 0x72, 0xC4); + WPD_COMMAND_COMMIT_KEYPAIR.pid = 3; + + WPD_COMMAND_PROCESS_WIRELESS_PROFILE.fmtid = new Guid(0x78F9C6FC, 0x79B8, 0x473C, 0x90, 0x60, 0x6B, 0xD2, 0x3D, 0xD0, 0x72, 0xC4); + WPD_COMMAND_PROCESS_WIRELESS_PROFILE.pid = 4; + + WPD_PROPERTY_PUBLIC_KEY.fmtid = new Guid(0x78F9C6FC, 0x79B8, 0x473C, 0x90, 0x60, 0x6B, 0xD2, 0x3D, 0xD0, 0x72, 0xC4); + WPD_PROPERTY_PUBLIC_KEY.pid = 1001; + } + + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_DEFAULT; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_CONTACT_PHOTO; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_THUMBNAIL; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ICON; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_AUDIO_CLIP; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ALBUM_ART; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_GENERIC; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_VIDEO_CLIP; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_BRANDING_ART; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_NULL; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_PARENT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_PERSISTENT_UNIQUE_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_CONTENT_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_ISHIDDEN; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_ISSYSTEM; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_ORIGINAL_FILE_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_NON_CONSUMABLE; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_REFERENCES; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_KEYWORDS; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_SYNC_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_IS_DRM_PROTECTED; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_DATE_CREATED; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_DATE_MODIFIED; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_DATE_AUTHORED; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_BACK_REFERENCES; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_GENERATE_THUMBNAIL_FROM_RESOURCE; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_HINT_LOCATION_DISPLAY_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_OBJECT_CAN_DELETE; + public static PortableDeviceApiLib._tagpropertykey WPD_FUNCTIONAL_OBJECT_CATEGORY; + public static PortableDeviceApiLib._tagpropertykey WPD_FOLDER_CONTENT_TYPES_ALLOWED; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_BITDEPTH; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_CROPPED_STATUS; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_COLOR_CORRECTED_STATUS; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_FNUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_EXPOSURE_TIME; + public static PortableDeviceApiLib._tagpropertykey WPD_IMAGE_EXPOSURE_INDEX; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_TOTAL_BITRATE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_BITRATE_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_COPYRIGHT; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SUBSCRIPTION_CONTENT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_USE_COUNT; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SKIP_COUNT; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_LAST_ACCESSED_TIME; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_PARENTAL_RATING; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_META_GENRE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_COMPOSER; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_EFFECTIVE_RATING; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SUB_TITLE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_RELEASE_DATE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SAMPLE_RATE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_STAR_RATING; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_USER_EFFECTIVE_RATING; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_TITLE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_DURATION; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_BUY_NOW; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_ENCODING_PROFILE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_WIDTH; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_HEIGHT; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_ARTIST; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_ALBUM_ARTIST; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_OWNER; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_MANAGING_EDITOR; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_WEBMASTER; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SOURCE_URL; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_DESTINATION_URL; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_DESCRIPTION; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_GENRE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_TIME_BOOKMARK; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_OBJECT_BOOKMARK; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_LAST_BUILD_DATE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_BYTE_BOOKMARK; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_TIME_TO_LIVE; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_GUID; + public static PortableDeviceApiLib._tagpropertykey WPD_MEDIA_SUB_DESCRIPTION; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_DISPLAY_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_FIRST_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_MIDDLE_NAMES; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_LAST_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PREFIX; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_SUFFIX; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PHONETIC_FIRST_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PHONETIC_LAST_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_FULL_POSTAL_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE1; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_LINE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_CITY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_REGION; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_POSTAL_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_POSTAL_ADDRESS_COUNTRY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_FULL_POSTAL_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE1; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_LINE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_CITY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_REGION; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_POSTAL_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_POSTAL_ADDRESS_COUNTRY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_FULL_POSTAL_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE1; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_LINE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_CITY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_REGION; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_POSTAL_ADDRESS_POSTAL_COUNTRY; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PRIMARY_EMAIL_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_EMAIL; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_EMAIL2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_EMAIL; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_EMAIL2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_EMAILS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PRIMARY_PHONE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_PHONE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_PHONE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_PHONE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_PHONE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_MOBILE_PHONE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_MOBILE_PHONE2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_FAX; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_FAX; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PAGER; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_OTHER_PHONES; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PRIMARY_WEB_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PERSONAL_WEB_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BUSINESS_WEB_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_INSTANT_MESSENGER; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_INSTANT_MESSENGER2; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_INSTANT_MESSENGER3; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_COMPANY_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PHONETIC_COMPANY_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_ROLE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_BIRTHDATE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_PRIMARY_FAX; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_SPOUSE; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_CHILDREN; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_ASSISTANT; + public static PortableDeviceApiLib._tagpropertykey WPD_CONTACT_ANNIVERSARY_DATE; + public static PortableDeviceApiLib._tagpropertykey WPD_MUSIC_ALBUM; + public static PortableDeviceApiLib._tagpropertykey WPD_MUSIC_TRACK; + public static PortableDeviceApiLib._tagpropertykey WPD_MUSIC_LYRICS; + public static PortableDeviceApiLib._tagpropertykey WPD_MUSIC_MOOD; + public static PortableDeviceApiLib._tagpropertykey WPD_AUDIO_BITRATE; + public static PortableDeviceApiLib._tagpropertykey WPD_AUDIO_CHANNEL_COUNT; + public static PortableDeviceApiLib._tagpropertykey WPD_AUDIO_FORMAT_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_AUDIO_BIT_DEPTH; + public static PortableDeviceApiLib._tagpropertykey WPD_AUDIO_BLOCK_ALIGNMENT; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_AUTHOR; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_RECORDEDTV_STATION_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_RECORDEDTV_CHANNEL_NUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_RECORDEDTV_REPEAT; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_BUFFER_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_CREDITS; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_KEY_FRAME_DISTANCE; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_QUALITY_SETTING; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_SCAN_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_BITRATE; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_FOURCC_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_VIDEO_FRAMERATE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_SUBJECT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_BODY_TEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_PRIORITY; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_START_DATETIME; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_END_DATETIME; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMON_INFORMATION_NOTES; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_TO_LINE; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_CC_LINE; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_BCC_LINE; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_HAS_BEEN_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_RECEIVED_TIME; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_HAS_ATTACHMENTS; + public static PortableDeviceApiLib._tagpropertykey WPD_EMAIL_SENDER_ADDRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_LOCATION; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_REQUIRED_ATTENDEES; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_OPTIONAL_ATTENDEES; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_ACCEPTED_ATTENDEES; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_RESOURCES; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_TENTATIVE_ATTENDEES; + public static PortableDeviceApiLib._tagpropertykey WPD_APPOINTMENT_DECLINED_ATTENDEES; + public static PortableDeviceApiLib._tagpropertykey WPD_TASK_STATUS; + public static PortableDeviceApiLib._tagpropertykey WPD_TASK_PERCENT_COMPLETE; + public static PortableDeviceApiLib._tagpropertykey WPD_TASK_REMINDER_DATE; + public static PortableDeviceApiLib._tagpropertykey WPD_TASK_OWNER; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_FILE_SYSTEM_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_CAPACITY; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_FREE_SPACE_IN_BYTES; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_FREE_SPACE_IN_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_DESCRIPTION; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_SERIAL_NUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_MAX_OBJECT_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_CAPACITY_IN_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_STORAGE_ACCESS_CAPABILITY; + public static PortableDeviceApiLib._tagpropertykey WPD_NETWORK_ASSOCIATION_HOST_NETWORK_IDENTIFIERS; + public static PortableDeviceApiLib._tagpropertykey WPD_NETWORK_ASSOCIATION_X509V3SEQUENCE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_CAPTURE_RESOLUTION; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_CAPTURE_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_COMPRESSION_SETTING; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_WHITE_BALANCE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_RGB_GAIN; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FNUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FOCAL_LENGTH; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FOCUS_DISTANCE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FOCUS_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EXPOSURE_METERING_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FLASH_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EXPOSURE_TIME; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EXPOSURE_PROGRAM_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EXPOSURE_INDEX; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EXPOSURE_BIAS_COMPENSATION; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_CAPTURE_DELAY; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_CAPTURE_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_CONTRAST; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_SHARPNESS; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_DIGITAL_ZOOM; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_EFFECT_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_BURST_NUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_BURST_INTERVAL; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_TIMELAPSE_NUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_TIMELAPSE_INTERVAL; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_FOCUS_METERING_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_UPLOAD_URL; + public static PortableDeviceApiLib._tagpropertykey WPD_STILL_IMAGE_ARTIST; + public static PortableDeviceApiLib._tagpropertykey WPD_SMS_PROVIDER; + public static PortableDeviceApiLib._tagpropertykey WPD_SMS_TIMEOUT; + public static PortableDeviceApiLib._tagpropertykey WPD_SMS_MAX_PAYLOAD; + public static PortableDeviceApiLib._tagpropertykey WPD_SMS_ENCODING; + public static PortableDeviceApiLib._tagpropertykey WPD_SECTION_DATA_OFFSET; + public static PortableDeviceApiLib._tagpropertykey WPD_SECTION_DATA_LENGTH; + public static PortableDeviceApiLib._tagpropertykey WPD_SECTION_DATA_UNITS; + public static PortableDeviceApiLib._tagpropertykey WPD_SECTION_DATA_REFERENCED_OBJECT_RESOURCE; + public static PortableDeviceApiLib._tagpropertykey WPD_RENDERING_INFORMATION_PROFILES; + public static PortableDeviceApiLib._tagpropertykey WPD_RENDERING_INFORMATION_PROFILE_ENTRY_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_RENDERING_INFORMATION_PROFILE_ENTRY_CREATABLE_RESOURCES; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_MAJOR_VERSION; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_MINOR_VERSION; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_REVISION; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_WMDRM_APPLICATION_PRIVATE_KEY; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_WMDRM_APPLICATION_CERTIFICATE; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_SECURITY_QUALITY_OF_SERVICE; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_DESIRED_ACCESS; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_SHARE_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_CLIENT_EVENT_COOKIE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_FORM; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_CAN_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_CAN_WRITE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_CAN_DELETE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_FAST_PROPERTY; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_RANGE_MIN; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_RANGE_MAX; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_RANGE_STEP; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_ENUMERATION_ELEMENTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_REGULAR_EXPRESSION; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_ATTRIBUTE_MAX_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_CLASS_EXTENSION_OPTIONS_SUPPORTED_CONTENT_TYPES; + public static PortableDeviceApiLib._tagpropertykey WPD_CLASS_EXTENSION_OPTIONS_DONT_REGISTER_WPD_DEVICE_INTERFACE; + public static PortableDeviceApiLib._tagpropertykey WPD_CLASS_EXTENSION_OPTIONS_REGISTER_WPD_PRIVATE_DEVICE_INTERFACE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_TOTAL_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_CAN_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_CAN_WRITE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_CAN_DELETE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_OPTIMAL_READ_BUFFER_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_OPTIMAL_WRITE_BUFFER_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_RESOURCE_ATTRIBUTE_RESOURCE_KEY; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_SYNC_PARTNER; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_FIRMWARE_VERSION; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_POWER_LEVEL; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_POWER_SOURCE; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_PROTOCOL; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_MANUFACTURER; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_MODEL; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_SERIAL_NUMBER; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_SUPPORTS_NON_CONSUMABLE; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_DATETIME; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_FRIENDLY_NAME; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_SUPPORTED_DRM_SCHEMES; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_SUPPORTED_FORMATS_ARE_ORDERED; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_DEVICE_NETWORK_IDENTIFIER; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_PNP_DEVICE_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_EVENT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_OPERATION_STATE; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_OPERATION_PROGRESS; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_OBJECT_PARENT_PERSISTENT_UNIQUE_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_OBJECT_CREATION_COOKIE; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_PARAMETER_CHILD_HIERARCHY_CHANGED; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_OPTION_IS_BROADCAST_EVENT; + public static PortableDeviceApiLib._tagpropertykey WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT; + public static PortableDeviceApiLib._tagpropertykey WPD_API_OPTION_USE_CLEAR_DATA_STREAM; + public static PortableDeviceApiLib._tagpropertykey WPD_API_OPTION_IOCTL_ACCESS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_COMMON_RESET_DEVICE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_COMMON_SAVE_CLIENT_INFORMATION; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_COMMAND_CATEGORY; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_COMMAND_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_HRESULT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_DRIVER_ERROR_CODE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_COMMAND_TARGET; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_PERSISTENT_UNIQUE_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_OBJECT_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_CLIENT_INFORMATION; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_OPTION_VALID_OBJECT_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_ENUMERATION_START_FIND; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_ENUMERATION_FIND_NEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_ENUMERATION_END_FIND; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_ENUMERATION_PARENT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_ENUMERATION_FILTER; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_ENUMERATION_OBJECT_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_ENUMERATION_CONTEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_ENUMERATION_NUM_OBJECTS_REQUESTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_GET; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_SET; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_DELETE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_KEYS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_VALUES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_PROPERTY_WRITE_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_START; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_NEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_LIST_END; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_START; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_NEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_GET_VALUES_BY_OBJECT_FORMAT_END; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_START; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_NEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_END; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_VALUES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PROPERTY_KEYS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_DEPTH; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_PARENT_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_OBJECT_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_PROPERTIES_BULK_WRITE_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_GET_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_GET_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_OPEN; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_WRITE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_CLOSE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_DELETE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_CREATE_RESOURCE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_REVERT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_RESOURCES_SEEK; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_ACCESS_MODE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_KEYS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_RESOURCE_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_WRITE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_WRITTEN; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_DATA; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_OPTIMAL_TRANSFER_BUFFER_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_SEEK_OFFSET; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_SEEK_ORIGIN_FLAG; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_RESOURCES_POSITION_FROM_START; + public static PortableDeviceApiLib._tagpropertykey WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_READ_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_OPTION_OBJECT_RESOURCES_SEEK_ON_WRITE_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_AND_DATA; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_WRITE_OBJECT_DATA; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_COMMIT_OBJECT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_REVERT_OBJECT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_DELETE_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_MOVE_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_OBJECT_MANAGEMENT_COPY_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_CREATION_PROPERTIES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_CONTEXT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_TO_WRITE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_NUM_BYTES_WRITTEN; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_DATA; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_OPTIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_OPTIMAL_TRANSFER_BUFFER_SIZE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_OBJECT_IDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_DELETE_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_DESTINATION_FOLDER_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_MOVE_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_OBJECT_MANAGEMENT_COPY_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_OPTION_OBJECT_MANAGEMENT_RECURSIVE_DELETE_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_COMMAND_OPTIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_FUNCTIONAL_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMAT_PROPERTIES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_FIXED_PROPERTY_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_EVENTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CAPABILITIES_GET_EVENT_OPTIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_SUPPORTED_COMMANDS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_COMMAND; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_COMMAND_OPTIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORY; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_OBJECTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_CONTENT_TYPES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_FORMATS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_PROPERTY_KEYS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_PROPERTY_ATTRIBUTES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_SUPPORTED_EVENTS; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_EVENT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CAPABILITIES_EVENT_OPTIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_STORAGE_FORMAT; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_STORAGE_EJECT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_STORAGE_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_STORAGE_DESTINATION_OBJECT_ID; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_SMS_SEND; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_SMS_RECIPIENT; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_SMS_MESSAGE_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_SMS_TEXT_MESSAGE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_SMS_BINARY_MESSAGE; + public static PortableDeviceApiLib._tagpropertykey WPD_OPTION_SMS_BINARY_MESSAGE_SUPPORTED; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_STILL_IMAGE_CAPTURE_INITIATE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_MEDIA_CAPTURE_START; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_MEDIA_CAPTURE_STOP; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_MEDIA_CAPTURE_PAUSE; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_DEVICE_HINTS_GET_CONTENT_LOCATION; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_DEVICE_HINTS_CONTENT_TYPE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_DEVICE_HINTS_CONTENT_LOCATIONS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_CLASS_EXTENSION_WRITE_DEVICE_INFORMATION; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_VALUES; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_CLASS_EXTENSION_DEVICE_INFORMATION_WRITE_RESULTS; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_GENERATE_KEYPAIR; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_COMMIT_KEYPAIR; + public static PortableDeviceApiLib._tagpropertykey WPD_COMMAND_PROCESS_WIRELESS_PROFILE; + public static PortableDeviceApiLib._tagpropertykey WPD_PROPERTY_PUBLIC_KEY; + //-------------------------------- MTp + internal static Guid WPD_CATEGORY_MTP_EXT_VENDOR_OPERATIONS = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56); + internal static Guid WPD_PROPERTIES_MTP_VENDOR_EXTENDED_OBJECT_PROPS = new Guid(0x4d545058, 0x4fce, 0x4578, 0x95, 0xc8, 0x86, 0x98, 0xa9, 0xbc, 0xf, 0x49); + internal static Guid WPD_PROPERTIES_MTP_VENDOR_EXTENDED_DEVICE_PROPS = new Guid(0x4d545058, 0x8900, 0x40b3, 0x8f, 0x1d, 0xdc, 0x24, 0x6e, 0x1e, 0x83, 0x70); + internal static Guid WPD_EVENT_MTP_VENDOR_EXTENDED_EVENTS = new Guid(0x00000000, 0x5738, 0x4ff2, 0x84, 0x45, 0xbe, 0x31, 0x26, 0x69, 0x10, 0x59); + + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_GET_SUPPORTED_VENDOR_OPCODES = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 11 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITHOUT_DATA_PHASE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 12 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 13 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_WRITE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 14 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_READ_DATA = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 15 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_WRITE_DATA = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 16 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 17 }; + internal static _tagpropertykey WPD_COMMAND_MTP_EXT_GET_VENDOR_EXTENSION_DESCRIPTION = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 18 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_OPERATION_CODE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1001 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1002 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_RESPONSE_CODE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1003 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_RESPONSE_PARAMS = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1004 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_VENDOR_OPERATION_CODES = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1005 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1006 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1007 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_READ = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1008 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_READ = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1009 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_WRITE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1010 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_WRITTEN = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1011 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_TRANSFER_DATA = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1012 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_OPTIMAL_TRANSFER_BUFFER_SIZE = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1013 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_VENDOR_EXTENSION_DESCRIPTION = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0x1a2e, 0x4106, 0xa3, 0x57, 0x77, 0x1e, 0x8, 0x19, 0xfc, 0x56), pid = 1014 }; + internal static _tagpropertykey WPD_PROPERTY_MTP_EXT_EVENT_PARAMS = new _tagpropertykey() { fmtid = new Guid(0x4d545058, 0xef88, 0x4e4d, 0x95, 0xc3, 0x4f, 0x32, 0x7f, 0x72, 0x8a, 0x96), pid = 1011 }; + } + + +} diff --git a/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceEventTypeFactory.cs b/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceEventTypeFactory.cs new file mode 100644 index 0000000..fef40c3 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceEventTypeFactory.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceLib.Model; + +namespace PortableDeviceLib.Factories +{ + /// + /// Represent a factory that can construct new object + /// + public class PortableDeviceEventTypeFactory + { + private static PortableDeviceEventTypeFactory instance; + + private Dictionary> factoryMethods; + + private PortableDeviceEventTypeFactory() + { + this.factoryMethods = new Dictionary>(); + } + + #region Properties + + /// + /// Gets the unique instance of the + /// + public static PortableDeviceEventTypeFactory Instance + { + get + { + if (instance == null) + instance = new PortableDeviceEventTypeFactory(); + return instance; + } + } + + #endregion + + #region Public functions + + /// + /// Create a new instance of the + /// + /// + /// + public PortableDeviceEventType CreateEventType(Guid guid) + { + if (this.factoryMethods.ContainsKey(guid)) + return this.factoryMethods[guid](); + else + return new PortableDeviceEventType(); + } + + #endregion + + } +} diff --git a/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceObjectFactory.cs b/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceObjectFactory.cs new file mode 100644 index 0000000..1721c5c --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Factories/PortableDeviceObjectFactory.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceLib.Model; + +namespace PortableDeviceLib.Factories +{ + /// + /// Represent a factory that can build + /// You can register new method to handle new object types + /// + public class PortableDeviceObjectFactory + { + private static PortableDeviceObjectFactory instance; + private Dictionary> factoryMethods; + + /// + /// Initialize a new instance of the class + /// This is a private constructor to support Singleton pattern + /// + private PortableDeviceObjectFactory() + { + this.factoryMethods = new Dictionary>(); + + // Register know object type + this.RegisterNewFactoryMethod(PortableDeviceGuids.WPD_CONTENT_TYPE_FOLDER, new Func(CreateFolderObject)); + this.RegisterNewFactoryMethod(PortableDeviceGuids.WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT, new Func(CreateFunctionalObject)); + } + + #region Properties + + /// + /// Gets the unique instance of factory + /// + public static PortableDeviceObjectFactory Instance + { + get + { + if (instance == null) + instance = new PortableDeviceObjectFactory(); + return instance; + } + } + + #endregion + + #region Public functions + + /// + /// Register a new factory method that enable create new object type + /// + /// + /// + public void RegisterNewFactoryMethod(Guid handledType, Func method) + { + if (handledType == Guid.Empty) + throw new ArgumentException("handledType cann't be Guid.Empty", "handledType"); + if (method == null) + throw new ArgumentNullException("method"); + + if (this.factoryMethods.ContainsKey(handledType)) + throw new ArgumentException(string.Format("Guid {0} is already registered", handledType), "handledType"); + + this.factoryMethods.Add(handledType, method); + } + + /// + /// Create a new instance of a portableDeviceObject or derived from type + /// + /// + /// + public PortableDeviceObject CreateInstance(Guid type, string id, string name, string contentType, string format) + { + if (this.factoryMethods.ContainsKey(type)) + return this.factoryMethods[type](id, name, contentType, format); + else + return this.CreateGenericObject(id, name, contentType, format); + } + + #endregion + + #region Private functions + + private PortableDeviceObject CreateFunctionalObject(string id, string name, string contentType, string format) + { + var obj = new PortableDeviceFonctionalObject(id); + this.InitializeInstance(obj, name, contentType, format); + return obj; + } + + private PortableDeviceObject CreateFolderObject(string id, string name, string contentType, string format) + { + var obj = new PortableDeviceFolderObject(id); + this.InitializeInstance(obj, name, contentType, format); + return obj; + } + + private PortableDeviceObject CreateGenericObject(string id, string name, string contentType, string format) + { + var obj = new PortableDeviceObject(id); + this.InitializeInstance(obj, name, contentType, format); + return obj; + } + + private void InitializeInstance(PortableDeviceObject obj, string name, string contentType, string format) + { + obj.Name = name; + obj.ContentType = contentType; + obj.Format = format; + } + + #endregion + + } +} diff --git a/DigiCamControl/PortableDeviceLib/FunctionalCategory.cs b/DigiCamControl/PortableDeviceLib/FunctionalCategory.cs new file mode 100644 index 0000000..66dfd0b --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/FunctionalCategory.cs @@ -0,0 +1,149 @@ +#region License +/* +FunctionalCategory.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceApiLib; + +namespace PortableDeviceLib +{ + /// + /// Represent a functional category and supported content type + /// + public class FunctionalCategory + { + + private Dictionary contentTypes; + + /// + /// Initialize a new instance of the class + /// + /// + /// + /// + internal FunctionalCategory(PortableDeviceClass portableDeviceClass, Guid guid, string name) + { + if (guid == Guid.Empty) + throw new ArgumentException("guid cann't be Guid.Empty"); + if (string.IsNullOrEmpty(name)) + throw new ArgumentNullException("name"); + this.contentTypes = new Dictionary(); + + this.Guid = guid; + this.Name = name; + + this.ExtractContentType(portableDeviceClass, guid); + } + + /// + /// Get the guid of this functional category + /// You can use it with PortableDeviceCabilities + /// + public Guid Guid + { + get; + private set; + } + + /// + /// Get the name of this functional category + /// + public string Name + { + get; + private set; + } + + /// + /// Get all content types in this category + /// + public IEnumerable ContentTypes + { + get + { + return this.contentTypes.Values; + } + } + + /// + /// + /// + /// + public override string ToString() + { + if (!string.IsNullOrEmpty(this.Name)) + return this.Name; + else + return this.Guid.ToString(); + } + + private void ExtractContentType(PortableDeviceClass portableDeviceClass, Guid functionalCategory) + { + if (portableDeviceClass == null) + throw new ArgumentNullException("portableDeviceClass"); + + try + { + PortableDeviceApiLib.IPortableDeviceCapabilities capabilities; + portableDeviceClass.Capabilities(out capabilities); + + if (capabilities == null) + { + System.Diagnostics.Trace.WriteLine("Cannot extract capabilities from device"); + throw new PortableDeviceException("Cannot extract capabilities from device"); + } + + + PortableDeviceApiLib.IPortableDeviceValues pValues = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + + //Functional objects variables + IPortableDevicePropVariantCollection contentTypes; + uint countObjects = 1; + tag_inner_PROPVARIANT values = new tag_inner_PROPVARIANT(); + string contentTypeName; + Guid currentContentTypeGuid; + capabilities.GetSupportedContentTypes(ref functionalCategory, out contentTypes); + + contentTypes.GetCount(ref countObjects); + for (uint i = 0; i < countObjects; i++) + { + contentTypes.GetAt(i, ref values); + + pValues.SetValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES, ref values); + pValues.GetStringValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_CONTENT_TYPES, out contentTypeName); + currentContentTypeGuid = new Guid(contentTypeName); + this.contentTypes.Add(currentContentTypeGuid, new ContentType( + portableDeviceClass, + currentContentTypeGuid, + PortableDeviceHelpers.GetKeyNameFromGuid(currentContentTypeGuid))); + } + + } + catch (Exception ex) + { + throw new PortableDeviceException("Error on extract functional object", ex); + } + } + + } +} diff --git a/DigiCamControl/PortableDeviceLib/ITreeNode.cs b/DigiCamControl/PortableDeviceLib/ITreeNode.cs new file mode 100644 index 0000000..adc6eec --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/ITreeNode.cs @@ -0,0 +1,32 @@ +#region License +/* +ITreeNode.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib +{ + public interface ITreeNode + { + + } +} diff --git a/DigiCamControl/PortableDeviceLib/MTPConstants.cs b/DigiCamControl/PortableDeviceLib/MTPConstants.cs new file mode 100644 index 0000000..0b5b9d8 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/MTPConstants.cs @@ -0,0 +1,116 @@ +#region License +/* +MTPConstants.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace PortableDeviceLib +{ + class MTPConstants + { + public static string DEVICE; + public static string DEVICE_BATTERY_LEVEL; + public static string DEVICE_FIRMWARE_VERSION; + public static string DEVICE_FRIENDLY_NAME; + public static string DEVICE_MANUFACTURER; + public static string DEVICE_MODEL; + public static string DEVICE_POWER_SOURCE; + public static string DEVICE_SERIAL_NUMBER; + public static string HISTORY_DIRECTORY; + public static string MUSIC; + public static string OBJECT_ALBUM; + public static string OBJECT_ALBUM_ART; + public static string OBJECT_ALBUM_ARTIST; + public static string OBJECT_ARTIST; + public static string OBJECT_BITRATE_TYPE; + public static string OBJECT_CONTENT_TYPE; + public static string OBJECT_DATE_AUTHORED; + public static string OBJECT_DATE_CREATED; + public static string OBJECT_DRM_PROTECTED; + public static string OBJECT_DURATION; + public static string OBJECT_EFFECTIVE_RATING; + public static string OBJECT_FILENAME; + public static string OBJECT_FORMAT; + public static string OBJECT_GENRE; + public static string OBJECT_ID; + public static string OBJECT_LAST_ACCESSED_TIME; + public static string OBJECT_LAST_BUILD_DATE; + public static string OBJECT_MODIFIED; + public static string OBJECT_NAME; + public static string OBJECT_PERSISTENT_ID; + public static string OBJECT_PLAY_COUNT; + public static string OBJECT_RELEASE_DATE; + public static string OBJECT_SAMPLE_RATE; + public static string OBJECT_SIZE; + public static string OBJECT_SKIP_COUNT; + public static string OBJECT_STAR_RATING; + public static string OBJECT_SUBSCRIPTION_CONTENT_ID; + public static string OBJECT_TITLE; + public static string OBJECT_TOTAL_BITRATE; + public static string OBJECT_TRACK; + public static string PLAYLIST_FOLDER; + public static string PLAYLISTS; + + // Methods + static MTPConstants() + { + DEVICE_FRIENDLY_NAME = "Device Friendly Name"; + DEVICE_MODEL = "Device Model"; + DEVICE_BATTERY_LEVEL = "Device Power Level"; + DEVICE_MANUFACTURER = "Device Manufacturer"; + DEVICE_FIRMWARE_VERSION = "Device Firmware Version"; + DEVICE_POWER_SOURCE = "Device Power Source"; + DEVICE_SERIAL_NUMBER = "Device Serial Number"; + OBJECT_ID = "Object ID"; + OBJECT_TITLE = "Title"; + OBJECT_ARTIST = "Artist"; + OBJECT_PLAY_COUNT = "Play Count"; + OBJECT_GENRE = "Genre"; + OBJECT_STAR_RATING = "Star Rating"; + OBJECT_ALBUM_ARTIST = "Album Artist"; + OBJECT_ALBUM = "Album"; + OBJECT_SUBSCRIPTION_CONTENT_ID = "Subscription Content ID"; + OBJECT_EFFECTIVE_RATING = "Effective Rating"; + OBJECT_TRACK = "Track"; + OBJECT_SIZE = "Object Size"; + OBJECT_DURATION = "Duration"; + OBJECT_CONTENT_TYPE = "Content Type"; + OBJECT_DATE_AUTHORED = "Date Authored"; + OBJECT_FORMAT = "Object Format"; + OBJECT_DRM_PROTECTED = "DRM Protected"; + OBJECT_FILENAME = "Filename"; + OBJECT_NAME = "Object Name"; + OBJECT_PERSISTENT_ID = "Persistent ID"; + OBJECT_TOTAL_BITRATE = "Total Bitrate"; + OBJECT_SKIP_COUNT = "Skip Count"; + OBJECT_SAMPLE_RATE = "Sample Rate"; + OBJECT_RELEASE_DATE = "Release Date"; + OBJECT_LAST_BUILD_DATE = "Last Build Date"; + OBJECT_LAST_ACCESSED_TIME = "Last Accessed Time"; + OBJECT_BITRATE_TYPE = "Bitrate Type"; + OBJECT_ALBUM_ART = "Album Art"; + OBJECT_DATE_CREATED = "Date Created"; + OBJECT_MODIFIED = "Modified"; + } + + } +} diff --git a/DigiCamControl/PortableDeviceLib/MTPDataResponse.cs b/DigiCamControl/PortableDeviceLib/MTPDataResponse.cs new file mode 100644 index 0000000..5f46fb0 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/MTPDataResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib +{ + public class MTPDataResponse + { + public byte[] Data { get; set; } + public uint ErrorCode { get; set; } + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceContainerObject.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceContainerObject.cs new file mode 100644 index 0000000..386385d --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceContainerObject.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Collections.ObjectModel; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent an object that can contains other objects + /// + public class PortableDeviceContainerObject : PortableDeviceObject + { + private ObservableCollection childs; + + /// + /// Initialize a new instance of the class + /// + /// + public PortableDeviceContainerObject(string id) + : base(id) + { + this.childs = new ObservableCollection(); + this.Childs = new ReadOnlyObservableCollection(this.childs); + } + + /// + /// Gets the childs of this object + /// + public ReadOnlyObservableCollection Childs + { + get; + private set; + } + + /// + /// Add a child in collection + /// + /// + internal void AddChild(PortableDeviceObject child) + { + if (this.childs.Contains(child)) + return; + this.childs.Add(child); + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventDescription.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventDescription.cs new file mode 100644 index 0000000..06cc305 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventDescription.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent a description for an event + /// + public class PortableDeviceEventDescription + { + private List options; + + #region Constructors + + /// + /// Initialize a new instance of the class + /// + /// The event guid key + /// The event name + public PortableDeviceEventDescription(Guid eventGuid, string eventName) + { + if (eventGuid == Guid.Empty) + throw new ArgumentException("eventGuid cann't be empty", "eventGuid"); + if (string.IsNullOrEmpty(eventName)) + throw new ArgumentNullException("eventName"); + + this.options = new List(); + this.Name = eventName; + this.Guid = eventGuid; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the guid of the event + /// + public Guid Guid + { + get; + set; + } + + /// + /// Gets or sets the name of the event + /// + public string Name + { + get; + set; + } + + /// + /// Gets the options of the event + /// + public IEnumerable Options + { + get + { + return this.options; + } + } + + #endregion + + #region Public functions + + + + #endregion + + #region Internal functions + + /// + /// Add an option in the event description + /// + /// + internal void AddOptions(PortableDeviceEventOption option) + { + if (option == null) + throw new ArgumentNullException("option"); + + if (this.options.Contains(option)) + return; + + this.options.Add(option); + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventOption.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventOption.cs new file mode 100644 index 0000000..6ba765a --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventOption.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent an option + /// + public class PortableDeviceEventOption + { + #region Properties + + /// + /// Gets or sets the guid + /// + public Guid Guid + { + get; + set; + } + + /// + /// Gets or sets the name + /// + public string Name + { + get; + set; + } + + /// + /// Gets or sets the value + /// + public object Value + { + get; + set; + } + + /// + /// Gets or sets the value type + /// + public TypeCode ValueType + { + get; + set; + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventType.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventType.cs new file mode 100644 index 0000000..54107be --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceEventType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent the base class for event type + /// + public class PortableDeviceEventType + { + public PortableDeviceObject DeviceObject { get; set; } + public Guid EventGuid { get; set; } + public uint ObjectHandle { get; set; } + public bool IsInSdram { get; set; } + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFile.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFile.cs new file mode 100644 index 0000000..a334570 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFile.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + public class PortableDeviceFile + { + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFolderObject.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFolderObject.cs new file mode 100644 index 0000000..4247e7c --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFolderObject.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent a folder + /// + public class PortableDeviceFolderObject : PortableDeviceContainerObject + { + #region Constructors + + /// + /// Initialize a new instance of the + /// + /// + public PortableDeviceFolderObject(string id) + : base(id) + { + + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFonctionalObject.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFonctionalObject.cs new file mode 100644 index 0000000..d2169a4 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceFonctionalObject.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent a fonctional object + /// + public class PortableDeviceFonctionalObject : PortableDeviceContainerObject + { + /// + /// Initialize a new instance of the class + /// + /// + public PortableDeviceFonctionalObject(string id) + : base(id) + { + + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/Model/PortableDeviceObject.cs b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceObject.cs new file mode 100644 index 0000000..5032495 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Model/PortableDeviceObject.cs @@ -0,0 +1,95 @@ +#region License +/* +PortableDeviceObject.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib.Model +{ + /// + /// Represent an objet in a WPD + /// + public class PortableDeviceObject + { + + /// + /// Initialize a new instance of the class + /// + /// + public PortableDeviceObject(string id) + { + if (string.IsNullOrEmpty(id)) + throw new ArgumentNullException("id"); + + this.ID = id; + } + + /// + /// Gets the ID of the object + /// + public string ID + { + get; + protected set; + } + + /// + /// Gets the name of the object + /// + public string Name + { + get; + internal set; + } + + /// + /// Gets the content type + /// + public string ContentType + { + get; + internal set; + } + + /// + /// Gets the format + /// + public string Format + { + get; + internal set; + } + + /// + /// + /// + /// + public override string ToString() + { + if (string.IsNullOrEmpty(Name)) + return this.ID; + else + return this.Name; + } + + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDevice.cs b/DigiCamControl/PortableDeviceLib/PortableDevice.cs new file mode 100644 index 0000000..2a51214 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDevice.cs @@ -0,0 +1,649 @@ +#region License +/* +PortableDevice.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Threading; +using PortableDeviceApiLib; +using System.Runtime.InteropServices; +using PortableDeviceLib.Model; +using System.ComponentModel; + +namespace PortableDeviceLib +{ + /// + /// Represent a portable device + /// + public class PortableDevice : IDisposable, INotifyPropertyChanged + { + /// + /// Event sended when portable device raise an event + /// + public event EventHandler DeviceEvent; + + /// + /// + /// + public event PropertyChangedEventHandler PropertyChanged; + + private object dispatcher; //Use an object for thread safety + + protected PortableDeviceApiLib.PortableDeviceClass portableDeviceClass; + private Dictionary values; + private PortableDeviceCapabilities deviceCapabilities; + private PortableDeviceFonctionalObject content; + + private string adviseCookie; + private PortableDeviceEventCallback eventCallback; + + #region Constructors + + /// + /// Default constructor + /// + /// + internal PortableDevice(string deviceId) + { + if (string.IsNullOrEmpty(deviceId)) + throw new ArgumentNullException("deviceId"); + this.dispatcher = new object(); + this.portableDeviceClass = new PortableDeviceApiLib.PortableDeviceClass(); + this.values = new Dictionary(); + + this.DeviceId = deviceId; + } + + #endregion + + #region Properties + + /// + /// Gets the device ID + /// + public string DeviceId + { + get; + private set; + } + + /// + /// Gets a value + /// + public bool IsConnected + { + get; + set; + } + + /// + /// Gets the Friendly name of the device + /// + public string FriendlyName + { + get + { + return GetStringProperty(PortableDevicePKeys.WPD_DEVICE_FRIENDLY_NAME); + } + } + + /// + /// Gets the battery level of the device + /// + public int BatteryLevel + { + get + { + return GetIntegerProperty(PortableDevicePKeys.WPD_DEVICE_POWER_LEVEL); + } + } + + public int FNumber + { + get + { + return GetIntegerProperty("StillCapture", PortableDevicePKeys.WPD_STILL_IMAGE_EXPOSURE_TIME); + } + } + + /// + /// Gets the device model + /// + public string Model + { + get + { + return GetStringProperty(PortableDevicePKeys.WPD_DEVICE_MODEL); + } + } + + /// + /// Gets the device Manufacturer + /// + public string Manufacturer + { + get + { + return GetStringProperty(PortableDevicePKeys.WPD_DEVICE_MANUFACTURER); + } + } + + /// + /// Gets the firmware version + /// + public string FirmwareVersion + { + get + { + return GetStringProperty(PortableDevicePKeys.WPD_DEVICE_FIRMWARE_VERSION); + } + } + + /// + /// Gets the serial number of device + /// + public string SerialNumber + { + get + { + return GetStringProperty(PortableDevicePKeys.WPD_DEVICE_SERIAL_NUMBER); + } + } + + /// + /// Gets the device type + /// + public string DeviceType + { + get + { + return this.GetStringProperty(PortableDevicePKeys.WPD_DEVICE_TYPE); + } + } + + /// + /// Gets the capabilities of the device + /// + public PortableDeviceCapabilities DeviceCapabilities + { + get + { + return deviceCapabilities; + } + } + + /// + /// Gets all content from device + /// If return is null be sure you call before + /// + public PortableDeviceFonctionalObject Content + { + get + { + return content; + } + } + + #endregion + + #region Public functions + + /// + /// Connect to the portable device + /// + /// + /// + /// + public void ConnectToDevice(string appName, float majorVersionNumber, float minorVersionNumber) + { + if (string.IsNullOrEmpty(appName)) + throw new ArgumentNullException("appName"); + + if(IsConnected) + return; + //Creating propValues for connection + IPortableDeviceValues clientValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + //Set the application name + _tagpropertykey prop = PortableDevicePKeys.WPD_CLIENT_NAME; + clientValues.SetStringValue(ref prop, appName); + //Set the App version + prop = PortableDevicePKeys.WPD_CLIENT_MAJOR_VERSION; + clientValues.SetFloatValue(ref prop, majorVersionNumber); + //Set the app minor version + prop = PortableDevicePKeys.WPD_CLIENT_MINOR_VERSION; + clientValues.SetFloatValue(ref prop, minorVersionNumber); + + //Open connection + this.portableDeviceClass.Open(this.DeviceId, clientValues); + + //Extract device capabilities + //this.ExtractDeviceCapabilities(); + + this.eventCallback = new PortableDeviceEventCallback(this); + // According to documentation pParameters should be null (see http://msdn.microsoft.com/en-us/library/dd375684%28v=VS.85%29.aspx ) + this.portableDeviceClass.Advise(0, this.eventCallback, null, out this.adviseCookie); + + IsConnected = true; + } + + /// + /// Disconnect from device + /// + public void Disconnect() + { + if (!this.IsConnected) + return; + + this.portableDeviceClass.Unadvise(this.adviseCookie); + this.eventCallback = null; + this.IsConnected = false; + } + + /// + /// Refresh content from device + /// + public void RefreshContent() + { + this.StartEnumerate(); + } + + /// + /// Execute the specified command + /// + /// + public void ExecuteCommand(_tagpropertykey command) + { + IPortableDeviceValues commandValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDeviceValues results; + + commandValues.SetGuidValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, ref command.fmtid); + commandValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, command.pid); + + // According to documentation, first parameter should be 0 (see http://msdn.microsoft.com/en-us/library/dd375691%28v=VS.85%29.aspx) + this.portableDeviceClass.SendCommand(0, commandValues, out results); + + } + + // uint tmpBufferSize = 0; + // uint tmpTransferSize = 0; + // string tmpTransferContext = string.Empty; + // { + // pResults.GetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, out tmpTransferContext); + // pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, out tmpBufferSize); + // pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPTIMAL_TRANSFER_BUFFER_SIZE, out tmpTransferSize); + + // try + // { + // int pValue; + // pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + // if(pValue!=0) + // { + // return null; + // } + // } + // catch + // { + // } + // } + + // pParameters.Clear(); + // pResults.Clear(); + + // byte[] tmpData = new byte[(int)tmpTransferSize]; + // //CCustomReadContext{81CD75F1-A997-4DA2-BAB1-FF5EC514E355} + // pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.fmtid); + // pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.pid); + // pParameters.SetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + // pParameters.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref tmpData[0], (uint)tmpTransferSize); + // pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_READ, (uint)tmpTransferSize); + // pParameters.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + + + // portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + // uint cbBytesRead = 0; + + // try + // { + // int pValue = 0; + // pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + // if (pValue != 0) + // return null; + // } + // catch(Exception ex) + // { + // } + // // 24,142,174,9 + // // 18, 8E + // GCHandle pinnedArray = GCHandle.Alloc(imgdate, GCHandleType.Pinned); + // IntPtr ptr = pinnedArray.AddrOfPinnedObject(); + + // uint dataread =0; + // pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_READ, out dataread); + // pResults.GetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ptr, out cbBytesRead); + + // IntPtr tmpPtr = new IntPtr(Marshal.ReadInt64(ptr)); + // byte[] res = new byte[(int)cbBytesRead]; + // for (int i = 0; i < cbBytesRead; i++) + // { + // res[i] = Marshal.ReadByte(tmpPtr, i); + // } + + // pParameters.Clear(); + // pResults.Clear(); + // { + // pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.fmtid); + // pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.pid); + // pParameters.SetStringValue(PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + // } + + // portableDeviceClass.SendCommand(0, pParameters, out pResults); + + // Marshal.FreeHGlobal(tmpPtr); + // pinnedArray.Free(); + // //Marshal.FreeHGlobal(ptr); + + // try + // { + // int tmpResult = 0; + + // pResults.GetErrorValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out tmpResult); + // if(tmpResult!=0) + // { + + // } + // } + // catch + // { + // } + // return res; + //} + + /// + /// Transfer from device to computer + /// Source : http://cgeers.com/2011/08/13/wpd-transferring-content/ + /// + /// + /// + public void SaveFile(string id, Stream targetStream) + { + IPortableDeviceContent content; + portableDeviceClass.Content(out content); + IPortableDeviceResources resources; + content.Transfer(out resources); + + PortableDeviceApiLib.IStream wpdStream = null; + uint optimalTransferSize = 0; + + var property = PortableDevicePKeys.WPD_RESOURCE_DEFAULT; + + + try + { + resources.GetStream(id, ref property, 0, ref optimalTransferSize, + out wpdStream); + } + catch (COMException comException) + { + // check if the device is busy, this may hapen when a another transfer not finished + if ((uint)comException.ErrorCode == PortableDeviceErrorCodes.ERROR_BUSY) + { + Thread.Sleep(500); + SaveFile(id, targetStream); + return; + } + throw comException; + } + + System.Runtime.InteropServices.ComTypes.IStream sourceStream = + (System.Runtime.InteropServices.ComTypes.IStream)wpdStream; + + unsafe + { + var buffer = new byte[1024*256]; + int bytesRead; + do + { + sourceStream.Read(buffer, buffer.Length, new IntPtr(&bytesRead)); + targetStream.Write(buffer, 0, bytesRead); + } while (bytesRead > 0); + + targetStream.Close(); + } + } + + /// + /// + /// + /// + public override string ToString() + { + if (IsConnected) + return FriendlyName; + else + return DeviceId; + } + + /// + /// Dispose the unmanaged resource + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + #endregion + + #region Protected functions + + /// + /// Raise the event + /// + /// + protected void RaisePropertyChanged(string propertyName) + { + if (this.PropertyChanged != null) + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + + #region Internal functions + + /// + /// Raise event from device + /// + internal void RaiseEvent(PortableDeviceEventType eventType) + { + if (this.DeviceEvent != null) + { + this.DeviceEvent(this, new PortableDeviceEventArgs(eventType)); + } + } + + #endregion + + #region Private functions + + private string GetStringProperty(_tagpropertykey propertyKey) + { + //Ensure we are connected to device + CheckIfIsConnected(); + + IPortableDeviceContent content; + IPortableDeviceProperties properties; + PortableDeviceApiLib.IPortableDeviceValues propertyValues; + + this.portableDeviceClass.Content(out content); + content.Properties(out properties); + + properties.GetValues("DEVICE", null, out propertyValues); + + string val = string.Empty; + propertyValues.GetStringValue(ref propertyKey, out val); + + return val; + } + + // + + private int GetIntegerProperty(string devisd, _tagpropertykey propertyKey) + { + //Ensure we are connected to device + CheckIfIsConnected(); + + IPortableDeviceContent content; + IPortableDeviceProperties properties; + PortableDeviceApiLib.IPortableDeviceValues propertyValues; + + this.portableDeviceClass.Content(out content); + + content.Properties(out properties); + properties.GetValues(devisd, null, out propertyValues); + float val = -1; + propertyValues.GetFloatValue(ref propertyKey, out val); + return Convert.ToInt32(val); + } + + private int GetIntegerProperty(_tagpropertykey propertyKey) + { + //Ensure we are connected to device + CheckIfIsConnected(); + + IPortableDeviceContent content; + IPortableDeviceProperties properties; + PortableDeviceApiLib.IPortableDeviceValues propertyValues; + + this.portableDeviceClass.Content(out content); + + content.Properties(out properties); + properties.GetValues("DEVICE", null, out propertyValues); + float val = -1; + propertyValues.GetFloatValue(ref propertyKey, out val); + return Convert.ToInt32(val); + } + + private void CheckIfIsConnected() + { + if (!this.IsConnected) + throw new Exception("Not connected"); + } + + private void ExtractDeviceCapabilities() + { + deviceCapabilities = new PortableDeviceCapabilities(); + deviceCapabilities.ExtractDeviceCapabilities(this.portableDeviceClass); + deviceCapabilities.ExtractCommands(this.portableDeviceClass); + deviceCapabilities.ExtractEvents(this.portableDeviceClass); + } + + private void StartEnumerate() + { + lock (this.dispatcher) + { + + PortableDeviceApiLib.IPortableDeviceContent pContent; + this.portableDeviceClass.Content(out pContent); + + this.content = new PortableDeviceFonctionalObject("DEVICE"); + Enumerate(ref pContent, "DEVICE", this.content); + + this.RaisePropertyChanged("Content"); + } + } + + private void Enumerate(ref PortableDeviceApiLib.IPortableDeviceContent pContent, string parentID, PortableDeviceContainerObject node) + { + PortableDeviceApiLib.IPortableDeviceProperties properties; + pContent.Properties(out properties); + + PortableDeviceApiLib.IEnumPortableDeviceObjectIDs pEnum; + pContent.EnumObjects(0, parentID, null, out pEnum); + + uint cFetched = 0; + PortableDeviceObject current; + do + { + string objectID; + pEnum.Next(1, out objectID, ref cFetched); + + if (cFetched > 0) + { + current = this.ExtractInformation(properties, objectID); + node.AddChild(current); + if (current is PortableDeviceContainerObject) + Enumerate(ref pContent, objectID, (PortableDeviceContainerObject)current); + } + + } while (cFetched > 0); + } + + private PortableDeviceObject ExtractInformation(PortableDeviceApiLib.IPortableDeviceProperties properties, string objectId) + { + PortableDeviceApiLib.IPortableDeviceKeyCollection keys; + properties.GetSupportedProperties(objectId, out keys); + + PortableDeviceApiLib.IPortableDeviceValues values; + properties.GetValues(objectId, keys, out values); + + string tmpVal; + string name; + values.GetStringValue(ref PortableDevicePKeys.WPD_OBJECT_NAME, out name); + + values.GetStringValue(ref PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE, out tmpVal); + var guid = new Guid(tmpVal); + string contentType = PortableDeviceHelpers.GetKeyNameFromGuid(guid); + + values.GetStringValue(ref PortableDevicePKeys.WPD_OBJECT_FORMAT, out tmpVal); + string formatType = PortableDeviceHelpers.GetKeyNameFromGuid(new Guid(tmpVal)); + + return Factories.PortableDeviceObjectFactory.Instance.CreateInstance(guid, objectId, name, contentType, formatType); + } + + private void Dispose(bool disposing) + { + if (disposing) + { + if (!string.IsNullOrEmpty(this.adviseCookie)) + this.portableDeviceClass.Unadvise(this.adviseCookie); + + if (this.IsConnected) + this.portableDeviceClass.Close(); + } + + this.portableDeviceClass = null; + } + + /// + /// Finalizer + /// + ~PortableDevice() + { + this.Dispose(false); + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceCapabilities.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceCapabilities.cs new file mode 100644 index 0000000..2a2cf18 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceCapabilities.cs @@ -0,0 +1,248 @@ +#region License +/* +PortableDeviceCapabilities.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using PortableDeviceApiLib; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Reflection; +using PortableDeviceLib.Model; + +namespace PortableDeviceLib +{ + /// + /// Represent the device capabilities + /// + public class PortableDeviceCapabilities + { + + private Dictionary functionalCategories; + private Dictionary commands; + private Dictionary events; + + /// + /// Default constructor + /// + internal PortableDeviceCapabilities() + { + this.functionalCategories = new Dictionary(); + this.commands = new Dictionary(); + this.events = new Dictionary(); + } + + /// + /// Gets all functional categories + /// + public IEnumerable FunctionalCategories + { + get + { + return this.functionalCategories.Values; + } + } + + /// + /// Gets commands from devices + /// + public IEnumerable Commands + { + get + { + return this.commands.Keys; + } + } + + /// + /// Gets supported events + /// + public IEnumerable Events + { + get + { + return this.events.Keys; + } + } + + /// + /// Extract device capabilities + /// + /// + internal void ExtractDeviceCapabilities(PortableDeviceClass portableDeviceClass) + { + if (portableDeviceClass == null) + throw new ArgumentNullException("portableDeviceClass"); + + try + { + PortableDeviceApiLib.IPortableDeviceCapabilities capabilities; + portableDeviceClass.Capabilities(out capabilities); + + if (capabilities == null) + { + Trace.WriteLine("Cannot extract capabilities from device"); + throw new PortableDeviceException("Cannot extract capabilities from device"); + } + + IPortableDevicePropVariantCollection functionalCategories; + capabilities.GetFunctionalCategories(out functionalCategories); + + if (functionalCategories == null) + { + throw new PortableDeviceException("Failed to extract functionnal categories"); + } + + uint countCategories = 1; + functionalCategories.GetCount(ref countCategories); + tag_inner_PROPVARIANT values = new tag_inner_PROPVARIANT(); + + PortableDeviceApiLib.IPortableDeviceValues pValues = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + string categoryName; + Guid currentGuid; + for (uint i = 0; i < countCategories; i++) + { + functionalCategories.GetAt(i, ref values); + + pValues.SetValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES, ref values); + pValues.GetStringValue(ref PortableDevicePKeys.WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES, out categoryName); + currentGuid = new Guid(categoryName); + this.functionalCategories.Add(currentGuid, new FunctionalCategory( + portableDeviceClass, + currentGuid, + PortableDeviceHelpers.GetKeyNameFromGuid(currentGuid))); + + } + + } + catch (Exception ex) + { + throw new PortableDeviceException("Error on extract device capabilities", ex); + } + } + + /// + /// Extract command supported by device + /// + /// + internal void ExtractCommands(PortableDeviceClass portableDeviceClass) + { + PortableDeviceApiLib.IPortableDeviceCapabilities capabilities; + portableDeviceClass.Capabilities(out capabilities); + + PortableDeviceApiLib.IPortableDeviceKeyCollection values; + capabilities.GetSupportedCommands(out values); + + _tagpropertykey key = new _tagpropertykey(); + _tagpropertykey tt; + string currentName; + + uint count = 1; + values.GetCount(ref count); + for (uint i = 0; i < count; i++) + { + values.GetAt(i, ref key); + + currentName = string.Empty; + foreach (FieldInfo fi in typeof(PortableDevicePKeys).GetFields()) + { + tt = (_tagpropertykey)fi.GetValue(null); + if (key.fmtid == tt.fmtid && key.pid == tt.pid) + currentName = fi.Name; + } + + if (!string.IsNullOrEmpty(currentName)) + this.commands.Add(currentName, key); + else + this.commands.Add(key.pid + " " + key.fmtid, key); + + } + } + + /// + /// Extract event supported by device + /// + /// + internal void ExtractEvents(PortableDeviceClass portableDeviceClass) + { + PortableDeviceApiLib.IPortableDeviceCapabilities capabilities; + portableDeviceClass.Capabilities(out capabilities); + + PortableDeviceApiLib.IPortableDevicePropVariantCollection events; + capabilities.GetSupportedEvents(out events); + + uint countEvents = 0; + events.GetCount(ref countEvents); + + PortableDeviceApiLib.IPortableDeviceValues pValues = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + tag_inner_PROPVARIANT evt = new tag_inner_PROPVARIANT(); + + Guid eventName; + IPortableDeviceValues eventOptions; + PortableDeviceEventDescription eventDescription; + + for (uint i = 0; i < countEvents; i++) + { + events.GetAt(i, ref evt); + pValues.SetValue(ref PortableDevicePKeys.WPD_EVENT_PARAMETER_EVENT_ID, ref evt); + pValues.GetGuidValue(ref PortableDevicePKeys.WPD_EVENT_PARAMETER_EVENT_ID, out eventName); + + eventDescription = new PortableDeviceEventDescription(eventName, PortableDeviceHelpers.GetKeyNameFromGuid(eventName)); + + //Retrieve options + try + { // Event option isn't always present, so ... + eventOptions = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + capabilities.GetEventOptions(ref eventName, out eventOptions); + + + + //eventOptions.GetBoolValue(ref PortableDevicePKeys.WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT, out isAutoPlayEvent); + //eventOptions.GetBoolValue(ref PortableDevicePKeys.WPD_EVENT_OPTION_IS_BROADCAST_EVENT, out isBroadcastEvent); + + //eventDescription.AddOptions(new PortableDeviceEventOption() + //{ + // Guid = PortableDevicePKeys.WPD_EVENT_OPTION_IS_BROADCAST_EVENT.fmtid, + // Name = PortableDeviceHelpers.GetKeyNameFromGuid(PortableDevicePKeys.WPD_EVENT_OPTION_IS_BROADCAST_EVENT.fmtid), + // Value = isBroadcastEvent, + // ValueType = TypeCode.Boolean + //}); + + //eventDescription.AddOptions(new PortableDeviceEventOption() + //{ + // Guid = PortableDevicePKeys.WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT.fmtid, + // Name = PortableDeviceHelpers.GetKeyNameFromGuid(PortableDevicePKeys.WPD_EVENT_OPTION_IS_AUTOPLAY_EVENT.fmtid), + // Value = isAutoPlayEvent, + // ValueType = TypeCode.Boolean + //}); + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + Debug.WriteLine(ex.StackTrace); + } + + this.events.Add(eventDescription, PortableDevicePKeys.WPD_EVENT_PARAMETER_EVENT_ID); + } + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceCollection.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceCollection.cs new file mode 100644 index 0000000..ba0fcbb --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceCollection.cs @@ -0,0 +1,208 @@ +#region License +/* +PortableDeviceCollection.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceApiLib; + +namespace PortableDeviceLib +{ + + /// + /// Manage a collection of from the WPD API Interop + /// + public class PortableDeviceCollection + { + private static PortableDeviceCollection _instance; + + private PortableDeviceManagerClass deviceManager; + private uint countDevices = 0; + private Dictionary portableDevices; + + private string appName; + private float majorVersion; + private float minorVersion; + + /// + /// Private default constructor + /// + private PortableDeviceCollection(string appName, float majorVersion, float minorVersion) + { + if (string.IsNullOrEmpty(appName)) + throw new ArgumentNullException("appName"); + + this.deviceManager = new PortableDeviceManagerClass(); + + this.portableDevices = new Dictionary(); + + this.appName = appName; + this.majorVersion = majorVersion; + this.minorVersion = minorVersion; + this.AutoConnectToPortableDevice = true; + } + + #region Properties + + /// + /// Get or set a value that indicate if we autoconnect to PortableDevice when creating a new instance + /// + public bool AutoConnectToPortableDevice + { + get; + set; + } + + /// + /// Gets the number of PortableDevice connected + /// + public int Count + { + get + { + RefreshDevices(); + return Convert.ToInt32(countDevices); + } + } + + /// + /// Get the device ID list + /// + public IEnumerable DeviceIds + { + get + { + return InternalGetDeviceIds(); + } + } + + /// + /// Get the list of devices + /// + public IEnumerable Devices + { + get + { + if (DeviceIds == null) + yield break; + + foreach (string id in DeviceIds) + yield return GetPortableDeviceById(id); + } + } + + /// + /// Gets or sets the instance of PortableDeviceCollection + /// + public static PortableDeviceCollection Instance + { + get + { + return _instance; + } + } + + #endregion + + /// + /// Get the portable device by his id + /// + /// + /// + public PortableDevice GetPortableDeviceById(string id) + { + if (string.IsNullOrEmpty(id)) + throw new ArgumentNullException("id"); + + if (!portableDevices.ContainsKey(id)) + { + PortableDevice portableDevice = new PortableDevice(id); + if( AutoConnectToPortableDevice ) + portableDevice.ConnectToDevice(appName, majorVersion, minorVersion); + portableDevices.Add(id, portableDevice); + } + + return this.portableDevices[id]; + } + + + /// + /// remove a disconected device, this should be call after device disconnected + /// + /// Device ide of the disconnected device + public void RemoveDevice(string id) + { + if(portableDevices.ContainsKey(id)) + { + portableDevices.Remove(id); + } + } + + /// + /// Create the unique instance of PortableDeviceCollection + /// + /// + /// + /// + /// + public static PortableDeviceCollection CreateInstance(string appName, float majorVersion, float minorVersion) + { + if (string.IsNullOrEmpty(appName)) + throw new ArgumentNullException("appName"); + + if (_instance == null) + _instance = new PortableDeviceCollection(appName, majorVersion, minorVersion); + + return _instance; + } + + public void RefreshDevices() + { + this.deviceManager.RefreshDeviceList(); + uint _countDevices = 1; + this.deviceManager.GetDevices(null, ref _countDevices); + string[] devicesIds = new string[_countDevices]; + this.deviceManager.GetDevices(devicesIds, ref _countDevices); + this.countDevices = _countDevices; + List removedDevices = + (from portableDevice in portableDevices + where devicesIds.Contains(portableDevice.Key) + select portableDevice.Key).ToList(); + foreach (string removedDevice in removedDevices) + { + RemoveDevice(removedDevice); + } + } + + private string[] InternalGetDeviceIds() + { + RefreshDevices(); + if (this.countDevices <= 0) + return null; + + string[] deviceIds = new string[this.countDevices]; + this.deviceManager.GetDevices(deviceIds, ref this.countDevices); + + return deviceIds; + } + + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceErrorCodes.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceErrorCodes.cs new file mode 100644 index 0000000..1d7e750 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceErrorCodes.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib +{ + public class PortableDeviceErrorCodes + { + public const uint ERROR_BUSY = 0x800700AA; + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceEventArgs.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceEventArgs.cs new file mode 100644 index 0000000..cb88096 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceEventArgs.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceLib.Model; + +namespace PortableDeviceLib +{ + /// + /// Event arguments for the event + /// + public class PortableDeviceEventArgs : EventArgs + { + #region Constructors + + /// + /// Initialize a new instance of the class + /// + public PortableDeviceEventArgs() + : base() + { + + } + + /// + /// Initialize a new instance of the class + /// + /// The event type + public PortableDeviceEventArgs(PortableDeviceEventType eventType) + : this() + { + this.EventType = eventType; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the event guid. + /// + public PortableDeviceEventType EventType + { + get; + set; + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceEventCallback.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceEventCallback.cs new file mode 100644 index 0000000..a9bae9d --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceEventCallback.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PortableDeviceApiLib; +using PortableDeviceLib.Factories; +using PortableDeviceLib.Model; + +namespace PortableDeviceLib +{ + /// + /// Manage event from device + /// + internal class PortableDeviceEventCallback : IPortableDeviceEventCallback + { + private PortableDevice device; + + /// + /// Initialize an new instance of the class + /// + /// + internal PortableDeviceEventCallback(PortableDevice portableDevice) + { + if (portableDevice == null) + throw new ArgumentNullException("portableDevice"); + + this.device = portableDevice; + } + + /// + /// Callback for event from device + /// + /// + public void OnEvent(IPortableDeviceValues pEventParameters) + { + string pnpDeviceId; + pEventParameters.GetStringValue(ref PortableDevicePKeys.WPD_EVENT_PARAMETER_PNP_DEVICE_ID, out pnpDeviceId); + if (this.device.DeviceId != pnpDeviceId) + return; + + Guid eventGuid; + pEventParameters.GetGuidValue(ref PortableDevicePKeys.WPD_EVENT_PARAMETER_EVENT_ID, out eventGuid); + + PortableDeviceEventType deviceEventType = new PortableDeviceEventType() {EventGuid = eventGuid}; + + if (eventGuid == PortableDeviceGuids.WPD_EVENT_OBJECT_ADDED) + { + string objectId; + pEventParameters.GetStringValue(ref PortableDevicePKeys.WPD_OBJECT_ID, out objectId); + string objectName; + pEventParameters.GetStringValue(ref PortableDevicePKeys.WPD_OBJECT_NAME, out objectName); + PortableDeviceObject deviceObject = new PortableDeviceObject(objectId) {Name = objectName}; + deviceEventType.DeviceObject = deviceObject; + } + + // the original api isn't finise, i use a siple workaroud, but this need to be fixed using event factory + //this.device.RaiseEvent(PortableDeviceEventTypeFactory.Instance.CreateEventType(eventGuid)); + this.device.RaiseEvent(deviceEventType); + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceException.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceException.cs new file mode 100644 index 0000000..ea49195 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceException.cs @@ -0,0 +1,50 @@ +#region License +/* +PortableDeviceException.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.Serialization; + +namespace PortableDeviceLib +{ + public class PortableDeviceException : Exception + { + + public PortableDeviceException() : + base() + { } + + public PortableDeviceException(string message) : + base(message) + { } + + public PortableDeviceException(string message, Exception innerException) + : base(message, innerException) + { } + + public PortableDeviceException(SerializationInfo info, StreamingContext context) + : base(info, context) + { } + + + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceGuids.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceGuids.cs new file mode 100644 index 0000000..bbccc2b --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceGuids.cs @@ -0,0 +1,140 @@ +#region License +/* +PortableDeviceGuids.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Text; + +namespace PortableDeviceLib +{ + + /// + /// Consts from wpd.h + /// + public static class PortableDeviceGuids + { + public static Guid GUID_DEVINTERFACE_WPD = new Guid(0x6AC27878, 0xA6FA, 0x4155, 0xBA, 0x85, 0xF9, 0x8F, 0x49, 0x1D, 0x4F, 0x33); + public static Guid GUID_DEVINTERFACE_WPD_PRIVATE = new Guid(0xBA0C718F, 0x4DED, 0x49B7, 0xBD, 0xD3, 0xFA, 0xBE, 0x28, 0x66, 0x12, 0x11); + public static Guid WPD_EVENT_NOTIFICATION = new Guid(0x2BA2E40A, 0x6B4C, 0x4295, 0xBB, 0x43, 0x26, 0x32, 0x2B, 0x99, 0xAE, 0xB2); + public static Guid WPD_EVENT_OBJECT_ADDED = new Guid(0xA726DA95, 0xE207, 0x4B02, 0x8D, 0x44, 0xBE, 0xF2, 0xE8, 0x6C, 0xBF, 0xFC); + public static Guid WPD_EVENT_OBJECT_REMOVED = new Guid(0xBE82AB88, 0xA52C, 0x4823, 0x96, 0xE5, 0xD0, 0x27, 0x26, 0x71, 0xFC, 0x38); + public static Guid WPD_EVENT_OBJECT_UPDATED = new Guid(0x1445A759, 0x2E01, 0x485D, 0x9F, 0x27, 0xFF, 0x07, 0xDA, 0xE6, 0x97, 0xAB); + public static Guid WPD_EVENT_DEVICE_RESET = new Guid(0x7755CF53, 0xC1ED, 0x44F3, 0xB5, 0xA2, 0x45, 0x1E, 0x2C, 0x37, 0x6B, 0x27); + public static Guid WPD_EVENT_DEVICE_CAPABILITIES_UPDATED = new Guid(0x36885AA1, 0xCD54, 0x4DAA, 0xB3, 0xD0, 0xAF, 0xB3, 0xE0, 0x3F, 0x59, 0x99); + public static Guid WPD_EVENT_STORAGE_FORMAT = new Guid(0x3782616B, 0x22BC, 0x4474, 0xA2, 0x51, 0x30, 0x70, 0xF8, 0xD3, 0x88, 0x57); + public static Guid WPD_EVENT_OBJECT_TRANSFER_REQUESTED = new Guid(0x8D16A0A1, 0xF2C6, 0x41DA, 0x8F, 0x19, 0x5E, 0x53, 0x72, 0x1A, 0xDB, 0xF2); + public static Guid WPD_EVENT_DEVICE_REMOVED = new Guid(0xE4CBCA1B, 0x6918, 0x48B9, 0x85, 0xEE, 0x02, 0xBE, 0x7C, 0x85, 0x0A, 0xF9); + public static Guid WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21); + public static Guid WPD_CONTENT_TYPE_FOLDER = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85); + public static Guid WPD_CONTENT_TYPE_IMAGE = new Guid(0xef2107d5, 0xa52a, 0x4243, 0xa2, 0x6b, 0x62, 0xd4, 0x17, 0x6d, 0x76, 0x03); + public static Guid WPD_CONTENT_TYPE_DOCUMENT = new Guid(0x680ADF52, 0x950A, 0x4041, 0x9B, 0x41, 0x65, 0xE3, 0x93, 0x64, 0x81, 0x55); + public static Guid WPD_CONTENT_TYPE_CONTACT = new Guid(0xEABA8313, 0x4525, 0x4707, 0x9F, 0x0E, 0x87, 0xC6, 0x80, 0x8E, 0x94, 0x35); + public static Guid WPD_CONTENT_TYPE_CONTACT_GROUP = new Guid(0x346B8932, 0x4C36, 0x40D8, 0x94, 0x15, 0x18, 0x28, 0x29, 0x1F, 0x9D, 0xE9); + public static Guid WPD_CONTENT_TYPE_AUDIO = new Guid(0x4AD2C85E, 0x5E2D, 0x45E5, 0x88, 0x64, 0x4F, 0x22, 0x9E, 0x3C, 0x6C, 0xF0); + public static Guid WPD_CONTENT_TYPE_VIDEO = new Guid(0x9261B03C, 0x3D78, 0x4519, 0x85, 0xE3, 0x02, 0xC5, 0xE1, 0xF5, 0x0B, 0xB9); + public static Guid WPD_CONTENT_TYPE_PLAYLIST = new Guid(0x1A33F7E4, 0xAF13, 0x48F5, 0x99, 0x4E, 0x77, 0x36, 0x9D, 0xFE, 0x04, 0xA3); + public static Guid WPD_CONTENT_TYPE_MIXED_CONTENT_ALBUM = new Guid(0x00F0C3AC, 0xA593, 0x49AC, 0x92, 0x19, 0x24, 0xAB, 0xCA, 0x5A, 0x25, 0x63); + public static Guid WPD_CONTENT_TYPE_AUDIO_ALBUM = new Guid(0xAA18737E, 0x5009, 0x48FA, 0xAE, 0x21, 0x85, 0xF2, 0x43, 0x83, 0xB4, 0xE6); + public static Guid WPD_CONTENT_TYPE_IMAGE_ALBUM = new Guid(0x75793148, 0x15F5, 0x4A30, 0xA8, 0x13, 0x54, 0xED, 0x8A, 0x37, 0xE2, 0x26); + public static Guid WPD_CONTENT_TYPE_VIDEO_ALBUM = new Guid(0x012B0DB7, 0xD4C1, 0x45D6, 0xB0, 0x81, 0x94, 0xB8, 0x77, 0x79, 0x61, 0x4F); + public static Guid WPD_CONTENT_TYPE_MEMO = new Guid(0x9CD20ECF, 0x3B50, 0x414F, 0xA6, 0x41, 0xE4, 0x73, 0xFF, 0xE4, 0x57, 0x51); + public static Guid WPD_CONTENT_TYPE_EMAIL = new Guid(0x8038044A, 0x7E51, 0x4F8F, 0x88, 0x3D, 0x1D, 0x06, 0x23, 0xD1, 0x45, 0x33); + public static Guid WPD_CONTENT_TYPE_APPOINTMENT = new Guid(0x0FED060E, 0x8793, 0x4B1E, 0x90, 0xC9, 0x48, 0xAC, 0x38, 0x9A, 0xC6, 0x31); + public static Guid WPD_CONTENT_TYPE_TASK = new Guid(0x63252F2C, 0x887F, 0x4CB6, 0xB1, 0xAC, 0xD2, 0x98, 0x55, 0xDC, 0xEF, 0x6C); + public static Guid WPD_CONTENT_TYPE_PROGRAM = new Guid(0xD269F96A, 0x247C, 0x4BFF, 0x98, 0xFB, 0x97, 0xF3, 0xC4, 0x92, 0x20, 0xE6); + public static Guid WPD_CONTENT_TYPE_GENERIC_FILE = new Guid(0x0085E0A6, 0x8D34, 0x45D7, 0xBC, 0x5C, 0x44, 0x7E, 0x59, 0xC7, 0x3D, 0x48); + public static Guid WPD_CONTENT_TYPE_CALENDAR = new Guid(0xA1FD5967, 0x6023, 0x49A0, 0x9D, 0xF1, 0xF8, 0x06, 0x0B, 0xE7, 0x51, 0xB0); + public static Guid WPD_CONTENT_TYPE_GENERIC_MESSAGE = new Guid(0xE80EAAF8, 0xB2DB, 0x4133, 0xB6, 0x7E, 0x1B, 0xEF, 0x4B, 0x4A, 0x6E, 0x5F); + public static Guid WPD_CONTENT_TYPE_NETWORK_ASSOCIATION = new Guid(0x031DA7EE, 0x18C8, 0x4205, 0x84, 0x7E, 0x89, 0xA1, 0x12, 0x61, 0xD0, 0xF3); + public static Guid WPD_CONTENT_TYPE_CERTIFICATE = new Guid(0xDC3876E8, 0xA948, 0x4060, 0x90, 0x50, 0xCB, 0xD7, 0x7E, 0x8A, 0x3D, 0x87); + public static Guid WPD_CONTENT_TYPE_WIRELESS_PROFILE = new Guid(0x0BAC070A, 0x9F5F, 0x4DA4, 0xA8, 0xF6, 0x3D, 0xE4, 0x4D, 0x68, 0xFD, 0x6C); + public static Guid WPD_CONTENT_TYPE_MEDIA_CAST = new Guid(0x5E88B3CC, 0x3E65, 0x4E62, 0xBF, 0xFF, 0x22, 0x94, 0x95, 0x25, 0x3A, 0xB0); + public static Guid WPD_CONTENT_TYPE_SECTION = new Guid(0x821089F5, 0x1D91, 0x4DC9, 0xBE, 0x3C, 0xBB, 0xB1, 0xB3, 0x5B, 0x18, 0xCE); + public static Guid WPD_CONTENT_TYPE_UNSPECIFIED = new Guid(0x28D8D31E, 0x249C, 0x454E, 0xAA, 0xBC, 0x34, 0x88, 0x31, 0x68, 0xE6, 0x34); + public static Guid WPD_CONTENT_TYPE_ALL = new Guid(0x80E170D2, 0x1055, 0x4A3E, 0xB9, 0x52, 0x82, 0xCC, 0x4F, 0x8A, 0x86, 0x89); + public static Guid WPD_FUNCTIONAL_CATEGORY_DEVICE = new Guid(0x08EA466B, 0xE3A4, 0x4336, 0xA1, 0xF3, 0xA4, 0x4D, 0x2B, 0x5C, 0x43, 0x8C); + public static Guid WPD_FUNCTIONAL_CATEGORY_STORAGE = new Guid(0x23F05BBC, 0x15DE, 0x4C2A, 0xA5, 0x5B, 0xA9, 0xAF, 0x5C, 0xE4, 0x12, 0xEF); + public static Guid WPD_FUNCTIONAL_CATEGORY_STILL_IMAGE_CAPTURE = new Guid(0x613CA327, 0xAB93, 0x4900, 0xB4, 0xFA, 0x89, 0x5B, 0xB5, 0x87, 0x4B, 0x79); + public static Guid WPD_FUNCTIONAL_CATEGORY_AUDIO_CAPTURE = new Guid(0x3F2A1919, 0xC7C2, 0x4A00, 0x85, 0x5D, 0xF5, 0x7C, 0xF0, 0x6D, 0xEB, 0xBB); + public static Guid WPD_FUNCTIONAL_CATEGORY_VIDEO_CAPTURE = new Guid(0xE23E5F6B, 0x7243, 0x43AA, 0x8D, 0xF1, 0x0E, 0xB3, 0xD9, 0x68, 0xA9, 0x18); + public static Guid WPD_FUNCTIONAL_CATEGORY_SMS = new Guid(0x0044A0B1, 0xC1E9, 0x4AFD, 0xB3, 0x58, 0xA6, 0x2C, 0x61, 0x17, 0xC9, 0xCF); + public static Guid WPD_FUNCTIONAL_CATEGORY_RENDERING_INFORMATION = new Guid(0x08600BA4, 0xA7BA, 0x4A01, 0xAB, 0x0E, 0x00, 0x65, 0xD0, 0xA3, 0x56, 0xD3); + public static Guid WPD_FUNCTIONAL_CATEGORY_NETWORK_CONFIGURATION = new Guid(0x48F4DB72, 0x7C6A, 0x4AB0, 0x9E, 0x1A, 0x47, 0x0E, 0x3C, 0xDB, 0xF2, 0x6A); + public static Guid WPD_FUNCTIONAL_CATEGORY_ALL = new Guid(0x2D8A6512, 0xA74C, 0x448E, 0xBA, 0x8A, 0xF4, 0xAC, 0x07, 0xC4, 0x93, 0x99); + public static Guid WPD_OBJECT_FORMAT_PROPERTIES_ONLY = new Guid(0x30010000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_UNSPECIFIED = new Guid(0x30000000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_SCRIPT = new Guid(0x30020000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_EXECUTABLE = new Guid(0x30030000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_TEXT = new Guid(0x30040000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_HTML = new Guid(0x30050000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_DPOF = new Guid(0x30060000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_AIFF = new Guid(0x30070000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_WAVE = new Guid(0x30080000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MP3 = new Guid(0x30090000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_AVI = new Guid(0x300A0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MPEG = new Guid(0x300B0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ASF = new Guid(0x300C0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_EXIF = new Guid(0x38010000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_TIFFEP = new Guid(0x38020000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_FLASHPIX = new Guid(0x38030000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_BMP = new Guid(0x38040000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_CIFF = new Guid(0x38050000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_GIF = new Guid(0x38070000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_JFIF = new Guid(0x38080000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_PCD = new Guid(0x38090000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_PICT = new Guid(0x380A0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_PNG = new Guid(0x380B0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_TIFF = new Guid(0x380D0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_TIFFIT = new Guid(0x380E0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_JP2 = new Guid(0x380F0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_JPX = new Guid(0x38100000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_WINDOWSIMAGEFORMAT = new Guid(0xB8810000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_WMA = new Guid(0xB9010000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_WMV = new Guid(0xB9810000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_WPLPLAYLIST = new Guid(0xBA100000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_M3UPLAYLIST = new Guid(0xBA110000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MPLPLAYLIST = new Guid(0xBA120000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ASXPLAYLIST = new Guid(0xBA130000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_PLSPLAYLIST = new Guid(0xBA140000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ABSTRACT_CONTACT_GROUP = new Guid(0xBA060000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ABSTRACT_MEDIA_CAST = new Guid(0xBA0B0000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_VCALENDAR1 = new Guid(0xBE020000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_VCARD2 = new Guid(0xBB820000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_VCARD3 = new Guid(0xBB830000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ICON = new Guid(0x077232ED, 0x102C, 0x4638, 0x9C, 0x22, 0x83, 0xF1, 0x42, 0xBF, 0xC8, 0x22); + public static Guid WPD_OBJECT_FORMAT_XML = new Guid(0xBA820000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_AAC = new Guid(0xB9030000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_AUDIBLE = new Guid(0xB9040000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_FLAC = new Guid(0xB9060000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_OGG = new Guid(0xB9020000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MP4 = new Guid(0xB9820000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MP2 = new Guid(0xB9830000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MICROSOFT_WORD = new Guid(0xBA830000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MHT_COMPILED_HTML = new Guid(0xBA840000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MICROSOFT_EXCEL = new Guid(0xBA850000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MICROSOFT_POWERPOINT = new Guid(0xBA860000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_NETWORK_ASSOCIATION = new Guid(0xB1020000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_X509V3CERTIFICATE = new Guid(0xB1030000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_MICROSOFT_WFC = new Guid(0xB1040000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_3GP = new Guid(0xB9840000, 0xAE6C, 0x4804, 0x98, 0xBA, 0xC5, 0x7B, 0x46, 0x96, 0x5F, 0xE7); + public static Guid WPD_OBJECT_FORMAT_ALL = new Guid(0xC1F62EB2, 0x4BB3, 0x479C, 0x9C, 0xFA, 0x05, 0xB5, 0xF3, 0xA5, 0x7B, 0x22); + + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceHelpers.cs b/DigiCamControl/PortableDeviceLib/PortableDeviceHelpers.cs new file mode 100644 index 0000000..1c5ef28 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceHelpers.cs @@ -0,0 +1,166 @@ +#region License +/* +PortableDeviceHelpers.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Reflection; + +namespace PortableDeviceLib +{ + + // Nested Types + [StructLayout(LayoutKind.Explicit, Size = 16)] + public struct PropVariant + { + [FieldOffset(0)] + public short variantType; + [FieldOffset(8)] + public IntPtr pointerValue; + [FieldOffset(8)] + public byte byteValue; + [FieldOffset(8)] + public long longValue; + [FieldOffset(8)] + public double dateValue; + [FieldOffset(8)] + public short boolValue; + } + + + internal static class PortableDeviceHelpers + { + public static int VT_DATE; + public static int VT_LPWSTR; + public static int VT_UI4; + public static int VT_UI8; + public static int VT_UINT; + + private static Dictionary _values; + private static Dictionary _portableDeviceGuidWithName; + + static PortableDeviceHelpers() + { + VT_LPWSTR = 0x1f; + VT_DATE = 7; + VT_UI4 = 0x13; + VT_UINT = 0x17; + VT_UI8 = 0x15; + + _values = new Dictionary(); + _values.Add(MTPConstants.OBJECT_PLAY_COUNT, PortableDevicePKeys.WPD_MEDIA_USE_COUNT); + _values.Add(MTPConstants.OBJECT_GENRE, PortableDevicePKeys.WPD_MEDIA_GENRE); + _values.Add(MTPConstants.OBJECT_STAR_RATING, PortableDevicePKeys.WPD_MEDIA_STAR_RATING); + _values.Add(MTPConstants.OBJECT_ARTIST, PortableDevicePKeys.WPD_MEDIA_ARTIST); + _values.Add(MTPConstants.OBJECT_ALBUM_ARTIST, PortableDevicePKeys.WPD_MEDIA_ALBUM_ARTIST); + _values.Add(MTPConstants.OBJECT_SUBSCRIPTION_CONTENT_ID, PortableDevicePKeys.WPD_MEDIA_SUBSCRIPTION_CONTENT_ID); + _values.Add(MTPConstants.OBJECT_EFFECTIVE_RATING, PortableDevicePKeys.WPD_MEDIA_USER_EFFECTIVE_RATING); + _values.Add(MTPConstants.OBJECT_ALBUM, PortableDevicePKeys.WPD_MUSIC_ALBUM); + _values.Add(MTPConstants.OBJECT_TRACK, PortableDevicePKeys.WPD_MUSIC_TRACK); + _values.Add(MTPConstants.OBJECT_ID, PortableDevicePKeys.WPD_OBJECT_ID); + _values.Add(MTPConstants.OBJECT_SIZE, PortableDevicePKeys.WPD_OBJECT_SIZE); + _values.Add(MTPConstants.OBJECT_DURATION, PortableDevicePKeys.WPD_MEDIA_DURATION); + _values.Add(MTPConstants.OBJECT_TITLE, PortableDevicePKeys.WPD_MEDIA_TITLE); + _values.Add(MTPConstants.OBJECT_DATE_AUTHORED, PortableDevicePKeys.WPD_OBJECT_DATE_AUTHORED); + _values.Add(MTPConstants.OBJECT_DATE_CREATED, PortableDevicePKeys.WPD_OBJECT_DATE_CREATED); + _values.Add(MTPConstants.OBJECT_MODIFIED, PortableDevicePKeys.WPD_OBJECT_DATE_MODIFIED); + _values.Add(MTPConstants.OBJECT_FORMAT, PortableDevicePKeys.WPD_OBJECT_FORMAT); + _values.Add(MTPConstants.OBJECT_DRM_PROTECTED, PortableDevicePKeys.WPD_OBJECT_IS_DRM_PROTECTED); + _values.Add(MTPConstants.OBJECT_FILENAME, PortableDevicePKeys.WPD_OBJECT_ORIGINAL_FILE_NAME); + _values.Add(MTPConstants.OBJECT_NAME, PortableDevicePKeys.WPD_OBJECT_NAME); + _values.Add(MTPConstants.OBJECT_PERSISTENT_ID, PortableDevicePKeys.WPD_OBJECT_PERSISTENT_UNIQUE_ID); + _values.Add(MTPConstants.OBJECT_TOTAL_BITRATE, PortableDevicePKeys.WPD_MEDIA_TOTAL_BITRATE); + _values.Add(MTPConstants.OBJECT_SKIP_COUNT, PortableDevicePKeys.WPD_MEDIA_SKIP_COUNT); + _values.Add(MTPConstants.OBJECT_SAMPLE_RATE, PortableDevicePKeys.WPD_MEDIA_SAMPLE_RATE); + _values.Add(MTPConstants.OBJECT_RELEASE_DATE, PortableDevicePKeys.WPD_MEDIA_RELEASE_DATE); + _values.Add(MTPConstants.OBJECT_LAST_BUILD_DATE, PortableDevicePKeys.WPD_MEDIA_LAST_BUILD_DATE); + _values.Add(MTPConstants.OBJECT_LAST_ACCESSED_TIME, PortableDevicePKeys.WPD_MEDIA_LAST_ACCESSED_TIME); + _values.Add(MTPConstants.OBJECT_BITRATE_TYPE, PortableDevicePKeys.WPD_MEDIA_BITRATE_TYPE); + _values.Add(MTPConstants.OBJECT_ALBUM_ART, PortableDevicePKeys.WPD_RESOURCE_ALBUM_ART); + _values.Add(MTPConstants.DEVICE_FIRMWARE_VERSION, PortableDevicePKeys.WPD_DEVICE_FIRMWARE_VERSION); + _values.Add(MTPConstants.DEVICE_FRIENDLY_NAME, PortableDevicePKeys.WPD_DEVICE_FRIENDLY_NAME); + _values.Add(MTPConstants.DEVICE_MANUFACTURER, PortableDevicePKeys.WPD_DEVICE_MANUFACTURER); + _values.Add(MTPConstants.DEVICE_MODEL, PortableDevicePKeys.WPD_DEVICE_MODEL); + _values.Add(MTPConstants.DEVICE_BATTERY_LEVEL, PortableDevicePKeys.WPD_DEVICE_POWER_LEVEL); + _values.Add(MTPConstants.DEVICE_POWER_SOURCE, PortableDevicePKeys.WPD_DEVICE_POWER_SOURCE); + _values.Add(MTPConstants.DEVICE_SERIAL_NUMBER, PortableDevicePKeys.WPD_DEVICE_SERIAL_NUMBER); + _values.Add(MTPConstants.OBJECT_CONTENT_TYPE, PortableDevicePKeys.WPD_OBJECT_CONTENT_TYPE); + + _portableDeviceGuidWithName = MakeGlobalDictionary(); + } + + public static Dictionary PortableDeviceGuidWithName + { + get + { + return _portableDeviceGuidWithName; + } + } + + public static string GetNameFromGuid(PortableDeviceApiLib._tagpropertykey key, PortableDeviceApiLib.tag_inner_PROPVARIANT values) + { + PortableDeviceApiLib.IPortableDeviceValues pValues = (PortableDeviceApiLib.IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + string contentTypeName; + + pValues.SetValue(ref key, ref values); + pValues.GetStringValue(ref key, out contentTypeName); + + return contentTypeName; + } + + public static string GetKeyNameFromGuid(Guid guid) + { + if (PortableDeviceHelpers.PortableDeviceGuidWithName.ContainsKey(guid)) + return PortableDeviceHelpers.PortableDeviceGuidWithName[guid]; + else + return guid.ToString(); + } + + internal static string GetKeyNameFromPropkey(PortableDeviceApiLib._tagpropertykey propertyKey) + { + foreach (KeyValuePair de in _values) + { + if ((propertyKey.pid == de.Value.pid) && (propertyKey.fmtid == de.Value.fmtid)) + { + return (string)de.Key; + } + } + + return (propertyKey.pid.ToString() + " " + propertyKey.fmtid.ToString()); + + } + + private static Dictionary MakeGlobalDictionary() + { + Dictionary dic = new Dictionary(); + foreach (FieldInfo fi in typeof(PortableDeviceGuids).GetFields()) + { + dic.Add((Guid)fi.GetValue(null), fi.Name); + } + + return dic; + } + + + + } +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj new file mode 100644 index 0000000..c9b9705 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj @@ -0,0 +1,256 @@ + + + + Debug + AnyCPU + 10.0.20728 + 2.0 + {E9F048C1-C6A0-4CCD-BE57-4E76A7F8B32D} + Library + Properties + PortableDeviceLib + PortableDeviceLib + v4.6 + 512 + + + + + + + + + + + 3.5 + + false + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + AnyCPU + AllRules.ruleset + true + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + false + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + true + false + + + bin\Release\ + TRACE + true + none + x86 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + true + false + + + true + bin\Debug\ + DEBUG;TRACE + true + full + x64 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + true + true + false + false + + + bin\x64\Release\ + TRACE + true + true + x64 + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + false + false + false + false + + + true + bin\Capture.Workflow\ + DEBUG;TRACE + true + full + x86 + prompt + AllRules.ruleset + + + true + bin\x86\Capture.Workflow\ + DEBUG;TRACE + true + full + x86 + prompt + AllRules.ruleset + + + true + bin\x64\Capture.Workflow\ + DEBUG;TRACE + true + full + x64 + prompt + AllRules.ruleset + + + false + + + PortableDeviceLib.snk + + + + False + ..\..\refs\Interop.PortableDeviceApiLib.dll + False + + + False + ..\..\refs\Interop.PortableDeviceTypesLib.dll + False + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj.vspscc b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj.vspscc new file mode 100644 index 0000000..b6d3289 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/DigiCamControl/PortableDeviceLib/PortableDeviceLib.snk b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.snk new file mode 100644 index 0000000..9567769 Binary files /dev/null and b/DigiCamControl/PortableDeviceLib/PortableDeviceLib.snk differ diff --git a/DigiCamControl/PortableDeviceLib/Properties/AssemblyInfo.cs b/DigiCamControl/PortableDeviceLib/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bfd9ac --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Properties/AssemblyInfo.cs @@ -0,0 +1,56 @@ +#region License +/* +AssemblyInfo.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("PortableDeviceLib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Vincent Lainé")] +[assembly: AssemblyProduct("PortableDeviceLib")] +[assembly: AssemblyCopyright("Copyright © Vincent Lainé 2009")] +[assembly: AssemblyTrademark("LGPL")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("4ed6171c-5f2f-4031-8d2f-4eb3b78670a1")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] \ No newline at end of file diff --git a/DigiCamControl/PortableDeviceLib/StillImageDevice.cs b/DigiCamControl/PortableDeviceLib/StillImageDevice.cs new file mode 100644 index 0000000..169d5ce --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/StillImageDevice.cs @@ -0,0 +1,615 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using PortableDeviceApiLib; + +namespace PortableDeviceLib +{ + + public class StillImageDevice : PortableDevice + { + public delegate void TransferCallback(uint total, uint current); + + public StillImageDevice(string deviceId) + : base(deviceId) + { + + } + + public uint ResetDevice() + { + IPortableDeviceValues commandValues = + (IPortableDeviceValues) new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDeviceValues results; + + commandValues.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_COMMON_RESET_DEVICE.fmtid); + commandValues.SetUnsignedIntegerValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_COMMON_RESET_DEVICE.pid); + + this.portableDeviceClass.SendCommand(0, commandValues, out results); + + try + { + int iValue = 0; + results.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out iValue); + if (iValue != 0) + return (uint)iValue; + uint pValue = 0; + results.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out pValue); + if (pValue != 0) + return pValue; + } + catch (Exception) + { + } + return 0; + } + + public uint ExecuteWithNoData(uint code, params uint[] parameters) + { + IPortableDeviceValues commandValues = + (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDevicePropVariantCollection propVariant = + (IPortableDevicePropVariantCollection)new PortableDeviceTypesLib.PortableDevicePropVariantCollection(); + IPortableDeviceValues results; + + //commandValues.SetGuidValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, ref command.fmtid); + commandValues.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITHOUT_DATA_PHASE.fmtid); + commandValues.SetUnsignedIntegerValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITHOUT_DATA_PHASE. + pid); + + foreach (uint parameter in parameters) + { + tag_inner_PROPVARIANT vparam = new tag_inner_PROPVARIANT(); + UintToPropVariant(parameter, out vparam); + propVariant.Add(ref vparam); + } + + commandValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_CODE, code); + + commandValues.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + + // According to documentation, first parameter should be 0 (see http://msdn.microsoft.com/en-us/library/dd375691%28v=VS.85%29.aspx) + this.portableDeviceClass.SendCommand(0, commandValues, out results); + //int pvalue = 0; + try + { + int iValue = 0; + results.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out iValue); + if (iValue != 0) + return (uint)iValue; + uint pValue = 0; + results.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out pValue); + if (pValue != 0) + return pValue; + } + catch (Exception) + { + } + //results.GetSignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out pvalue); + return 0; + } + + public MTPDataResponse ExecuteReadBigData(uint code,Stream stream, TransferCallback callback, params uint[] parameters) + { + MTPDataResponse res = new MTPDataResponse(); + // source: http://msdn.microsoft.com/en-us/library/windows/desktop/ff384843(v=vs.85).aspx + // and view-source:http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26860397.html + // error codes http://msdn.microsoft.com/en-us/library/windows/desktop/dd319335(v=vs.85).aspx + byte[] imgdate = new byte[8]; + + IPortableDeviceValues commandValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDeviceValues pParameters = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValues(); + + IPortableDevicePropVariantCollection propVariant = + (IPortableDevicePropVariantCollection)new PortableDeviceTypesLib.PortableDevicePropVariantCollection(); + IPortableDeviceValues pResults; + + //commandValues.SetGuidValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, ref command.fmtid); + commandValues.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ.fmtid); + commandValues.SetUnsignedIntegerValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ.pid); + commandValues.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref imgdate[0], (uint)imgdate.Length); + + foreach (uint parameter in parameters) + { + tag_inner_PROPVARIANT vparam = new tag_inner_PROPVARIANT(); + UintToPropVariant(parameter, out vparam); + propVariant.Add(ref vparam); + + } + + commandValues.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + commandValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_CODE, (uint)code); + + // According to documentation, first parameter should be 0 (see http://msdn.microsoft.com/en-us/library/dd375691%28v=VS.85%29.aspx) + this.portableDeviceClass.SendCommand(0, commandValues, out pResults); + + try + { + int pValue = 0; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + // check if the device is busy, and after 100 ms seconds try again + if (((uint)pValue) == PortableDeviceErrorCodes.ERROR_BUSY) + { + Thread.Sleep(50); + return ExecuteReadBigData(code, stream, callback, parameters); + } + } + } + catch (Exception) + { + } + //string pwszContext = string.Empty; + //pResults.GetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, out pwszContext); + //uint cbReportedDataSize = 0; + //pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, out cbReportedDataSize); + + + uint tmpBufferSize = 0; + uint tmpTransferSize = 0; + string tmpTransferContext = string.Empty; + { + pResults.GetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, out tmpTransferContext); + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, out tmpBufferSize); + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPTIMAL_TRANSFER_BUFFER_SIZE, out tmpTransferSize); + + try + { + int pValue; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + return null; + } + } + catch + { + } + } + + + pParameters.Clear(); + pResults.Clear(); + uint offset = 0; + res.Data = null; + bool cont = true; + + do + { + if (offset + tmpTransferSize >= tmpBufferSize) + { + cont = false; + tmpTransferSize = (uint)(tmpBufferSize - offset); + } + + byte[] tmpData = new byte[(int)tmpTransferSize]; + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.pid); + pParameters.SetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + pParameters.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref tmpData[0], + (uint)tmpTransferSize); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_READ, + (uint)tmpTransferSize); + pParameters.SetIPortableDevicePropVariantCollectionValue( + ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + uint cbBytesRead = 0; + + try + { + int pValue = 0; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + res.ErrorCode = (uint)pValue; + return res; + } + } + catch (Exception) + { + } + + callback(tmpBufferSize, offset); + + GCHandle pinnedArray = GCHandle.Alloc(imgdate, GCHandleType.Pinned); + IntPtr ptr = pinnedArray.AddrOfPinnedObject(); + + uint dataread = 0; + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_READ, + out dataread); + pResults.GetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ptr, out cbBytesRead); + + IntPtr tmpPtr = new IntPtr(Marshal.ReadInt64(ptr)); + + byte[] buffer = new byte[(int)cbBytesRead]; + Marshal.Copy(tmpPtr, buffer, 0, (int)cbBytesRead); + stream.Write(buffer, 0, (int)cbBytesRead); + + + //for (int i = 0; i < cbBytesRead; i++) + //{ + // res.Data[offset + i] = Marshal.ReadByte(tmpPtr, i); + //} + + Marshal.FreeHGlobal(tmpPtr); + pinnedArray.Free(); + + offset += cbBytesRead; + } while (cont); + + pParameters.Clear(); + pResults.Clear(); + { + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.pid); + pParameters.SetStringValue(PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + } + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + try + { + int tmpResult = 0; + + pResults.GetErrorValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out tmpResult); + if (tmpResult != 0) + { + + } + } + catch + { + } + return res; + } + + public MTPDataResponse ExecuteReadData(uint code, params uint[] parameters) + { + IPortableDevicePropVariantCollection propVariant = + (IPortableDevicePropVariantCollection)new PortableDeviceTypesLib.PortableDevicePropVariantCollection(); + + foreach (uint parameter in parameters) + { + if (parameter != 0) + { + tag_inner_PROPVARIANT vparam1 = new tag_inner_PROPVARIANT(); + UintToPropVariant(parameter, out vparam1); + propVariant.Add(ref vparam1); + } + + } + return ExecuteReadData(code, propVariant); + } + + private MTPDataResponse ExecuteReadData(uint code, IPortableDevicePropVariantCollection propVariant) + { + MTPDataResponse resp = new MTPDataResponse(); + + // source: http://msdn.microsoft.com/en-us/library/windows/desktop/ff384843(v=vs.85).aspx + // and view-source:http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26860397.html + // error codes http://msdn.microsoft.com/en-us/library/windows/desktop/dd319335(v=vs.85).aspx + byte[] imgdate = new byte[8]; + + IPortableDeviceValues commandValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDeviceValues pParameters = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValues(); + + IPortableDeviceValues pResults; + + //commandValues.SetGuidValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, ref command.fmtid); + commandValues.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ.fmtid); + commandValues.SetUnsignedIntegerValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ.pid); + commandValues.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref imgdate[0], (uint)imgdate.Length); + + + + commandValues.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + commandValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_CODE, (uint)code); + + // According to documentation, first parameter should be 0 (see http://msdn.microsoft.com/en-us/library/dd375691%28v=VS.85%29.aspx) + this.portableDeviceClass.SendCommand(0, commandValues, out pResults); + + try + { + int pValue; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + resp.ErrorCode = (uint)pValue; + return resp; + } + } + catch (Exception) + { + } + + uint tmpBufferSize = 0; + uint tmpTransferSize = 0; + string tmpTransferContext = string.Empty; + { + pResults.GetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, out tmpTransferContext); + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, out tmpBufferSize); + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPTIMAL_TRANSFER_BUFFER_SIZE, out tmpTransferSize); + + } + + pParameters.Clear(); + pResults.Clear(); + + byte[] tmpData = new byte[(int)tmpTransferSize]; + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_READ_DATA.pid); + pParameters.SetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + pParameters.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref tmpData[0], (uint)tmpTransferSize); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_READ, (uint)tmpTransferSize); + pParameters.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + uint cbBytesRead = 0; + + try + { + int pValue; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + resp.ErrorCode = (uint)pValue; + return resp; + } + } + catch (Exception) + { + } + // 24,142,174,9 + // 18, 8E + GCHandle pinnedArray = GCHandle.Alloc(imgdate, GCHandleType.Pinned); + IntPtr ptr = pinnedArray.AddrOfPinnedObject(); + + uint dataread = 0; + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_READ, out dataread); + pResults.GetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ptr, out cbBytesRead); + + + IntPtr tmpPtr = new IntPtr(Marshal.ReadInt64(ptr)); + resp.Data = new byte[(int)cbBytesRead]; + Marshal.Copy(tmpPtr, resp.Data, 0, (int)cbBytesRead); + //for (int i = 0; i < cbBytesRead; i++) + //{ + // resp.Data[i] = Marshal.ReadByte(tmpPtr, i); + //} + + Marshal.FreeHGlobal(tmpPtr); + pinnedArray.Free(); + + pParameters.Clear(); + pResults.Clear(); + { + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.pid); + pParameters.SetStringValue(PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + } + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + + try + { + int pValue; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + resp.ErrorCode = (uint)pValue; + return resp; + } + + uint iValue; + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out iValue); + if (iValue != 0) + { + resp.ErrorCode = iValue; + return resp; + } + } + catch + { + } + return resp; + } + + public uint ExecuteWriteData(uint code, byte[] data, params uint[] parameters) + { + // source: http://msdn.microsoft.com/en-us/library/windows/desktop/ff384843(v=vs.85).aspx + // and view-source:http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26860397.html + // error codes http://msdn.microsoft.com/en-us/library/windows/desktop/dd319335(v=vs.85).aspx + //byte[] imgdate = new byte[8]; + + IPortableDeviceValues commandValues = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValuesClass(); + IPortableDeviceValues pParameters = (IPortableDeviceValues)new PortableDeviceTypesLib.PortableDeviceValues(); + + IPortableDevicePropVariantCollection propVariant = + (IPortableDevicePropVariantCollection)new PortableDeviceTypesLib.PortableDevicePropVariantCollection(); + IPortableDeviceValues pResults; + + //commandValues.SetGuidValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, ref command.fmtid); + commandValues.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_WRITE.fmtid); + commandValues.SetUnsignedIntegerValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, + PortableDevicePKeys.WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_WRITE.pid); + commandValues.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref data[0], (uint)data.Length); + + foreach (uint parameter in parameters) + { + tag_inner_PROPVARIANT vparam = new tag_inner_PROPVARIANT(); + UintToPropVariant(parameter, out vparam); + propVariant.Add(ref vparam); + } + + commandValues.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + commandValues.SetUnsignedLargeIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_TOTAL_DATA_SIZE, + (ulong)data.Length); + commandValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_CODE, (uint)code); + + // According to documentation, first parameter should be 0 (see http://msdn.microsoft.com/en-us/library/dd375691%28v=VS.85%29.aspx) + this.portableDeviceClass.SendCommand(0, commandValues, out pResults); + + try + { + int pValue = 0; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + { + return (uint)pValue; + } + //uint mtperror; + //pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out mtperror); + //if (mtperror != 0) + // return mtperror; + } + catch (Exception) + { + } + string tmpTransferContext = string.Empty; + pResults.GetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, out tmpTransferContext); + + + pParameters.Clear(); + pResults.Clear(); + + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_WRITE_DATA.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_WRITE_DATA.pid); + pParameters.SetStringValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + pParameters.SetBufferValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_DATA, ref data[0], (uint)data.Length); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_NUM_BYTES_TO_WRITE, (uint)data.Length); + pParameters.SetIPortableDevicePropVariantCollectionValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_OPERATION_PARAMS, propVariant); + + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + try + { + int pValue = 0; + pResults.GetErrorValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out pValue); + if (pValue != 0) + return (uint)pValue; + //uint mtperror; + //pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out mtperror); + //if (mtperror != 0) + // return mtperror; + } + catch (Exception) + { + } + + + pParameters.Clear(); + pResults.Clear(); + { + pParameters.SetGuidValue(PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_CATEGORY, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.fmtid); + pParameters.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_COMMAND_ID, PortableDevicePKeys.WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER.pid); + pParameters.SetStringValue(PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_TRANSFER_CONTEXT, tmpTransferContext); + } + + portableDeviceClass.SendCommand(0, pParameters, out pResults); + + + try + { + int tmpResult = 0; + + pResults.GetErrorValue(ref PortableDevicePKeys.WPD_PROPERTY_COMMON_HRESULT, out tmpResult); + if (tmpResult != 0) + { + return (uint)tmpResult; + } + uint mtperror; + pResults.GetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_PROPERTY_MTP_EXT_RESPONSE_CODE, out mtperror); + if (mtperror != 0) + return mtperror; + } + catch + { + } + return 0; + } + + private void StringToPropVariant(string value, + out PortableDeviceApiLib.tag_inner_PROPVARIANT propvarValue) + { + // We'll use an IPortableDeviceValues object to transform the + // string into a PROPVARIANT + PortableDeviceApiLib.IPortableDeviceValues pValues = + (PortableDeviceApiLib.IPortableDeviceValues) + new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + // We insert the string value into the IPortableDeviceValues object + // using the SetStringValue method + pValues.SetStringValue(ref PortableDevicePKeys.WPD_OBJECT_ID, value); + + // We then extract the string into a PROPVARIANT by using the + // GetValue method + pValues.GetValue(ref PortableDevicePKeys.WPD_OBJECT_ID, + out propvarValue); + } + + private void UintToPropVariant(uint value, + out PortableDeviceApiLib.tag_inner_PROPVARIANT propvarValue) + { + // We'll use an IPortableDeviceValues object to transform the + // string into a PROPVARIANT + PortableDeviceApiLib.IPortableDeviceValues pValues = + (PortableDeviceApiLib.IPortableDeviceValues) + new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + // We insert the string value into the IPortableDeviceValues object + // using the SetStringValue method + pValues.SetUnsignedIntegerValue(ref PortableDevicePKeys.WPD_OBJECT_ID, (uint)value); + + // We then extract the string into a PROPVARIANT by using the + // GetValue method + pValues.GetValue(ref PortableDevicePKeys.WPD_OBJECT_ID, + out propvarValue); + } + + private void uLongIntToPropVariant(ulong value, out PortableDeviceApiLib.tag_inner_PROPVARIANT propvarValue) + { + // We'll use an IPortableDeviceValues object to transform the + // string into a PROPVARIANT + PortableDeviceApiLib.IPortableDeviceValues pValues = + (PortableDeviceApiLib.IPortableDeviceValues) + new PortableDeviceTypesLib.PortableDeviceValuesClass(); + + // We insert the string value into the IPortableDeviceValues object + // using the SetStringValue method + pValues.SetUnsignedLargeIntegerValue(ref PortableDevicePKeys.WPD_OBJECT_ID, (ulong)value); + + // We then extract the string into a PROPVARIANT by using the + // GetValue method + pValues.GetValue(ref PortableDevicePKeys.WPD_OBJECT_ID, + out propvarValue); + } + } +} diff --git a/DigiCamControl/PortableDeviceLib/Tree.cs b/DigiCamControl/PortableDeviceLib/Tree.cs new file mode 100644 index 0000000..c40ce34 --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/Tree.cs @@ -0,0 +1,35 @@ +#region License +/* +Tree.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib +{ + public class Tree : TreeNode + { + public Tree() + : base(null) + { } + + } +} diff --git a/DigiCamControl/PortableDeviceLib/TreeNode.cs b/DigiCamControl/PortableDeviceLib/TreeNode.cs new file mode 100644 index 0000000..ea1799c --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/TreeNode.cs @@ -0,0 +1,132 @@ +#region License +/* +TreeNode.cs +Copyright (C) 2009 Vincent Lainé + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#endregion +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PortableDeviceLib +{ + public class TreeNode : IEnumerable>, ITreeNode + { + + private List> childs; + + public TreeNode(TreeNode parent) + { + this.childs = new List>(); + this.Parent = parent; + } + + public TreeNode(TreeNode parent, T value) + : this(parent) + { + this.Value = value; + } + + public TreeNode Parent + { + get; + private set; + } + + public TreeNode this[int index] + { + get + { + return this.childs[index]; + } + } + + public IEnumerable> Childs + { + get + { + return this.childs; + } + } + + public int Count + { + get + { + return this.childs.Count; + } + } + + public T Value + { + get; + set; + } + + public TreeNode AddChild(T value) + { + TreeNode child = new TreeNode(this, value); + this.AddChild(child); + return child; + } + + public void AddChild(TreeNode child) + { + if (child == null) + throw new ArgumentNullException("child"); + + this.childs.Add(child); + } + + public void RemoveChild(TreeNode child) + { + if (child == null) + throw new ArgumentNullException("child"); + + this.childs.Remove(child); + } + + public TreeNode RemoveChild(int index) + { + if (index < 0 || index >= this.childs.Count) + throw new ArgumentOutOfRangeException("index"); + + TreeNode child = this.childs[index]; + this.childs.RemoveAt(index); + return child; + } + + #region IEnumerable> Members + + public IEnumerator> GetEnumerator() + { + return this.childs.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.childs.GetEnumerator(); + } + + #endregion + } +} diff --git a/DigiCamControl/PortableDeviceLib/WinApi.cs b/DigiCamControl/PortableDeviceLib/WinApi.cs new file mode 100644 index 0000000..37f268f --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/WinApi.cs @@ -0,0 +1,70 @@ +using System; +using System.Runtime.InteropServices; +using System.Threading; + +namespace PortableDeviceLib +{ + public class WinApi + { + [Flags] + public enum DesiredAccess : uint + { + GENERIC_READ = 0x80000000, + GENERIC_WRITE = 0x40000000 + } + [Flags] + public enum ShareMode : uint + { + FILE_SHARE_NONE = 0x0, + FILE_SHARE_READ = 0x1, + FILE_SHARE_WRITE = 0x2, + FILE_SHARE_DELETE = 0x4, + + } + + public enum CreationDisposition : uint + { + CREATE_NEW = 1, + CREATE_ALWAYS = 2, + OPEN_EXISTING = 3, + OPEN_ALWAYS = 4, + TRUNCATE_EXSTING = 5 + } + + [Flags] + public enum FlagsAndAttributes : uint + { + FILE_ATTRIBUTES_ARCHIVE = 0x20, + FILE_ATTRIBUTE_HIDDEN = 0x2, + FILE_ATTRIBUTE_NORMAL = 0x80, + FILE_ATTRIBUTE_OFFLINE = 0x1000, + FILE_ATTRIBUTE_READONLY = 0x1, + FILE_ATTRIBUTE_SYSTEM = 0x4, + FILE_ATTRIBUTE_TEMPORARY = 0x100, + FILE_FLAG_WRITE_THROUGH = 0x80000000, + FILE_FLAG_OVERLAPPED = 0x40000000, + FILE_FLAG_NO_BUFFERING = 0x20000000, + FILE_FLAG_RANDOM_ACCESS = 0x10000000, + FILE_FLAG_SEQUENTIAL_SCAN = 0x8000000, + FILE_FLAG_DELETE_ON = 0x4000000, + FILE_FLAG_POSIX_SEMANTICS = 0x1000000, + FILE_FLAG_OPEN_REPARSE_POINT = 0x200000, + FILE_FLAG_OPEN_NO_CALL = 0x100000 + } + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern IntPtr CreateFile( + string lpFileName, uint dwDesiredAccess, + uint dwShareMode, IntPtr lpSecurityAttributes, + uint dwCreationDisposition, + uint dwFlagsAndAttributes, IntPtr hTemplateFile); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern public bool WriteFile(IntPtr handle, IntPtr buffer, + int numBytesToWrite, IntPtr numBytesWritten, [In] ref NativeOverlapped lpOverlapped); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern bool CloseHandle(IntPtr hObject); + + } +} diff --git a/DigiCamControl/PortableDeviceLib/packages.config b/DigiCamControl/PortableDeviceLib/packages.config new file mode 100644 index 0000000..702580e --- /dev/null +++ b/DigiCamControl/PortableDeviceLib/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/EDSDKLib/API/Base/Camera.cs b/EDSDKLib/API/Base/Camera.cs index 1064af6..e67523f 100644 --- a/EDSDKLib/API/Base/Camera.cs +++ b/EDSDKLib/API/Base/Camera.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using EDSDKLib.API.Base; +using Logging; namespace EOSDigital.API { @@ -207,6 +208,36 @@ internal protected Camera(IntPtr camRef) Dispose(false); } + public bool IsOldCanon() + { + string[] models = + { + " 1000D", " 40D", " 450D", " 50D", " 400D", " 500D", " 550D", "Rebel XSi", "Rebel XTi", + "Rebel XS", "Rebel T1i", "1Ds Mark III" + }; + + Logger.WriteTraceMessage(Info.DeviceDescription.ToLower()); + return models.Any(model => Info.DeviceDescription.ToLower().Contains(model.ToLower())); + } + + + + public bool IsManualMode() + { + UInt32 mode; + CanonSDK.EdsGetPropertyData(CamRef, PropertyID.AEModeSelect, 0, out mode); + bool isManual = (mode == 3); + return isManual; + } + + public bool IsBulbMode() + { + UInt32 mode; + CanonSDK.EdsGetPropertyData(CamRef, PropertyID.AEModeSelect, 0, out mode); + bool isBulb = (mode == 4); + return isBulb; + } + /// /// Open a new session with camera /// @@ -445,7 +476,19 @@ private ErrorCode Camera_SDKStateEvent(StateEventID inEvent, int inParameter, In public void TakePhoto() { CheckState(); - SendCommand(CameraCommand.TakePicture); + //SendCommand(CameraCommand.TakePicture); + + if (IsOldCanon()) + { + SendCommand(CameraCommand.TakePicture); + return; + } + Logger.WriteTraceMessage("TakePhoto Completely"); + SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); + Logger.WriteTraceMessage("Sending OFF"); + SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF); + + } /// @@ -473,11 +516,15 @@ public void TakePhotoAsync() public void TakePhotoShutter() { CheckState(); - MainThread.Invoke(() => - { - SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); - SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF); - }); + try + { + MainThread.Invoke(() => + { + SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); + //SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); + }); + } + catch (Exception ex) { if (!ErrorHandler.ReportError(this, ex)) throw; } } /// @@ -496,7 +543,7 @@ public void TakePhotoShutterAsync() MainThread.Invoke(() => { SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); - SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF); + //SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); }); } catch (Exception ex) { if (!ErrorHandler.ReportError(this, ex)) throw; } @@ -538,15 +585,18 @@ public void TakePhotoBulbAsync(int bulbTime, CanceledFlag canceledFlag) catch (Exception ex) { if (!ErrorHandler.ReportError(this, ex)) throw; } }); } - + private void BulbExposure(int bulbTime, CanceledFlag canceledFlag) { try { + Logger.WriteTraceMessage("Try Press"); + //SendCommand(CameraCommand.PressShutterButton, (int)65539); SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); } catch (ExecutionException) { + Logger.WriteTraceMessage("Try BulbStart"); SendCommand(CameraCommand.BulbStart); } @@ -566,10 +616,13 @@ private void BulbExposure(int bulbTime, CanceledFlag canceledFlag) try { - SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF); + Logger.WriteTraceMessage("Try Press"); + SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely); + SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF); // Test for new cameras } catch (ExecutionException) { + Logger.WriteTraceMessage("Try BulbEnd"); SendCommand(CameraCommand.BulbEnd); } } @@ -817,10 +870,13 @@ public CameraValue[] GetSettingsList(PropertyID propId) /// An SDK call failed public void SendCommand(CameraCommand command, int inParam = 0) { + Logger.WriteTraceMessage("Sending Command = " + command.ToString() + "'"); + CheckState(); MainThread.Invoke(() => ErrorHandler.CheckError(this, CanonSDK.EdsSendCommand(CamRef, command, inParam))); } + /// /// Sends a Status Command to the camera /// @@ -832,6 +888,8 @@ public void SendCommand(CameraCommand command, int inParam = 0) /// An SDK call failed public void SendStatusCommand(CameraStatusCommand command, int inParam = 0) { + Logger.WriteTraceMessage("SendStatusCommand = " + command.ToString() + "'"); + CheckState(); MainThread.Invoke(() => ErrorHandler.CheckError(this, CanonSDK.EdsSendStatusCommand(CamRef, command, inParam))); } @@ -946,12 +1004,113 @@ public void SetSetting(PropertyID propID, object value, int inParam = 0) { CheckState(); + //Teste BUSY + //System.Timers.Timer _timer = new System.Timers.Timer(1000 / 10); + ErrorCode _error = 0; + int retrynum = 0; + bool retry = false; + //_timer.Start(); + //bool timerstate = _timer.Enabled; + //_timer.Stop(); + + MainThread.Invoke(() => { - int propsize; + Logger.WriteTraceMessage("SetSetting Start " + propID + "=" + value); + int propsize=0; DataType proptype; - ErrorHandler.CheckError(this, CanonSDK.EdsGetPropertySize(CamRef, propID, inParam, out proptype, out propsize)); - ErrorHandler.CheckError(this, CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propsize, value)); + Logger.WriteTraceMessage("GetPropertySize Start " + propID + "=" + value); + + //ErrorHandler.CheckError(this, CanonSDK.EdsGetPropertySize(CamRef, propID, inParam, out proptype, out propsize)); + + do + { + if (retrynum > 5) + { + return; + } + try + { + retry = false; + _error = CanonSDK.EdsGetPropertySize(CamRef, propID, inParam, out proptype, out propsize); + + if (_error != ErrorCode.OK) + { + if (_error == ErrorCode.DEVICE_BUSY) + { + Logger.WriteTraceMessage("GetPropertySize DEVICE BUSY " + _error.ToString()); + Thread.Sleep(100); + retry = true; + retrynum++; + } + else + { + ErrorHandler.CheckError(this, _error); + } + Logger.WriteTraceMessage("GetPropertySize NOT OK " + _error.ToString()); + } + else + { + Logger.WriteTraceMessage("GetPropertySize OK " + _error.ToString()); + } + } + catch (Exception exception) + { + Logger.WriteTraceMessage("Error EOS set property :" + propID.ToString("X") + " | " + exception); + } + } while (retry); + //if (timerstate) + // _timer.Start(); + //ErrorHandler.CheckError(this, CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propsize, value)); + _error = 0; + + + Logger.WriteTraceMessage("GetPropertySize End " + propID + "=" + value); + Logger.WriteTraceMessage("SetPropertyData Start " + propID + "=" + value); + + + do { + if (retrynum > 5) + { + return; + } + try { + retry = false; + _error = CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propsize, value); + + if (_error != ErrorCode.OK) + { + if (_error == ErrorCode.DEVICE_BUSY) + { + Logger.WriteTraceMessage("SetPropertyData DEVICE BUSY " + _error.ToString()); + Thread.Sleep(100); + retry = true; + retrynum++; + } + else + { + ErrorHandler.CheckError(this, _error); + } + Logger.WriteTraceMessage("SetPropertyData NOT OK " + _error.ToString()); + + } + else + { + Logger.WriteTraceMessage("SetPropertyData OK " + _error.ToString()); + } + } + catch (Exception exception) + { + Logger.WriteTraceMessage("Error EOS set property :" + propID.ToString("X") + " | " + exception); + } + } while (retry); + //if (timerstate) + // _timer.Start(); + //ErrorHandler.CheckError(this, CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propsize, value)); + _error = 0; + + Logger.WriteTraceMessage("SetPropertyData Start " + propID + "=" + value); + Logger.WriteTraceMessage("SetSetting End " + propID + "=" + value); }); } @@ -968,8 +1127,10 @@ public void SetSetting(PropertyID propID, object value, int inParam = 0) /// An SDK call failed public void SetSetting(PropertyID propID, string value, int inParam = 0, int MAX = 32) { + Logger.WriteTraceMessage("SetSetting Start2 " + propID + "=" + value); CheckState(); + if (value == null) value = string.Empty; if (value.Length > MAX - 1) value = value.Substring(0, MAX - 1); @@ -979,6 +1140,7 @@ public void SetSetting(PropertyID propID, string value, int inParam = 0, int MAX ErrorHandler.CheckError(this, CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propBytes.Length, propBytes)); }); + Logger.WriteTraceMessage("SetSetting End2 " + propID + "=" + value); } /// diff --git a/EDSDKLib/API/Helper/ExceptionHandling.cs b/EDSDKLib/API/Helper/ExceptionHandling.cs index ccd96a6..b20dfc2 100644 --- a/EDSDKLib/API/Helper/ExceptionHandling.cs +++ b/EDSDKLib/API/Helper/ExceptionHandling.cs @@ -1,418 +1,434 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Remoting.Messaging; -using System.Runtime.Serialization; -using System.Security.Permissions; -using System.Threading.Tasks; -using EOSDigital.SDK; - -namespace EOSDigital.API -{ - /// - /// An Exception that happened while handling the Canon SDK - /// - [Serializable] - public sealed class SDKException : Exception - { - /// - /// The specific SDK error code that happened - /// - public ErrorCode Error { get; private set; } - - /// - /// Initializes a new instance of the class - /// - public SDKException() - { - Error = ErrorCode.INTERNAL_ERROR; - } - - /// - /// Initializes a new instance of the class with a specified error code - /// - /// The SDK error code of the error that happened - public SDKException(ErrorCode Error) - : base(Error.ToString()) - { - this.Error = Error; - } - - /// - /// Initializes a new instance of the class with a specified error message - /// - /// The error message that explains the reason for the exception. - public SDKException(string message) - : base(message) - { - Error = ErrorCode.INTERNAL_ERROR; - } - - /// - /// Initializes a new instance of the class with a specified - /// error message and a reference to the inner exception that is the cause of - /// this exception - /// - /// The error message that explains the reason for the exception - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified - public SDKException(string message, Exception innerException) - : base(message, innerException) - { - Error = ErrorCode.INTERNAL_ERROR; - } - - /// - /// Initializes a new instance of the class with a specified error message and error code - /// - /// The SDK error code of the error that happened - /// The error message that explains the reason for the exception - public SDKException(string message, ErrorCode Error) - : base(message) - { - this.Error = Error; - } - - /// - /// Initializes a new instance of the class with a specified - /// error message, error code and a reference to the inner exception that is the cause of - /// this exception - /// - /// The error message that explains the reason for the exception - /// The SDK error code of the error that happened - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified. - public SDKException(string message, ErrorCode Error, Exception innerException) - : base(message, innerException) - { - this.Error = Error; - } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual - /// information about the source or destination. - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - private SDKException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - Error = (ErrorCode)info.GetUInt32("Error"); - } - - /// - /// When overridden in a derived class, sets the - /// with information about the exception. - /// - /// The - /// that holds the serialized object data about the exception being thrown - /// The - /// that contains contextual information about the source or destination. - /// The info parameter is a null reference - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - info.AddValue("Error", Error); - - base.GetObjectData(info, context); - } - } - - /// - /// An Exception that states a problem with the session state of the camera - /// - [Serializable] - public sealed class CameraSessionException : Exception - { - /// - /// Initializes a new instance of the class - /// - public CameraSessionException() - { } - - /// - /// Initializes a new instance of the class with a specified error message - /// - /// The error message that explains the reason for the exception. - public CameraSessionException(string message) - : base(message) - { } - - /// - /// Initializes a new instance of the class with a specified - /// error message and a reference to the inner exception that is the cause of - /// this exception - /// - /// The error message that explains the reason for the exception - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified - public CameraSessionException(string message, Exception innerException) - : base(message, innerException) - { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual - /// information about the source or destination. - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - private CameraSessionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - - /// - /// When overridden in a derived class, sets the - /// with information about the exception. - /// - /// The - /// that holds the serialized object data about the exception being thrown - /// The - /// that contains contextual information about the source or destination. - /// The info parameter is a null reference - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - base.GetObjectData(info, context); - } - } - - /// - /// An Exception that states a problem with the state of the Canon SDK - /// - [Serializable] - public sealed class SDKStateException : Exception - { - /// - /// Initializes a new instance of the class - /// - public SDKStateException() - { } - - /// - /// Initializes a new instance of the class with a specified error message - /// - /// The error message that explains the reason for the exception. - public SDKStateException(string message) - : base(message) - { } - - /// - /// Initializes a new instance of the class with a specified - /// error message and a reference to the inner exception that is the cause of - /// this exception - /// - /// The error message that explains the reason for the exception - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified - public SDKStateException(string message, Exception innerException) - : base(message, innerException) - { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual - /// information about the source or destination. - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - private SDKStateException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - - /// - /// When overridden in a derived class, sets the - /// with information about the exception. - /// - /// The - /// that holds the serialized object data about the exception being thrown - /// The - /// that contains contextual information about the source or destination. - /// The info parameter is a null reference - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - base.GetObjectData(info, context); - } - } - - /// - /// An Exception that happened while executing on an STA thread - /// - [Serializable] - public sealed class ExecutionException : Exception - { - /// - /// Initializes a new instance of the class with a specified error message - /// - /// The error message that explains the reason for the exception. - public ExecutionException(string message) - : base(message) - { } - - /// - /// Initializes a new instance of the class with a reference to - /// the inner exception that is the cause of this exception - /// - /// The error message that explains the reason for the exception - /// The exception that is the cause of the current exception, or a null reference - /// (Nothing in Visual Basic) if no inner exception is specified - public ExecutionException(string message, Exception innerException) - : base(message, innerException) - { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The that holds the serialized - /// object data about the exception being thrown. - /// The that contains contextual - /// information about the source or destination. - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - private ExecutionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - - /// - /// When overridden in a derived class, sets the - /// with information about the exception. - /// - /// The - /// that holds the serialized object data about the exception being thrown - /// The - /// that contains contextual information about the source or destination. - /// The info parameter is a null reference - [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - base.GetObjectData(info, context); - } - } - - /// - /// Handles errors and provides events for errors (e.g. focus problems or general exceptions) - /// - public static class ErrorHandler - { - /// - /// If an error happened, that does not break the program, this event is fired (e.g. a focus error) - /// - public static event SDKExceptionHandler NonSevereErrorHappened; - - /// - /// If an error happened on a thread that does not fall into the non-severe category, this event is fired - /// - public static event GeneralExceptionHandler SevereErrorHappened; - - /// - /// List of all non-severe errors. Items can be added or removed. - /// - public static List NonSevereErrors { get; private set; } - - static ErrorHandler() - { - NonSevereErrors = new List() - { - ErrorCode.TAKE_PICTURE_AF_NG, - ErrorCode.TAKE_PICTURE_CARD_NG, - ErrorCode.TAKE_PICTURE_CARD_PROTECT_NG, - ErrorCode.TAKE_PICTURE_LV_REL_PROHIBIT_MODE_NG, - ErrorCode.TAKE_PICTURE_MIRROR_UP_NG, - ErrorCode.TAKE_PICTURE_MOVIE_CROP_NG, - ErrorCode.TAKE_PICTURE_NO_CARD_NG, - ErrorCode.TAKE_PICTURE_NO_LENS_NG, - ErrorCode.TAKE_PICTURE_SENSOR_CLEANING_NG, - ErrorCode.TAKE_PICTURE_SILENCE_NG, - ErrorCode.TAKE_PICTURE_SPECIAL_MOVIE_MODE_NG, - ErrorCode.TAKE_PICTURE_STROBO_CHARGE_NG, - ErrorCode.LENS_COVER_CLOSE, - ErrorCode.DEVICE_BUSY, - }; - } - - /// - /// Checks for an error in SDK calls and checks how to treat it - /// - /// The sender object - /// The return code of the SDK call - /// If a severe error is recognized or the - /// event is null with a non-severe error, it will be thrown as an exception - public static void CheckError(object sender, ErrorCode errorCode) - { - if (errorCode == ErrorCode.OK) return; - else - { - bool Severe = !NonSevereErrors.Any(t => t == errorCode); - - var NonSevereErrorHappenedEvent = NonSevereErrorHappened; - if (!Severe) Severe = NonSevereErrorHappenedEvent == null; - - if (Severe) throw new SDKException(errorCode); - else +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Remoting.Messaging; +using System.Runtime.Serialization; +using System.Security.Permissions; +using System.Threading.Tasks; +using EOSDigital.SDK; +using Logging; + +namespace EOSDigital.API +{ + /// + /// An Exception that happened while handling the Canon SDK + /// + [Serializable] + public sealed class SDKException : Exception + { + /// + /// The specific SDK error code that happened + /// + public ErrorCode Error { get; private set; } + + /// + /// Initializes a new instance of the class + /// + public SDKException() + { + Error = ErrorCode.INTERNAL_ERROR; + } + + /// + /// Initializes a new instance of the class with a specified error code + /// + /// The SDK error code of the error that happened + public SDKException(ErrorCode Error) + : base(Error.ToString()) + { + this.Error = Error; + } + + /// + /// Initializes a new instance of the class with a specified error message + /// + /// The error message that explains the reason for the exception. + public SDKException(string message) + : base(message) + { + Error = ErrorCode.INTERNAL_ERROR; + } + + /// + /// Initializes a new instance of the class with a specified + /// error message and a reference to the inner exception that is the cause of + /// this exception + /// + /// The error message that explains the reason for the exception + /// The exception that is the cause of the current exception, or a null reference + /// (Nothing in Visual Basic) if no inner exception is specified + public SDKException(string message, Exception innerException) + : base(message, innerException) + { + Error = ErrorCode.INTERNAL_ERROR; + } + + /// + /// Initializes a new instance of the class with a specified error message and error code + /// + /// The SDK error code of the error that happened + /// The error message that explains the reason for the exception + public SDKException(string message, ErrorCode Error) + : base(message) + { + this.Error = Error; + } + + /// + /// Initializes a new instance of the class with a specified + /// error message, error code and a reference to the inner exception that is the cause of + /// this exception + /// + /// The error message that explains the reason for the exception + /// The SDK error code of the error that happened + /// The exception that is the cause of the current exception, or a null reference + /// (Nothing in Visual Basic) if no inner exception is specified. + public SDKException(string message, ErrorCode Error, Exception innerException) + : base(message, innerException) + { + this.Error = Error; + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + private SDKException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + Error = (ErrorCode)info.GetUInt32("Error"); + } + + /// + /// When overridden in a derived class, sets the + /// with information about the exception. + /// + /// The + /// that holds the serialized object data about the exception being thrown + /// The + /// that contains contextual information about the source or destination. + /// The info parameter is a null reference + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) throw new ArgumentNullException(nameof(info)); + info.AddValue("Error", Error); + + base.GetObjectData(info, context); + } + } + + /// + /// An Exception that states a problem with the session state of the camera + /// + [Serializable] + public sealed class CameraSessionException : Exception + { + /// + /// Initializes a new instance of the class + /// + public CameraSessionException() + { } + + /// + /// Initializes a new instance of the class with a specified error message + /// + /// The error message that explains the reason for the exception. + public CameraSessionException(string message) + : base(message) + { } + + /// + /// Initializes a new instance of the class with a specified + /// error message and a reference to the inner exception that is the cause of + /// this exception + /// + /// The error message that explains the reason for the exception + /// The exception that is the cause of the current exception, or a null reference + /// (Nothing in Visual Basic) if no inner exception is specified + public CameraSessionException(string message, Exception innerException) + : base(message, innerException) + { } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + private CameraSessionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { } + + /// + /// When overridden in a derived class, sets the + /// with information about the exception. + /// + /// The + /// that holds the serialized object data about the exception being thrown + /// The + /// that contains contextual information about the source or destination. + /// The info parameter is a null reference + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) throw new ArgumentNullException(nameof(info)); + base.GetObjectData(info, context); + } + } + + /// + /// An Exception that states a problem with the state of the Canon SDK + /// + [Serializable] + public sealed class SDKStateException : Exception + { + /// + /// Initializes a new instance of the class + /// + public SDKStateException() + { } + + /// + /// Initializes a new instance of the class with a specified error message + /// + /// The error message that explains the reason for the exception. + public SDKStateException(string message) + : base(message) + { } + + /// + /// Initializes a new instance of the class with a specified + /// error message and a reference to the inner exception that is the cause of + /// this exception + /// + /// The error message that explains the reason for the exception + /// The exception that is the cause of the current exception, or a null reference + /// (Nothing in Visual Basic) if no inner exception is specified + public SDKStateException(string message, Exception innerException) + : base(message, innerException) + { } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + private SDKStateException(SerializationInfo info, StreamingContext context) + : base(info, context) + { } + + /// + /// When overridden in a derived class, sets the + /// with information about the exception. + /// + /// The + /// that holds the serialized object data about the exception being thrown + /// The + /// that contains contextual information about the source or destination. + /// The info parameter is a null reference + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) throw new ArgumentNullException(nameof(info)); + base.GetObjectData(info, context); + } + } + + /// + /// An Exception that happened while executing on an STA thread + /// + [Serializable] + public sealed class ExecutionException : Exception + { + /// + /// Initializes a new instance of the class with a specified error message + /// + /// The error message that explains the reason for the exception. + public ExecutionException(string message) + : base(message) + { } + + /// + /// Initializes a new instance of the class with a reference to + /// the inner exception that is the cause of this exception + /// + /// The error message that explains the reason for the exception + /// The exception that is the cause of the current exception, or a null reference + /// (Nothing in Visual Basic) if no inner exception is specified + public ExecutionException(string message, Exception innerException) + : base(message, innerException) + { } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + private ExecutionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { } + + /// + /// When overridden in a derived class, sets the + /// with information about the exception. + /// + /// The + /// that holds the serialized object data about the exception being thrown + /// The + /// that contains contextual information about the source or destination. + /// The info parameter is a null reference + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + if (info == null) throw new ArgumentNullException(nameof(info)); + base.GetObjectData(info, context); + } + } + + /// + /// Handles errors and provides events for errors (e.g. focus problems or general exceptions) + /// + public static class ErrorHandler + { + /// + /// If an error happened, that does not break the program, this event is fired (e.g. a focus error) + /// + public static event SDKExceptionHandler NonSevereErrorHappened; + + /// + /// If an error happened on a thread that does not fall into the non-severe category, this event is fired + /// + public static event GeneralExceptionHandler SevereErrorHappened; + + /// + /// List of all non-severe errors. Items can be added or removed. + /// + public static List NonSevereErrors { get; private set; } + + static ErrorHandler() + { + NonSevereErrors = new List() + { + ErrorCode.TAKE_PICTURE_AF_NG, + ErrorCode.TAKE_PICTURE_CARD_NG, + ErrorCode.TAKE_PICTURE_CARD_PROTECT_NG, + ErrorCode.TAKE_PICTURE_LV_REL_PROHIBIT_MODE_NG, + ErrorCode.TAKE_PICTURE_MIRROR_UP_NG, + ErrorCode.TAKE_PICTURE_MOVIE_CROP_NG, + ErrorCode.TAKE_PICTURE_NO_CARD_NG, + ErrorCode.TAKE_PICTURE_NO_LENS_NG, + ErrorCode.TAKE_PICTURE_SENSOR_CLEANING_NG, + ErrorCode.TAKE_PICTURE_SILENCE_NG, + ErrorCode.TAKE_PICTURE_SPECIAL_MOVIE_MODE_NG, + ErrorCode.TAKE_PICTURE_STROBO_CHARGE_NG, + ErrorCode.LENS_COVER_CLOSE, + ErrorCode.DEVICE_BUSY, + }; + } + + /// + /// Checks for an error in SDK calls and checks how to treat it + /// + /// The sender object + /// The return code of the SDK call + /// If a severe error is recognized or the + /// event is null with a non-severe error, it will be thrown as an exception + public static void CheckError(object sender, ErrorCode errorCode) + { + Logger.WriteTraceMessage("CheckError(object, errorCode) errorCode = '" + errorCode.ToString() + "'"); + + if (errorCode == ErrorCode.OK) return; + else + { + bool Severe = !NonSevereErrors.Any(t => t == errorCode); + + var NonSevereErrorHappenedEvent = NonSevereErrorHappened; + if (!Severe) Severe = NonSevereErrorHappenedEvent == null; + + if (Severe) { - Task.Run(() => NonSevereErrorHappenedEvent.Invoke(sender, errorCode)); - } - } - } - - /// - /// Checks for an error in SDK calls and throws an exception if it's not - /// - /// The return code of the SDK call - /// If is something other than - public static void CheckError(ErrorCode errorCode) - { - if (errorCode != ErrorCode.OK) throw new SDKException(errorCode); - } - - /// - /// Checks for an error in and calls - /// and throws an exception if it's not valid - /// - /// The return code of the SDK call - /// The number of references for the pointer that was used for the SDK call - public static int CheckError(int countOrError) - { - if (countOrError == unchecked((int) 0xFFFFFFFF)) throw new SDKException(ErrorCode.INVALID_HANDLE); - else return countOrError; - } - - /// - /// Checks for an error in and calls - /// and throws an exception if it's not valid - /// - /// The calling object instance. This is currently not used and is ignored. - /// The return code of the SDK call - /// The number of references for the pointer that was used for the SDK call - public static int CheckError(object sender, int countOrError) - { - return CheckError(countOrError); - } - - /// - /// Reports an error that happened in a threading environment - /// - /// The sender object - /// The exception that happened - /// True if the error could be passed on; false otherwise - public static bool ReportError(object sender, Exception ex) - { - var onSevereErrorHappened = SevereErrorHappened; - if (onSevereErrorHappened != null) - { - Task.Run(() => onSevereErrorHappened?.Invoke(sender, ex)); - return true; - } - - return false; - } - } -} + Logger.WriteTraceMessage("CheckError, throwing SKDException"); + + throw new SDKException(errorCode); + } + else + { + Logger.WriteTraceMessage("CheckError, invoking '" + sender.ToString() + "'"); + + Task.Run(() => NonSevereErrorHappenedEvent.Invoke(sender, errorCode)); + } + } + } + + /// + /// Checks for an error in SDK calls and throws an exception if it's not + /// + /// The return code of the SDK call + /// If is something other than + public static void CheckError(ErrorCode errorCode) + { + Logger.WriteTraceMessage("CheckError(errorCode) errorCode = '" + errorCode.ToString() + "'"); + + if (errorCode != ErrorCode.OK) throw new SDKException(errorCode); + } + + /// + /// Checks for an error in and calls + /// and throws an exception if it's not valid + /// + /// The return code of the SDK call + /// The number of references for the pointer that was used for the SDK call + public static int CheckError(int countOrError) + { + Logger.WriteTraceMessage("CheckError(countOrError) countOrError = '" + countOrError.ToString() + "'"); + + if (countOrError == unchecked((int) 0xFFFFFFFF)) throw new SDKException(ErrorCode.INVALID_HANDLE); + else return countOrError; + } + + /// + /// Checks for an error in and calls + /// and throws an exception if it's not valid + /// + /// The calling object instance. This is currently not used and is ignored. + /// The return code of the SDK call + /// The number of references for the pointer that was used for the SDK call + public static int CheckError(object sender, int countOrError) + { + Logger.WriteTraceMessage("CheckError(object, countOrError) errorCode = '" + countOrError.ToString() + "'"); + + return CheckError(countOrError); + } + + /// + /// Reports an error that happened in a threading environment + /// + /// The sender object + /// The exception that happened + /// True if the error could be passed on; false otherwise + public static bool ReportError(object sender, Exception ex) + { + var onSevereErrorHappened = SevereErrorHappened; + if (onSevereErrorHappened != null) + { + Task.Run(() => onSevereErrorHappened?.Invoke(sender, ex)); + return true; + } + + return false; + } + } +} diff --git a/EDSDKLib/API/Helper/ValueCollections.cs b/EDSDKLib/API/Helper/ValueCollections.cs index cd917e1..289b653 100644 --- a/EDSDKLib/API/Helper/ValueCollections.cs +++ b/EDSDKLib/API/Helper/ValueCollections.cs @@ -399,6 +399,9 @@ static ISOValues() values = new List() { Auto, + new CameraValue("ISO 6", 0x00000028, 6, PropertyID.ISO), + new CameraValue("ISO 12", 0x00000030, 12, PropertyID.ISO), + new CameraValue("ISO 25", 0x00000038, 25, PropertyID.ISO), new CameraValue("ISO 50", 0x00000040, 50, PropertyID.ISO), new CameraValue("ISO 100", 0x00000048, 100, PropertyID.ISO), new CameraValue("ISO 125", 0x0000004b, 125, PropertyID.ISO), diff --git a/EDSDKLib/EDSDKLib.csproj b/EDSDKLib/EDSDKLib.csproj index e66e88a..97df839 100644 --- a/EDSDKLib/EDSDKLib.csproj +++ b/EDSDKLib/EDSDKLib.csproj @@ -12,6 +12,8 @@ v4.6 512 + + true @@ -37,7 +39,7 @@ false - true + false EDSDKLib.snk @@ -78,8 +80,22 @@ + + + + + {7eb5d33d-e000-4766-9119-eda40d04af74} + Logging + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + 0xee are reserved. + kNkMAIDCapability_FocusAreaFrame = 33265, + kNkMAIDCapability_ISOAutoHiLimit = 33266, + kNkMAIDCapability_BeepEx = 33267, + kNkMAIDCapability_AFLockOnEx = 33268, + kNkMAIDCapability_WarningDisp = 33269, + kNkMAIDCapability_CellKind = 33270, + kNkMAIDCapability_InternalSplMRPTValue = 33271, + kNkMAIDCapability_InternalSplMRPTCount = 33272, + kNkMAIDCapability_InternalSplMRPTInterval = 33273, + kNkMAIDCapability_InternalSplCommandChannel = 33274, + kNkMAIDCapability_InternalSplCmdSelfComp = 33275, + kNkMAIDCapability_InternalSplCmdGroupAMode = 33276, + kNkMAIDCapability_InternalSplCmdGroupAComp = 33277, + kNkMAIDCapability_InternalSplCmdGroupAValue = 33278, + kNkMAIDCapability_InternalSplCmdGroupBMode = 33279, + kNkMAIDCapability_InternalSplCmdGroupBComp = 33280, + kNkMAIDCapability_InternalSplCmdGroupBValue = 33281, + kNkMAIDCapability_InternalSplCmdSelfMode = 33282, + kNkMAIDCapability_InternalSplCmdSelfValue = 33283, + kNkMAIDCapability_SelectFUNC2 = 33284, + kNkMAIDCapability_LutIndexNumber = 33285, + kNkMAIDCapability_MonochromeFilterEffect = 33312, + kNkMAIDCapability_MonochromeEdgeEnhancement = 33313, + kNkMAIDCapability_MonochromeCurve = 33314, + kNkMAIDCapability_AutoFPShoot = 33315, + kNkMAIDCapability_MonochromeSettingType = 33316, + kNkMAIDCapability_AFCapture = 33317, + kNkMAIDCapability_AutoOffTimer = 33318, + kNkMAIDCapability_ImageConfirmTime = 33319, + kNkMAIDCapability_InfoDisplayErrStatus = 33320, + kNkMAIDCapability_ExternalSplMode = 33321, + kNkMAIDCapability_ExternalSplValue = 33322, + kNkMAIDCapability_Slot2ImageSaveMode = 33324, + kNkMAIDCapability_CompressRAWBitMode = 33325, + kNkMAIDCapability_PictureControl = 33326, + kNkMAIDCapability_IntegratedLevel = 33327, + kNkMAIDCapability_Brightness = 33328, + kNkMAIDCapability_MonochromeTuneColors = 33329, + kNkMAIDCapability_Active_D_Lighting = 33330, + kNkMAIDCapability_DynamicAFArea = 33331, + kNkMAIDCapability_ShootingSpeedHigh = 33332, + kNkMAIDCapability_InfoDispSetting = 33333, + kNkMAIDCapability_PreviewButton = 33335, + kNkMAIDCapability_PreviewButton2 = 33336, + kNkMAIDCapability_AEAFLockButton2 = 33338, + kNkMAIDCapability_IndicatorDisplay = 33339, + kNkMAIDCapability_LiveViewMode = 33340, + kNkMAIDCapability_LiveViewDriveMode = 33341, + kNkMAIDCapability_LiveViewStatus = 33342, + kNkMAIDCapability_LiveViewImageZoomRate = 33343, + kNkMAIDCapability_ContrastAF = 33344, + kNkMAIDCapability_DeleteDramImage = 33347, + kNkMAIDCapability_CurrentPreviewID = 33348, + kNkMAIDCapability_GetPreviewImageLow = 33349, + kNkMAIDCapability_GetPreviewImageNormal = 33350, + kNkMAIDCapability_GetLiveViewImage = 33351, + kNkMAIDCapability_MFDriveStep = 33352, + kNkMAIDCapability_MFDrive = 33353, + kNkMAIDCapability_ContrastAFArea = 33354, + kNkMAIDCapability_CompressRAWEx = 33355, + kNkMAIDCapability_CellKindPriority = 33356, + kNkMAIDCapability_WBFluorescentType = 33357, + kNkMAIDCapability_WBTuneColorAdjust = 33358, + kNkMAIDCapability_WBTunePreset1 = 33359, + kNkMAIDCapability_WBTunePreset2 = 33360, + kNkMAIDCapability_WBTunePreset3 = 33361, + kNkMAIDCapability_WBTunePreset4 = 33362, + kNkMAIDCapability_WBTunePreset5 = 33363, + kNkMAIDCapability_AFAreaPoint = 33364, + kNkMAIDCapability_NormalAfButton = 33365, + kNkMAIDCapability_ManualSetLensNo = 33366, + kNkMAIDCapability_AutoDXCrop = 33367, + kNkMAIDCapability_PictureControlData = 33368, + kNkMAIDCapability_GetPicCtrlInfo = 33369, + kNkMAIDCapability_DeleteCustomPictureControl = 33370, + kNkMAIDCapability_LensType = 33372, + kNkMAIDCapability_ChangedPictureControl = 33373, + kNkMAIDCapability_LiveViewProhibit = 33374, + kNkMAIDCapability_DateImprintSetting = 33375, + kNkMAIDCapability_DateCounterSelect = 33376, + kNkMAIDCapability_DateCounterData = 33377, + kNkMAIDCapability_DateCounterDispSetting = 33378, + kNkMAIDCapability_RangeFinderSetting = 33379, + kNkMAIDCapability_RangeFinderStatus = 33380, + kNkMAIDCapability_AutoOffPhoto = 33381, + kNkMAIDCapability_AutoOffMenu = 33382, + kNkMAIDCapability_AutoOffInfo = 33383, + kNkMAIDCapability_ScreenTips = 33384, + kNkMAIDCapability_IlluminationSetting = 33385, + kNkMAIDCapability_ShutterSpeedLockSetting = 33386, + kNkMAIDCapability_ApertureLockSetting = 33387, + kNkMAIDCapability_VignetteControl = 33388, + kNkMAIDCapability_FocusPointBrightness = 33389, + kNkMAIDCapability_EnableCopyright = 33390, + kNkMAIDCapability_ArtistName = 33391, + kNkMAIDCapability_CopyrightInfo = 33392, + kNkMAIDCapability_AngleLevel = 33393, + kNkMAIDCapability_MovieScreenSize = 33394, + kNkMAIDCapability_MovieVoice = 33395, + kNkMAIDCapability_LiveViewAF = 33397, + kNkMAIDCapability_SelfTimerShootNum = 33398, + kNkMAIDCapability_FinderISODisplay = 33399, + kNkMAIDCapability_EnableCommandDialOnPlaybackEx = 33400, + kNkMAIDCapability_ExchangeDialsEx = 33401, + kNkMAIDCapability_CenterButtonOnLiveView = 33408, + kNkMAIDCapability_ZoomRateOnLiveView = 33409, + kNkMAIDCapability_AutoDistortion = 33410, + kNkMAIDCapability_SceneMode = 33411, + kNkMAIDCapability_LiveViewScreenDispSetting = 33412, + kNkMAIDCapability_MovieRecMicrophone = 33413, + kNkMAIDCapability_MovieRecDestination = 33414, + kNkMAIDCapability_PrimarySlot = 33415, + kNkMAIDCapability_ADLBracketingType = 33416, + kNkMAIDCapability_SelectFUNC2CapAreaCrop = 33425, + kNkMAIDCapability_PreviewButton2CapAreaCrop = 33426, + kNkMAIDCapability_AEAFLockButton2CapAreaCrop = 33427, + kNkMAIDCapability_BracketButton = 33428, + kNkMAIDCapability_RemainCountInMedia = 33429, + kNkMAIDCapability_AngleLevelPitch = 33430, + kNkMAIDCapability_AngleLevelYaw = 33431, + kNkMAIDCapability_MovRecInCardStatus = 33432, + kNkMAIDCapability_MovRecInCardProhibit = 33433, // kNkMAIDCapability_VendorBaseDX2 + 0x200 <--> + 0x203 are reserved. + kNkMAIDCapability_ActiveSlot = 33540, + kNkMAIDCapability_SaveMedia = 33541, + kNkMAIDCapability_MovieRecHiISO = 33542, + kNkMAIDCapability_UserMode1 = 33543, + kNkMAIDCapability_UserMode2 = 33544, + kNkMAIDCapability_MovieManualSetting = 33545, + kNkMAIDCapability_AFModeAtLiveView = 33552, + kNkMAIDCapability_SelfTimerShootInterval = 33553, + kNkMAIDCapability_AutoOffLiveView = 33554, + kNkMAIDCapability_RemoteCtrlWaitTime = 33555, + kNkMAIDCapability_BeepVolume = 33556, + kNkMAIDCapability_VideoMode = 33557, + kNkMAIDCapability_WBAutoType = 33558, + kNkMAIDCapability_GetVideoImage = 33559, + kNkMAIDCapability_TerminateCapture = 33560, + kNkMAIDCapability_EffectMode = 33561, + kNkMAIDCapability_HDRMode = 33568, + kNkMAIDCapability_HDRExposure = 33569, + kNkMAIDCapability_HDRSmoothing = 33570, + kNkMAIDCapability_BlinkingStatus = 33571, + kNkMAIDCapability_AutoSceneModeStatus = 33572, + kNkMAIDCapability_WBTuneColorTempEx = 33573, + kNkMAIDCapability_WBPresetProtect1 = 33574, + kNkMAIDCapability_WBPresetProtect2 = 33575, + kNkMAIDCapability_WBPresetProtect3 = 33576, + kNkMAIDCapability_WBPresetProtect4 = 33577, + kNkMAIDCapability_ISOAutoShutterTimeAutoValue = 33584, + kNkMAIDCapability_MovieImageQuality = 33585, + kNkMAIDCapability_MovieRecMicrophoneValue = 33586, + kNkMAIDCapability_LiveViewExposurePreview = 33587, + kNkMAIDCapability_LiveViewSelector = 33588, + kNkMAIDCapability_LiveViewWBMode = 33589, + kNkMAIDCapability_MovieShutterSpeed = 33590, + kNkMAIDCapability_MovieAperture = 33591, + kNkMAIDCapability_MovieSensitivity = 33592, + kNkMAIDCapability_MovieExposureComp = 33593, + kNkMAIDCapability_ADLBracketingStep = 33603, + kNkMAIDCapability_ResetWBMode = 33604, + kNkMAIDCapability_ExpCompFlashUsed = 33605, + kNkMAIDCapability_LiveViewPhotoShootingMode = 33606, + kNkMAIDCapability_ExposureDelayEx = 33607, + kNkMAIDCapability_MovieISORange = 33608, + kNkMAIDCapability_MovieReleaseButton = 33609, + kNkMAIDCapability_MovieRecFrameCount = 33616, + kNkMAIDCapability_CurrentItemID = 33617, + kNkMAIDCapability_GetIPTCInfo = 33618, + kNkMAIDCapability_LiveViewImageSize = 33619, + kNkMAIDCapability_RemoteControlMode = 33620, + kNkMAIDCapability_WBTunePreset6 = 33621, + kNkMAIDCapability_WBPresetProtect5 = 33622, + kNkMAIDCapability_WBPresetProtect6 = 33623, + kNkMAIDCapability_SpotWBMode = 33624, + kNkMAIDCapability_SpotWBMeasure = 33625, + kNkMAIDCapability_SpotWBChangeArea = 33632, + kNkMAIDCapability_SpotWBResultDispEnd = 33633, // kNkMAIDCapability_VendorBaseDX2 + 0x262 <--> + 0x319 are reserved. + kNkMAIDCapability_MovieWindNoiseReduction = 33824, + kNkMAIDCapability_RetractableLensWarningStatus = 33825, + kNkMAIDCapability_ISOControlSensitivity = 33826, + kNkMAIDCapability_ExposureMeterLinkage = 33840, // kNkMAIDCapability_VendorBaseDX2 + 0x331 <--> + 0x340 are reserved. + kNkMAIDCapability_MovieRecordingZone = 33872, + kNkMAIDCapability_MovieISOControl = 33873, + kNkMAIDCapability_MovieISOAutoHiLimit = 33874, + kNkMAIDCapability_RawImageSize = 33875, + kNkMAIDCapability_RawJpegTransferStatus = 33876, + kNkMAIDCapability_LimitAFAreaMode = 33877, + kNkMAIDCapability_AFModeRestrictions = 33878, + kNkMAIDCapability_ExpBaseHighlight = 33879, + kNkMAIDCapability_ElectronicFrontCurtainShutter = 33880, + kNkMAIDCapability_PictureControlDataEx = 33881, + kNkMAIDCapability_MovieWBMode = 33888, + kNkMAIDCapability_MovieWBTuneAuto = 33889, + kNkMAIDCapability_MovieWBAutoType = 33890, + kNkMAIDCapability_MovieWBTuneIncandescent = 33891, + kNkMAIDCapability_MovieWBFluorescentType = 33892, + kNkMAIDCapability_MovieWBTuneFluorescent = 33893, + kNkMAIDCapability_MovieWBTuneSunny = 33894, + kNkMAIDCapability_MovieWBTuneShade = 33896, + kNkMAIDCapability_MovieWBTuneCloudy = 33897, + kNkMAIDCapability_MovieWBTuneColorTempEx = 33898, + kNkMAIDCapability_MovieWBTuneColorAdjust = 33899, + kNkMAIDCapability_MovieWBTunePreset1 = 33900, + kNkMAIDCapability_MovieWBTunePreset2 = 33901, + kNkMAIDCapability_MovieWBTunePreset3 = 33902, + kNkMAIDCapability_MovieWBTunePreset4 = 33903, + kNkMAIDCapability_MovieWBTunePreset5 = 33904, + kNkMAIDCapability_MovieWBTunePreset6 = 33905, + kNkMAIDCapability_MovieWBPresetProtect1 = 33906, + kNkMAIDCapability_MovieWBPresetProtect2 = 33907, + kNkMAIDCapability_MovieWBPresetProtect3 = 33908, + kNkMAIDCapability_MovieWBPresetProtect4 = 33909, + kNkMAIDCapability_MovieWBPresetProtect5 = 33910, + kNkMAIDCapability_MovieWBPresetProtect6 = 33911, + kNkMAIDCapability_MovieWBPresetNumber = 33912, + kNkMAIDCapability_MovieWBPresetName = 33913, + kNkMAIDCapability_MovieWBGainRed = 33914, + kNkMAIDCapability_MovieWBGainBlue = 33915, + kNkMAIDCapability_MoviePictureControlData = 33916, + kNkMAIDCapability_MoviePictureControlDataEx = 33917, + kNkMAIDCapability_MovieResetMenuBank = 33918, + kNkMAIDCapability_MovieCCDDataMode = 33919, + kNkMAIDCapability_MovieAutoDXCrop = 33920, + kNkMAIDCapability_MovieNoiseReductionHighISO = 33921, + kNkMAIDCapability_MoviePictureControl = 33922, + kNkMAIDCapability_ChangedMoviePictureControl = 33923, + kNkMAIDCapability_MovieResetWBMode = 33924, + kNkMAIDCapability_MovieMeteringMode = 33925, + kNkMAIDCapability_GetMoviePicCtrlInfo = 33926, + kNkMAIDCapability_DeleteMovieCustomPictureControl = 33927, + kNkMAIDCapability_MovieWBPresetData = 33928, + kNkMAIDCapability_PowerZoomByFocalLength = 33929, + kNkMAIDCapability_MovieCaptureMode = 33930, + kNkMAIDCapability_SlowMotionMovieRecordScreenSize = 33931, + kNkMAIDCapability_HighSpeedStillCaptureRate = 33932, + kNkMAIDCapability_BestMomentCaptureMode = 33933, + kNkMAIDCapability_ActiveSelectionFrameSavedDefault = 33934, + kNkMAIDCapability_ActiveSelectionCapture40frameOver = 33935, + kNkMAIDCapability_ActiveSelectionOnReleaseRecord = 33936, + kNkMAIDCapability_ActiveSelectionControl = 33937, + kNkMAIDCapability_ActiveSelectionSelectedPictures = 33938, + kNkMAIDCapability_SaveSelectionPictures = 33939, + kNkMAIDCapability_LensTypeNikon1 = 33940, + kNkMAIDCapability_SilentPhotography = 33941, + kNkMAIDCapability_FacePriority = 33942, + kNkMAIDCapability_OpticalVR = 33943, + kNkMAIDCapability_ElectronicVR = 33944, + kNkMAIDCapability_CaptureLV = 33945, + kNkMAIDCapability_AFCaptureLV = 33946, + kNkMAIDCapability_DeviceReadyLV = 33947, + kNkMAIDCapability_AFLockOnAcross = 33980, + kNkMAIDCapability_AFLockOnMove = 33981, + kNkMAIDCapability_IPTCPresetSelect = 33982, + kNkMAIDCapability_FlashISOAutoHighLimit = 33985, + kNkMAIDCapability_SBWirelessMode = 33986, + kNkMAIDCapability_SBWirelessMultipleFlashMode = 33987, + kNkMAIDCapability_SBUsableGroup = 33988, + kNkMAIDCapability_WirelessCLSEntryMode = 33989, + kNkMAIDCapability_SBPINCode = 33990, + kNkMAIDCapability_RadioMultipleFlashChannel = 33991, + kNkMAIDCapability_OpticalMultipleFlashChannel = 33992, + kNkMAIDCapability_FlashRangeDisplay = 33993, + kNkMAIDCapability_AllTestFiringDisable = 33994, + kNkMAIDCapability_IPTCPresetInfo = 33996, + kNkMAIDCapability_GetSBHandles = 33997, + kNkMAIDCapability_GetSBAttrDesc = 33998, + kNkMAIDCapability_SBAttrValue = 33999, + kNkMAIDCapability_GetSBGroupAttrDesc = 34000, + kNkMAIDCapability_SBGroupAttrValue = 34001, + kNkMAIDCapability_TestFlash = 34002, + kNkMAIDCapability_FaceDetection = 34003, + kNkMAIDCapability_3DTrackingCaptuerArea = 34004, + kNkMAIDCapability_SBSettingMemberLock = 34006, + kNkMAIDCapability_MatrixMetering = 34007, + kNkMAIDCapability_CaptureAsync = 34008, + kNkMAIDCapability_AFCaptureAsync = 34009, + kNkMAIDCapability_DeviceReady = 34010, + kNkMAIDCapability_SBIntegrationFlashReady = 34011, + kNkMAIDCapability_MirrorUpCancel = 34031, + kNkMAIDCapability_MirrorUpStatus = 34032, + kNkMAIDCapability_MirrorUpReleaseShootingCount = 34033, // kNkMAIDCapability_VendorBaseDX2 + 0x3f2 <--> + 0x3f3 are reserved. + kNkMAIDCapability_MovieActive_D_Lighting = 34034, + kNkMAIDCapability_FlickerReductionSetting = 34035, + kNkMAIDCapability_ExposureCompFlashUsed = 34036 + } + + public enum eNkMAIDCapAreaCrop : int + { + kNkMAIDCapAreaCrop_FX = 1, + kNkMAIDCapAreaCrop_DX = 2, + kNkMAIDCapAreaCrop_54 = 4, + kNkMAIDCapAreaCrop_12x = 8 + } + + public enum eNkMAIDCapOperation : int + { + kNkMAIDCapOperation_Start = 1, + kNkMAIDCapOperation_Get = 2, + kNkMAIDCapOperation_Set = 4, + kNkMAIDCapOperation_GetArray = 8, + kNkMAIDCapOperation_GetDefault = 16 + } + + public enum eNkMAIDCapType : int + { + kNkMAIDCapType_Process = 0, // a process that can be started + kNkMAIDCapType_Boolean = 1, // single byte boolean value + kNkMAIDCapType_Integer = 2, // signed 4 byte value + kNkMAIDCapType_Unsigned = 3, // unsigned 4 byte value + kNkMAIDCapType_Float = 4, // DOUB_P value + kNkMAIDCapType_Point = 5, // NkMAIDPoint structure + kNkMAIDCapType_Size = 6, // NkMAIDSize structure + kNkMAIDCapType_Rect = 7, // NkMAIDRect structure + kNkMAIDCapType_String = 8, // NkMAIDString structure + kNkMAIDCapType_DateTime = 9, // NkMAIDDateTime structure + kNkMAIDCapType_Callback = 10, // NkMAIDCallback structure + kNkMAIDCapType_Array = 11, // NkMAIDArray structure + kNkMAIDCapType_Enum = 12, // NkMAIDEnum structure + kNkMAIDCapType_Range = 13, // NkMAIDRange structure + kNkMAIDCapType_Generic = 14, // generic data + kNkMAIDCapType_BoolDefault = 15 // Reserved + } + + public enum eNkMAIDCapVisibility : int + { + kNkMAIDCapVisibility_Hidden = 1, + kNkMAIDCapVisibility_Advanced = 2, + kNkMAIDCapVisibility_Vendor = 4, + kNkMAIDCapVisibility_Group = 8, + kNkMAIDCapVisibility_GroupMember = 16, + kNkMAIDCapVisibility_Invalid = 32 + } + + public enum eNkMAIDCCDDataMode : int + { + kNkMAIDCCDDataMode_Full = 0, + kNkMAIDCCDDataMode_HiSpeedCrop = 1, + kNkMAIDCCDDataMode_AutoDXCrop = 2, + kNkMAIDCCDDataMode_FXFormat = 3, + kNkMAIDCCDDataMode_DXFormat = 4, + kNkMAIDCCDDataMode_5_4 = 5, + kNkMAIDCCDDataMode_12x = 6, + kNkMAIDCCDDataMode_13x = 7 + } + + public enum eNkMAIDCellKind : int + { + kNkMAIDCellKind_Alkaline = 0, + kNkMAIDCellKind_NiMH = 1, + kNkMAIDCellKind_Lithium = 2, + kNkMAIDCellKind_NiMn = 3 + } + + public enum eNkMAIDCellKindPriority : int + { + kNkMAIDCellKindPriority_MB_D11 = 0, + kNkMAIDCellKindPriority_MB_D10 = 0, + kNkMAIDCellKindPriority_Camera = 1 + } + + public enum eNkMAIDCFStatus : int + { + kNkMAIDCFStatus_Good = 0, + kNkMAIDCFStatus_Full = 1, + kNkMAIDCFStatus_NotFormated = 2, + kNkMAIDCFStatus_NotExist = 3, + kNkMAIDCFStatus_NotAvailable = 4 + } + + public enum eNkMAIDColorAdjustment : int + { + kNkMAIDColorAdjustment_Minus9 = 0, + kNkMAIDColorAdjustment_Minus6 = 1, + kNkMAIDColorAdjustment_Minus3 = 2, + kNkMAIDColorAdjustment_0 = 3, + kNkMAIDColorAdjustment_Plus3 = 4, + kNkMAIDColorAdjustment_Plus6 = 5, + kNkMAIDColorAdjustment_Plus9 = 6 + } + + public enum eNkMAIDColorSpace : int + { + kNkMAIDColorSpace_LineArt = 0, + kNkMAIDColorSpace_Grey = 1, + kNkMAIDColorSpace_RGB = 2, + kNkMAIDColorSpace_sRGB = 3, + kNkMAIDColorSpace_CMYK = 4, + kNkMAIDColorSpace_Lab = 5, + kNkMAIDColorSpace_LCH = 6, + kNkMAIDColorSpace_AppleRGB = 7, + kNkMAIDColorSpace_ColorMatchRGB = 8, + kNkMAIDColorSpace_NTSCRGB = 9, + kNkMAIDColorSpace_BruceRGB = 10, + kNkMAIDColorSpace_AdobeRGB = 11, + kNkMAIDColorSpace_CIERGB = 12, + kNkMAIDColorSpace_AdobeWideRGB = 13, + kNkMAIDColorSpace_AppleRGB_Compensated = 14, + kNkMAIDColorSpace_VendorBase = 32768, // vendor supplied colorspaces start here + kNkMAIDColorSpace_RGBD = 32769 + } + + public enum eNkMAIDCommand : int + { + kNkMAIDCommand_Async = 0, // process asynchronous operations + kNkMAIDCommand_Open = 1, // opens a child object + kNkMAIDCommand_Close = 2, // closes a previously opened object + kNkMAIDCommand_GetCapCount = 3, // get number of capabilities of an object + kNkMAIDCommand_GetCapInfo = 4, // get capabilities of an object + kNkMAIDCommand_CapStart = 5, // starts capability + kNkMAIDCommand_CapSet = 6, // set value of capability + kNkMAIDCommand_CapGet = 7, // get value of capability + kNkMAIDCommand_CapGetDefault = 8, // get default value of capability + kNkMAIDCommand_CapGetArray = 9, // get data for array capability + kNkMAIDCommand_Mark = 10, // insert mark in the command queue + kNkMAIDCommand_AbortToMark = 11, // abort asynchronous commands to mark + kNkMAIDCommand_Abort = 12, // abort current asynchronous command + kNkMAIDCommand_EnumChildren = 13, // requests �add� events for all child IDs + kNkMAIDCommand_GetParent = 14, // gets previously opened parent for object + kNkMAIDCommand_ResetToDefault = 15 // resets all capabilities to their default value + } + + public enum eNkMAIDCompressRAWBitMode : int + { + kNkMAIDCompressRAWBitMode_12bit = 0, // 12-bit depth recording + kNkMAIDCompressRAWBitMode_14bit = 1 // 14-bit depth recording + } + + public enum eNkMAIDCompressRAWEx : int + { + kNkMAIDCompressRAWEx_Uncompressed = 0, // Uncompressed + kNkMAIDCompressRAWEx_Compressed = 1, // Compressed + kNkMAIDCompressRAWEx_LosslessCompressed = 2 // Lossless compressed + } + + public enum eNkMAIDContrastAF : int + { + kNkMAIDContrastAF_Start = 0, // Start the AF driving + kNkMAIDContrastAF_Stop = 1, // Stop the AF driving + kNkMAIDContrastAF_OK = 16, // Completed in the focused status + kNkMAIDContrastAF_OutOfFocus = 17, // Completed in the non-focused status + kNkMAIDContrastAF_Busy = 18 // AF driving + } + + public enum eNkMAIDConverter : int + { + kNkMAIDConverter_None = 0, + kNkMAIDConverter_Wide = 1, + kNkMAIDConverter_FishEye = 2 + } + + public enum eNkMAIDCPXCameraType : int + { + kNkMAIDCPXCameraType_E8400 = 0, + kNkMAIDCPXCameraType_E8800 = 1, + kNkMAIDCPXCameraType_S4 = 2, + kNkMAIDCPXCameraType_L1 = 3 + } + + public enum eNkMAIDDataObjType : int + { + kNkMAIDDataObjType_Image = 1, + kNkMAIDDataObjType_Sound = 2, + kNkMAIDDataObjType_Video = 4, + kNkMAIDDataObjType_Thumbnail = 8, + kNkMAIDDataObjType_File = 16 + } + + public enum eNkMAIDDataType : int + { + kNkMAIDDataType_Null = 0, + kNkMAIDDataType_Boolean = 1, // passed by value, set only + kNkMAIDDataType_Integer = 2, // signed 32 bit int, passed by value, set only + kNkMAIDDataType_Unsigned = 3, // unsigned 32 bit int, passed by value, set only + kNkMAIDDataType_BooleanPtr = 4, // pointer to single byte boolean value(s) + kNkMAIDDataType_IntegerPtr = 5, // pointer to signed 4 byte value(s) + kNkMAIDDataType_UnsignedPtr = 6, // pointer to unsigned 4 byte value(s) + kNkMAIDDataType_FloatPtr = 7, // pointer to DOUB_P value(s) + kNkMAIDDataType_PointPtr = 8, // pointer to NkMAIDPoint structure(s) + kNkMAIDDataType_SizePtr = 9, // pointer to NkMAIDSize structure(s) + kNkMAIDDataType_RectPtr = 10, // pointer to NkMAIDRect structure(s) + kNkMAIDDataType_StringPtr = 11, // pointer to NkMAIDString structure(s) + kNkMAIDDataType_DateTimePtr = 12, // pointer to NkMAIDDateTime structure(s) + kNkMAIDDataType_CallbackPtr = 13, // pointer to NkMAIDCallback structure(s) + kNkMAIDDataType_RangePtr = 14, // pointer to NkMAIDRange structure(s) + kNkMAIDDataType_ArrayPtr = 15, // pointer to NkMAIDArray structure(s) + kNkMAIDDataType_EnumPtr = 16, // pointer to NkMAIDEnum structure(s) + kNkMAIDDataType_ObjectPtr = 17, // pointer to NkMAIDObject structure(s) + kNkMAIDDataType_CapInfoPtr = 18, // pointer to NkMAIDCapInfo structure(s) + kNkMAIDDataType_GenericPtr = 19 // pointer to generic data + } + + public enum eNkMAIDDateCounterDispSetting : int + { + kNkMAIDDateCounterDispSetting_NumberOfDays = 0, // Number of days + kNkMAIDDateCounterDispSetting_Years_Days = 1, // Years and days + kNkMAIDDateCounterDispSetting_Years_Months_Days = 2 // Years, months, and days + } + + public enum eNkMAIDDateCounterSelect : int + { + kNkMAIDDateCounterSelect_1 = 0, // First + kNkMAIDDateCounterSelect_2 = 1, // Second + kNkMAIDDateCounterSelect_3 = 2 // Third + } + + public enum eNkMAIDDateFormat : int + { + kNkMAIDDateFormat_Off = 0, + kNkMAIDDateFormat_YMD = 1, + kNkMAIDDateFormat_MDY = 2, + kNkMAIDDateFormat_DMY = 3 + } + + public enum eNkMAIDDateImprintSetting : int + { + kNkMAIDDateImprintSetting_Off = 0, // OFF + kNkMAIDDateImprintSetting_Date = 1, // Year/month/date + kNkMAIDDateImprintSetting_Date_Time = 2, // Year/month/date/time + kNkMAIDDateImprintSetting_DateCounter = 3 // Birthday counter + } + + public enum eNkMAIDDynamicAFArea : int + { + kNkMAIDDynamicAFArea_9 = 0, // Dynamic AF mode (9 points) + kNkMAIDDynamicAFArea_21 = 1, // Dynamic AF mode (21 points) + kNkMAIDDynamicAFArea_51 = 2, // Dynamic AF mode (51 points) + kNkMAIDDynamicAFArea_51_3DTtracking = 3 // 3D-tracking + } + + public enum eNkMAIDEasyExposureCompMode : int + { + kNkMAIDEasyExposureCompMode_Off = 0, + kNkMAIDEasyExposureCompMode_On = 1, + kNkMAIDEasyExposureCompMode_AutoReset = 2 + } + + public enum eNkMAIDEffectMode : int + { + kNkMAIDEffectMode_NightVision = 0, // 0: Night vision + kNkMAIDEffectMode_ColorSketch = 1, // 1: Color sketch + kNkMAIDEffectMode_Miniature = 2, // 2: Miniature effect + kNkMAIDEffectMode_SelectColor = 3, // 3: Selective color + kNkMAIDEffectMode_Silhouette = 4, // 4: Silhouette + kNkMAIDEffectMode_Highkey = 5, // 5: High key + kNkMAIDEffectMode_Lowkey = 6, // 6: Low key + kNkMAIDEffectMode_ToyCamera = 7, // 7: Toy camera + kNkMAIDEffectMode_HDRPainting = 8, // 8: HDR painting + kNkMAIDEffectMode_SuperVivid = 9, // 9: Super vivid + kNkMAIDEffectMode_Pop = 10, // 10: Pop + kNkMAIDEffectMode_PhotoIllustration = 11 // 11: Photo Illustration + } + + public enum eNkMAIDElectronicFrontCurtainShutter : int + { + kNkMAIDElectronicFrontCurtainShutter_Off = 0, + kNkMAIDElectronicFrontCurtainShutter_On = 1 + } + + public enum eNkMAIDElectronicVR : int + { + kNkMAIDElectronicVR_OFF = 0, + kNkMAIDElectronicVR_ON = 1 + } + + public enum eNkMAIDElectronicZoom : int + { + kNkMAIDElectronicZoom_100 = 0, + kNkMAIDElectronicZoom_120 = 1, + kNkMAIDElectronicZoom_140 = 2, + kNkMAIDElectronicZoom_160 = 3, + kNkMAIDElectronicZoom_180 = 4, + kNkMAIDElectronicZoom_200 = 5, + kNkMAIDElectronicZoom_220 = 6, + kNkMAIDElectronicZoom_240 = 7, + kNkMAIDElectronicZoom_260 = 8, + kNkMAIDElectronicZoom_280 = 9, + kNkMAIDElectronicZoom_300 = 10, + kNkMAIDElectronicZoom_320 = 11, + kNkMAIDElectronicZoom_340 = 12, + kNkMAIDElectronicZoom_360 = 13, + kNkMAIDElectronicZoom_380 = 14, + kNkMAIDElectronicZoom_400 = 15 + } + + public enum eNkMAIDEnableCommandDialOnPlaybackEx : int + { + kNkMAIDEnableCommandDialOnPlaybackEx_Off = 0, // OFF + kNkMAIDEnableCommandDialOnPlaybackEx_On = 1, // ON + kNkMAIDEnableCommandDialOnPlaybackEx_On_WithoutImageConf = 2 // ON (except during image review) + } + + public enum eNkMAIDEvent : int + { + kNkMAIDEvent_AddChild = 0, + kNkMAIDEvent_RemoveChild = 1, + kNkMAIDEvent_WarmingUp = 2, + kNkMAIDEvent_WarmedUp = 3, + kNkMAIDEvent_CapChange = 4, + kNkMAIDEvent_OrphanedChildren = 5, + kNkMAIDEvent_CapChangeValueOnly = 6, + kNkMAIDEvent_AddPreviewImage = 263, // 0x107 + kNkMAIDEvent_CaptureComplete = 264, // 0x108 + kNkMAIDEvent_AddChildInCard = 265, // 0x109 + kNkMAIDEvent_RecordingInterrupted = 266, // 0x10A + kNkMAIDEvent_CapChangeOperationOnly = 267, // 0x10B + kNkMAIDEvent_1stCaptureComplete = 268, // 0x10C + kNkMAIDEvent_MirrorUpCancelComplete = 269, // 0x10D + kNkMAIDEvent_SBAdded = 270, // 0x10E + kNkMAIDEvent_SBRemoved = 271, // 0x10F + kNkMAIDEvent_SBAttrChanged = 272, // 0x110 + kNkMAIDEvent_SBGroupAttrChanged = 273, // 0x111// kNkMAIDEvent_DX2Origin + 11(0x112) is reserved. + kNkMAIDEvent_ActiveSelectionInterrupted = 275, // 0x113 + kNkMAIDEvent_StoreRemoved = 276, // 0x114 + kNkMAIDEvent_MovieRecordComplete = 277 // 0x115 + } + + public enum eNkMAIDExchangeDialsEx : int + { + kNkMAIDExchangeDialsEx_Off = 0, + kNkMAIDExchangeDialsEx_On = 1, + kNkMAIDExchangeDialsEx_On_Amode = 2 + } + + public enum eNkMAIDExposureCompFlashUsed : int + { + kNkMAIDExposureCompFlashUsed_Entireframe = 0, + kNkMAIDExposureCompFlashUsed_Backgroundonly = 1 + } + + public enum eNkMAIDExposureDelayEx : int + { + kNkMAIDExposureDelayEx_3sec = 0, + kNkMAIDExposureDelayEx_2sec = 1, + kNkMAIDExposureDelayEx_1sec = 2, + kNkMAIDExposureDelayEx_Off = 3 + } + + public enum eNkMAIDExposureDisplayStatus : int + { + kNkMAIDExposureDisplayStatus_None = 0, + kNkMAIDExposureDisplayStatus_ShutterSpeedLo = 1, + kNkMAIDExposureDisplayStatus_ShutterSpeedHi = 2, + kNkMAIDExposureDisplayStatus_ApertureLo = 3, + kNkMAIDExposureDisplayStatus_ApertureHi = 4, + kNkMAIDExposureDisplayStatus_SpLo_ApLo = 5, + kNkMAIDExposureDisplayStatus_SpLo_ApHi = 6, + kNkMAIDExposureDisplayStatus_SpHi_ApLo = 7, + kNkMAIDExposureDisplayStatus_SpHi_ApHi = 8 + } + + public enum eNkMAIDExposureMeterLinkage : int + { + kNkMAIDExposureMeterLinkage_AI = 0, + kNkMAIDExposureMeterLinkage_NON_AI = 1 + } + + public enum eNkMAIDExposureMode : int + { + kNkMAIDExposureMode_Program = 0, + kNkMAIDExposureMode_AperturePriority = 1, + kNkMAIDExposureMode_SpeedPriority = 2, + kNkMAIDExposureMode_Manual = 3, + kNkMAIDExposureMode_Disable = 4, + kNkMAIDExposureMode_Auto = 5, + kNkMAIDExposureMode_Portrait = 6, + kNkMAIDExposureMode_Landscape = 7, + kNkMAIDExposureMode_Closeup = 8, + kNkMAIDExposureMode_Sports = 9, + kNkMAIDExposureMode_NightPortrait = 10, + kNkMAIDExposureMode_NightView = 11, + kNkMAIDExposureMode_Child = 12, + kNkMAIDExposureMode_FlashOff = 13, + kNkMAIDExposureMode_Scene = 14, + kNkMAIDExposureMode_UserMode1 = 15, + kNkMAIDExposureMode_UserMode2 = 16, + kNkMAIDExposureMode_Effects = 17 + } + + public enum eNkMAIDExternalFlashSort : int + { + kNkMAIDExternalFlashSort_NoCommunicate = 0, + kNkMAIDExternalFlashSort_OldType = 1, + kNkMAIDExternalFlashSort_NewType = 2, + kNkMAIDExternalFlashSort_NotExist = 3, + kNkMAIDExternalFlashSort_NewTypeControl = 4 + } + + public enum eNkMAIDExternalFlashStatus : int + { + kNkMAIDExternalFlashStatus_Ready = 0, + kNkMAIDExternalFlashStatus_NotReady = 1, + kNkMAIDExternalFlashStatus_NotExist = 2 + } + + public enum eNkMAIDExternalNewTypeFlashMode : int + { + kNkMAIDExternalNewTypeFlashMode_OFF = 0, + kNkMAIDExternalNewTypeFlashMode_CompTTL = 1, + kNkMAIDExternalNewTypeFlashMode_NoCompTTL = 2, + kNkMAIDExternalNewTypeFlashMode_AA = 3, + kNkMAIDExternalNewTypeFlashMode_ExtAutoFlash = 4, + kNkMAIDExternalNewTypeFlashMode_ManualLengthPriority = 5, + kNkMAIDExternalNewTypeFlashMode_Manual = 6, + kNkMAIDExternalNewTypeFlashMode_Multi = 7, + kNkMAIDExternalNewTypeFlashMode_NotExist = 8 + } + + public enum eNkMAIDExternalOldTypeFlashMode : int + { + kNkMAIDExternalOldTypeFlashMode_TTL = 0, + kNkMAIDExternalOldTypeFlashMode_DTTL = 1, + kNkMAIDExternalOldTypeFlashMode_AA = 2, + kNkMAIDExternalOldTypeFlashMode_ExtAutoFlash = 3, + kNkMAIDExternalOldTypeFlashMode_Manual = 4, + kNkMAIDExternalOldTypeFlashMode_FP = 5, + kNkMAIDExternalOldTypeFlashMode_NotExist = 6, + kNkMAIDExternalOldTypeFlashMode_NonTTL = 7 + } + + public enum eNkMAIDExternalSplValue : int + { + kNkMAIDExternalSplValue_Full = 0, // Full + kNkMAIDExternalSplValue_2 = 1, // 1/2 + kNkMAIDExternalSplValue_4 = 2, // 1/4 + kNkMAIDExternalSplValue_8 = 3, // 1/8 + kNkMAIDExternalSplValue_16 = 4, // 1/16 + kNkMAIDExternalSplValue_32 = 5, // 1/32 + kNkMAIDExternalSplValue_64 = 6, // 1/64 + kNkMAIDExternalSplValue_128 = 7, // 1/128 + kNkMAIDExternalSplValue_256 = 8 // 1/256 + } + + public enum eNkMAIDFaceDetection : int + { + kNkMAIDFaceDetection_Off = 0, + kNkMAIDFaceDetection_On = 1 + } + + public enum eNkMAIDFacePriority : int + { + kNkMAIDFacePriority_Off = 0, + kNkMAIDFacePriority_On = 1 + } + + public enum eNkMAIDFileDataType : int + { + kNkMAIDFileDataType_NotSpecified = 0, + kNkMAIDFileDataType_JPEG = 1, + kNkMAIDFileDataType_TIFF = 2, + kNkMAIDFileDataType_FlashPix = 3, + kNkMAIDFileDataType_NIF = 4, + kNkMAIDFileDataType_QuickTime = 5, + kNkMAIDFileDataType_VendorBaseDx2 = 256, // 0x100 + kNkMAIDFileDataType_UserType = 256, + kNkMAIDFileDataType_NDF = 257, + kNkMAIDFileDataType_AVI = 258, + kNkMAIDFileDataType_MOV = 259 + } + + public enum eNkMAIDFilter : int + { + kNkMAIDFilter_White = 0, + kNkMAIDFilter_Infrared = 1, + kNkMAIDFilter_Red = 2, + kNkMAIDFilter_Green = 3, + kNkMAIDFilter_Blue = 4, + kNkMAIDFilter_Ultraviolet = 5 + } + + public enum eNkMAIDFinderISODisplay : int + { + kNkMAIDFinderISODisplay_ISO = 0, // Sensitivity display ON + kNkMAIDFinderISODisplay_EasyISO = 1, // Sensitivity display/easy setting ON + kNkMAIDFinderISODisplay_FrameCount = 2 // Off + } + + public enum eNkMAIDFlashISOAutoHighLimit : int + { + kNkMAIDFlashISOAutoHighLimit_ISO200 = 0, + kNkMAIDFlashISOAutoHighLimit_ISO250 = 1, + kNkMAIDFlashISOAutoHighLimit_ISO280 = 2, + kNkMAIDFlashISOAutoHighLimit_ISO320 = 3, + kNkMAIDFlashISOAutoHighLimit_ISO400 = 4, + kNkMAIDFlashISOAutoHighLimit_ISO500 = 5, + kNkMAIDFlashISOAutoHighLimit_ISO560 = 6, + kNkMAIDFlashISOAutoHighLimit_ISO640 = 7, + kNkMAIDFlashISOAutoHighLimit_ISO800 = 8, + kNkMAIDFlashISOAutoHighLimit_ISO1000 = 9, + kNkMAIDFlashISOAutoHighLimit_ISO1100 = 10, + kNkMAIDFlashISOAutoHighLimit_ISO1250 = 11, + kNkMAIDFlashISOAutoHighLimit_ISO1600 = 12, + kNkMAIDFlashISOAutoHighLimit_ISO2000 = 13, + kNkMAIDFlashISOAutoHighLimit_ISO2200 = 14, + kNkMAIDFlashISOAutoHighLimit_ISO2500 = 15, + kNkMAIDFlashISOAutoHighLimit_ISO3200 = 16, + kNkMAIDFlashISOAutoHighLimit_ISO4000 = 17, + kNkMAIDFlashISOAutoHighLimit_ISO4500 = 18, + kNkMAIDFlashISOAutoHighLimit_ISO5000 = 19, + kNkMAIDFlashISOAutoHighLimit_ISO6400 = 20, + kNkMAIDFlashISOAutoHighLimit_ISO8000 = 21, + kNkMAIDFlashISOAutoHighLimit_ISO9000 = 22, + kNkMAIDFlashISOAutoHighLimit_ISO10000 = 23, + kNkMAIDFlashISOAutoHighLimit_ISO12800 = 24, + kNkMAIDFlashISOAutoHighLimit_ISO16000 = 25, + kNkMAIDFlashISOAutoHighLimit_ISO18000 = 26, + kNkMAIDFlashISOAutoHighLimit_ISO20000 = 27, + kNkMAIDFlashISOAutoHighLimit_ISO25600 = 28, + kNkMAIDFlashISOAutoHighLimit_ISO32000 = 29, + kNkMAIDFlashISOAutoHighLimit_ISO36000 = 30, + kNkMAIDFlashISOAutoHighLimit_ISO40000 = 31, + kNkMAIDFlashISOAutoHighLimit_ISO51200 = 32, + kNkMAIDFlashISOAutoHighLimit_ISO64000 = 33, + kNkMAIDFlashISOAutoHighLimit_ISO72000 = 34, + kNkMAIDFlashISOAutoHighLimit_ISO81200 = 35, + kNkMAIDFlashISOAutoHighLimit_ISO102400 = 36, + kNkMAIDFlashISOAutoHighLimit_Hi03 = 37, + kNkMAIDFlashISOAutoHighLimit_Hi05 = 38, + kNkMAIDFlashISOAutoHighLimit_Hi07 = 39, + kNkMAIDFlashISOAutoHighLimit_Hi1 = 40, + kNkMAIDFlashISOAutoHighLimit_Hi2 = 41, + kNkMAIDFlashISOAutoHighLimit_Hi3 = 42, + kNkMAIDFlashISOAutoHighLimit_Hi4 = 43, + kNkMAIDFlashISOAutoHighLimit_Hi5 = 44, + kNkMAIDFlashISOAutoHighLimit_NoneFlash = 45 + } + + public enum eNkMAIDFlashMode : int + { + kNkMAIDFlashMode_FrontCurtain = 0, + kNkMAIDFlashMode_RearCurtain = 1, + kNkMAIDFlashMode_SlowSync = 2, + kNkMAIDFlashMode_RedEyeReduction = 3, + kNkMAIDFlashMode_SlowSyncRedEyeReduction = 4, + kNkMAIDFlashMode_SlowSyncRearCurtain = 5, + kNkMAIDFlashMode_VendorBaseDx2 = 261, + kNkMAIDFlashMode_Off = 262, + kNkMAIDFlashMode_Auto = 263, + kNkMAIDFlashMode_On = 264 + } + + public enum eNkMAIDFlashRangeDisplay : int + { + kNkMAIDFlashRangeDisplay_m = 0, + kNkMAIDFlashRangeDisplay_ft = 1 + } + + public enum eNkMAIDFlashStatus : int + { + kNkMAIDFlashStatus_Ready = 0, + kNkMAIDFlashStatus_NotReady = 1, + kNkMAIDFlashStatus_NotExist = 2, + kNkMAIDFlashStatus_NormalTTL = 3 + } + + public enum eNkMAIDFlickerReductionSetting : int + { + kNkMAIDFlickerReductionSetting_Off = 0, // Off + kNkMAIDFlickerReductionSetting_On = 1 // On + } + + public enum eNkMAIDFmmManual : int + { + kNkMAIDFmmManual_0 = 0, + kNkMAIDFmmManual_6 = 6, + kNkMAIDFmmManual_8 = 8, + kNkMAIDFmmManual_13 = 13, + kNkMAIDFmmManual_15 = 15, + kNkMAIDFmmManual_16 = 16, + kNkMAIDFmmManual_18 = 18, + kNkMAIDFmmManual_20 = 20, + kNkMAIDFmmManual_24 = 24, + kNkMAIDFmmManual_25 = 25, + kNkMAIDFmmManual_28 = 28, + kNkMAIDFmmManual_35 = 35, + kNkMAIDFmmManual_43 = 43, + kNkMAIDFmmManual_45 = 45, + kNkMAIDFmmManual_50 = 50, + kNkMAIDFmmManual_55 = 55, + kNkMAIDFmmManual_58 = 58, + kNkMAIDFmmManual_70 = 70, + kNkMAIDFmmManual_80 = 80, + kNkMAIDFmmManual_85 = 85, + kNkMAIDFmmManual_86 = 86, + kNkMAIDFmmManual_100 = 100, + kNkMAIDFmmManual_105 = 105, + kNkMAIDFmmManual_135 = 135, + kNkMAIDFmmManual_180 = 180, + kNkMAIDFmmManual_200 = 200, + kNkMAIDFmmManual_300 = 300, + kNkMAIDFmmManual_360 = 360, + kNkMAIDFmmManual_400 = 400, + kNkMAIDFmmManual_500 = 500, + kNkMAIDFmmManual_600 = 600, + kNkMAIDFmmManual_800 = 800, + kNkMAIDFmmManual_1000 = 1000, + kNkMAIDFmmManual_1200 = 1200, + kNkMAIDFmmManual_1400 = 1400, + kNkMAIDFmmManual_1600 = 1600, + kNkMAIDFmmManual_2000 = 2000, + kNkMAIDFmmManual_2400 = 2400, + kNkMAIDFmmManual_2800 = 2800, + kNkMAIDFmmManual_3200 = 3200, + kNkMAIDFmmManual_4000 = 4000 + } + + public enum eNkMAIDFocusAreaFrame : int + { + kNkMAIDFocusAreaFrame_Normal = 0, + kNkMAIDFocusAreaFrame_Wide = 1 + } + + public enum eNkMAIDFocusGroupPreferred : int + { + kNkMAIDFocusGroupPreferred_Center = 0, + kNkMAIDFocusGroupPreferred_Upper = 1, + kNkMAIDFocusGroupPreferred_Bottom = 2, + kNkMAIDFocusGroupPreferred_Left = 3, + kNkMAIDFocusGroupPreferred_Right = 4 + } + + public enum eNkMAIDFocusMode : int + { + kNkMAIDFocusMode_MF = 0, + kNkMAIDFocusMode_AFs = 1, + kNkMAIDFocusMode_AFc = 2, + kNkMAIDFocusMode_AFa = 3, + kNkMAIDFocusMode_AFf = 4, + kNkMAIDFocusMode_AF = 16, + kNkMAIDFocusMode_Macro = 17, + kNkMAIDFocusMode_Infinity = 18 + } + + public enum eNkMAIDFocusPointBrightness : int + { + kNkMAIDFocusPointBrightness_Low = 0, // Dark + kNkMAIDFocusPointBrightness_Normal = 1, // Normal + kNkMAIDFocusPointBrightness_High = 2, // Bright + kNkMAIDFocusPointBrightness_ExtraHigh = 3 // Extra bright + } + + public enum eNkMAIDFocusPreferred : int + { + kNkMAIDFocusPreferred_Center = 0, + kNkMAIDFocusPreferred_Upper = 1, + kNkMAIDFocusPreferred_Bottom = 2, + kNkMAIDFocusPreferred_Left = 3, + kNkMAIDFocusPreferred_Right = 4, + kNkMAIDFocusPreferred_UpperLeft = 5, + kNkMAIDFocusPreferred_UpperRight = 6, + kNkMAIDFocusPreferred_BottomLeft = 7, + kNkMAIDFocusPreferred_BottomRight = 8, + kNkMAIDFocusPreferred_LeftEnd = 9, + kNkMAIDFocusPreferred_RightEnd = 10 + } + + public enum eNkMAIDFocusPreferred2 : int + { + kNkMAIDFocusPreferred2_Unknown = 0, + kNkMAIDFocusPreferred2_C = 1, + kNkMAIDFocusPreferred2_CT = 2, + kNkMAIDFocusPreferred2_CTT = 3, + kNkMAIDFocusPreferred2_CB = 4, + kNkMAIDFocusPreferred2_CBB = 5, + kNkMAIDFocusPreferred2_CR = 6, + kNkMAIDFocusPreferred2_CRT = 7, + kNkMAIDFocusPreferred2_CRTT = 8, + kNkMAIDFocusPreferred2_CRB = 9, + kNkMAIDFocusPreferred2_CRBB = 10, + kNkMAIDFocusPreferred2_CL = 11, + kNkMAIDFocusPreferred2_CLT = 12, + kNkMAIDFocusPreferred2_CLTT = 13, + kNkMAIDFocusPreferred2_CLB = 14, + kNkMAIDFocusPreferred2_CLBB = 15, + kNkMAIDFocusPreferred2_RA = 16, + kNkMAIDFocusPreferred2_RAT = 17, + kNkMAIDFocusPreferred2_RATT = 18, + kNkMAIDFocusPreferred2_RAB = 19, + kNkMAIDFocusPreferred2_RABB = 20, + kNkMAIDFocusPreferred2_RB = 21, + kNkMAIDFocusPreferred2_RBT = 22, + kNkMAIDFocusPreferred2_RBTT = 23, + kNkMAIDFocusPreferred2_RBB = 24, + kNkMAIDFocusPreferred2_RBBB = 25, + kNkMAIDFocusPreferred2_RC = 26, + kNkMAIDFocusPreferred2_RCT = 27, + kNkMAIDFocusPreferred2_RCTT = 28, + kNkMAIDFocusPreferred2_RCB = 29, + kNkMAIDFocusPreferred2_RCBB = 30, + kNkMAIDFocusPreferred2_RD = 31, + kNkMAIDFocusPreferred2_RDT = 32, + kNkMAIDFocusPreferred2_RDB = 33, + kNkMAIDFocusPreferred2_LA = 34, + kNkMAIDFocusPreferred2_LAT = 35, + kNkMAIDFocusPreferred2_LATT = 36, + kNkMAIDFocusPreferred2_LAB = 37, + kNkMAIDFocusPreferred2_LABB = 38, + kNkMAIDFocusPreferred2_LB = 39, + kNkMAIDFocusPreferred2_LBT = 40, + kNkMAIDFocusPreferred2_LBTT = 41, + kNkMAIDFocusPreferred2_LBB = 42, + kNkMAIDFocusPreferred2_LBBB = 43, + kNkMAIDFocusPreferred2_LC = 44, + kNkMAIDFocusPreferred2_LCT = 45, + kNkMAIDFocusPreferred2_LCTT = 46, + kNkMAIDFocusPreferred2_LCB = 47, + kNkMAIDFocusPreferred2_LCBB = 48, + kNkMAIDFocusPreferred2_LD = 49, + kNkMAIDFocusPreferred2_LDT = 50, + kNkMAIDFocusPreferred2_LDB = 51 + } + + public enum eNkMAIDFocusPreferred3 : int + { + kNkMAIDFocusPreferred3_Unknown = 0, + kNkMAIDFocusPreferred3_Center = 1, + kNkMAIDFocusPreferred3_Upper = 2, + kNkMAIDFocusPreferred3_Bottom = 3, + kNkMAIDFocusPreferred3_Left = 4, + kNkMAIDFocusPreferred3_UpperLeft = 5, + kNkMAIDFocusPreferred3_BottomLeft = 6, + kNkMAIDFocusPreferred3_LeftEnd = 7, + kNkMAIDFocusPreferred3_Right = 8, + kNkMAIDFocusPreferred3_UpperRight = 9, + kNkMAIDFocusPreferred3_BottomRight = 10, + kNkMAIDFocusPreferred3_RightEnd = 11 + } + + public enum eNkMAIDFocusPreferred4 : int + { + kNkMAIDFocusPreferred4_Unknown = 0, + kNkMAIDFocusPreferred4_C = 1, + kNkMAIDFocusPreferred4_CT = 2, + kNkMAIDFocusPreferred4_CTT = 3, + kNkMAIDFocusPreferred4_CB = 4, + kNkMAIDFocusPreferred4_CBB = 5, + kNkMAIDFocusPreferred4_CR = 6, + kNkMAIDFocusPreferred4_CRT = 7, + kNkMAIDFocusPreferred4_CRTT = 8, + kNkMAIDFocusPreferred4_CRB = 9, + kNkMAIDFocusPreferred4_CRBB = 10, + kNkMAIDFocusPreferred4_CL = 11, + kNkMAIDFocusPreferred4_CLT = 12, + kNkMAIDFocusPreferred4_CLTT = 13, + kNkMAIDFocusPreferred4_CLB = 14, + kNkMAIDFocusPreferred4_CLBB = 15, + kNkMAIDFocusPreferred4_RA = 16, + kNkMAIDFocusPreferred4_RAT = 17, + kNkMAIDFocusPreferred4_RAB = 18, + kNkMAIDFocusPreferred4_RB = 19, + kNkMAIDFocusPreferred4_RBT = 20, + kNkMAIDFocusPreferred4_RBB = 21, + kNkMAIDFocusPreferred4_RC = 22, + kNkMAIDFocusPreferred4_RCT = 23, + kNkMAIDFocusPreferred4_RCB = 24, + kNkMAIDFocusPreferred4_RD = 25, + kNkMAIDFocusPreferred4_RDT = 26, + kNkMAIDFocusPreferred4_RDB = 27, + kNkMAIDFocusPreferred4_LA = 28, + kNkMAIDFocusPreferred4_LAT = 29, + kNkMAIDFocusPreferred4_LAB = 30, + kNkMAIDFocusPreferred4_LB = 31, + kNkMAIDFocusPreferred4_LBT = 32, + kNkMAIDFocusPreferred4_LBB = 33, + kNkMAIDFocusPreferred4_LC = 34, + kNkMAIDFocusPreferred4_LCT = 35, + kNkMAIDFocusPreferred4_LCB = 36, + kNkMAIDFocusPreferred4_LD = 37, + kNkMAIDFocusPreferred4_LDT = 38, + kNkMAIDFocusPreferred4_LDB = 39 + } + + public enum eNkMAIDFocusPreferred5 : int + { + kNkMAIDFocusPreferred5_Unknown = 0, + kNkMAIDFocusPreferred5_C = 1, + kNkMAIDFocusPreferred5_CT1 = 2, + kNkMAIDFocusPreferred5_CT2 = 3, + kNkMAIDFocusPreferred5_CT3 = 4, + kNkMAIDFocusPreferred5_CT4 = 5, + kNkMAIDFocusPreferred5_CB1 = 6, + kNkMAIDFocusPreferred5_CB2 = 7, + kNkMAIDFocusPreferred5_CB3 = 8, + kNkMAIDFocusPreferred5_CB4 = 9, + kNkMAIDFocusPreferred5_CR1 = 10, + kNkMAIDFocusPreferred5_CR1T1 = 11, + kNkMAIDFocusPreferred5_CR1T2 = 12, + kNkMAIDFocusPreferred5_CR1T3 = 13, + kNkMAIDFocusPreferred5_CR1T4 = 14, + kNkMAIDFocusPreferred5_CR1B1 = 15, + kNkMAIDFocusPreferred5_CR1B2 = 16, + kNkMAIDFocusPreferred5_CR1B3 = 17, + kNkMAIDFocusPreferred5_CR1B4 = 18, + kNkMAIDFocusPreferred5_CR2 = 19, + kNkMAIDFocusPreferred5_CR2T1 = 20, + kNkMAIDFocusPreferred5_CR2T2 = 21, + kNkMAIDFocusPreferred5_CR2T3 = 22, + kNkMAIDFocusPreferred5_CR2T4 = 23, + kNkMAIDFocusPreferred5_CR2B1 = 24, + kNkMAIDFocusPreferred5_CR2B2 = 25, + kNkMAIDFocusPreferred5_CR2B3 = 26, + kNkMAIDFocusPreferred5_CR2B4 = 27, + kNkMAIDFocusPreferred5_CL1 = 28, + kNkMAIDFocusPreferred5_CL1T1 = 29, + kNkMAIDFocusPreferred5_CL1T2 = 30, + kNkMAIDFocusPreferred5_CL1T3 = 31, + kNkMAIDFocusPreferred5_CL1T4 = 32, + kNkMAIDFocusPreferred5_CL1B1 = 33, + kNkMAIDFocusPreferred5_CL1B2 = 34, + kNkMAIDFocusPreferred5_CL1B3 = 35, + kNkMAIDFocusPreferred5_CL1B4 = 36, + kNkMAIDFocusPreferred5_CL2 = 37, + kNkMAIDFocusPreferred5_CL2T1 = 38, + kNkMAIDFocusPreferred5_CL2T2 = 39, + kNkMAIDFocusPreferred5_CL2T3 = 40, + kNkMAIDFocusPreferred5_CL2T4 = 41, + kNkMAIDFocusPreferred5_CL2B1 = 42, + kNkMAIDFocusPreferred5_CL2B2 = 43, + kNkMAIDFocusPreferred5_CL2B3 = 44, + kNkMAIDFocusPreferred5_CL2B4 = 45, + kNkMAIDFocusPreferred5_R1 = 46, + kNkMAIDFocusPreferred5_R1T1 = 47, + kNkMAIDFocusPreferred5_R1T2 = 48, + kNkMAIDFocusPreferred5_R1T3 = 49, + kNkMAIDFocusPreferred5_R1T4 = 50, + kNkMAIDFocusPreferred5_R1B1 = 51, + kNkMAIDFocusPreferred5_R1B2 = 52, + kNkMAIDFocusPreferred5_R1B3 = 53, + kNkMAIDFocusPreferred5_R1B4 = 54, + kNkMAIDFocusPreferred5_R2 = 55, + kNkMAIDFocusPreferred5_R2T1 = 56, + kNkMAIDFocusPreferred5_R2T2 = 57, + kNkMAIDFocusPreferred5_R2T3 = 58, + kNkMAIDFocusPreferred5_R2T4 = 59, + kNkMAIDFocusPreferred5_R2B1 = 60, + kNkMAIDFocusPreferred5_R2B2 = 61, + kNkMAIDFocusPreferred5_R2B3 = 62, + kNkMAIDFocusPreferred5_R2B4 = 63, + kNkMAIDFocusPreferred5_R3 = 64, + kNkMAIDFocusPreferred5_R3T1 = 65, + kNkMAIDFocusPreferred5_R3T2 = 66, + kNkMAIDFocusPreferred5_R3T3 = 67, + kNkMAIDFocusPreferred5_R3T4 = 68, + kNkMAIDFocusPreferred5_R3B1 = 69, + kNkMAIDFocusPreferred5_R3B2 = 70, + kNkMAIDFocusPreferred5_R3B3 = 71, + kNkMAIDFocusPreferred5_R3B4 = 72, + kNkMAIDFocusPreferred5_RS1 = 73, + kNkMAIDFocusPreferred5_RS1T1 = 74, + kNkMAIDFocusPreferred5_RS1T2 = 75, + kNkMAIDFocusPreferred5_RS1T3 = 76, + kNkMAIDFocusPreferred5_RS1T4 = 77, + kNkMAIDFocusPreferred5_RS1B1 = 78, + kNkMAIDFocusPreferred5_RS1B2 = 79, + kNkMAIDFocusPreferred5_RS1B3 = 80, + kNkMAIDFocusPreferred5_RS1B4 = 81, + kNkMAIDFocusPreferred5_RS2 = 82, + kNkMAIDFocusPreferred5_RS2T1 = 83, + kNkMAIDFocusPreferred5_RS2T2 = 84, + kNkMAIDFocusPreferred5_RS2T3 = 85, + kNkMAIDFocusPreferred5_RS2T4 = 86, + kNkMAIDFocusPreferred5_RS2B1 = 87, + kNkMAIDFocusPreferred5_RS2B2 = 88, + kNkMAIDFocusPreferred5_RS2B3 = 89, + kNkMAIDFocusPreferred5_RS2B4 = 90, + kNkMAIDFocusPreferred5_RS3 = 91, + kNkMAIDFocusPreferred5_RS3T1 = 92, + kNkMAIDFocusPreferred5_RS3T2 = 93, + kNkMAIDFocusPreferred5_RS3T3 = 94, + kNkMAIDFocusPreferred5_RS3T4 = 95, + kNkMAIDFocusPreferred5_RS3B1 = 96, + kNkMAIDFocusPreferred5_RS3B2 = 97, + kNkMAIDFocusPreferred5_RS3B3 = 98, + kNkMAIDFocusPreferred5_RS3B4 = 99, + kNkMAIDFocusPreferred5_L1 = 100, + kNkMAIDFocusPreferred5_L1T1 = 101, + kNkMAIDFocusPreferred5_L1T2 = 102, + kNkMAIDFocusPreferred5_L1T3 = 103, + kNkMAIDFocusPreferred5_L1T4 = 104, + kNkMAIDFocusPreferred5_L1B1 = 105, + kNkMAIDFocusPreferred5_L1B2 = 106, + kNkMAIDFocusPreferred5_L1B3 = 107, + kNkMAIDFocusPreferred5_L1B4 = 108, + kNkMAIDFocusPreferred5_L2 = 109, + kNkMAIDFocusPreferred5_L2T1 = 110, + kNkMAIDFocusPreferred5_L2T2 = 111, + kNkMAIDFocusPreferred5_L2T3 = 112, + kNkMAIDFocusPreferred5_L2T4 = 113, + kNkMAIDFocusPreferred5_L2B1 = 114, + kNkMAIDFocusPreferred5_L2B2 = 115, + kNkMAIDFocusPreferred5_L2B3 = 116, + kNkMAIDFocusPreferred5_L2B4 = 117, + kNkMAIDFocusPreferred5_L3 = 118, + kNkMAIDFocusPreferred5_L3T1 = 119, + kNkMAIDFocusPreferred5_L3T2 = 120, + kNkMAIDFocusPreferred5_L3T3 = 121, + kNkMAIDFocusPreferred5_L3T4 = 122, + kNkMAIDFocusPreferred5_L3B1 = 123, + kNkMAIDFocusPreferred5_L3B2 = 124, + kNkMAIDFocusPreferred5_L3B3 = 125, + kNkMAIDFocusPreferred5_L3B4 = 126, + kNkMAIDFocusPreferred5_LS1 = 127, + kNkMAIDFocusPreferred5_LS1T1 = 128, + kNkMAIDFocusPreferred5_LS1T2 = 129, + kNkMAIDFocusPreferred5_LS1T3 = 130, + kNkMAIDFocusPreferred5_LS1T4 = 131, + kNkMAIDFocusPreferred5_LS1B1 = 132, + kNkMAIDFocusPreferred5_LS1B2 = 133, + kNkMAIDFocusPreferred5_LS1B3 = 134, + kNkMAIDFocusPreferred5_LS1B4 = 135, + kNkMAIDFocusPreferred5_LS2 = 136, + kNkMAIDFocusPreferred5_LS2T1 = 137, + kNkMAIDFocusPreferred5_LS2T2 = 138, + kNkMAIDFocusPreferred5_LS2T3 = 139, + kNkMAIDFocusPreferred5_LS2T4 = 140, + kNkMAIDFocusPreferred5_LS2B1 = 141, + kNkMAIDFocusPreferred5_LS2B2 = 142, + kNkMAIDFocusPreferred5_LS2B3 = 143, + kNkMAIDFocusPreferred5_LS2B4 = 144, + kNkMAIDFocusPreferred5_LS3 = 145, + kNkMAIDFocusPreferred5_LS3T1 = 146, + kNkMAIDFocusPreferred5_LS3T2 = 147, + kNkMAIDFocusPreferred5_LS3T3 = 148, + kNkMAIDFocusPreferred5_LS3T4 = 149, + kNkMAIDFocusPreferred5_LS3B1 = 150, + kNkMAIDFocusPreferred5_LS3B2 = 151, + kNkMAIDFocusPreferred5_LS3B3 = 152, + kNkMAIDFocusPreferred5_LS3B4 = 153 + } + + public enum eNkMAIDGetIPTCInfo : int + { + kNkMAIDGetIPTCInfo_None = 0, + kNkMAIDGetIPTCInfo_Attached = 1 + } + + public enum eNkMAIDHDRExposure : int + { + kNkMAIDHDRExposure_Auto = 0, + kNkMAIDHDRExposure_1EV = 1, + kNkMAIDHDRExposure_2EV = 2, + kNkMAIDHDRExposure_3EV = 3 + } + + public enum eNkMAIDHDRMode : int + { + kNkMAIDHDRMode_Off = 0, // Off + kNkMAIDHDRMode_On = 1, // On (single photo) + kNkMAIDHDRMode_Continuous = 2 // On (series) + } + + public enum eNkMAIDHDRMode2 : int + { + kNkMAIDHDRMode2_Off = 0, // Off + kNkMAIDHDRMode2_Low = 1, // Low + kNkMAIDHDRMode2_Normal = 2, // Normal + kNkMAIDHDRMode2_High = 3, // High + kNkMAIDHDRMode2_ExtraHigh = 4, // Extra high + kNkMAIDHDRMode2_Auto = 5 // Auto + } + + public enum eNkMAIDHDRSmoothing : int + { + kNkMAIDHDRSmoothing_High = 0, // High + kNkMAIDHDRSmoothing_Normal = 1, // Normal + kNkMAIDHDRSmoothing_Low = 2, // Low + kNkMAIDHDRSmoothing_Auto = 3, // �I�[�g + kNkMAIDHDRSmoothing_ExtraHigh = 4 // Extra high + } + + public enum eNkMAIDHighSpeedStillCaptureRate : int + { + kNkMAIDHighSpeedStillCaptureRate_CL = 0, // Continuous shot + kNkMAIDHighSpeedStillCaptureRate_10fps = 1, // Continuous high-speed shot 10 frames/second + kNkMAIDHighSpeedStillCaptureRate_20fps = 2, // Continuous high-speed shot 20 frames/second + kNkMAIDHighSpeedStillCaptureRate_30fps = 3, // Continuous high-speed shot 30 frames/second + kNkMAIDHighSpeedStillCaptureRate_60fps = 4 // Continuous high-speed shot 60 frames/second + } + + public enum eNkMAIDIlluminationSetting : int + { + kNkMAIDIlluminationSetting_LCDBacklight = 0, // Illuminator ON/OFF + kNkMAIDIlluminationSetting_Both = 1 // ON/OFF of the illuminator and Info screen + } + + public enum eNkMAIDImageColorSpace : int + { + kNkMAIDImageColorSpace_sRGB = 0, + kNkMAIDImageColorSpace_AdobeRGB = 1 + } + + public enum eNkMAIDImageMode : int + { + kNkMAIDImageMode_6M_High = 0, // 6M(2816*2112) + kNkMAIDImageMode_6M_Normal = 1, // 6M(2816*2112) + kNkMAIDImageMode_3M = 2, // 3M(2048*1536) + kNkMAIDImageMode_PC = 3, // PC(1024*768) + kNkMAIDImageMode_TV = 4 // TV(640*480) + } + + public enum eNkMAIDImageSetting : int + { + kNkMAIDImageSetting_Normal = 0, + kNkMAIDImageSetting_Clear = 1, + kNkMAIDImageSetting_Sharp = 2, + kNkMAIDImageSetting_Soft = 3, + kNkMAIDImageSetting_DirectPrint = 4, + kNkMAIDImageSetting_Portrait = 5, + kNkMAIDImageSetting_Landscape = 6, + kNkMAIDImageSetting_Custom = 7, + kNkMAIDImageSetting_Black_and_White = 8, + kNkMAIDImageSetting_MoreClear = 9 + } + + public enum eNkMAIDIndicatorDisplay : int + { + kNkMAIDIndicatorDisplay_Plus = 0, // + + kNkMAIDIndicatorDisplay_Minus = 1 // - + } + + public enum eNkMAIDInfoDispSetting : int + { + kNkMAIDInfoDispSetting_Auto = 0, // Auto + kNkMAIDInfoDispSetting_M_DarkOnLight = 1, // Manual (black letters) + kNkMAIDInfoDispSetting_M_LightOnDark = 2 // Manual (black letters) + } + + public enum eNkMAIDInternalFlashStatus : int + { + kNkMAIDInternalFlashStatus_Ready = 0, + kNkMAIDInternalFlashStatus_NotReady = 1, + kNkMAIDInternalFlashStatus_Close = 2, + kNkMAIDInternalFlashStatus_TTL = 3 + } + + public enum eNkMAIDInternalSplCmdGroupComp : int + { + kNkMAIDInternalSplCmdGroupComp_M30 = 0, // -3.0 + kNkMAIDInternalSplCmdGroupComp_M27 = 1, // -2.7 + kNkMAIDInternalSplCmdGroupComp_M23 = 2, // -2.3 + kNkMAIDInternalSplCmdGroupComp_M20 = 3, // -2.0 + kNkMAIDInternalSplCmdGroupComp_M17 = 4, // -1.7 + kNkMAIDInternalSplCmdGroupComp_M13 = 5, // -1.3 + kNkMAIDInternalSplCmdGroupComp_M10 = 6, // -1.0 + kNkMAIDInternalSplCmdGroupComp_M07 = 7, // -0.7 + kNkMAIDInternalSplCmdGroupComp_M03 = 8, // -0.3 + kNkMAIDInternalSplCmdGroupComp_0 = 9, // 0 + kNkMAIDInternalSplCmdGroupComp_P03 = 10, // +0.3 + kNkMAIDInternalSplCmdGroupComp_P07 = 11, // +0.7 + kNkMAIDInternalSplCmdGroupComp_P10 = 12, // +1.0 + kNkMAIDInternalSplCmdGroupComp_P13 = 13, // +1.3 + kNkMAIDInternalSplCmdGroupComp_P17 = 14, // +1.7 + kNkMAIDInternalSplCmdGroupComp_P20 = 15, // +2.0 + kNkMAIDInternalSplCmdGroupComp_P23 = 16, // +2.3 + kNkMAIDInternalSplCmdGroupComp_P27 = 17, // +2.7 + kNkMAIDInternalSplCmdGroupComp_P30 = 18 // +3.0 + } + + public enum eNkMAIDInternalSplCmdGroupMode : int + { + kNkMAIDInternalSplCmdGroupMode_TTL = 0, + kNkMAIDInternalSplCmdGroupMode_AA = 1, + kNkMAIDInternalSplCmdGroupMode_Manual = 2, + kNkMAIDInternalSplCmdGroupMode_Off = 3 + } + + public enum eNkMAIDInternalSplCmdGroupValue : int + { + kNkMAIDInternalSplCmdGroupValue_1 = 0, // 1/1 + kNkMAIDInternalSplCmdGroupValue_2 = 1, // 1/2 + kNkMAIDInternalSplCmdGroupValue_4 = 2, // 1/4 + kNkMAIDInternalSplCmdGroupValue_8 = 3, // 1/8 + kNkMAIDInternalSplCmdGroupValue_16 = 4, // 1/16 + kNkMAIDInternalSplCmdGroupValue_32 = 5, // 1/32 + kNkMAIDInternalSplCmdGroupValue_64 = 6, // 1/64 + kNkMAIDInternalSplCmdGroupValue_128 = 7, // 1/128 + kNkMAIDInternalSplCmdGroupValue_1_3 = 8, // 1/1.3 + kNkMAIDInternalSplCmdGroupValue_1_7 = 9, // 1/1.7 + kNkMAIDInternalSplCmdGroupValue_2_5 = 10, // 1/2.5 + kNkMAIDInternalSplCmdGroupValue_3_2 = 11, // 1/3.2 + kNkMAIDInternalSplCmdGroupValue_5 = 12, // 1/5 + kNkMAIDInternalSplCmdGroupValue_6_4 = 13, // 1/6.4 + kNkMAIDInternalSplCmdGroupValue_10 = 14, // 1/10 + kNkMAIDInternalSplCmdGroupValue_13 = 15, // 1/13 + kNkMAIDInternalSplCmdGroupValue_20 = 16, // 1/20 + kNkMAIDInternalSplCmdGroupValue_25 = 17, // 1/25 + kNkMAIDInternalSplCmdGroupValue_40 = 18, // 1/40 + kNkMAIDInternalSplCmdGroupValue_50 = 19, // 1/50 + kNkMAIDInternalSplCmdGroupValue_80 = 20, // 1/80 + kNkMAIDInternalSplCmdGroupValue_100 = 21 // 1/100 + } + + public enum eNkMAIDInternalSplCmdSelfComp : int + { + kNkMAIDInternalSplCmdSelfComp_M30 = 0, + kNkMAIDInternalSplCmdSelfComp_M27 = 1, + kNkMAIDInternalSplCmdSelfComp_M23 = 2, + kNkMAIDInternalSplCmdSelfComp_M20 = 3, + kNkMAIDInternalSplCmdSelfComp_M17 = 4, + kNkMAIDInternalSplCmdSelfComp_M13 = 5, + kNkMAIDInternalSplCmdSelfComp_M10 = 6, + kNkMAIDInternalSplCmdSelfComp_M07 = 7, + kNkMAIDInternalSplCmdSelfComp_M03 = 8, + kNkMAIDInternalSplCmdSelfComp_0 = 9, + kNkMAIDInternalSplCmdSelfComp_P03 = 10, + kNkMAIDInternalSplCmdSelfComp_P07 = 11, + kNkMAIDInternalSplCmdSelfComp_P10 = 12, + kNkMAIDInternalSplCmdSelfComp_P13 = 13, + kNkMAIDInternalSplCmdSelfComp_P17 = 14, + kNkMAIDInternalSplCmdSelfComp_P20 = 15, + kNkMAIDInternalSplCmdSelfComp_P23 = 16, + kNkMAIDInternalSplCmdSelfComp_P27 = 17, + kNkMAIDInternalSplCmdSelfComp_P30 = 18 + } + + public enum eNkMAIDInternalSplCmdSelfMode : int + { + kNkMAIDInternalSplCmdSelfMode_TTL = 0, + kNkMAIDInternalSplCmdSelfMode_Manual = 1, + kNkMAIDInternalSplCmdSelfMode_Off = 2 + } + + public enum eNkMAIDInternalSplCmdSelfValue : int + { + kNkMAIDInternalSplCmdSelfValue_1 = 0, // 1/1 + kNkMAIDInternalSplCmdSelfValue_2 = 1, // 1/2 + kNkMAIDInternalSplCmdSelfValue_4 = 2, // 1/4 + kNkMAIDInternalSplCmdSelfValue_8 = 3, // 1/8 + kNkMAIDInternalSplCmdSelfValue_16 = 4, // 1/16 + kNkMAIDInternalSplCmdSelfValue_32 = 5, // 1/32 + kNkMAIDInternalSplCmdSelfValue_64 = 6, // 1/64 + kNkMAIDInternalSplCmdSelfValue_128 = 7, // 1/128 + kNkMAIDInternalSplCmdSelfValue_1_3 = 8, // 1/1.3 + kNkMAIDInternalSplCmdSelfValue_1_7 = 9, // 1/1.7 + kNkMAIDInternalSplCmdSelfValue_2_5 = 10, // 1/2.5 + kNkMAIDInternalSplCmdSelfValue_3_2 = 11, // 1/3.2 + kNkMAIDInternalSplCmdSelfValue_5 = 12, // 1/5 + kNkMAIDInternalSplCmdSelfValue_6_4 = 13, // 1/6.4 + kNkMAIDInternalSplCmdSelfValue_10 = 14, // 1/10 + kNkMAIDInternalSplCmdSelfValue_13 = 15, // 1/13 + kNkMAIDInternalSplCmdSelfValue_20 = 16, // 1/20 + kNkMAIDInternalSplCmdSelfValue_25 = 17, // 1/25 + kNkMAIDInternalSplCmdSelfValue_40 = 18, // 1/40 + kNkMAIDInternalSplCmdSelfValue_50 = 19, // 1/50 + kNkMAIDInternalSplCmdSelfValue_80 = 20, // 1/80 + kNkMAIDInternalSplCmdSelfValue_100 = 21 // 1/100 + } + + public enum eNkMAIDInternalSplCommand : int + { + kNkMAIDInternalSplCommand_TTL = 0, + kNkMAIDInternalSplCommand_AA = 1, + kNkMAIDInternalSplCommand_Manual = 2, + kNkMAIDInternalSplCommand_Off = 3 + } + + public enum eNkMAIDInternalSplCommandChannel : int + { + kNkMAIDInternalSplCommandChannel_1 = 0, + kNkMAIDInternalSplCommandChannel_2 = 1, + kNkMAIDInternalSplCommandChannel_3 = 2, + kNkMAIDInternalSplCommandChannel_4 = 3 + } + + public enum eNkMAIDInternalSplCommandValue : int + { + kNkMAIDInternalSplCommandValue_Full = 0, + kNkMAIDInternalSplCommandValue_2 = 1, + kNkMAIDInternalSplCommandValue_4 = 2, + kNkMAIDInternalSplCommandValue_8 = 3, + kNkMAIDInternalSplCommandValue_16 = 4, + kNkMAIDInternalSplCommandValue_32 = 5, + kNkMAIDInternalSplCommandValue_64 = 6, + kNkMAIDInternalSplCommandValue_128 = 7 + } + + public enum eNkMAIDInternalSplMRPTCount : int + { + kNkMAIDInternalSplMRPTCount_2 = 0, + kNkMAIDInternalSplMRPTCount_3 = 1, + kNkMAIDInternalSplMRPTCount_4 = 2, + kNkMAIDInternalSplMRPTCount_5 = 3, + kNkMAIDInternalSplMRPTCount_6 = 4, + kNkMAIDInternalSplMRPTCount_7 = 5, + kNkMAIDInternalSplMRPTCount_8 = 6, + kNkMAIDInternalSplMRPTCount_9 = 7, + kNkMAIDInternalSplMRPTCount_10 = 8, + kNkMAIDInternalSplMRPTCount_15 = 9, + kNkMAIDInternalSplMRPTCount_20 = 10, + kNkMAIDInternalSplMRPTCount_25 = 11, + kNkMAIDInternalSplMRPTCount_30 = 12, + kNkMAIDInternalSplMRPTCount_35 = 13 + } + + public enum eNkMAIDInternalSplMRPTInterval : int + { + kNkMAIDInternalSplMRPTInterval_1 = 0, + kNkMAIDInternalSplMRPTInterval_2 = 1, + kNkMAIDInternalSplMRPTInterval_3 = 2, + kNkMAIDInternalSplMRPTInterval_4 = 3, + kNkMAIDInternalSplMRPTInterval_5 = 4, + kNkMAIDInternalSplMRPTInterval_6 = 5, + kNkMAIDInternalSplMRPTInterval_7 = 6, + kNkMAIDInternalSplMRPTInterval_8 = 7, + kNkMAIDInternalSplMRPTInterval_9 = 8, + kNkMAIDInternalSplMRPTInterval_10 = 9, + kNkMAIDInternalSplMRPTInterval_20 = 10, + kNkMAIDInternalSplMRPTInterval_30 = 11, + kNkMAIDInternalSplMRPTInterval_40 = 12, + kNkMAIDInternalSplMRPTInterval_50 = 13 + } + + public enum eNkMAIDInternalSplMRPTValue : int + { + kNkMAIDInternalSplMRPTValue_4 = 0, + kNkMAIDInternalSplMRPTValue_8 = 1, + kNkMAIDInternalSplMRPTValue_16 = 2, + kNkMAIDInternalSplMRPTValue_32 = 3, + kNkMAIDInternalSplMRPTValue_64 = 4, + kNkMAIDInternalSplMRPTValue_128 = 5, + kNkMAIDInternalSplMRPTValue_Full = 6 + } + + public enum eNkMAIDInternalSplValue : int + { + kNkMAIDInternalSplValue_Full = 0, // Full + kNkMAIDInternalSplValue_2 = 1, // 1/2 + kNkMAIDInternalSplValue_4 = 2, // 1/4 + kNkMAIDInternalSplValue_8 = 3, // 1/8 + kNkMAIDInternalSplValue_16 = 4, // 1/16 + kNkMAIDInternalSplValue_32 = 5, // 1/32 + kNkMAIDInternalSplValue_64 = 6, // 1/64 + kNkMAIDInternalSplValue_128 = 7, // 1/128 + kNkMAIDInternalSplValue_1_3 = 8, // 1/1.3 + kNkMAIDInternalSplValue_1_7 = 9, // 1/1.7 + kNkMAIDInternalSplValue_2_5 = 10, // 1/2.5 + kNkMAIDInternalSplValue_3_2 = 11, // 1/3.2 + kNkMAIDInternalSplValue_5 = 12, // 1/5 + kNkMAIDInternalSplValue_6_4 = 13, // 1/6.4 + kNkMAIDInternalSplValue_10 = 14, // 1/10 + kNkMAIDInternalSplValue_13 = 15, // 1/13 + kNkMAIDInternalSplValue_20 = 16, // 1/20 + kNkMAIDInternalSplValue_25 = 17, // 1/25 + kNkMAIDInternalSplValue_40 = 18, // 1/40 + kNkMAIDInternalSplValue_50 = 19, // 1/50 + kNkMAIDInternalSplValue_80 = 20, // 1/80 + kNkMAIDInternalSplValue_100 = 21, // 1/100 + kNkMAIDInternalSplValue_256 = 22 // 1/256 + } + + public enum eNkMAIDIPTCPresetInfo : int + { + kNkMAIDIPTCPresetInfo_ALL = 0, // All Preset. + kNkMAIDIPTCPresetInfo_1 = 1, // Preset No.1. + kNkMAIDIPTCPresetInfo_2 = 2, // Preset No.2. + kNkMAIDIPTCPresetInfo_3 = 3, // Preset No.3. + kNkMAIDIPTCPresetInfo_4 = 4, // Preset No.4. + kNkMAIDIPTCPresetInfo_5 = 5, // Preset No.5. + kNkMAIDIPTCPresetInfo_6 = 6, // Preset No.6. + kNkMAIDIPTCPresetInfo_7 = 7, // Preset No.7. + kNkMAIDIPTCPresetInfo_8 = 8, // Preset No.8. + kNkMAIDIPTCPresetInfo_9 = 9, // Preset No.9. + kNkMAIDIPTCPresetInfo_10 = 10 // Preset No.10. + } + + public enum eNkMAIDIPTCPresetSelect : int + { + kNkMAIDIPTCPresetSelect_OFF = 0, + kNkMAIDIPTCPresetSelect_1 = 1, + kNkMAIDIPTCPresetSelect_2 = 2, + kNkMAIDIPTCPresetSelect_3 = 3, + kNkMAIDIPTCPresetSelect_4 = 4, + kNkMAIDIPTCPresetSelect_5 = 5, + kNkMAIDIPTCPresetSelect_6 = 6, + kNkMAIDIPTCPresetSelect_7 = 7, + kNkMAIDIPTCPresetSelect_8 = 8, + kNkMAIDIPTCPresetSelect_9 = 9, + kNkMAIDIPTCPresetSelect_10 = 10 + } + + public enum eNkMAIDISOAutoHiLimit : int + { + kNkMAIDISOAutoHiLimit_ISO200 = 0, + kNkMAIDISOAutoHiLimit_ISO400 = 1, + kNkMAIDISOAutoHiLimit_ISO800 = 2, + kNkMAIDISOAutoHiLimit_ISO1600 = 3, + kNkMAIDISOAutoHiLimit_ISO3200 = 4, + kNkMAIDISOAutoHiLimit_ISO6400 = 5, + kNkMAIDISOAutoHiLimit_Hi1 = 6, + kNkMAIDISOAutoHiLimit_Hi2 = 7, + kNkMAIDISOAutoHiLimit_ISO12800 = 8, + kNkMAIDISOAutoHiLimit_ISO25600 = 9 + } + + public enum eNkMAIDISOAutoHiLimit2 : int + { + kNkMAIDISOAutoHiLimit2_ISO400 = 0, + kNkMAIDISOAutoHiLimit2_ISO500 = 1, + kNkMAIDISOAutoHiLimit2_ISO560 = 2, + kNkMAIDISOAutoHiLimit2_ISO640 = 3, + kNkMAIDISOAutoHiLimit2_ISO800 = 4, + kNkMAIDISOAutoHiLimit2_ISO1000 = 5, + kNkMAIDISOAutoHiLimit2_ISO1100 = 6, + kNkMAIDISOAutoHiLimit2_ISO1250 = 7, + kNkMAIDISOAutoHiLimit2_ISO1600 = 8, + kNkMAIDISOAutoHiLimit2_ISO2000 = 9, + kNkMAIDISOAutoHiLimit2_ISO2200 = 10, + kNkMAIDISOAutoHiLimit2_ISO2500 = 11, + kNkMAIDISOAutoHiLimit2_ISO3200 = 12, + kNkMAIDISOAutoHiLimit2_ISO4000 = 13, + kNkMAIDISOAutoHiLimit2_ISO4500 = 14, + kNkMAIDISOAutoHiLimit2_ISO5000 = 15, + kNkMAIDISOAutoHiLimit2_ISO6400 = 16, + kNkMAIDISOAutoHiLimit2_ISO8000 = 17, + kNkMAIDISOAutoHiLimit2_ISO9000 = 18, + kNkMAIDISOAutoHiLimit2_ISO10000 = 19, + kNkMAIDISOAutoHiLimit2_ISO12800 = 20, + kNkMAIDISOAutoHiLimit2_ISOHi03 = 21, + kNkMAIDISOAutoHiLimit2_ISOHi05 = 22, + kNkMAIDISOAutoHiLimit2_ISOHi07 = 23, + kNkMAIDISOAutoHiLimit2_ISOHi10 = 24, + kNkMAIDISOAutoHiLimit2_ISOHi20 = 25, + kNkMAIDISOAutoHiLimit2_ISOHi30 = 26 + } + + public enum eNkMAIDISOAutoHiLimit3 : int + { + kNkMAIDISOAutoHiLimit3_ISO200 = 0, + kNkMAIDISOAutoHiLimit3_ISO250 = 1, + kNkMAIDISOAutoHiLimit3_ISO280 = 2, + kNkMAIDISOAutoHiLimit3_ISO320 = 3, + kNkMAIDISOAutoHiLimit3_ISO400 = 4, + kNkMAIDISOAutoHiLimit3_ISO500 = 5, + kNkMAIDISOAutoHiLimit3_ISO560 = 6, + kNkMAIDISOAutoHiLimit3_ISO640 = 7, + kNkMAIDISOAutoHiLimit3_ISO800 = 8, + kNkMAIDISOAutoHiLimit3_ISO1000 = 9, + kNkMAIDISOAutoHiLimit3_ISO1100 = 10, + kNkMAIDISOAutoHiLimit3_ISO1250 = 11, + kNkMAIDISOAutoHiLimit3_ISO1600 = 12, + kNkMAIDISOAutoHiLimit3_ISO2000 = 13, + kNkMAIDISOAutoHiLimit3_ISO2200 = 14, + kNkMAIDISOAutoHiLimit3_ISO2500 = 15, + kNkMAIDISOAutoHiLimit3_ISO3200 = 16, + kNkMAIDISOAutoHiLimit3_ISO4000 = 17, + kNkMAIDISOAutoHiLimit3_ISO4500 = 18, + kNkMAIDISOAutoHiLimit3_ISO5000 = 19, + kNkMAIDISOAutoHiLimit3_ISO6400 = 20, + kNkMAIDISOAutoHiLimit3_ISOHi03 = 21, + kNkMAIDISOAutoHiLimit3_ISOHi05 = 22, + kNkMAIDISOAutoHiLimit3_ISOHi07 = 23, + kNkMAIDISOAutoHiLimit3_ISOHi10 = 24, + kNkMAIDISOAutoHiLimit3_ISOHi20 = 25, + kNkMAIDISOAutoHiLimit3_ISO8000 = 26, + kNkMAIDISOAutoHiLimit3_ISO9000 = 27, + kNkMAIDISOAutoHiLimit3_ISO10000 = 28, + kNkMAIDISOAutoHiLimit3_ISO12800 = 29, + kNkMAIDISOAutoHiLimit3_ISOHi30 = 30, + kNkMAIDISOAutoHiLimit3_ISOHi40 = 31, + kNkMAIDISOAutoHiLimit3_ISO16000 = 32, + kNkMAIDISOAutoHiLimit3_ISO18000 = 33, + kNkMAIDISOAutoHiLimit3_ISO20000 = 34, + kNkMAIDISOAutoHiLimit3_ISO25600 = 35, + kNkMAIDISOAutoHiLimit3_ISO32000 = 36, + kNkMAIDISOAutoHiLimit3_ISO36000 = 37, + kNkMAIDISOAutoHiLimit3_ISO40000 = 38, + kNkMAIDISOAutoHiLimit3_ISO51200 = 39, + kNkMAIDISOAutoHiLimit3_ISO64000 = 40, + kNkMAIDISOAutoHiLimit3_ISO72000 = 41, + kNkMAIDISOAutoHiLimit3_ISO81200 = 42, + kNkMAIDISOAutoHiLimit3_ISO102400 = 43, + kNkMAIDISOAutoHiLimit3_ISOHi50 = 44 + } + + public enum eNkMAIDISOAutoHiLimit4 : int + { + kNkMAIDISOAutoHiLimit4_ISO72 = 0, + kNkMAIDISOAutoHiLimit4_ISO80 = 1, + kNkMAIDISOAutoHiLimit4_ISO100 = 2, + kNkMAIDISOAutoHiLimit4_ISO125 = 3, + kNkMAIDISOAutoHiLimit4_ISO140 = 4, + kNkMAIDISOAutoHiLimit4_ISO160 = 5, + kNkMAIDISOAutoHiLimit4_ISO200 = 6, + kNkMAIDISOAutoHiLimit4_ISO250 = 7, + kNkMAIDISOAutoHiLimit4_ISO280 = 8, + kNkMAIDISOAutoHiLimit4_ISO320 = 9, + kNkMAIDISOAutoHiLimit4_ISO400 = 10, + kNkMAIDISOAutoHiLimit4_ISO500 = 11, + kNkMAIDISOAutoHiLimit4_ISO560 = 12, + kNkMAIDISOAutoHiLimit4_ISO640 = 13, + kNkMAIDISOAutoHiLimit4_ISO800 = 14, + kNkMAIDISOAutoHiLimit4_ISO1000 = 15, + kNkMAIDISOAutoHiLimit4_ISO1100 = 16, + kNkMAIDISOAutoHiLimit4_ISO1250 = 17, + kNkMAIDISOAutoHiLimit4_ISO1600 = 18, + kNkMAIDISOAutoHiLimit4_ISO2000 = 19, + kNkMAIDISOAutoHiLimit4_ISO2200 = 20, + kNkMAIDISOAutoHiLimit4_ISO2500 = 21, + kNkMAIDISOAutoHiLimit4_ISO3200 = 22, + kNkMAIDISOAutoHiLimit4_ISO4000 = 23, + kNkMAIDISOAutoHiLimit4_ISO4500 = 24, + kNkMAIDISOAutoHiLimit4_ISO5000 = 25, + kNkMAIDISOAutoHiLimit4_ISO6400 = 26, + kNkMAIDISOAutoHiLimit4_ISO8000 = 27, + kNkMAIDISOAutoHiLimit4_ISO9000 = 28, + kNkMAIDISOAutoHiLimit4_ISO10000 = 29, + kNkMAIDISOAutoHiLimit4_ISO12800 = 30, + kNkMAIDISOAutoHiLimit4_ISOHi03 = 31, + kNkMAIDISOAutoHiLimit4_ISOHi05 = 32, + kNkMAIDISOAutoHiLimit4_ISOHi07 = 33, + kNkMAIDISOAutoHiLimit4_ISOHi10 = 34, + kNkMAIDISOAutoHiLimit4_ISOHi20 = 35 + } + + public enum eNkMAIDISOAutoShutterTime : int + { + kNkMAIDISOAutoShutterTime_0 = 0, // 1/125 + kNkMAIDISOAutoShutterTime_1 = 1, // 1/60 + kNkMAIDISOAutoShutterTime_2 = 2, // 1/30 + kNkMAIDISOAutoShutterTime_3 = 3, // 1/15 + kNkMAIDISOAutoShutterTime_4 = 4, // 1/8 + kNkMAIDISOAutoShutterTime_5 = 5, // 1/4 + kNkMAIDISOAutoShutterTime_6 = 6, // 1/2 + kNkMAIDISOAutoShutterTime_7 = 7, // 1 + kNkMAIDISOAutoShutterTime_8 = 8, // 2 + kNkMAIDISOAutoShutterTime_9 = 9, // 4 + kNkMAIDISOAutoShutterTime_10 = 10, // 8 + kNkMAIDISOAutoShutterTime_11 = 11, // 15 + kNkMAIDISOAutoShutterTime_12 = 12, // 30 + kNkMAIDISOAutoShutterTime_13 = 13, // 1/250 + kNkMAIDISOAutoShutterTime_14 = 14, // 1/200 + kNkMAIDISOAutoShutterTime_15 = 15, // 1/160 + kNkMAIDISOAutoShutterTime_16 = 16, // 1/100 + kNkMAIDISOAutoShutterTime_17 = 17, // 1/80 + kNkMAIDISOAutoShutterTime_18 = 18, // 1/40 + kNkMAIDISOAutoShutterTime_19 = 19, // 1/50 + kNkMAIDISOAutoShutterTime_20 = 20, // 1/4000 + kNkMAIDISOAutoShutterTime_21 = 21, // 1/3200 + kNkMAIDISOAutoShutterTime_22 = 22, // 1/2500 + kNkMAIDISOAutoShutterTime_23 = 23, // 1/2000 + kNkMAIDISOAutoShutterTime_24 = 24, // 1/1600 + kNkMAIDISOAutoShutterTime_25 = 25, // 1/1250 + kNkMAIDISOAutoShutterTime_26 = 26, // 1/1000 + kNkMAIDISOAutoShutterTime_27 = 27, // 1/800 + kNkMAIDISOAutoShutterTime_28 = 28, // 1/640 + kNkMAIDISOAutoShutterTime_29 = 29, // 1/500 + kNkMAIDISOAutoShutterTime_30 = 30, // 1/400 + kNkMAIDISOAutoShutterTime_31 = 31, // 1/320 + kNkMAIDISOAutoShutterTime_32 = 32 // auto + } + + public enum eNkMAIDISOAutoShutterTimeAutoValue : int + { + kNkMAIDISOAutoShutterTimeAutoValue_Minus2 = 0, + kNkMAIDISOAutoShutterTimeAutoValue_Minus1 = 1, + kNkMAIDISOAutoShutterTimeAutoValue_0 = 2, + kNkMAIDISOAutoShutterTimeAutoValue_Plus1 = 3, + kNkMAIDISOAutoShutterTimeAutoValue_Plus2 = 4 + } + + public enum eNkMAIDISOControlSensitivity : int + { + kNkMAIDISOControlSensitivity_Lo10 = 50, + kNkMAIDISOControlSensitivity_Lo08 = 56, + kNkMAIDISOControlSensitivity_Lo12 = 56, + kNkMAIDISOControlSensitivity_Lo07 = 64, + kNkMAIDISOControlSensitivity_Lo13 = 64, + kNkMAIDISOControlSensitivity_Lo05 = 72, + kNkMAIDISOControlSensitivity_Lo15 = 72, + kNkMAIDISOControlSensitivity_Lo17 = 80, + kNkMAIDISOControlSensitivity_Lo03 = 80, + kNkMAIDISOControlSensitivity_Lo02 = 90, + kNkMAIDISOControlSensitivity_Lo18 = 90, + kNkMAIDISOControlSensitivity_ISO100 = 100, + kNkMAIDISOControlSensitivity_ISO110 = 110, + kNkMAIDISOControlSensitivity_ISO125 = 125, + kNkMAIDISOControlSensitivity_ISO140 = 140, + kNkMAIDISOControlSensitivity_ISO160 = 160, + kNkMAIDISOControlSensitivity_ISO180 = 180, + kNkMAIDISOControlSensitivity_ISO200 = 200, + kNkMAIDISOControlSensitivity_ISO220 = 220, + kNkMAIDISOControlSensitivity_ISO250 = 250, + kNkMAIDISOControlSensitivity_ISO280 = 280, + kNkMAIDISOControlSensitivity_ISO320 = 320, + kNkMAIDISOControlSensitivity_ISO360 = 360, + kNkMAIDISOControlSensitivity_ISO400 = 400, + kNkMAIDISOControlSensitivity_ISO450 = 450, + kNkMAIDISOControlSensitivity_ISO500 = 500, + kNkMAIDISOControlSensitivity_ISO560 = 560, + kNkMAIDISOControlSensitivity_ISO640 = 640, + kNkMAIDISOControlSensitivity_ISO720 = 720, + kNkMAIDISOControlSensitivity_ISO800 = 800, + kNkMAIDISOControlSensitivity_ISO900 = 900, + kNkMAIDISOControlSensitivity_ISO1000 = 1000, + kNkMAIDISOControlSensitivity_ISO1100 = 1100, + kNkMAIDISOControlSensitivity_ISO1250 = 1250, + kNkMAIDISOControlSensitivity_ISO1400 = 1400, + kNkMAIDISOControlSensitivity_ISO1600 = 1600, + kNkMAIDISOControlSensitivity_ISO1800 = 1800, + kNkMAIDISOControlSensitivity_ISO2000 = 2000, + kNkMAIDISOControlSensitivity_ISO2200 = 2200, + kNkMAIDISOControlSensitivity_ISO2500 = 2500, + kNkMAIDISOControlSensitivity_ISO2800 = 2800, + kNkMAIDISOControlSensitivity_ISO3200 = 3200, + kNkMAIDISOControlSensitivity_ISO3600 = 3600, + kNkMAIDISOControlSensitivity_ISO4000 = 4000, + kNkMAIDISOControlSensitivity_ISO4500 = 4500, + kNkMAIDISOControlSensitivity_ISO5000 = 5000, + kNkMAIDISOControlSensitivity_ISO5600 = 5600, + kNkMAIDISOControlSensitivity_ISO6400 = 6400, + kNkMAIDISOControlSensitivity_ISO7200 = 7200, + kNkMAIDISOControlSensitivity_ISO8000 = 8000, + kNkMAIDISOControlSensitivity_ISO9000 = 9000, + kNkMAIDISOControlSensitivity_ISO10000 = 10000, + kNkMAIDISOControlSensitivity_ISO11000 = 11000, + kNkMAIDISOControlSensitivity_ISO12800 = 12800, + kNkMAIDISOControlSensitivity_Hi02 = 14400, + kNkMAIDISOControlSensitivity_Hi03 = 16000, + kNkMAIDISOControlSensitivity_Hi05 = 18000, + kNkMAIDISOControlSensitivity_Hi07 = 20000, + kNkMAIDISOControlSensitivity_Hi08 = 22000, + kNkMAIDISOControlSensitivity_Hi10 = 25600, + kNkMAIDISOControlSensitivity_Hi12 = 28800, + kNkMAIDISOControlSensitivity_Hi13 = 32000, + kNkMAIDISOControlSensitivity_Hi15 = 36000, + kNkMAIDISOControlSensitivity_Hi17 = 40000, + kNkMAIDISOControlSensitivity_Hi18 = 45600, + kNkMAIDISOControlSensitivity_Hi20 = 51200, + kNkMAIDISOControlSensitivity_Hi22 = 57600, + kNkMAIDISOControlSensitivity_Hi23 = 64000, + kNkMAIDISOControlSensitivity_Hi25 = 72000, + kNkMAIDISOControlSensitivity_Hi27 = 81200, + kNkMAIDISOControlSensitivity_Hi28 = 91200, + kNkMAIDISOControlSensitivity_Hi30 = 102400, + kNkMAIDISOControlSensitivity_Hi32 = 115000, + kNkMAIDISOControlSensitivity_Hi33 = 128000, + kNkMAIDISOControlSensitivity_Hi35 = 144000, + kNkMAIDISOControlSensitivity_Hi37 = 162000, + kNkMAIDISOControlSensitivity_Hi38 = 182000, + kNkMAIDISOControlSensitivity_Hi40 = 204800 + } + + public enum eNkMAIDISOControlSensitivity2 : int + { + kNkMAIDISOControlSensitivity2_Lo10 = 50, + kNkMAIDISOControlSensitivity2_Lo08 = 56, + kNkMAIDISOControlSensitivity2_Lo07 = 64, + kNkMAIDISOControlSensitivity2_Lo05 = 72, + kNkMAIDISOControlSensitivity2_Lo03 = 80, + kNkMAIDISOControlSensitivity2_Lo02 = 90, + kNkMAIDISOControlSensitivity2_ISO100 = 100, + kNkMAIDISOControlSensitivity2_ISO110 = 110, + kNkMAIDISOControlSensitivity2_ISO125 = 125, + kNkMAIDISOControlSensitivity2_ISO140 = 140, + kNkMAIDISOControlSensitivity2_ISO160 = 160, + kNkMAIDISOControlSensitivity2_ISO180 = 180, + kNkMAIDISOControlSensitivity2_ISO200 = 200, + kNkMAIDISOControlSensitivity2_ISO220 = 220, + kNkMAIDISOControlSensitivity2_ISO250 = 250, + kNkMAIDISOControlSensitivity2_ISO280 = 280, + kNkMAIDISOControlSensitivity2_ISO320 = 320, + kNkMAIDISOControlSensitivity2_ISO360 = 360, + kNkMAIDISOControlSensitivity2_ISO400 = 400, + kNkMAIDISOControlSensitivity2_ISO450 = 450, + kNkMAIDISOControlSensitivity2_ISO500 = 500, + kNkMAIDISOControlSensitivity2_ISO560 = 560, + kNkMAIDISOControlSensitivity2_ISO640 = 640, + kNkMAIDISOControlSensitivity2_ISO720 = 720, + kNkMAIDISOControlSensitivity2_ISO800 = 800, + kNkMAIDISOControlSensitivity2_ISO900 = 900, + kNkMAIDISOControlSensitivity2_ISO1000 = 1000, + kNkMAIDISOControlSensitivity2_ISO1100 = 1100, + kNkMAIDISOControlSensitivity2_ISO1250 = 1250, + kNkMAIDISOControlSensitivity2_ISO1400 = 1400, + kNkMAIDISOControlSensitivity2_ISO1600 = 1600, + kNkMAIDISOControlSensitivity2_ISO1800 = 1800, + kNkMAIDISOControlSensitivity2_ISO2000 = 2000, + kNkMAIDISOControlSensitivity2_ISO2200 = 2200, + kNkMAIDISOControlSensitivity2_ISO2500 = 2500, + kNkMAIDISOControlSensitivity2_ISO2800 = 2800, + kNkMAIDISOControlSensitivity2_ISO3200 = 3200, + kNkMAIDISOControlSensitivity2_ISO3600 = 3600, + kNkMAIDISOControlSensitivity2_ISO4000 = 4000, + kNkMAIDISOControlSensitivity2_ISO4500 = 4500, + kNkMAIDISOControlSensitivity2_ISO5000 = 5000, + kNkMAIDISOControlSensitivity2_ISO5600 = 5600, + kNkMAIDISOControlSensitivity2_ISO6400 = 6400, + kNkMAIDISOControlSensitivity2_ISO7200 = 7200, + kNkMAIDISOControlSensitivity2_ISO8000 = 8000, + kNkMAIDISOControlSensitivity2_ISO9000 = 9000, + kNkMAIDISOControlSensitivity2_ISO10000 = 10000, + kNkMAIDISOControlSensitivity2_ISO11000 = 11000, + kNkMAIDISOControlSensitivity2_ISO12800 = 12800, + kNkMAIDISOControlSensitivity2_ISO14400 = 14400, + kNkMAIDISOControlSensitivity2_ISO16000 = 16000, + kNkMAIDISOControlSensitivity2_ISO18000 = 18000, + kNkMAIDISOControlSensitivity2_ISO20000 = 20000, + kNkMAIDISOControlSensitivity2_ISO22000 = 22000, + kNkMAIDISOControlSensitivity2_ISO25600 = 25600, + kNkMAIDISOControlSensitivity2_Hi02 = 28800, + kNkMAIDISOControlSensitivity2_Hi03 = 32000, + kNkMAIDISOControlSensitivity2_Hi05 = 36000, + kNkMAIDISOControlSensitivity2_Hi07 = 40000, + kNkMAIDISOControlSensitivity2_Hi08 = 45600, + kNkMAIDISOControlSensitivity2_Hi10 = 51200, + kNkMAIDISOControlSensitivity2_Hi12 = 57600, + kNkMAIDISOControlSensitivity2_Hi13 = 64000, + kNkMAIDISOControlSensitivity2_Hi15 = 72000, + kNkMAIDISOControlSensitivity2_Hi17 = 81200, + kNkMAIDISOControlSensitivity2_Hi18 = 91200, + kNkMAIDISOControlSensitivity2_Hi20 = 102400, + kNkMAIDISOControlSensitivity2_Hi22 = 115000, + kNkMAIDISOControlSensitivity2_Hi23 = 128000, + kNkMAIDISOControlSensitivity2_Hi25 = 144000, + kNkMAIDISOControlSensitivity2_Hi27 = 162000, + kNkMAIDISOControlSensitivity2_Hi28 = 182000, + kNkMAIDISOControlSensitivity2_Hi30 = 204800, + kNkMAIDISOControlSensitivity2_Hi32 = 230000, + kNkMAIDISOControlSensitivity2_Hi33 = 256000, + kNkMAIDISOControlSensitivity2_Hi35 = 288000, + kNkMAIDISOControlSensitivity2_Hi37 = 324000, + kNkMAIDISOControlSensitivity2_Hi38 = 364000, + kNkMAIDISOControlSensitivity2_Hi40 = 409600 + } + + public enum eNkMAIDISOControlSensitivity3 : int + { + kNkMAIDISOControlSensitivity3_Lo10 = 32, + kNkMAIDISOControlSensitivity3_Lo07 = 40, + kNkMAIDISOControlSensitivity3_Lo05 = 45, + kNkMAIDISOControlSensitivity3_Lo03 = 56, + kNkMAIDISOControlSensitivity3_ISO64 = 64, + kNkMAIDISOControlSensitivity3_ISO72 = 72, + kNkMAIDISOControlSensitivity3_ISO80 = 80, + kNkMAIDISOControlSensitivity3_ISO100 = 100, + kNkMAIDISOControlSensitivity3_ISO110 = 110, + kNkMAIDISOControlSensitivity3_ISO125 = 125, + kNkMAIDISOControlSensitivity3_ISO140 = 140, + kNkMAIDISOControlSensitivity3_ISO160 = 160, + kNkMAIDISOControlSensitivity3_ISO180 = 180, + kNkMAIDISOControlSensitivity3_ISO200 = 200, + kNkMAIDISOControlSensitivity3_ISO220 = 220, + kNkMAIDISOControlSensitivity3_ISO250 = 250, + kNkMAIDISOControlSensitivity3_ISO280 = 280, + kNkMAIDISOControlSensitivity3_ISO320 = 320, + kNkMAIDISOControlSensitivity3_ISO360 = 360, + kNkMAIDISOControlSensitivity3_ISO400 = 400, + kNkMAIDISOControlSensitivity3_ISO450 = 450, + kNkMAIDISOControlSensitivity3_ISO500 = 500, + kNkMAIDISOControlSensitivity3_ISO560 = 560, + kNkMAIDISOControlSensitivity3_ISO640 = 640, + kNkMAIDISOControlSensitivity3_ISO720 = 720, + kNkMAIDISOControlSensitivity3_ISO800 = 800, + kNkMAIDISOControlSensitivity3_ISO900 = 900, + kNkMAIDISOControlSensitivity3_ISO1000 = 1000, + kNkMAIDISOControlSensitivity3_ISO1100 = 1100, + kNkMAIDISOControlSensitivity3_ISO1250 = 1250, + kNkMAIDISOControlSensitivity3_ISO1400 = 1400, + kNkMAIDISOControlSensitivity3_ISO1600 = 1600, + kNkMAIDISOControlSensitivity3_ISO1800 = 1800, + kNkMAIDISOControlSensitivity3_ISO2000 = 2000, + kNkMAIDISOControlSensitivity3_ISO2200 = 2200, + kNkMAIDISOControlSensitivity3_ISO2500 = 2500, + kNkMAIDISOControlSensitivity3_ISO2800 = 2800, + kNkMAIDISOControlSensitivity3_ISO3200 = 3200, + kNkMAIDISOControlSensitivity3_ISO3600 = 3600, + kNkMAIDISOControlSensitivity3_ISO4000 = 4000, + kNkMAIDISOControlSensitivity3_ISO4500 = 4500, + kNkMAIDISOControlSensitivity3_ISO5000 = 5000, + kNkMAIDISOControlSensitivity3_ISO5600 = 5600, + kNkMAIDISOControlSensitivity3_ISO6400 = 6400, + kNkMAIDISOControlSensitivity3_ISO7200 = 7200, + kNkMAIDISOControlSensitivity3_ISO8000 = 8000, + kNkMAIDISOControlSensitivity3_ISO9000 = 9000, + kNkMAIDISOControlSensitivity3_ISO10000 = 10000, + kNkMAIDISOControlSensitivity3_ISO11000 = 11000, + kNkMAIDISOControlSensitivity3_ISO12800 = 12800, + kNkMAIDISOControlSensitivity3_Hi02 = 14400, + kNkMAIDISOControlSensitivity3_Hi03 = 16000, + kNkMAIDISOControlSensitivity3_Hi05 = 18000, + kNkMAIDISOControlSensitivity3_Hi07 = 20000, + kNkMAIDISOControlSensitivity3_Hi08 = 22000, + kNkMAIDISOControlSensitivity3_Hi10 = 25600, + kNkMAIDISOControlSensitivity3_Hi12 = 28800, + kNkMAIDISOControlSensitivity3_Hi13 = 32000, + kNkMAIDISOControlSensitivity3_Hi15 = 36000, + kNkMAIDISOControlSensitivity3_Hi17 = 40000, + kNkMAIDISOControlSensitivity3_Hi18 = 45600, + kNkMAIDISOControlSensitivity3_Hi20 = 51200 + } + + public enum eNkMAIDISOControlSensitivity4 : int + { + kNkMAIDISOControlSensitivity4_Lo10 = 100, + kNkMAIDISOControlSensitivity4_Lo08 = 110, + kNkMAIDISOControlSensitivity4_Lo07 = 125, + kNkMAIDISOControlSensitivity4_Lo05 = 140, + kNkMAIDISOControlSensitivity4_Lo03 = 160, + kNkMAIDISOControlSensitivity4_Lo02 = 180, + kNkMAIDISOControlSensitivity4_ISO200 = 200, + kNkMAIDISOControlSensitivity4_ISO220 = 220, + kNkMAIDISOControlSensitivity4_ISO250 = 250, + kNkMAIDISOControlSensitivity4_ISO280 = 280, + kNkMAIDISOControlSensitivity4_ISO320 = 320, + kNkMAIDISOControlSensitivity4_ISO360 = 360, + kNkMAIDISOControlSensitivity4_ISO400 = 400, + kNkMAIDISOControlSensitivity4_ISO450 = 450, + kNkMAIDISOControlSensitivity4_ISO500 = 500, + kNkMAIDISOControlSensitivity4_ISO560 = 560, + kNkMAIDISOControlSensitivity4_ISO640 = 640, + kNkMAIDISOControlSensitivity4_ISO720 = 720, + kNkMAIDISOControlSensitivity4_ISO800 = 800, + kNkMAIDISOControlSensitivity4_ISO900 = 900, + kNkMAIDISOControlSensitivity4_ISO1000 = 1000, + kNkMAIDISOControlSensitivity4_ISO1100 = 1100, + kNkMAIDISOControlSensitivity4_ISO1250 = 1250, + kNkMAIDISOControlSensitivity4_ISO1400 = 1400, + kNkMAIDISOControlSensitivity4_ISO1600 = 1600, + kNkMAIDISOControlSensitivity4_ISO1800 = 1800, + kNkMAIDISOControlSensitivity4_ISO2000 = 2000, + kNkMAIDISOControlSensitivity4_ISO2200 = 2200, + kNkMAIDISOControlSensitivity4_ISO2500 = 2500, + kNkMAIDISOControlSensitivity4_ISO2800 = 2800, + kNkMAIDISOControlSensitivity4_ISO3200 = 3200, + kNkMAIDISOControlSensitivity4_ISO3600 = 3600, + kNkMAIDISOControlSensitivity4_ISO4000 = 4000, + kNkMAIDISOControlSensitivity4_ISO4500 = 4500, + kNkMAIDISOControlSensitivity4_ISO5000 = 5000, + kNkMAIDISOControlSensitivity4_ISO5600 = 5600, + kNkMAIDISOControlSensitivity4_ISO6400 = 6400, + kNkMAIDISOControlSensitivity4_ISO7200 = 7200, + kNkMAIDISOControlSensitivity4_ISO8000 = 8000, + kNkMAIDISOControlSensitivity4_ISO9000 = 9000, + kNkMAIDISOControlSensitivity4_ISO10000 = 10000, + kNkMAIDISOControlSensitivity4_ISO11000 = 11000, + kNkMAIDISOControlSensitivity4_ISO12800 = 12800, + kNkMAIDISOControlSensitivity4_Hi02 = 14400, + kNkMAIDISOControlSensitivity4_Hi03 = 16000, + kNkMAIDISOControlSensitivity4_Hi05 = 18000, + kNkMAIDISOControlSensitivity4_Hi07 = 20000, + kNkMAIDISOControlSensitivity4_Hi08 = 22000, + kNkMAIDISOControlSensitivity4_Hi10 = 25600, + kNkMAIDISOControlSensitivity4_Hi12 = 28800, + kNkMAIDISOControlSensitivity4_Hi13 = 32000, + kNkMAIDISOControlSensitivity4_Hi15 = 36000, + kNkMAIDISOControlSensitivity4_Hi17 = 40000, + kNkMAIDISOControlSensitivity4_Hi18 = 45600, + kNkMAIDISOControlSensitivity4_Hi20 = 51200 + } + + public enum eNkMAIDISOControlSensitivity5 : int + { + kNkMAIDISOControlSensitivity5_Lo10 = 50, + kNkMAIDISOControlSensitivity5_Lo08 = 56, + kNkMAIDISOControlSensitivity5_Lo07 = 64, + kNkMAIDISOControlSensitivity5_Lo05 = 72, + kNkMAIDISOControlSensitivity5_Lo03 = 80, + kNkMAIDISOControlSensitivity5_Lo02 = 90, + kNkMAIDISOControlSensitivity5_ISO100 = 100, + kNkMAIDISOControlSensitivity5_ISO110 = 110, + kNkMAIDISOControlSensitivity5_ISO125 = 125, + kNkMAIDISOControlSensitivity5_ISO140 = 140, + kNkMAIDISOControlSensitivity5_ISO160 = 160, + kNkMAIDISOControlSensitivity5_ISO180 = 180, + kNkMAIDISOControlSensitivity5_ISO200 = 200, + kNkMAIDISOControlSensitivity5_ISO220 = 220, + kNkMAIDISOControlSensitivity5_ISO250 = 250, + kNkMAIDISOControlSensitivity5_ISO280 = 280, + kNkMAIDISOControlSensitivity5_ISO320 = 320, + kNkMAIDISOControlSensitivity5_ISO360 = 360, + kNkMAIDISOControlSensitivity5_ISO400 = 400, + kNkMAIDISOControlSensitivity5_ISO450 = 450, + kNkMAIDISOControlSensitivity5_ISO500 = 500, + kNkMAIDISOControlSensitivity5_ISO560 = 560, + kNkMAIDISOControlSensitivity5_ISO640 = 640, + kNkMAIDISOControlSensitivity5_ISO720 = 720, + kNkMAIDISOControlSensitivity5_ISO800 = 800, + kNkMAIDISOControlSensitivity5_ISO900 = 900, + kNkMAIDISOControlSensitivity5_ISO1000 = 1000, + kNkMAIDISOControlSensitivity5_ISO1100 = 1100, + kNkMAIDISOControlSensitivity5_ISO1250 = 1250, + kNkMAIDISOControlSensitivity5_ISO1400 = 1400, + kNkMAIDISOControlSensitivity5_ISO1600 = 1600, + kNkMAIDISOControlSensitivity5_ISO1800 = 1800, + kNkMAIDISOControlSensitivity5_ISO2000 = 2000, + kNkMAIDISOControlSensitivity5_ISO2200 = 2200, + kNkMAIDISOControlSensitivity5_ISO2500 = 2500, + kNkMAIDISOControlSensitivity5_ISO2800 = 2800, + kNkMAIDISOControlSensitivity5_ISO3200 = 3200, + kNkMAIDISOControlSensitivity5_ISO3600 = 3600, + kNkMAIDISOControlSensitivity5_ISO4000 = 4000, + kNkMAIDISOControlSensitivity5_ISO4500 = 4500, + kNkMAIDISOControlSensitivity5_ISO5000 = 5000, + kNkMAIDISOControlSensitivity5_ISO5600 = 5600, + kNkMAIDISOControlSensitivity5_ISO6400 = 6400, + kNkMAIDISOControlSensitivity5_ISO7200 = 7200, + kNkMAIDISOControlSensitivity5_ISO8000 = 8000, + kNkMAIDISOControlSensitivity5_ISO9000 = 9000, + kNkMAIDISOControlSensitivity5_ISO10000 = 10000, + kNkMAIDISOControlSensitivity5_ISO11000 = 11000, + kNkMAIDISOControlSensitivity5_ISO12800 = 12800, + kNkMAIDISOControlSensitivity5_ISO14400 = 14400, + kNkMAIDISOControlSensitivity5_ISO16000 = 16000, + kNkMAIDISOControlSensitivity5_ISO18000 = 18000, + kNkMAIDISOControlSensitivity5_ISO20000 = 20000, + kNkMAIDISOControlSensitivity5_ISO22000 = 22000, + kNkMAIDISOControlSensitivity5_ISO25600 = 25600, + kNkMAIDISOControlSensitivity5_ISO28800 = 28800, + kNkMAIDISOControlSensitivity5_ISO32000 = 32000, + kNkMAIDISOControlSensitivity5_ISO36000 = 36000, + kNkMAIDISOControlSensitivity5_ISO40000 = 40000, + kNkMAIDISOControlSensitivity5_ISO45600 = 45600, + kNkMAIDISOControlSensitivity5_ISO51200 = 51200, + kNkMAIDISOControlSensitivity5_ISO57600 = 57600, + kNkMAIDISOControlSensitivity5_ISO64000 = 64000, + kNkMAIDISOControlSensitivity5_ISO72000 = 72000, + kNkMAIDISOControlSensitivity5_ISO81200 = 81200, + kNkMAIDISOControlSensitivity5_ISO91200 = 91200, + kNkMAIDISOControlSensitivity5_ISO102400 = 102400, + kNkMAIDISOControlSensitivity5_Hi02 = 115000, + kNkMAIDISOControlSensitivity5_Hi03 = 128000, + kNkMAIDISOControlSensitivity5_Hi05 = 144000, + kNkMAIDISOControlSensitivity5_Hi07 = 162000, + kNkMAIDISOControlSensitivity5_Hi08 = 182000, + kNkMAIDISOControlSensitivity5_Hi10 = 204800, + kNkMAIDISOControlSensitivity5_Hi12 = 230000, + kNkMAIDISOControlSensitivity5_Hi13 = 256000, + kNkMAIDISOControlSensitivity5_Hi15 = 288000, + kNkMAIDISOControlSensitivity5_Hi17 = 324000, + kNkMAIDISOControlSensitivity5_Hi18 = 364000, + kNkMAIDISOControlSensitivity5_Hi20 = 409600, + kNkMAIDISOControlSensitivity5_Hi22 = 460000, + kNkMAIDISOControlSensitivity5_Hi23 = 512000, + kNkMAIDISOControlSensitivity5_Hi25 = 576000, + kNkMAIDISOControlSensitivity5_Hi27 = 648000, + kNkMAIDISOControlSensitivity5_Hi28 = 728000, + kNkMAIDISOControlSensitivity5_Hi30 = 820000, + kNkMAIDISOControlSensitivity5_Hi32 = 920000, + kNkMAIDISOControlSensitivity5_Hi33 = 1030000, + kNkMAIDISOControlSensitivity5_Hi35 = 1160000, + kNkMAIDISOControlSensitivity5_Hi37 = 1300000, + kNkMAIDISOControlSensitivity5_Hi38 = 1460000, + kNkMAIDISOControlSensitivity5_Hi40 = 1640000, + kNkMAIDISOControlSensitivity5_Hi42 = 1840000, + kNkMAIDISOControlSensitivity5_Hi43 = 2060000, + kNkMAIDISOControlSensitivity5_Hi45 = 2320000, + kNkMAIDISOControlSensitivity5_Hi47 = 2600000, + kNkMAIDISOControlSensitivity5_Hi48 = 2920000, + kNkMAIDISOControlSensitivity5_Hi50 = 3280000 + } + + public enum eNkMAIDISOControlSensitivity6 : int + { + kNkMAIDISOControlSensitivity6_Lo10 = 50, + kNkMAIDISOControlSensitivity6_Lo08 = 56, + kNkMAIDISOControlSensitivity6_Lo07 = 64, + kNkMAIDISOControlSensitivity6_Lo05 = 72, + kNkMAIDISOControlSensitivity6_Lo03 = 80, + kNkMAIDISOControlSensitivity6_Lo02 = 90, + kNkMAIDISOControlSensitivity6_ISO100 = 100, + kNkMAIDISOControlSensitivity6_ISO110 = 110, + kNkMAIDISOControlSensitivity6_ISO125 = 125, + kNkMAIDISOControlSensitivity6_ISO140 = 140, + kNkMAIDISOControlSensitivity6_ISO160 = 160, + kNkMAIDISOControlSensitivity6_ISO180 = 180, + kNkMAIDISOControlSensitivity6_ISO200 = 200, + kNkMAIDISOControlSensitivity6_ISO220 = 220, + kNkMAIDISOControlSensitivity6_ISO250 = 250, + kNkMAIDISOControlSensitivity6_ISO280 = 280, + kNkMAIDISOControlSensitivity6_ISO320 = 320, + kNkMAIDISOControlSensitivity6_ISO360 = 360, + kNkMAIDISOControlSensitivity6_ISO400 = 400, + kNkMAIDISOControlSensitivity6_ISO450 = 450, + kNkMAIDISOControlSensitivity6_ISO500 = 500, + kNkMAIDISOControlSensitivity6_ISO560 = 560, + kNkMAIDISOControlSensitivity6_ISO640 = 640, + kNkMAIDISOControlSensitivity6_ISO720 = 720, + kNkMAIDISOControlSensitivity6_ISO800 = 800, + kNkMAIDISOControlSensitivity6_ISO900 = 900, + kNkMAIDISOControlSensitivity6_ISO1000 = 1000, + kNkMAIDISOControlSensitivity6_ISO1100 = 1100, + kNkMAIDISOControlSensitivity6_ISO1250 = 1250, + kNkMAIDISOControlSensitivity6_ISO1400 = 1400, + kNkMAIDISOControlSensitivity6_ISO1600 = 1600, + kNkMAIDISOControlSensitivity6_ISO1800 = 1800, + kNkMAIDISOControlSensitivity6_ISO2000 = 2000, + kNkMAIDISOControlSensitivity6_ISO2200 = 2200, + kNkMAIDISOControlSensitivity6_ISO2500 = 2500, + kNkMAIDISOControlSensitivity6_ISO2800 = 2800, + kNkMAIDISOControlSensitivity6_ISO3200 = 3200, + kNkMAIDISOControlSensitivity6_ISO3600 = 3600, + kNkMAIDISOControlSensitivity6_ISO4000 = 4000, + kNkMAIDISOControlSensitivity6_ISO4500 = 4500, + kNkMAIDISOControlSensitivity6_ISO5000 = 5000, + kNkMAIDISOControlSensitivity6_ISO5600 = 5600, + kNkMAIDISOControlSensitivity6_ISO6400 = 6400, + kNkMAIDISOControlSensitivity6_ISO7200 = 7200, + kNkMAIDISOControlSensitivity6_ISO8000 = 8000, + kNkMAIDISOControlSensitivity6_ISO9000 = 9000, + kNkMAIDISOControlSensitivity6_ISO10000 = 10000, + kNkMAIDISOControlSensitivity6_ISO11000 = 11000, + kNkMAIDISOControlSensitivity6_ISO12800 = 12800, + kNkMAIDISOControlSensitivity6_ISO14400 = 14400, + kNkMAIDISOControlSensitivity6_ISO16000 = 16000, + kNkMAIDISOControlSensitivity6_ISO18000 = 18000, + kNkMAIDISOControlSensitivity6_ISO20000 = 20000, + kNkMAIDISOControlSensitivity6_ISO22000 = 22000, + kNkMAIDISOControlSensitivity6_ISO25600 = 25600, + kNkMAIDISOControlSensitivity6_ISO28800 = 28800, + kNkMAIDISOControlSensitivity6_ISO32000 = 32000, + kNkMAIDISOControlSensitivity6_ISO36000 = 36000, + kNkMAIDISOControlSensitivity6_ISO40000 = 40000, + kNkMAIDISOControlSensitivity6_ISO45600 = 45600, + kNkMAIDISOControlSensitivity6_ISO51200 = 51200, + kNkMAIDISOControlSensitivity6_ISO57600 = 57600, + kNkMAIDISOControlSensitivity6_ISO64000 = 64000, + kNkMAIDISOControlSensitivity6_ISO72000 = 72000, + kNkMAIDISOControlSensitivity6_ISO81200 = 81200, + kNkMAIDISOControlSensitivity6_ISO91200 = 91200, + kNkMAIDISOControlSensitivity6_ISO102400 = 102400, + kNkMAIDISOControlSensitivity6_Hi12 = 115000, + kNkMAIDISOControlSensitivity6_Hi13 = 128000, + kNkMAIDISOControlSensitivity6_Hi15 = 144000, + kNkMAIDISOControlSensitivity6_Hi17 = 162000, + kNkMAIDISOControlSensitivity6_Hi18 = 182000, + kNkMAIDISOControlSensitivity6_Hi22 = 230000, + kNkMAIDISOControlSensitivity6_Hi23 = 256000, + kNkMAIDISOControlSensitivity6_Hi25 = 288000, + kNkMAIDISOControlSensitivity6_Hi27 = 324000, + kNkMAIDISOControlSensitivity6_Hi28 = 364000, + kNkMAIDISOControlSensitivity6_Hi30 = 409600, + kNkMAIDISOControlSensitivity6_Hi32 = 460000, + kNkMAIDISOControlSensitivity6_Hi33 = 512000, + kNkMAIDISOControlSensitivity6_Hi35 = 576000, + kNkMAIDISOControlSensitivity6_Hi37 = 648000, + kNkMAIDISOControlSensitivity6_Hi38 = 728000, + kNkMAIDISOControlSensitivity6_Hi40 = 820000, + kNkMAIDISOControlSensitivity6_Hi42 = 920000, + kNkMAIDISOControlSensitivity6_Hi43 = 1030000, + kNkMAIDISOControlSensitivity6_Hi45 = 1160000, + kNkMAIDISOControlSensitivity6_Hi47 = 1300000, + kNkMAIDISOControlSensitivity6_Hi48 = 1460000, + kNkMAIDISOControlSensitivity6_Hi50 = 1640000 + } + + public enum eNkMAIDJpegCompressionPolicy : int + { + kNkMAIDJpegCompressionPolicy_Size = 0, + kNkMAIDJpegCompressionPolicy_Quality = 1 + } + + public enum eNkMAIDLensType : int + { + kNkMAIDLensType_D = 1, // D type + kNkMAIDLensType_G = 16, // G type + kNkMAIDLensType_E = 32, // E type + kNkMAIDLensType_STM = 64, // STM + kNkMAIDLensType_VR = 256, // VR + kNkMAIDLensType_DX = 4096, // DX + kNkMAIDLensType_AFS = 65536, // AF-S lens + kNkMAIDLensType_AD = 1048576, // Auto Distortion + kNkMAIDLensType_RET = 16777216 // Retractable lens + } + + public enum eNkMAIDLensTypeNikon1 : int + { + kNkMAIDLensTypeNikon1_MountAdapter = 1, // (bit:0) Mount adapter + kNkMAIDLensTypeNikon1_ShrinkLens = 256, // (bit:8) Power retractable lens + kNkMAIDLensTypeNikon1_PowerZoom = 512, // (bit:9) Power zoom lens + kNkMAIDLensTypeNikon1_VR = 536870912 // (bit:29)Anti-vibration mechanism + } + + public enum eNkMAIDLimitAFAreaMode : int + { + kNkMAIDLimitAFAreaMode_Dynamic9 = 2, // Bit1:Dynamic AF mode (9 points) + kNkMAIDLimitAFAreaMode_Dynamic21 = 4, // Bit2:Dynamic AF mode (21 points) + kNkMAIDLimitAFAreaMode_Dynamic51 = 16, // Bit4:Dynamic AF mode (51 points) + kNkMAIDLimitAFAreaMode_3DTtracking = 32, // Bit5:3D-tracking + kNkMAIDLimitAFAreaMode_Group = 64, // Bit6:Group-area AF mode + kNkMAIDLimitAFAreaMode_Auto = 128 // Bit7:Auto-area AF mode + } + + public enum eNkMAIDLimitAFAreaMode2 : int + { + kNkMAIDLimitAFAreaMode2_Dynamic25 = 2, // Bit1:Dynamic AF mode (25 points) + kNkMAIDLimitAFAreaMode2_Dynamic72 = 4, // Bit2:Dynamic AF mode (72 points) + kNkMAIDLimitAFAreaMode2_Dynamic153 = 16, // Bit4:Dynamic AF mode (153 points) + kNkMAIDLimitAFAreaMode2_3DTtracking = 32, // Bit5:3D-tracking + kNkMAIDLimitAFAreaMode2_Group = 64, // Bit6:Group-area AF mode + kNkMAIDLimitAFAreaMode2_Auto = 128 // Bit7:Auto-area AF mode + } + + public enum eNkMAIDLiveViewAF : int + { + kNkMAIDLiveViewAF_Face = 0, // Face detection system AF + kNkMAIDLiveViewAF_Wide = 1, // Wide area AF + kNkMAIDLiveViewAF_Normal = 2, // Normal area AF + kNkMAIDLiveViewAF_SubjectTracking = 3 // Target tracking AF + } + + public enum eNkMAIDLiveViewDriveMode : int + { + kNkMAIDLiveViewDriveMode_Single = 0, // Single + kNkMAIDLiveViewDriveMode_ContinuousLow = 1, // Continuous low + kNkMAIDLiveViewDriveMode_ContinuousHigh = 2 // Continuous high + } + + public enum eNkMAIDLiveViewExposurePreview : int + { + kNkMAIDLiveViewExposurePreview_Off = 0, + kNkMAIDLiveViewExposurePreview_On = 1 + } + + public enum eNkMAIDLiveViewImageSize : int + { + kNkMAIDLiveViewImageSize_QVGA = 1, + kNkMAIDLiveViewImageSize_VGA = 2, + kNkMAIDLiveViewImageSize_XGA = 3 + } + + public enum eNkMAIDLiveViewImageZoomRate : int + { + kNkMAIDLiveViewImageZoomRate_All = 0, // Entire display + kNkMAIDLiveViewImageZoomRate_25 = 1, // 25�� + kNkMAIDLiveViewImageZoomRate_33 = 2, // 33�� + kNkMAIDLiveViewImageZoomRate_50 = 3, // 50�� + kNkMAIDLiveViewImageZoomRate_66 = 4, // 66.7�� + kNkMAIDLiveViewImageZoomRate_100 = 5, // 100�� + kNkMAIDLiveViewImageZoomRate_200 = 6, // 200�� + kNkMAIDLiveViewImageZoomRate_13 = 7, // 13�� + kNkMAIDLiveViewImageZoomRate_17 = 8 // 17% + } + + public enum eNkMAIDLiveViewMode : int + { + kNkMAIDLiveViewMode_Handheld = 0, // Handheld + kNkMAIDLiveViewMode_Tripod = 1 // Tripod + } + + public enum eNkMAIDLiveViewPhotoShootingMode : int + { + kNkMAIDLiveViewPhotoShootingMode_Quiet = 0, // Quiet shooting(Off) + kNkMAIDLiveViewPhotoShootingMode_Silent = 1 // Silent shooting(On) + } + + public enum eNkMAIDLiveViewProhibit : int + { + kNkMAIDLiveViewProhibit_ExpModeScene = -2147483648, // Bit31:ExposureMode is SCENE. + kNkMAIDLiveViewProhibit_CF = 1, // Bit0:The recording destination is the CF. + kNkMAIDLiveViewProhibit_Sequence = 4, // Bit2:Sequence error + kNkMAIDLiveViewProhibit_Button = 16, // Bit4:Fully pressed button error + kNkMAIDLiveViewProhibit_FEE = 32, // Bit5:The aperture value is being set by the lens aperture ring. + kNkMAIDLiveViewProhibit_Bulb = 64, // Bit6:Bulb error(0: Invalid, 1: Valid) + kNkMAIDLiveViewProhibit_Mirrorup = 128, // Bit7:During cleaning mirror-up operation + kNkMAIDLiveViewProhibit_Battery = 256, // Bit8:During insufficiency of battery(0: Invalid, 1: Valid) + kNkMAIDLiveViewProhibit_TTL = 512, // Bit9:TTL error(0: Invalid, 1: Valid) + kNkMAIDLiveViewProhibit_ApertureRing = 1024, // Bit10:While the aperture value operation by the lens aperture ring is valid + kNkMAIDLiveViewProhibit_NonCPU = 2048, // Bit11:The CPU lens is not mounted and the exposure mode is not M. + kNkMAIDLiveViewProhibit_SdramImg = 4096, // Bit12:There is an image whose recording destination is SDRAM. + kNkMAIDLiveViewProhibit_MirrorMode = 8192, // Bit13:The release mode is [Mirror-up]. + kNkMAIDLiveViewProhibit_NoCardLock = 16384, // Bit14:The recording destination is the card or the card & SDRAM,// and the card is not inserted with the release disabled without a card. + kNkMAIDLiveViewProhibit_Capture = 32768, // Bit15:During processing by the shooting command(*Until the shooting operation ends.) + kNkMAIDLiveViewProhibit_EffectMode = 65536, // Bit16:ExposureMode is EFFECTS. + kNkMAIDLiveViewProhibit_TempRise = 131072, // Bit17:The live view cannot be started when the temperature rises. + kNkMAIDLiveViewProhibit_CardProtect = 262144, // Bit18:Card protected + kNkMAIDLiveViewProhibit_CardError = 524288, // Bit19:Card error + kNkMAIDLiveViewProhibit_CardUnformat = 1048576, // Bit20:Card unformatted + kNkMAIDLiveViewProhibit_BulbWarning = 2097152, // Bit21:During bulb warning. + kNkMAIDLiveViewProhibit_DuringMirrorup = 4194304, // Bit22:Release mode is mirror up and during cleaning mirror-up operation. + kNkMAIDLiveViewProhibit_DuringLiveView = 8388608, + kNkMAIDLiveViewProhibit_Retractable = 16777216, // Bit24:The lens is retracting. + kNkMAIDLiveViewProhibit_RecordingImage = 67108864 // Bit26:During image recording. + } + + public enum eNkMAIDLiveViewScreenDispSetting : int + { + kNkMAIDLiveViewScreenDispSetting_ShowIndicators = 1, + kNkMAIDLiveViewScreenDispSetting_HideIndicators = 2, + kNkMAIDLiveViewScreenDispSetting_FramingGrid = 4, + kNkMAIDLiveViewScreenDispSetting_ShowShootingInfo = 8, + kNkMAIDLiveViewScreenDispSetting_ALL = 15 + } + + public enum eNkMAIDLiveViewSelector : int + { + kNkMAIDLiveViewSelector_Photo = 0, + kNkMAIDLiveViewSelector_Movie = 1 + } + + public enum eNkMAIDLiveViewStatus : int + { + kNkMAIDLiveViewStatus_OFF = 0, + kNkMAIDLiveViewStatus_ON = 1 + } + + public enum eNkMAIDMatrixMetering : int + { + kNkMAIDMatrixMetering_Off = 0, + kNkMAIDMatrixMetering_On = 1 + } + + public enum eNkMAIDMediaType : int + { + kNkMAIDMediaType_CFCard = 0, + kNkMAIDMediaType_1394 = 1 + } + + public enum eNkMAIDMeteringMode : int + { + kNkMAIDMeteringMode_Matrix = 0, + kNkMAIDMeteringMode_CenterWeighted = 1, + kNkMAIDMeteringMode_Spot = 2, + kNkMAIDMeteringMode_AfSpot = 3, + kNkMAIDMeteringMode_HighLight = 4 + } + + public enum eNkMAIDMFDrive : int + { + kNkMAIDMFDrive_InfinityToClosest = 0, // No limit -> Closest + kNkMAIDMFDrive_ClosestToInfinity = 1 // Closest -> No limit + } + + public enum eNkMAIDMirrorUpReleaseShootingCount : int + { + kNkMAIDMirrorUpReleaseShootingCount_0 = 0, + kNkMAIDMirrorUpReleaseShootingCount_1 = 1, + kNkMAIDMirrorUpReleaseShootingCount_2 = 2 + } + + public enum eNkMAIDMirrorUpStatus : int + { + kNkMAIDMirrorUpStatus_Down = 0, + kNkMAIDMirrorUpStatus_Up = 1 + } + + public enum eNkMAIDModuleMode : int + { + kNkMAIDModuleMode_Browser = 0, + kNkMAIDModuleMode_Controller = 1 + } + + public enum eNkMAIDModuleType : int + { + kNkMAIDModuleType_Scanner = 1, + kNkMAIDModuleType_Camera = 2 + } + + public enum eNkMAIDMonochromeFilterEffect : int + { + kNkMAIDMonochromeFilterEffect_NoBorder = 0, + kNkMAIDMonochromeFilterEffect_Yellow = 1, + kNkMAIDMonochromeFilterEffect_Orange = 2, + kNkMAIDMonochromeFilterEffect_Red = 3, + kNkMAIDMonochromeFilterEffect_Green = 4 + } + + public enum eNkMAIDMonochromeSettingType : int + { + kNkMAIDMonochromeSettingType_Standard = 0, + kNkMAIDMonochromeSettingType_Custom = 1 + } + + public enum eNkMAIDMovieActive : int + { + kNkMAIDMovieActive_D_Lighting_Off = 0, // Off + kNkMAIDMovieActive_D_Lighting_Low = 1, // Low + kNkMAIDMovieActive_D_Lighting_Normal = 2, // Normal + kNkMAIDMovieActive_D_Lighting_High = 3, // High + kNkMAIDMovieActive_D_Lighting_ExtraHigh = 4, // Extra high + kNkMAIDMovieActive_D_Lighting_SamePhoto = 5 // Same as photo + } + + public enum eNkMAIDMovieCaptureMode : int + { + kNkMAIDMovieCaptureMode_HD = 0, // Normal Movie + kNkMAIDMovieCaptureMode_SlowMotion = 1 // Slow Motion Movie + } + + public enum eNkMAIDMovieCCDDataMode : int + { + kNkMAIDMovieCCDDataMode_FXFormat = 0, + kNkMAIDMovieCCDDataMode_DXFormat = 1, + kNkMAIDMovieCCDDataMode_13x = 2 + } + + public enum eNkMAIDMovieImageQuality : int + { + kNkMAIDMovieImageQuality_Normal = 0, + kNkMAIDMovieImageQuality_Fine = 1 + } + + public enum eNkMAIDMovieISOAutoHiLimit : int + { + kNkMAIDMovieISOAutoHiLimit_ISO400 = 0, + kNkMAIDMovieISOAutoHiLimit_ISO500 = 1, + kNkMAIDMovieISOAutoHiLimit_ISO560 = 2, + kNkMAIDMovieISOAutoHiLimit_ISO640 = 3, + kNkMAIDMovieISOAutoHiLimit_ISO800 = 4, + kNkMAIDMovieISOAutoHiLimit_ISO1000 = 5, + kNkMAIDMovieISOAutoHiLimit_ISO1100 = 6, + kNkMAIDMovieISOAutoHiLimit_ISO1250 = 7, + kNkMAIDMovieISOAutoHiLimit_ISO1600 = 8, + kNkMAIDMovieISOAutoHiLimit_ISO2000 = 9, + kNkMAIDMovieISOAutoHiLimit_ISO2200 = 10, + kNkMAIDMovieISOAutoHiLimit_ISO2500 = 11, + kNkMAIDMovieISOAutoHiLimit_ISO3200 = 12, + kNkMAIDMovieISOAutoHiLimit_ISO4000 = 13, + kNkMAIDMovieISOAutoHiLimit_ISO4500 = 14, + kNkMAIDMovieISOAutoHiLimit_ISO5000 = 15, + kNkMAIDMovieISOAutoHiLimit_ISO6400 = 16, + kNkMAIDMovieISOAutoHiLimit_ISO8000 = 17, + kNkMAIDMovieISOAutoHiLimit_ISO9000 = 18, + kNkMAIDMovieISOAutoHiLimit_ISO10000 = 19, + kNkMAIDMovieISOAutoHiLimit_ISO12800 = 20, + kNkMAIDMovieISOAutoHiLimit_ISO16000 = 21, + kNkMAIDMovieISOAutoHiLimit_ISO18000 = 22, + kNkMAIDMovieISOAutoHiLimit_ISO20000 = 23, + kNkMAIDMovieISOAutoHiLimit_ISO25600 = 24, + kNkMAIDMovieISOAutoHiLimit_ISOHi03 = 25, + kNkMAIDMovieISOAutoHiLimit_ISOHi05 = 26, + kNkMAIDMovieISOAutoHiLimit_ISOHi07 = 27, + kNkMAIDMovieISOAutoHiLimit_ISOHi10 = 28, + kNkMAIDMovieISOAutoHiLimit_ISOHi20 = 29, + kNkMAIDMovieISOAutoHiLimit_ISOHi30 = 30, + kNkMAIDMovieISOAutoHiLimit_ISOHi40 = 31 + } + + public enum eNkMAIDMovieISOAutoHiLimit2 : int + { + kNkMAIDMovieISOAutoHiLimit2_ISO72 = 0, + kNkMAIDMovieISOAutoHiLimit2_ISO80 = 1, + kNkMAIDMovieISOAutoHiLimit2_ISO100 = 2, + kNkMAIDMovieISOAutoHiLimit2_ISO125 = 3, + kNkMAIDMovieISOAutoHiLimit2_ISO140 = 4, + kNkMAIDMovieISOAutoHiLimit2_ISO160 = 5, + kNkMAIDMovieISOAutoHiLimit2_ISO200 = 6, + kNkMAIDMovieISOAutoHiLimit2_ISO250 = 7, + kNkMAIDMovieISOAutoHiLimit2_ISO280 = 8, + kNkMAIDMovieISOAutoHiLimit2_ISO320 = 9, + kNkMAIDMovieISOAutoHiLimit2_ISO400 = 10, + kNkMAIDMovieISOAutoHiLimit2_ISO500 = 11, + kNkMAIDMovieISOAutoHiLimit2_ISO560 = 12, + kNkMAIDMovieISOAutoHiLimit2_ISO640 = 13, + kNkMAIDMovieISOAutoHiLimit2_ISO800 = 14, + kNkMAIDMovieISOAutoHiLimit2_ISO1000 = 15, + kNkMAIDMovieISOAutoHiLimit2_ISO1100 = 16, + kNkMAIDMovieISOAutoHiLimit2_ISO1250 = 17, + kNkMAIDMovieISOAutoHiLimit2_ISO1600 = 18, + kNkMAIDMovieISOAutoHiLimit2_ISO2000 = 19, + kNkMAIDMovieISOAutoHiLimit2_ISO2200 = 20, + kNkMAIDMovieISOAutoHiLimit2_ISO2500 = 21, + kNkMAIDMovieISOAutoHiLimit2_ISO3200 = 22, + kNkMAIDMovieISOAutoHiLimit2_ISO4000 = 23, + kNkMAIDMovieISOAutoHiLimit2_ISO4500 = 24, + kNkMAIDMovieISOAutoHiLimit2_ISO5000 = 25, + kNkMAIDMovieISOAutoHiLimit2_ISO6400 = 26, + kNkMAIDMovieISOAutoHiLimit2_ISO8000 = 27, + kNkMAIDMovieISOAutoHiLimit2_ISO9000 = 28, + kNkMAIDMovieISOAutoHiLimit2_ISO10000 = 29, + kNkMAIDMovieISOAutoHiLimit2_ISO12800 = 30, + kNkMAIDMovieISOAutoHiLimit2_ISOHi03 = 31, + kNkMAIDMovieISOAutoHiLimit2_ISOHi05 = 32, + kNkMAIDMovieISOAutoHiLimit2_ISOHi07 = 33, + kNkMAIDMovieISOAutoHiLimit2_ISOHi10 = 34, + kNkMAIDMovieISOAutoHiLimit2_ISOHi20 = 35 + } + + public enum eNkMAIDMovieISOAutoHiLimit3 : int + { + kNkMAIDMovieISOAutoHiLimit3_ISO200 = 0, + kNkMAIDMovieISOAutoHiLimit3_ISO250 = 1, + kNkMAIDMovieISOAutoHiLimit3_ISO280 = 2, + kNkMAIDMovieISOAutoHiLimit3_ISO320 = 3, + kNkMAIDMovieISOAutoHiLimit3_ISO400 = 4, + kNkMAIDMovieISOAutoHiLimit3_ISO500 = 5, + kNkMAIDMovieISOAutoHiLimit3_ISO560 = 6, + kNkMAIDMovieISOAutoHiLimit3_ISO640 = 7, + kNkMAIDMovieISOAutoHiLimit3_ISO800 = 8, + kNkMAIDMovieISOAutoHiLimit3_ISO1000 = 9, + kNkMAIDMovieISOAutoHiLimit3_ISO1100 = 10, + kNkMAIDMovieISOAutoHiLimit3_ISO1250 = 11, + kNkMAIDMovieISOAutoHiLimit3_ISO1600 = 12, + kNkMAIDMovieISOAutoHiLimit3_ISO2000 = 13, + kNkMAIDMovieISOAutoHiLimit3_ISO2200 = 14, + kNkMAIDMovieISOAutoHiLimit3_ISO2500 = 15, + kNkMAIDMovieISOAutoHiLimit3_ISO3200 = 16, + kNkMAIDMovieISOAutoHiLimit3_ISO4000 = 17, + kNkMAIDMovieISOAutoHiLimit3_ISO4500 = 18, + kNkMAIDMovieISOAutoHiLimit3_ISO5000 = 19, + kNkMAIDMovieISOAutoHiLimit3_ISO6400 = 20, + kNkMAIDMovieISOAutoHiLimit3_ISO8000 = 21, + kNkMAIDMovieISOAutoHiLimit3_ISO9000 = 22, + kNkMAIDMovieISOAutoHiLimit3_ISO10000 = 23, + kNkMAIDMovieISOAutoHiLimit3_ISO12800 = 24, + kNkMAIDMovieISOAutoHiLimit3_ISOHi03 = 25, + kNkMAIDMovieISOAutoHiLimit3_ISOHi05 = 26, + kNkMAIDMovieISOAutoHiLimit3_ISOHi07 = 27, + kNkMAIDMovieISOAutoHiLimit3_ISOHi10 = 28, + kNkMAIDMovieISOAutoHiLimit3_ISOHi20 = 29, + kNkMAIDMovieISOAutoHiLimit3_ISO16000 = 30, + kNkMAIDMovieISOAutoHiLimit3_ISO18000 = 31, + kNkMAIDMovieISOAutoHiLimit3_ISO20000 = 32, + kNkMAIDMovieISOAutoHiLimit3_ISO25600 = 33, + kNkMAIDMovieISOAutoHiLimit3_ISO32000 = 34, + kNkMAIDMovieISOAutoHiLimit3_ISO36000 = 35, + kNkMAIDMovieISOAutoHiLimit3_ISO40000 = 36, + kNkMAIDMovieISOAutoHiLimit3_ISO51200 = 37, + kNkMAIDMovieISOAutoHiLimit3_ISO64000 = 38, + kNkMAIDMovieISOAutoHiLimit3_ISO72000 = 39, + kNkMAIDMovieISOAutoHiLimit3_ISO81200 = 40, + kNkMAIDMovieISOAutoHiLimit3_ISO102400 = 41, + kNkMAIDMovieISOAutoHiLimit3_ISOHi30 = 42, + kNkMAIDMovieISOAutoHiLimit3_ISOHi40 = 43, + kNkMAIDMovieISOAutoHiLimit3_ISOHi50 = 44 + } + + public enum eNkMAIDMovieISOAutoHiLimit4 : int + { + kNkMAIDMovieISOAutoHiLimit4_ISO400 = 0, + kNkMAIDMovieISOAutoHiLimit4_ISO500 = 1, + kNkMAIDMovieISOAutoHiLimit4_ISO560 = 2, + kNkMAIDMovieISOAutoHiLimit4_ISO640 = 3, + kNkMAIDMovieISOAutoHiLimit4_ISO800 = 4, + kNkMAIDMovieISOAutoHiLimit4_ISO1000 = 5, + kNkMAIDMovieISOAutoHiLimit4_ISO1100 = 6, + kNkMAIDMovieISOAutoHiLimit4_ISO1250 = 7, + kNkMAIDMovieISOAutoHiLimit4_ISO1600 = 8, + kNkMAIDMovieISOAutoHiLimit4_ISO2000 = 9, + kNkMAIDMovieISOAutoHiLimit4_ISO2200 = 10, + kNkMAIDMovieISOAutoHiLimit4_ISO2500 = 11, + kNkMAIDMovieISOAutoHiLimit4_ISO3200 = 12, + kNkMAIDMovieISOAutoHiLimit4_ISO4000 = 13, + kNkMAIDMovieISOAutoHiLimit4_ISO4500 = 14, + kNkMAIDMovieISOAutoHiLimit4_ISO5000 = 15, + kNkMAIDMovieISOAutoHiLimit4_ISO6400 = 16, + kNkMAIDMovieISOAutoHiLimit4_ISO8000 = 17, + kNkMAIDMovieISOAutoHiLimit4_ISO9000 = 18, + kNkMAIDMovieISOAutoHiLimit4_ISO10000 = 19, + kNkMAIDMovieISOAutoHiLimit4_ISO12800 = 20, + kNkMAIDMovieISOAutoHiLimit4_ISOHi03 = 21, + kNkMAIDMovieISOAutoHiLimit4_ISOHi05 = 22, + kNkMAIDMovieISOAutoHiLimit4_ISOHi07 = 23, + kNkMAIDMovieISOAutoHiLimit4_ISOHi10 = 24, + kNkMAIDMovieISOAutoHiLimit4_ISOHi20 = 25 + } + + public enum eNkMAIDMovieISORange : int + { + kNkMAIDMovieISORange_200to12800 = 0, + kNkMAIDMovieISORange_200toHi40 = 1 + } + + public enum eNkMAIDMovieMeteringMode : int + { + kNkMAIDMovieMeteringMode_Matrix = 0, + kNkMAIDMovieMeteringMode_CenterWeighted = 1, + kNkMAIDMovieMeteringMode_HighLight = 2 + } + + public enum eNkMAIDMovieNoiseReductionHighISO : int + { + kNkMAIDMovieNoiseReductionHighISO_Off = 0, + kNkMAIDMovieNoiseReductionHighISO_Normal = 1, + kNkMAIDMovieNoiseReductionHighISO_High = 2, + kNkMAIDMovieNoiseReductionHighISO_Low = 3 + } + + public enum eNkMAIDMoviePictureControl : int + { + kNkMAIDMoviePictureControl_Undefined = 0, // Undefined + kNkMAIDMoviePictureControl_Standard = 1, // Standard + kNkMAIDMoviePictureControl_Neutral = 2, // Neutral + kNkMAIDMoviePictureControl_Vivid = 3, // Vivid + kNkMAIDMoviePictureControl_Monochrome = 4, // Monochrome + kNkMAIDMoviePictureControl_Portrait = 5, // Portrait + kNkMAIDMoviePictureControl_Landscape = 6, // Landscape + kNkMAIDMoviePictureControl_Flat = 7, // Flat + kNkMAIDMoviePictureControl_SamePhoto = 100, // Same as photo + kNkMAIDMoviePictureControl_Option1 = 101, // Option picture control1 + kNkMAIDMoviePictureControl_Option2 = 102, // Option picture control2 + kNkMAIDMoviePictureControl_Option3 = 103, // Option picture control3 + kNkMAIDMoviePictureControl_Option4 = 104, // Option picture control4 + kNkMAIDMoviePictureControl_Custom1 = 201, // Custom picture control1 + kNkMAIDMoviePictureControl_Custom2 = 202, // Custom picture control2 + kNkMAIDMoviePictureControl_Custom3 = 203, // Custom picture control3 + kNkMAIDMoviePictureControl_Custom4 = 204, // Custom picture control4 + kNkMAIDMoviePictureControl_Custom5 = 205, // Custom picture control5 + kNkMAIDMoviePictureControl_Custom6 = 206, // Custom picture control6 + kNkMAIDMoviePictureControl_Custom7 = 207, // Custom picture control7 + kNkMAIDMoviePictureControl_Custom8 = 208, // Custom picture control8 + kNkMAIDMoviePictureControl_Custom9 = 209 // Custom picture control9 + } + + public enum eNkMAIDMovieRecMicrophoneValue : int + { + kNkMAIDMovieRecMicrophoneValue_Off = 0, + kNkMAIDMovieRecMicrophoneValue_1 = 1, + kNkMAIDMovieRecMicrophoneValue_2 = 2, + kNkMAIDMovieRecMicrophoneValue_3 = 3, + kNkMAIDMovieRecMicrophoneValue_4 = 4, + kNkMAIDMovieRecMicrophoneValue_5 = 5, + kNkMAIDMovieRecMicrophoneValue_6 = 6, + kNkMAIDMovieRecMicrophoneValue_7 = 7, + kNkMAIDMovieRecMicrophoneValue_8 = 8, + kNkMAIDMovieRecMicrophoneValue_9 = 9, + kNkMAIDMovieRecMicrophoneValue_10 = 10, + kNkMAIDMovieRecMicrophoneValue_11 = 11, + kNkMAIDMovieRecMicrophoneValue_12 = 12, + kNkMAIDMovieRecMicrophoneValue_13 = 13, + kNkMAIDMovieRecMicrophoneValue_14 = 14, + kNkMAIDMovieRecMicrophoneValue_15 = 15, + kNkMAIDMovieRecMicrophoneValue_16 = 16, + kNkMAIDMovieRecMicrophoneValue_17 = 17, + kNkMAIDMovieRecMicrophoneValue_18 = 18, + kNkMAIDMovieRecMicrophoneValue_19 = 19, + kNkMAIDMovieRecMicrophoneValue_20 = 20 + } + + public enum eNkMAIDMovieRecordingZone : int + { + kNkMAIDMovieRecordingZone_WideRange = 0, + kNkMAIDMovieRecordingZone_VocalRange = 1 + } + + public enum eNkMAIDMovieReleaseButton : int + { + kNkMAIDMovieReleaseButton_Photo = 0, // Take photos + kNkMAIDMovieReleaseButton_Movie = 1, // Record movies + kNkMAIDMovieReleaseButton_SaveFrame = 2 // Live frame grab + } + + public enum eNkMAIDMovieScreenSize : int + { + kNkMAIDMovieScreenSize_QVGA = 0, // QVGA (320x216) + kNkMAIDMovieScreenSize_VGA = 1, // VGA (640x424) + kNkMAIDMovieScreenSize_720p = 2, // 720p (1280x720) + kNkMAIDMovieScreenSize_VGA_Normal = 3, // VGA (640x424):Normal + kNkMAIDMovieScreenSize_VGA_Fine = 4, // VGA (640x424):High image quality + kNkMAIDMovieScreenSize_720p_Normal_Lowfps = 5, // 720p (1280x720):Normal, 24fps + kNkMAIDMovieScreenSize_720p_Fine_Lowfps = 6, // 720p (1280x720):High image quality, 24fps + kNkMAIDMovieScreenSize_VGA_30fps = 7, // VGA (640x424):30fps + kNkMAIDMovieScreenSize_720p_Normal_Highfps = 7, // 720p (1280x720):Normal, 30fps(NTSC)/25fps(PAL) + kNkMAIDMovieScreenSize_VGA_25fps = 8, // VGA (640x424):25fps + kNkMAIDMovieScreenSize_720p_Fine_Highfps = 8, // 720p (1280x720):High image quality, 30fps(NTSC)/25fps(PAL) + kNkMAIDMovieScreenSize_FullHD_Normal = 9, // FullHD (1920x1080):Normal + kNkMAIDMovieScreenSize_FullHD_Fine = 10, // FullHD (1920x1080):High image quality + kNkMAIDMovieScreenSize_FullHD_Normal_Highfps = 11, // FullHD (1920x1080):Normal, 30fps(NTSC)/25fps(PAL) + kNkMAIDMovieScreenSize_FullHD_Fine_Highfps = 12 // FullHD (1920x1080):High image quality, 30fps(NTSC)/25fps(PAL) + } + + public enum eNkMAIDMovieScreenSize2 : int + { + kNkMAIDMovieScreenSize2_FullHD_30fps = 0, // FullHD (1920x1080):30fps + kNkMAIDMovieScreenSize2_FullHD_2 = 1, // FullHD (1920�~1080):30p/25p + kNkMAIDMovieScreenSize2_FullHD_25fps = 1, // FullHD (1920x1080):25fps + kNkMAIDMovieScreenSize2_FullHD_24fps = 2, // FullHD (1920x1080):24fps + kNkMAIDMovieScreenSize2_720p_60fps = 3, // 720p (1280x720):60fps + kNkMAIDMovieScreenSize2_720p_50fps = 4, // 720p (1280x720):50fps + kNkMAIDMovieScreenSize2_720p_30fps = 5, // 720p (1280x720):30fps + kNkMAIDMovieScreenSize2_720p_25fps = 6, // 720p (1280x720):25fps + kNkMAIDMovieScreenSize2_FullHD_30fps_Crop = 9, // FullHD (1920x1080):30fps Crop + kNkMAIDMovieScreenSize2_FullHD_25fps_Crop = 10, // FullHD (1920x1080):25fps Crop + kNkMAIDMovieScreenSize2_FullHD_24fps_Crop = 11 // FullHD (1920x1080):24fps Crop + } + + public enum eNkMAIDMovieScreenSize3 : int + { + kNkMAIDMovieScreenSize3_FullHD_1 = 0, // FullHD (1920�~1080):60i/50i + kNkMAIDMovieScreenSize3_FullHD_3 = 2, // FullHD (1920�~1080):24p/24p + kNkMAIDMovieScreenSize3_720p = 3, // 720p (1280�~720):60p/50p + kNkMAIDMovieScreenSize3_VGA = 4 // VGA (640�~424) :30p/25p + } + + public enum eNkMAIDMovieScreenSize4 : int + { + kNkMAIDMovieScreenSize4_FullHD_60i = 0, // FullHD (1920�~1080):60i + kNkMAIDMovieScreenSize4_FullHD_50i = 1, // FullHD (1920�~1080):50i + kNkMAIDMovieScreenSize4_FullHD_30p = 2, // FullHD (1920�~1080):30p + kNkMAIDMovieScreenSize4_FullHD_25p = 3, // FullHD (1920�~1080):25p + kNkMAIDMovieScreenSize4_FullHD_24p = 4, // FullHD (1920�~1080):24p + kNkMAIDMovieScreenSize4_720p_60p = 5, // 720p (1280�~720):60p + kNkMAIDMovieScreenSize4_720p_50p = 6 // 720p (1280�~720):50p + } + + public enum eNkMAIDMovieScreenSize5 : int + { + kNkMAIDMovieScreenSize5_FullHD_1 = 0, // FullHD (1920�~1080):60p/50p + kNkMAIDMovieScreenSize5_FullHD_2 = 1, // FullHD (1920�~1080):60i/50i + kNkMAIDMovieScreenSize5_FullHD_3 = 2, // FullHD (1920�~1080):30p/25p + kNkMAIDMovieScreenSize5_FullHD_4 = 3, // FullHD (1920�~1080):24p/24p + kNkMAIDMovieScreenSize5_720p = 4, // 720p (1280�~720):60p/50p + kNkMAIDMovieScreenSize5_VGA = 5 // VGA (640�~424) :30p/25p + } + + public enum eNkMAIDMovieScreenSize6 : int + { + kNkMAIDMovieScreenSize6_FullHD_60p = 0, // FullHD (1920�~1080):60p + kNkMAIDMovieScreenSize6_FullHD_50p = 1, // FullHD (1920�~1080):50p + kNkMAIDMovieScreenSize6_FullHD_30p = 2, // FullHD (1920�~1080):30p + kNkMAIDMovieScreenSize6_FullHD_25p = 3, // FullHD (1920�~1080):25p + kNkMAIDMovieScreenSize6_FullHD_24p = 4, // FullHD (1920�~1080):24p + kNkMAIDMovieScreenSize6_720p_60p = 5, // 720p (1280�~720):60p + kNkMAIDMovieScreenSize6_720p_50p = 6, // 720p (1280�~720):50p + kNkMAIDMovieScreenSize6_VGA_30p = 7, // VGA (640�~424) :30p + kNkMAIDMovieScreenSize6_VGA_25p = 8, // VGA (640�~424) :25p + kNkMAIDMovieScreenSize6_FullHD_30p_Crop = 9, // FullHD (1920�~1080):30p Crop + kNkMAIDMovieScreenSize6_FullHD_25p_Crop = 10, // FullHD (1920�~1080):25p Crop + kNkMAIDMovieScreenSize6_FullHD_24p_Crop = 11 // FullHD (1920�~1080):24p Crop + } + + public enum eNkMAIDMovieScreenSize7 : int + { + kNkMAIDMovieScreenSize7_FullHD_60p = 0, + kNkMAIDMovieScreenSize7_FullHD_30p = 1, + kNkMAIDMovieScreenSize7_720p_60p = 2, + kNkMAIDMovieScreenSize7_720p_30p = 3 + } + + public enum eNkMAIDMovieScreenSize8 : int + { + kNkMAIDMovieScreenSize8_QFHD_30p = 0, + kNkMAIDMovieScreenSize8_QFHD_25p = 1, + kNkMAIDMovieScreenSize8_QFHD_24p = 2, + kNkMAIDMovieScreenSize8_FullHD_60p = 3, + kNkMAIDMovieScreenSize8_FullHD_50p = 4, + kNkMAIDMovieScreenSize8_FullHD_30p = 5, + kNkMAIDMovieScreenSize8_FullHD_25p = 6, + kNkMAIDMovieScreenSize8_FullHD_24p = 7, + kNkMAIDMovieScreenSize8_820p_60p = 8, + kNkMAIDMovieScreenSize8_820p_50p = 9, + kNkMAIDMovieScreenSize8_FullHD_60p_Crop = 10, + kNkMAIDMovieScreenSize8_FullHD_50p_Crop = 11, + kNkMAIDMovieScreenSize8_FullHD_30p_Crop = 12, + kNkMAIDMovieScreenSize8_FullHD_25p_Crop = 13, + kNkMAIDMovieScreenSize8_FullHD_24p_Crop = 14 + } + + public enum eNkMAIDMovieVoice : int + { + kNkMAIDMovieVoice_Off = 0, // Off + kNkMAIDMovieVoice_On = 1 // On + } + + public enum eNkMAIDMovieWBPresetProtect1 : int + { + kNkMAIDMovieWBPresetProtect1_Off = 0, + kNkMAIDMovieWBPresetProtect1_On = 1 + } + + public enum eNkMAIDMovieWBPresetProtect2 : int + { + kNkMAIDMovieWBPresetProtect2_Off = 0, + kNkMAIDMovieWBPresetProtect2_On = 1 + } + + public enum eNkMAIDMovieWBPresetProtect3 : int + { + kNkMAIDMovieWBPresetProtect3_Off = 0, + kNkMAIDMovieWBPresetProtect3_On = 1 + } + + public enum eNkMAIDMovieWBPresetProtect4 : int + { + kNkMAIDMovieWBPresetProtect4_Off = 0, + kNkMAIDMovieWBPresetProtect4_On = 1 + } + + public enum eNkMAIDMovieWBPresetProtect5 : int + { + kNkMAIDMovieWBPresetProtect5_Off = 0, + kNkMAIDMovieWBPresetProtect5_On = 1 + } + + public enum eNkMAIDMovieWBPresetProtect6 : int + { + kNkMAIDMovieWBPresetProtect6_Off = 0, + kNkMAIDMovieWBPresetProtect6_On = 1 + } + + public enum eNkMAIDMovieWindNoiseReduction : int + { + kNkMAIDMovieWindNoiseReduction_OFF = 0, + kNkMAIDMovieWindNoiseReduction_ON = 1 + } + + public enum eNkMAIDMovManualSetting : int + { + kNkMAIDMovManualSetting_OFF = 0, + kNkMAIDMovManualSetting_ON = 1 + } + + public enum eNkMAIDMovRecDestination : int + { + kNkMAIDMovRecDestination_CF = 0, + kNkMAIDMovRecDestination_SD = 1, + kNkMAIDMovRecDestination_XQD = 2 + } + + public enum eNkMAIDMovRecDestination2 : int + { + kNkMAIDMovRecDestination2_Slot1 = 0, + kNkMAIDMovRecDestination2_Slot2 = 1 + } + + public enum eNkMAIDMovRecHiISO : int + { + kNkMAIDMovRecHiISO_Off = 0, + kNkMAIDMovRecHiISO_On = 1 + } + + public enum eNkMAIDMovRecInCardProhibit : int + { + kNkMAIDMovRecInCardProhibit_NoCard = 1, // Bit:0 + kNkMAIDMovRecInCardProhibit_CardErr = 2, // Bit:1 + kNkMAIDMovRecInCardProhibit_NoFormat = 4, // Bit:2 + kNkMAIDMovRecInCardProhibit_CardFull = 8, // Bit:3 + kNkMAIDMovRecInCardProhibit_CardInBuf = 128, // Bit:7 + kNkMAIDMovRecInCardProhibit_PCInBuf = 256, // Bit:8 + kNkMAIDMovRecInCardProhibit_MovInBuf = 512, // Bit:9 + kNkMAIDMovRecInCardProhibit_RecMov = 1024, // Bit:10 + kNkMAIDMovRecInCardProhibit_CardProtect = 2048, // Bit:11 + kNkMAIDMovRecInCardProhibit_LVImageZoom = 4096, // Bit:12 + kNkMAIDMovRecInCardProhibit_LVPhoto = 8192 // Bit:13 + } + + public enum eNkMAIDMovRecInCardStatus : int + { + kNkMAIDMovRecInCardStatus_Off = 0, + kNkMAIDMovRecInCardStatus_On = 1 + } + + public enum eNkMAIDMovRecMicrophone : int + { + kNkMAIDMovRecMicrophone_Auto = 0, + kNkMAIDMovRecMicrophone_High = 1, + kNkMAIDMovRecMicrophone_Medium = 2, + kNkMAIDMovRecMicrophone_Low = 3, + kNkMAIDMovRecMicrophone_Off = 4, + kNkMAIDMovRecMicrophone_Manual = 5 + } + + public enum eNkMAIDNegativeScanMode : int + { + kNkMAIDNegativeScanMode_Original = 0, // The original method of Nikon is used. + kNkMAIDNegativeScanMode_NoProcess = 1 + } + + public enum eNkMAIDNoiseReductionHighISO : int + { + kNkMAIDNoiseReductionHighISO_Off = 0, + kNkMAIDNoiseReductionHighISO_Normal = 1, + kNkMAIDNoiseReductionHighISO_High = 2, + kNkMAIDNoiseReductionHighISO_Low = 3 + } + + public enum eNkMAIDObjectType : int + { + kNkMAIDObjectType_Module = 1, + kNkMAIDObjectType_Source = 2, + kNkMAIDObjectType_Item = 3, + kNkMAIDObjectType_DataObj = 4 + } + + public enum eNkMAIDOpticalMultipleFlashChannel : int + { + kNkMAIDOpticalMultipleFlashChannel_1ch = 1, + kNkMAIDOpticalMultipleFlashChannel_2ch = 2, + kNkMAIDOpticalMultipleFlashChannel_3ch = 3, + kNkMAIDOpticalMultipleFlashChannel_4ch = 4 + } + + public enum eNkMAIDOpticalVR : int + { + kNkMAIDOpticalVR_NORMAL = 0, + kNkMAIDOpticalVR_ACTIVE = 1, + kNkMAIDOpticalVR_OFF = 2 + } + + public enum eNkMAIDPictureControl : int + { + kNkMAIDPictureControl_Undefined = 0, // Undefined + kNkMAIDPictureControl_Standard = 1, // Standard + kNkMAIDPictureControl_Neutral = 2, // Neutral + kNkMAIDPictureControl_Vivid = 3, // Vivid + kNkMAIDPictureControl_Monochrome = 4, // Monochrome + kNkMAIDPictureControl_Portrait = 5, // Portrait + kNkMAIDPictureControl_Landscape = 6, // Landscape + kNkMAIDPictureControl_Flat = 7, // Flat + kNkMAIDPictureControl_Option1 = 101, // Option picture control1 + kNkMAIDPictureControl_Option2 = 102, // Option picture control2 + kNkMAIDPictureControl_Option3 = 103, // Option picture control3 + kNkMAIDPictureControl_Option4 = 104, // Option picture control4 + kNkMAIDPictureControl_Custom1 = 201, // Custom picture control1 + kNkMAIDPictureControl_Custom2 = 202, // Custom picture control2 + kNkMAIDPictureControl_Custom3 = 203, // Custom picture control3 + kNkMAIDPictureControl_Custom4 = 204, // Custom picture control4 + kNkMAIDPictureControl_Custom5 = 205, // Custom picture control5 + kNkMAIDPictureControl_Custom6 = 206, // Custom picture control6 + kNkMAIDPictureControl_Custom7 = 207, // Custom picture control7 + kNkMAIDPictureControl_Custom8 = 208, // Custom picture control8 + kNkMAIDPictureControl_Custom9 = 209 // Custom picture control9 + } + + public enum eNkMAIDPrimarySlot : int + { + kNkMAIDPrimarySlot_CF = 0, + kNkMAIDPrimarySlot_SD = 1, + kNkMAIDPrimarySlot_XQD = 2 + } + + public enum eNkMAIDPrimarySlot2 : int + { + kNkMAIDPrimarySlot2_Slot1 = 0, + kNkMAIDPrimarySlot2_Slot2 = 1 + } + + public enum eNkMAIDRadioMultipleFlashChannel : int + { + kNkMAIDRadioMultipleFlashChannel_Unknown = 0, + kNkMAIDRadioMultipleFlashChannel_5ch = 5, + kNkMAIDRadioMultipleFlashChannel_10ch = 10, + kNkMAIDRadioMultipleFlashChannel_15ch = 15 + } + + public enum eNkMAIDRangeFinderSetting : int + { + kNkMAIDRangeFinderSetting_Off = 0, // OFF + kNkMAIDRangeFinderSetting_On = 1 // ON + } + + public enum eNkMAIDRangeFinderStatus : int + { + kNkMAIDRangeFinderStatus_OutOfFocus = 0, // out of focus + kNkMAIDRangeFinderStatus_FrontFocusL = 1, // in front of the subject(large distance) + kNkMAIDRangeFinderStatus_FrontFocusS = 2, // in front of the subject (small distance) + kNkMAIDRangeFinderStatus_InFocus = 3, // In focus + kNkMAIDRangeFinderStatus_RearFocusS = 4, // behind the subject (small distance) + kNkMAIDRangeFinderStatus_RearFocusL = 5 // behind the subject (large distance) + } + + public enum eNkMAIDRawJpegImageStatus : int + { + kNkMAIDRawJpegImageStatus_Single = 0, + kNkMAIDRawJpegImageStatus_RawJpeg = 1 + } + + public enum eNkMAIDRemoteControlMode : int + { + kNkMAIDRemoteControlMode_Delayed = 0, + kNkMAIDRemoteControlMode_QuickResponse = 1, + kNkMAIDRemoteControlMode_MirrorUp = 2, + kNkMAIDRemoteControlMode_Off = 3 + } + + public enum eNkMAIDRemoteTimer : int + { + kNkMAIDRemoteTimer_1min = 0, + kNkMAIDRemoteTimer_5min = 1, + kNkMAIDRemoteTimer_10min = 2, + kNkMAIDRemoteTimer_15min = 3 + } + + public enum eNkMAIDResult : int + { + kNkMAIDResult_NotSupported = -127, + kNkMAIDResult_UnexpectedDataType = -126, + kNkMAIDResult_ValueOutOfBounds = -125, + kNkMAIDResult_BufferSize = -124, + kNkMAIDResult_Aborted = -123, + kNkMAIDResult_NoMedia = -122, + kNkMAIDResult_NoEventProc = -121, + kNkMAIDResult_NoDataProc = -120, + kNkMAIDResult_ZombieObject = -119, + kNkMAIDResult_OutOfMemory = -118, + kNkMAIDResult_UnexpectedError = -117, + kNkMAIDResult_HardwareError = -116, + kNkMAIDResult_MissingComponent = -115, + kNkMAIDResult_NoError = 0, // these values are warnings + kNkMAIDResult_Pending = 1, + kNkMAIDResult_OrphanedChildren = 2, + kNkMAIDResult_VendorBase = 127, + kNkMAIDResult_ApertureFEE = 128, // = 128 + kNkMAIDResult_BufferNotReady = 129, + kNkMAIDResult_NormalTTL = 130, + kNkMAIDResult_MediaFull = 131, + kNkMAIDResult_InvalidMedia = 132, + kNkMAIDResult_EraseFailure = 133, + kNkMAIDResult_CameraNotFound = 134, + kNkMAIDResult_BatteryDontWork = 135, + kNkMAIDResult_ShutterBulb = 136, + kNkMAIDResult_OutOfFocus = 137, + kNkMAIDResult_Protected = 138, + kNkMAIDResult_FileExists = 139, + kNkMAIDResult_SharingViolation = 140, + kNkMAIDResult_DataTransFailure = 141, + kNkMAIDResult_SessionFailure = 142, + kNkMAIDResult_FileRemoved = 143, + kNkMAIDResult_BusReset = 144, + kNkMAIDResult_NonCPULens = 145, + kNkMAIDResult_ReleaseButtonPressed = 146, + kNkMAIDResult_BatteryExhausted = 147, + kNkMAIDResult_CaptureFailure = 148, + kNkMAIDResult_InvalidString = 149, + kNkMAIDResult_NotInitialized = 150, + kNkMAIDResult_CaptureDisable = 151, + kNkMAIDResult_DeviceBusy = 152, + kNkMAIDResult_CaptureDustFailure = 153, + kNkMAIDResult_ICADown = 154, + kNkMAIDResult_CpxInvalidStatus = 155, + kNkMAIDResult_CpxInternalMemoryFull = 156, + kNkMAIDResult_CpxBatteryLow = 157, + kNkMAIDResult_CpxPlaybackMode = 158, + kNkMAIDResult_NotLiveView = 159, + kNkMAIDResult_MFDriveEnd = 160, + kNkMAIDResult_UnformattedMedia = 161, + kNkMAIDResult_MediaReadOnly = 162, + kNkMAIDResult_DuringUpdate = 163, + kNkMAIDResult_BulbReleaseBusy = 164, + kNkMAIDResult_SilentReleaseBusy = 165, + kNkMAIDResult_MovieFrameReleaseBusy = 166, + kNkMAIDResult_ShutterTime = 167, + kNkMAIDResult_Waiting_2ndRelease = 168, + kNkMAIDResult_MirrorUpCapture_Already_Start = 169, + kNkMAIDResult_High_Temperature = 170, + kNkMAIDResult_InvalidSBAttributeValue = 171, + kNkMAIDResult_CameraModeNotAdjustFnumber = 172, + kNkMAIDResult_AutoFocusFailed = 385, // From Nikon Scan 3.1 + kNkMAIDResult_NoFilm = 386, // From Nikon Scan 3.1 + kNkMAIDResult_NoAction = 639 // From Nikon Scan 3.1 + } + + public enum eNkMAIDReverseState : int + { + kNkMAIDReverseState_None = 0, // It is not reversed. + kNkMAIDReverseState_Horizontal = 1, // It is horizontally reversed. + kNkMAIDReverseState_Vertical = 2, // It is vertically reversed. + kNkMAIDReverseState_Both = 3 // It is horizontally and vertically reversed. + } + + public enum eNkMAIDSaturationSetting : int + { + kNkMAIDSaturationSetting_Normal = 0, + kNkMAIDSaturationSetting_Low = 1, + kNkMAIDSaturationSetting_High = 2, + kNkMAIDSaturationSetting_Auto = 3 + } + + public enum eNkMAIDSaveMedia : int + { + kNkMAIDSaveMedia_Card = 0, + kNkMAIDSaveMedia_SDRAM = 1, + kNkMAIDSaveMedia_Card_SDRAM = 2 + } + + public enum eNkMAIDSBAttribute : int + { + kNkMAIDSBAttribute_ALL = 0, + kNkMAIDSBAttribute_MaxNum = 4, + kNkMAIDSBAttribute_Name = 4097, + kNkMAIDSBAttribute_GroupID = 4098, + kNkMAIDSBAttribute_Status = 4099, + kNkMAIDSBAttribute_TestFlashDisable = 4101 + } + + public enum eNkMAIDSBGroupAttribute : int + { + kNkMAIDSBGroupAttribute_ALL = 0, + kNkMAIDSBGroupAttribute_MaxNum = 9, + kNkMAIDSBGroupAttribute_FlashMode = 16385, + kNkMAIDSBGroupAttribute_FlashCompensation = 16386, + kNkMAIDSBGroupAttribute_FlashRatio = 16387, + kNkMAIDSBGroupAttribute_FlashLevel = 16388, + kNkMAIDSBGroupAttribute_FlashRange = 16389, + kNkMAIDSBGroupAttribute_Repeat = 16390, + kNkMAIDSBGroupAttribute_RepeatCount = 16391, + kNkMAIDSBGroupAttribute_RepeatInterval = 16392, + kNkMAIDSBGroupAttribute_Invalid = 16393 + } + + public enum eNkMAIDSBGroupID : int + { + kNkMAIDSBGroupID_ALL = 0, + kNkMAIDSBGroupID_Master = 1, + kNkMAIDSBGroupID_A = 2, + kNkMAIDSBGroupID_B = 4, + kNkMAIDSBGroupID_C = 8, + kNkMAIDSBGroupID_D = 16, + kNkMAIDSBGroupID_E = 32, + kNkMAIDSBGroupID_F = 64 + } + + public enum eNkMAIDSBHandle : int + { + kNkMAIDSBHandle_ALL = 0 // All Handle + } + + public enum eNkMAIDSBIntegrationFlashReady : int + { + kNkMAIDSBIntegrationFlashReady_NotReady = 0, + kNkMAIDSBIntegrationFlashReady_Ready = 1 + } + + public enum eNkMAIDSBSettingMemberLock : int + { + kNkMAIDSBSettingMemberLock_Off = 0, + kNkMAIDSBSettingMemberLock_On = 1 + } + + public enum eNkMAIDSBUsableGroup : int + { + kNkMAIDSBUsableGroup_Disable = 0 + } + + public enum eNkMAIDSBWirelessMode : int + { + kNkMAIDSBWirelessMode_Off = 0, + kNkMAIDSBWirelessMode_Radio = 1, + kNkMAIDSBWirelessMode_Optical = 2, + kNkMAIDSBWirelessMode_OpticalandRadio = 3 + } + + public enum eNkMAIDSBWirelessMultipleFlashMode : int + { + kNkMAIDSBWirelessMultipleFlashMode_Group = 0, + kNkMAIDSBWirelessMultipleFlashMode_QuickWireless = 1, + kNkMAIDSBWirelessMultipleFlashMode_Repeat = 2 + } + + public enum eNkMAIDSceneMode : int + { + kNkMAIDSceneMode_NightLandscape = 0, // 0: Night landscape + kNkMAIDSceneMode_PartyIndoor = 1, // 1: Party/indoor + kNkMAIDSceneMode_BeachSnow = 2, // 2: Beach/snow + kNkMAIDSceneMode_Sunset = 3, // 3: Sunset + kNkMAIDSceneMode_Duskdawn = 4, // 4: Dusk/dawn + kNkMAIDSceneMode_Petportrait = 5, // 5: Pet portrait + kNkMAIDSceneMode_Candlelight = 6, // 6: Candlelight + kNkMAIDSceneMode_Blossom = 7, // 7: Blossom + kNkMAIDSceneMode_AutumnColors = 8, // 8: Autumn colors + kNkMAIDSceneMode_Food = 9, // 9: Food + kNkMAIDSceneMode_Silhouette = 10, // 10: Silhouette + kNkMAIDSceneMode_Highkey = 11, // 11: High key + kNkMAIDSceneMode_Lowkey = 12, // 12: Low key + kNkMAIDSceneMode_Portrait = 13, // 13: Portrait + kNkMAIDSceneMode_Landscape = 14, // 14: Landscape + kNkMAIDSceneMode_Child = 15, // 15: Child + kNkMAIDSceneMode_Sports = 16, // 16: Sports + kNkMAIDSceneMode_Closeup = 17, // 17: Close up + kNkMAIDSceneMode_NightPortrait = 18 // 18: Night portrait + } + + public enum eNkMAIDScreenTips : int + { + kNkMAIDScreenTips_On = 0, // Guide display ON + kNkMAIDScreenTips_Off = 1 // Guide display OFF + } + + public enum eNkMAIDSelfTimerShootNum : int + { + kNkMAIDSelfTimerShootNum_1 = 0, + kNkMAIDSelfTimerShootNum_2 = 1, + kNkMAIDSelfTimerShootNum_3 = 2, + kNkMAIDSelfTimerShootNum_4 = 3, + kNkMAIDSelfTimerShootNum_5 = 4, + kNkMAIDSelfTimerShootNum_6 = 5, + kNkMAIDSelfTimerShootNum_7 = 6, + kNkMAIDSelfTimerShootNum_8 = 7, + kNkMAIDSelfTimerShootNum_9 = 8 + } + + public enum eNkMAIDShootingMode : int + { + kNkMAIDShootingMode_S = 0, + kNkMAIDShootingMode_C = 1, + kNkMAIDShootingMode_CH = 2, + kNkMAIDShootingMode_SelfTimer = 3, + kNkMAIDShootingMode_MirrorUp = 4, + kNkMAIDShootingMode_RemoteTimer_Instant = 5, + kNkMAIDShootingMode_RemoteTimer_2sec = 6, + kNkMAIDShootingMode_LiveView = 7, + kNkMAIDShootingMode_Quiet = 8, + kNkMAIDShootingMode_RemoteCtrl = 9, + kNkMAIDShootingMode_QuietC = 10, + kNkMAIDShootingMode_Unknown = 255 + } + + public enum eNkMAIDShutterSpeedLockSetting : int + { + kNkMAIDShutterSpeedLockSetting_Off = 0, // Off + kNkMAIDShutterSpeedLockSetting_On = 1 // On + } + + public enum eNkMAIDSilentPhotography : int + { + kNkMAIDSilentPhotography_Off = 0, + kNkMAIDSilentPhotography_On = 1 + } + + public enum eNkMAIDSlot2ImageSaveMode : int + { + kNkMAIDSlot2ImageSaveMode_Overflow = 0, // Overflow + kNkMAIDSlot2ImageSaveMode_Backup = 1, // Backup + kNkMAIDSlot2ImageSaveMode_Jpeg = 2 // RAW primary - JPEG secondary + } + + public enum eNkMAIDSlowMotionMovieRecordScreenSize : int + { + kNkMAIDSlowMotionMovieRecordScreenSize_1280x720_120fps = 0, // 1280x720 Recording120fps Playback 30fps + kNkMAIDSlowMotionMovieRecordScreenSize_768x288_400fps = 1, // 768x288 Recording 400fps Playback 30fps + kNkMAIDSlowMotionMovieRecordScreenSize_416x144_1200fps = 2 // 416x144 Recording 1200fps Playback 30fps + } + + public enum eNkMAIDSlowMotionMovieScreenSize : int + { + kNkMAIDSlowMotionMovieScreenSize_1280x720_120fps = 0, + kNkMAIDSlowMotionMovieScreenSize_768x288_400fps = 1, + kNkMAIDSlowMotionMovieScreenSize_416x144_1200fps = 2 + } + + public enum eNkMAIDSpotWBMode : int + { + kNkMAIDSpotWBMode_OFF = 0, + kNkMAIDSpotWBMode_ON = 1 + } + + public enum eNkMAIDTestFlash : int + { + kNkMAIDTestFlash_Test = 0 + } + + public enum eNkMAIDThumbnailRotate : int + { + kNkMAIDThumbnailRotate_0 = 0, + kNkMAIDThumbnailRotate_90 = 1, + kNkMAIDThumbnailRotate_270 = 2 + } + + public enum eNkMAIDTypicalFlashMode : int + { + kNkMAIDTypicalFlashMode_Auto = 0, + kNkMAIDTypicalFlashMode_ForcedOn = 1, + kNkMAIDTypicalFlashMode_Off = 2, + kNkMAIDTypicalFlashMode_RedEyeReduction = 3, + kNkMAIDTypicalFlashMode_SlowSync = 4 + } + + public enum eNkMAIDUIRequestResult : int + { + kNkMAIDUIRequestResult_None = 0, + kNkMAIDUIRequestResult_Ok = 1, + kNkMAIDUIRequestResult_Cancel = 2, + kNkMAIDUIRequestResult_Yes = 3, + kNkMAIDUIRequestResult_No = 4 + } + + public enum eNkMAIDUIRequestType : int + { + kNkMAIDUIRequestType_Ok = 0, + kNkMAIDUIRequestType_OkCancel = 1, + kNkMAIDUIRequestType_YesNo = 2, + kNkMAIDUIRequestType_YesNoCancel = 3 + } + + public enum eNkMAIDUSBSpeed : int + { + kNkMAIDUSBSpeed_FullSpeed = 0, + kNkMAIDUSBSpeed_HighSpeed = 1, + kNkMAIDUSBSpeed_SuperSpeed = 2 + } + + public enum eNkMAIDUserMode : int + { + kNkMAIDUserMode_NightLandscape = 0, // 0: Night landscape + kNkMAIDUserMode_PartyIndoor = 1, // 1: Party/indoor + kNkMAIDUserMode_BeachSnow = 2, // 2: Beach/snow + kNkMAIDUserMode_Sunset = 3, // 3: Sunset + kNkMAIDUserMode_Duskdawn = 4, // 4: Dusk/dawn + kNkMAIDUserMode_Petportrait = 5, // 5: Pet portrait + kNkMAIDUserMode_Candlelight = 6, // 6: Candlelight + kNkMAIDUserMode_Blossom = 7, // 7: Blossom + kNkMAIDUserMode_AutumnColors = 8, // 8: Autumn colors + kNkMAIDUserMode_Food = 9, // 9: Food + kNkMAIDUserMode_Silhouette = 10, // 10: Silhouette + kNkMAIDUserMode_Highkey = 11, // 11: High key + kNkMAIDUserMode_Lowkey = 12, // 12: Low key + kNkMAIDUserMode_Portrait = 13, // 13: Portrait + kNkMAIDUserMode_Landscape = 14, // 14: Landscape + kNkMAIDUserMode_Child = 15, // 15: Child + kNkMAIDUserMode_Sports = 16, // 16: Sports + kNkMAIDUserMode_Closeup = 17, // 17: Close up + kNkMAIDUserMode_NightPortrait = 18, // 18: Night portrait + kNkMAIDUserMode_Program = 19, // 19: Program auto + kNkMAIDUserMode_SpeedPriority = 20, // 20: Shutter speed priority + kNkMAIDUserMode_AperturePriority = 21, // 21: Aperture priority + kNkMAIDUserMode_Manual = 22, // 22: Manual + kNkMAIDUserMode_Auto = 23, // 23: Auto + kNkMAIDUserMode_FlashOff = 24, // 24: Flash prohibition Auto + kNkMAIDUserMode_NightVision = 25, // 25: Night vision + kNkMAIDUserMode_ColorSketch = 26, // 26: Color sketch + kNkMAIDUserMode_Miniature = 27, // 27: Miniature effect + kNkMAIDUserMode_SelectColor = 28 // 28: Selective color + } + + public enum eNkMAIDVideoMode : int + { + kNkMAIDVideoMode_NTSC = 0, + kNkMAIDVideoMode_PAL = 1 + } + + public enum eNkMAIDVignetteControl : int + { + kNkMAIDVignetteControl_High = 0, // High + kNkMAIDVignetteControl_Normal = 1, // Normal + kNkMAIDVignetteControl_Low = 2, // Low + kNkMAIDVignetteControl_Off = 3 // Off + } + + public enum eNkMAIDWarningDisp : int + { + kNkMAIDWarningDisp_On = 0, + kNkMAIDWarningDisp_Off = 1 + } + + public enum eNkMAIDWBBracketingStep : int + { + kNkMAIDWBBracketingStep_1STEP = 0, + kNkMAIDWBBracketingStep_2STEP = 1, + kNkMAIDWBBracketingStep_3STEP = 2 + } + + public enum eNkMAIDWBPresetProtect1 : int + { + kNkMAIDWBPresetProtect1_Off = 0, + kNkMAIDWBPresetProtect1_On = 1 + } + + public enum eNkMAIDWBPresetProtect2 : int + { + kNkMAIDWBPresetProtect2_Off = 0, + kNkMAIDWBPresetProtect2_On = 1 + } + + public enum eNkMAIDWBPresetProtect3 : int + { + kNkMAIDWBPresetProtect3_Off = 0, + kNkMAIDWBPresetProtect3_On = 1 + } + + public enum eNkMAIDWBPresetProtect4 : int + { + kNkMAIDWBPresetProtect4_Off = 0, + kNkMAIDWBPresetProtect4_On = 1 + } + + public enum eNkMAIDWBPresetProtect5 : int + { + kNkMAIDWBPresetProtect5_Off = 0, + kNkMAIDWBPresetProtect5_On = 1 + } + + public enum eNkMAIDWBPresetProtect6 : int + { + kNkMAIDWBPresetProtect6_Off = 0, + kNkMAIDWBPresetProtect6_On = 1 + } + + public enum eNkMAIDWBTuneColorTemp : int + { + kNkMAIDWBTuneColorTemp_Unknown = 0, + kNkMAIDWBTuneColorTemp_2500 = 2500, + kNkMAIDWBTuneColorTemp_2550 = 2550, + kNkMAIDWBTuneColorTemp_2560 = 2560, + kNkMAIDWBTuneColorTemp_2630 = 2630, + kNkMAIDWBTuneColorTemp_2650 = 2650, + kNkMAIDWBTuneColorTemp_2700 = 2700, + kNkMAIDWBTuneColorTemp_2780 = 2780, + kNkMAIDWBTuneColorTemp_2800 = 2800, + kNkMAIDWBTuneColorTemp_2850 = 2850, + kNkMAIDWBTuneColorTemp_2860 = 2860, + kNkMAIDWBTuneColorTemp_2940 = 2940, + kNkMAIDWBTuneColorTemp_2950 = 2950, + kNkMAIDWBTuneColorTemp_3000 = 3000, + kNkMAIDWBTuneColorTemp_3030 = 3030, + kNkMAIDWBTuneColorTemp_3100 = 3100, + kNkMAIDWBTuneColorTemp_3130 = 3130, + kNkMAIDWBTuneColorTemp_3200 = 3200, + kNkMAIDWBTuneColorTemp_3230 = 3230, + kNkMAIDWBTuneColorTemp_3300 = 3300, + kNkMAIDWBTuneColorTemp_3330 = 3330, + kNkMAIDWBTuneColorTemp_3400 = 3400, + kNkMAIDWBTuneColorTemp_3450 = 3450, + kNkMAIDWBTuneColorTemp_3570 = 3570, + kNkMAIDWBTuneColorTemp_3600 = 3600, + kNkMAIDWBTuneColorTemp_3700 = 3700, + kNkMAIDWBTuneColorTemp_3800 = 3800, + kNkMAIDWBTuneColorTemp_3850 = 3850, + kNkMAIDWBTuneColorTemp_4000 = 4000, + kNkMAIDWBTuneColorTemp_4170 = 4170, + kNkMAIDWBTuneColorTemp_4200 = 4200, + kNkMAIDWBTuneColorTemp_4300 = 4300, + kNkMAIDWBTuneColorTemp_4350 = 4350, + kNkMAIDWBTuneColorTemp_4500 = 4500, + kNkMAIDWBTuneColorTemp_4550 = 4550, + kNkMAIDWBTuneColorTemp_4760 = 4760, + kNkMAIDWBTuneColorTemp_4800 = 4800, + kNkMAIDWBTuneColorTemp_5000 = 5000, + kNkMAIDWBTuneColorTemp_5260 = 5260, + kNkMAIDWBTuneColorTemp_5300 = 5300, + kNkMAIDWBTuneColorTemp_5560 = 5560, + kNkMAIDWBTuneColorTemp_5600 = 5600, + kNkMAIDWBTuneColorTemp_5880 = 5880, + kNkMAIDWBTuneColorTemp_5900 = 5900, + kNkMAIDWBTuneColorTemp_6250 = 6250, + kNkMAIDWBTuneColorTemp_6300 = 6300, + kNkMAIDWBTuneColorTemp_6670 = 6670, + kNkMAIDWBTuneColorTemp_6700 = 6700, + kNkMAIDWBTuneColorTemp_7100 = 7100, + kNkMAIDWBTuneColorTemp_7140 = 7140, + kNkMAIDWBTuneColorTemp_7690 = 7690, + kNkMAIDWBTuneColorTemp_7700 = 7700, + kNkMAIDWBTuneColorTemp_8300 = 8300, + kNkMAIDWBTuneColorTemp_8330 = 8330, + kNkMAIDWBTuneColorTemp_9090 = 9090, + kNkMAIDWBTuneColorTemp_9100 = 9100, + kNkMAIDWBTuneColorTemp_9900 = 9900, + kNkMAIDWBTuneColorTemp_10000 = 10000 + } + + public enum eNkMAIDWirelessCLSEntryMode : int + { + kNkMAIDWirelessCLSEntryMode_Peering = 0, + kNkMAIDWirelessCLSEntryMode_PINCode = 1 + } + + public enum eNkMovieWBAutoType : int + { + kNkMovieWBAutoType_Normal = 0, + kNkMovieWBAutoType_WarmWhite = 1, + kNkMovieWBAutoType_KeepWhite = 2 + } + + public enum eNkMovieWBFluorescentType : int + { + kNkMovieWBFluorescentType_SodiumVapor = 0, + kNkMovieWBFluorescentType_WarmWhite = 1, + kNkMovieWBFluorescentType_White = 2, + kNkMovieWBFluorescentType_CoolWhite = 3, + kNkMovieWBFluorescentType_DayWhite = 4, + kNkMovieWBFluorescentType_Daylight = 5, + kNkMovieWBFluorescentType_HiTempMercuryVapor = 6 + } + + public enum eNkWBAutoType : int + { + kNkWBAutoType_Normal = 0, + kNkWBAutoType_WarmWhite = 1, + kNkWBAutoType_KeepWhite = 2 + } + + public enum eNkWBFluorescentType : int + { + kNkWBFluorescentType_SodiumVapor = 0, + kNkWBFluorescentType_WarmWhite = 1, + kNkWBFluorescentType_White = 2, + kNkWBFluorescentType_CoolWhite = 3, + kNkWBFluorescentType_DayWhite = 4, + kNkWBFluorescentType_Daylight = 5, + kNkWBFluorescentType_HiTempMercuryVapor = 6 + } +} + diff --git a/nikoncswrapper/NikonNativeStructs.cs b/nikoncswrapper/NikonNativeStructs.cs new file mode 100644 index 0000000..b061eb6 --- /dev/null +++ b/nikoncswrapper/NikonNativeStructs.cs @@ -0,0 +1,319 @@ +// +// This work is licensed under a Creative Commons Attribution 3.0 Unported License. +// +// Thomas Dideriksen (thomas@dideriksen.com) +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +namespace Nikon +{ + // Note: This file is auto generated + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDActiveSelectionSelectedPictures + { + public UInt32 ulPicIDNum; + public IntPtr pulSelPicIDs; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDArray + { + public eNkMAIDArrayType ulType; // one of eNkMAIDArrayType + public UInt32 ulElements; // total number of elements + public UInt32 ulDimSize1; // size of first dimention + public UInt32 ulDimSize2; // size of second dimention, zero for 1 dim + public UInt32 ulDimSize3; // size of third dimention, zero for 1 or 2 dim + public UInt16 wPhysicalBytes; // bytes per element + public UInt16 wLogicalBits; // must be <= wPhysicalBytes * 8 + public IntPtr pData; // allocated by the client + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDCallback + { + public IntPtr pProc; + public IntPtr refProc; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDCapInfo + { + public eNkMAIDCapability ulID; // one of eNkMAIDCapability or vendor specified + public eNkMAIDCapType ulType; // one of eNkMAIDCapabilityType + public eNkMAIDCapVisibility ulVisibility; // eNkMAIDCapVisibility bits + public eNkMAIDCapOperation ulOperations; // eNkMAIDCapOperations bits + public fixed byte szDescription[256]; // text describing the capability + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDCMLProfile + { + public eNkMAIDColorSpace ulColorSpace; // one of eNkMAIDColorSpace + public UInt32 ulBits; // Bit depth of the supported image by this profile. + public fixed UInt32 ulReserved[5]; + public NkMAIDString file; // DOS path and filename + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDDataInfo + { + public eNkMAIDDataObjType ulType; // one of eNkMAIDDataObjType + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDDateCounterData + { + public fixed UInt16 wcDate1[9]; // First date + public fixed UInt16 wcDate2[9]; // Second date + public fixed UInt16 wcDate3[9]; // Third date + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDDateTime + { + public UInt16 nYear; // ie 1997, 1998 + public UInt16 nMonth; // 0-11 = Jan-Dec + public UInt16 nDay; // 1-31 + public UInt16 nHour; // 0-23 + public UInt16 nMinute; // 0-59 + public UInt16 nSecond; // 0-59 + public UInt32 nSubsecond; // Module dependent + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDEnum + { + public eNkMAIDArrayType ulType; // one of eNkMAIDArrayType + public UInt32 ulElements; // total number of elements + public UInt32 ulValue; // current index + public UInt32 ulDefault; // default index + public Int16 wPhysicalBytes; // bytes per element + public IntPtr pData; // allocated by the client + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDEventParam + { + public eNkMAIDEvent ulEvent; // one of eNkMAIDEvent + public UInt32 ulElements; // total number of valid params + public fixed UInt32 ulParam[2]; // event parameter + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDFileInfo + { + public NkMAIDDataInfo baseInfo; + public eNkMAIDFileDataType ulFileDataType; // One of eNkMAIDFileDataTypes + public UInt32 ulTotalLength; // total number of bytes to be transferred + public UInt32 ulStart; // index of starting byte (0-based) + public UInt32 ulLength; // number of bytes in this delivery + public UInt32 fDiskFile; // TRUE if the file is delivered on disk + public UInt32 fRemoveObject; // TRUE if the object should be removed + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDGetPicCtrlInfo + { + public UInt32 ulPicCtrlItem; // picture control item + public UInt32 ulSize; // the data sizer of pData + public IntPtr pData; // The pointer to Quick Adjust Param + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDGetSBAttrDesc + { + public UInt32 ulSBHandle; + public UInt32 ulSBAttrID; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDGetSBGroupAttrDesc + { + public UInt32 ulSBGroupID; + public UInt32 ulSBGroupAttrID; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDGetSBHandles + { + public UInt32 ulSBGroupID; + public UInt32 ulNumber; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDGetVideoImage + { + public eNkMAIDArrayType ulType; // one of eNkMAIDArrayType + public UInt32 ulOffset; // Offset + public UInt32 ulReadSize; // size of get data + public UInt32 ulDataSize; // size of "pData" + public IntPtr pData; // allocated by the client + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDImageInfo + { + public NkMAIDDataInfo baseInfo; + public NkMAIDSize szTotalPixels; // total size of image to be transfered + public eNkMAIDColorSpace ulColorSpace; // One of eNkMAIDColorSpace + public NkMAIDRect rData; // Coords of data, (0,0) = top,left + public UInt32 ulRowBytes; // number of bytes per row of pixels + public fixed UInt16 wBits[4]; // number of bits per plane per pixel + public UInt16 wPlane; // Plane of the image being delivered + public UInt32 fRemoveObject; // TRUE if the object should be removed + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDIPTCPresetInfo + { + public UInt32 ulPresetNo; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDLensTypeNikon1 + { + public UInt32 ulLensType1; + public UInt32 ulLensType2; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDObject + { + public eNkMAIDObjectType ulType; // One of eNkMAIDObjectType + public UInt32 ulID; + public IntPtr refClient; + public IntPtr refModule; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDPicCtrlData + { + public UInt32 ulPicCtrlItem; // picture control item + public UInt32 ulSize; // the data sizer of pData + public UInt32 bModifiedFlag; // Flag to set New or current + public IntPtr pData; // The pointer to picture control data + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDPoint + { + public Int32 x; + public Int32 y; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDRange + { + public double lfValue; + public double lfDefault; + public UInt32 ulValueIndex; + public UInt32 ulDefaultIndex; + public double lfLower; + public double lfUpper; + public UInt32 ulSteps; // zero for infinite range, otherwise must be >= 2 + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDRect + { + public Int32 x; // left coordinate + public Int32 y; // top coordinate + public UInt32 w; // width + public UInt32 h; // height + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDSBAttrValue + { + public UInt32 ulSBHandle; + public UInt32 ulSBAttrID; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDSBGroupAttrValue + { + public UInt32 ulSBGroupID; + public UInt32 ulSBGroupAttrID; + public UInt32 ulSize; + public IntPtr pData; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDSize + { + public UInt32 w; + public UInt32 h; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDSoundInfo + { + public NkMAIDDataInfo baseInfo; + public UInt32 ulTotalSamples; // number of full samples to be transferred + public UInt32 fStereo; // TRUE if stereo, FALSE if mono + public UInt32 ulStart; // index of starting sample of data + public UInt32 ulLength; // number of samples of data + public UInt16 wBits; // number of bits per channel + public UInt16 wChannel; // 0 = mono or L+R; 1,2 = left, right + public UInt32 fRemoveObject; // TRUE if the object should be removed + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDString + { + public fixed byte str[256]; // allows a 255 character null terminated string + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDTerminateCapture + { + public UInt32 ulParameter1; // Recognize client + public UInt32 ulParameter2; // The shooting time specified 100msec unit + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDTestFlash + { + public UInt32 ulType; + public UInt32 ulParam; + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDUIRequestInfo + { + public eNkMAIDUIRequestType ulType; // one of eNkMAIDUIReqestType + public eNkMAIDUIRequestResult ulDefault; // default return value � one of eNkMAIDUIRequestResult + public UInt32 fSync; // TRUE if user must respond before returning + public IntPtr lpPrompt; // NULL terminated text to show to user + public IntPtr lpDetail; // NULL terminated text indicating more detail + public IntPtr pObject; // module, source, item, or data object + public IntPtr data; // Pointer to an NkMAIDArray structure + } + + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public unsafe struct NkMAIDWBPresetData + { + public UInt32 ulPresetNumber; // Preset Number + public UInt32 ulPresetGain; // Preset Gain + public UInt32 ulThumbnailSize; // Thumbnail size of pThumbnailData + public UInt32 ulThumbnailRotate; // add for D70 One of eNkMAIDThumbnailRotate + public IntPtr pThumbnailData; // The pointer to Thumbnail Data + } + +} diff --git a/nikoncswrapper/NikonTaskQueue.cs b/nikoncswrapper/NikonTaskQueue.cs new file mode 100644 index 0000000..195c842 --- /dev/null +++ b/nikoncswrapper/NikonTaskQueue.cs @@ -0,0 +1,253 @@ +// +// This work is licensed under a Creative Commons Attribution 3.0 Unported License. +// +// Thomas Dideriksen (thomas@dideriksen.com) +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Reflection; +using System.Diagnostics; +using Timer = System.Timers.Timer; + +namespace Nikon +{ + internal class NikonTaskQueue + { + Queue _tasks; + bool _shuttingDown; + AutoResetEvent _haveTask; + List _taskDoneEvents; + List _timers; + Exception _asyncException; + + internal NikonTaskQueue() + { + _tasks = new Queue(); + _shuttingDown = false; + _haveTask = new AutoResetEvent(false); + _taskDoneEvents = new List(); + _timers = new List(); + _asyncException = null; + } + + public void SchedulePeriodicTask(Delegate d, double interval) + { + Timer timer = new Timer(interval); + timer.AutoReset = true; + timer.Elapsed += (s, e) => + { + // Start asynchronous task every time the timer elapses + BeginInvoke(d); + }; + + lock (_timers) + { + _timers.Add(timer); + } + + timer.Start(); + } + + public void BeginInvoke(Delegate d, params object[] args) + { + // Schedule asynchronous task + + NikonTask task = new NikonTask(d, args); + + EnqueueTask(task); + } + + public object Invoke(Delegate d, params object[] args) + { + // Schedule synchronous task + + AutoResetEvent taskDone = new AutoResetEvent(false); + + lock (_taskDoneEvents) + { + _taskDoneEvents.Add(taskDone); + } + + NikonTask task = new NikonTask(d, args, taskDone); + + EnqueueTask(task); + + taskDone.WaitOne(); + + lock (_taskDoneEvents) + { + _taskDoneEvents.Remove(taskDone); + } + + // If an exception occurred during execution of the + // task (on the worker thread), re-throw it here, on + // the waiting thread. + if (task.Exception != null) + { + throw task.Exception; + } + + return task.Result; + } + + internal Exception AsyncException + { + get { return _asyncException; } + } + + void EnqueueTask(NikonTask task) + { + // Add task to queue + lock (_tasks) + { + _tasks.Enqueue(task); + } + + // Signal the run loop that we have a pending task + _haveTask.Set(); + } + + public void Run() + { + // Enter the run loop + while (!_shuttingDown) + { + // Get next task in queue + NikonTask task = null; + + lock (_tasks) + { + if (_tasks.Count > 0) + { + task = _tasks.Dequeue(); + } + } + + // If we have a task, execute it. Otherwise wait for a new task to arrive + if (task != null) + { + task.Execute(); + + // Store first exceptions caused by an asynchronous task + if (task.Exception != null && !task.IsSynchronous && _asyncException == null) + { + Interlocked.Exchange(ref _asyncException, task.Exception); + } + } + else + { + _haveTask.WaitOne(); + } + } + } + + public void Shutdown() + { + // Set 'shutting down' flag + _shuttingDown = true; + + // Stop all timers + lock (_timers) + { + foreach (Timer timer in _timers) + { + timer.Stop(); + } + } + + // Stop waiting for all synchronous tasks + lock (_taskDoneEvents) + { + foreach (AutoResetEvent taskDone in _taskDoneEvents) + { + taskDone.Set(); + } + } + + // Pretend we have a new task. In case we're waiting for + // tasks, this will force an iteration in the run loop, + // causing it to check the '_shuttingDown' flag. + _haveTask.Set(); + } + } + + internal class NikonTask + { + Delegate _delegate; + object[] _args; + AutoResetEvent _done; + Exception _exception; + object _result; + + internal NikonTask(Delegate d, object[] args) + : this(d, args, null) + { + } + + internal NikonTask(Delegate d, object[] args, AutoResetEvent done) + { + _delegate = d; + _args = args; + _done = done; + _exception = null; + _result = null; + } + + internal bool IsSynchronous + { + get { return _done != null; } + } + + internal Exception Exception + { + get { return _exception; } + } + + internal object Result + { + get { return _result; } + } + + internal void Execute() + { + try + { + _result = _delegate.DynamicInvoke(_args); + } + catch (Exception ex) + { + _exception = FindFirstNonTargetInvocationException(ex); + } + + if (IsSynchronous) + { + // This is a synchronous task. Signal the waiting thread + // that we are done. + Debug.Assert(_done != null); + _done.Set(); + } + } + + Exception FindFirstNonTargetInvocationException(Exception ex) + { + // Note: + // When exceptions are thrown inside a function invoked via + // a DynamicInvoke, the actual exceptions (that contain the + // interesting information about the error) is wrapped inside + // one or more TargetInvocationExceptions. + + Exception result = ex; + + while (result is TargetInvocationException) + { + result = result.InnerException; + } + + return (result == null) ? ex : result; + } + } +} diff --git a/nikoncswrapper/NikonThreading.cs b/nikoncswrapper/NikonThreading.cs new file mode 100644 index 0000000..f762b2b --- /dev/null +++ b/nikoncswrapper/NikonThreading.cs @@ -0,0 +1,189 @@ +// +// This work is licensed under a Creative Commons Attribution 3.0 Unported License. +// +// Thomas Dideriksen (thomas@dideriksen.com) +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Windows.Threading; +using System.Diagnostics; +using Nikon; + +namespace Nikon +{ + internal class NikonWorkerThread + { + Thread _thread; + NikonTaskQueue _queue; + + internal NikonWorkerThread(string name) + { + _queue = new NikonTaskQueue(); + + _thread = new Thread(ThreadFunc); + _thread.Name = name; + _thread.Start(); + } + + internal int ThreadId + { + get { return _thread.ManagedThreadId; } + } + + void ThreadFunc(object o) + { + _queue.Run(); + } + + internal void Shutdown() + { + _queue.Shutdown(); + _queue = null; + + _thread.Join(); + } + + void RethrowAsyncExceptionIfAny() + { + // Note: + // An exception thrown by an asynchronus task is considered + // a fatal event. So once it happens ALL subsequent calls to + // Invoke, BeginInvoke or SchedulePeriodicTask will rethrow the + // asynchronous exception on the calling thread. + if (_queue.AsyncException != null) + { + throw _queue.AsyncException; + } + } + + internal object Invoke(Delegate d, params object[] args) + { + RethrowAsyncExceptionIfAny(); + + return _queue.Invoke(d, args); + } + + internal void BeginInvoke(Delegate d, params object[] args) + { + RethrowAsyncExceptionIfAny(); + + _queue.BeginInvoke(d, args); + } + + internal void SchedulePeriodicTask(Delegate d, double interval) + { + RethrowAsyncExceptionIfAny(); + + _queue.SchedulePeriodicTask(d, interval); + } + } + + internal class NikonScheduler + { + NikonWorkerThread _worker; + NikonWorkerThread _callback; + SynchronizationContext _context; + + internal NikonScheduler() + : this(null) + { + } + + internal NikonScheduler(SynchronizationContext context) + { + _worker = new NikonWorkerThread("NikonScheduler worker thread"); + + _context = context; + + if (_context == null) + { + _callback = new NikonWorkerThread("NikonScheduler callback thread"); + } + } + + internal int WorkerThreadId + { + get { return _worker.ThreadId; } + } + + internal void AddOrRemoveEvent(Action a) + { + if (_context != null) + { + _context.Post(new SendOrPostCallback((o) => + { + a.Invoke(); + }), null); + } + else + { + // Note: + // We add or remove events on the callback thread, since this + // is where events are fired. Also, we use 'BeginInvoke' to avoid + // deadlocks if the user attempts to hook up an event from within + // another event handler (example: Hook up ImageReady from within + // DeviceAdded) + _callback.BeginInvoke(a); + } + } + + internal void Callback(Delegate d, params object[] args) + { + if (_context != null) + { + _context.Post(new SendOrPostCallback((o) => + { + d.DynamicInvoke(args); + }), null); + } + else + { + _callback.BeginInvoke(d, args); + } + } + + internal object Invoke(Delegate d, params object[] args) + { + return _worker.Invoke(d, args); + } + + internal object Invoke(Action a) + { + return Invoke((Delegate)a); + } + + internal void BeginInvoke(Delegate d, params object[] args) + { + _worker.BeginInvoke(d, args); + } + + internal void BeginInvoke(Action a) + { + BeginInvoke((Delegate)a); + } + + internal void SchedulePeriodicTask(Delegate d, double interval) + { + _worker.SchedulePeriodicTask(d, interval); + } + + internal void SchedulePeriodicTask(Action a, double interval) + { + SchedulePeriodicTask((Delegate)a, interval); + } + + internal void Shutdown() + { + _worker.Shutdown(); + + if (_callback != null) + { + _callback.Shutdown(); + } + } + } +} diff --git a/nikoncswrapper/NikonTypes.cs b/nikoncswrapper/NikonTypes.cs new file mode 100644 index 0000000..18079e4 --- /dev/null +++ b/nikoncswrapper/NikonTypes.cs @@ -0,0 +1,267 @@ +// +// This work is licensed under a Creative Commons Attribution 3.0 Unported License. +// +// Thomas Dideriksen (thomas@dideriksen.com) +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Nikon; +using System.Diagnostics; + +namespace Nikon +{ + // + // NikonRange - wrapper for NkMAIDRange + // + public class NikonRange + { + NkMAIDRange _range; + + internal NikonRange(NkMAIDRange range) + { + _range = range; + } + + public NkMAIDRange Range + { + get { return _range; } + } + + public double Min + { + get { return _range.lfLower; } + } + + public double Max + { + get { return _range.lfUpper; } + } + + double Delta + { + get + { + Debug.Assert(_range.ulSteps > 1); + return (Max - Min) / ((double)(_range.ulSteps - 1)); + } + } + + double ValueFromIndex(uint index) + { + return Min + index * Delta; + } + + uint IndexFromValue(double value) + { + if (value < Min || value > Max) + { + throw new NikonException("Value out of range"); + } + + return (uint)Math.Floor((value - Min) / Delta); + } + + public double DefaultValue + { + get + { + if (_range.ulSteps == 0) + { + return _range.lfDefault; + } + else + { + return ValueFromIndex(_range.ulDefaultIndex); + } + } + } + + public double Value + { + get + { + if (_range.ulSteps == 0) + { + return _range.lfValue; + } + else + { + return ValueFromIndex(_range.ulValueIndex); + } + } + + set + { + if (_range.ulSteps == 0) + { + _range.lfValue = value; + } + else + { + _range.ulValueIndex = IndexFromValue(value); + } + } + } + } + + // + // NikonArray - wrapper for NkMAIDArray + // + public class NikonArray + { + NkMAIDArray _array; + byte[] _buffer; + + internal NikonArray(NkMAIDArray a, byte[] buffer) + { + _array = a; + _array.pData = IntPtr.Zero; + _buffer = buffer; + } + + public NkMAIDArray Array + { + get { return _array; } + } + + public byte[] Buffer + { + get { return _buffer; } + } + } + + // + // NikonEnum - wrapper for NkMAIDEnum + // + public class NikonEnum + { + object[] _list; + NkMAIDEnum _enum; + + internal NikonEnum(NkMAIDEnum e, byte[] buffer) + { + _enum = e; + _enum.pData = IntPtr.Zero; + + switch (e.ulType) + { + case eNkMAIDArrayType.kNkMAIDArrayType_PackedString: + _list = GetPackedStringArray(buffer); + break; + + case eNkMAIDArrayType.kNkMAIDArrayType_Unsigned: + _list = GetUint32Array(buffer, e.ulElements); + break; + + default: + throw new NikonException("Enum of type " + e.ulType.ToString() + " cannot be parsed. Not implemented."); + } + } + + private object[] GetUint32Array(byte[] data, uint length) + { + Debug.Assert(data.Length / 4 >= length); + + List result = new List(); + + for (int i = 0; i < length; i++) + { + UInt32 val = BitConverter.ToUInt32(data, i * 4); + result.Add(val); + } + + return result.ToArray(); + } + + private string[] GetPackedStringArray(byte[] data) + { + List result = new List(); + List item = new List(); + + foreach (byte character in data) + { + if (character == 0) + { + string itemString = ASCIIEncoding.ASCII.GetString(item.ToArray()); + result.Add(itemString); + item.Clear(); + } + else + { + item.Add(character); + } + } + + return result.ToArray(); + } + + public NkMAIDEnum Enum + { + get { return _enum; } + } + + public object this[int index] + { + get { return _list[index]; } + } + + public object GetEnumValueByIndex(int index) + { + return _list[index]; + } + + public int Length + { + get { return _list.Length; } + } + + public int DefaultIndex + { + get { return (int)_enum.ulDefault; } + } + + public int Index + { + get { return (int)_enum.ulValue; } + set { _enum.ulValue = (uint)value; } + } + + public object DefaultValue + { + get + { + if (_enum.ulDefault < _list.Length) + { + return _list[_enum.ulDefault]; + } + else + { + return null; + } + } + } + + public object Value + { + get + { + if (_enum.ulValue < _list.Length) + { + return _list[_enum.ulValue]; + } + else + { + return null; + } + } + } + + public override string ToString() + { + return (Value != null) ? Value.ToString() : null; + } + } +} diff --git a/nikoncswrapper/Properties/AssemblyInfo.cs b/nikoncswrapper/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..41c0a79 --- /dev/null +++ b/nikoncswrapper/Properties/AssemblyInfo.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("nikoncswrapper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("nikoncswrapper")] +[assembly: AssemblyCopyright("Copyright © 2012 - 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d2690adc-3b27-4656-a8ed-efb50a0a772b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)] +[assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)] +[assembly: AssemblyInformationalVersion( + ThisAssembly.Git.SemVer.Major + "." + + ThisAssembly.Git.SemVer.Minor + "." + + ThisAssembly.Git.SemVer.Patch + "-" + + ThisAssembly.Git.Branch + "+" + + ThisAssembly.Git.Commit)] diff --git a/nikoncswrapper/nikoncswrapper.csproj b/nikoncswrapper/nikoncswrapper.csproj new file mode 100644 index 0000000..e7846bc --- /dev/null +++ b/nikoncswrapper/nikoncswrapper.csproj @@ -0,0 +1,80 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AADE1DF5-4C46-4760-B72B-474D90336F5B} + Library + Properties + nikoncswrapper + nikoncswrapper + v4.6 + 512 + + + + + + true + ..\bin\ + DEBUG;TRACE + true + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + false + + + bin\Release\ + TRACE + true + true + pdbonly + AnyCPU + prompt + MinimumRecommendedRules.ruleset + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/nikoncswrapper/packages.config b/nikoncswrapper/packages.config new file mode 100644 index 0000000..702580e --- /dev/null +++ b/nikoncswrapper/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/pktriggercord/Changelog b/pktriggercord/Changelog index 2e94733..9ab3f7f 100644 --- a/pktriggercord/Changelog +++ b/pktriggercord/Changelog @@ -1,3 +1,51 @@ +version 0.85.00 ( 2019-JAN-27 ) + K-1 battery fields fix + K-70: read one push bracketing field + Using one push bracketing field in command line + Print out command line in debug mode + K-70 bulb mode bugfix + --settings + K-1 bulb mode bugfix (testing) + --dangerous no longer required for K-70 + bulb_mode setting reading for K-70, K-50, K-01 + better handling of unknown and n/a settings + K-x settings parser (very simple) + Checking both both /dev/block and /dev + Android: using gradle instead of ant + Android: nicer image download indicator + GUI ISO table bugfix + Updating lens info database ( exiftool 10.70 ) + Android: better support of landscape mode + GTK code cleanup + Requires at least gtk+ 2.18 + GTK status info/status hex bugfix + Using command 0x02 0x00 for buffer mask (K-70, K-3II) + Possibility to specify stdout as output file using - + Default mode prints out status info instead of taking a picture + using_aperture_ring setting reading for K-70 + shake_reduction setting reading for K-70 + astrotracer setting reading for K70, K-3II + horizon_correction setting reading for K-70 + astrotracer timer sec setting reading for K-3II + K-3II bulb mode bugfix (testing) + Restore bulb_timer, astrotracer fields after bulb + CLI: Support for single buffer mode mode (K-70) + GUI: Settings info + GUI: Support for single buffer mode mode (K-70) + Testing support for KP + K-70 GUI image save bugfixes + Android: Better error message if root access is missing. + GUI ISO table simplification + GUI Preview image bugfix + Filename extension bugfixes + Avoid double unrecognized option error message + Show error message if servermode is specified in Windows + Human readable selected/focused af point (for 11 AF points) + K-70 AF selection mode reading hack + K-70 reading selected af point + --select_af_point also accepts raw numerical values + Testing support for K-1 II + version 0.84.04 ( 2017-05-13 ) Android: adding icon about/version code cleanup diff --git a/pktriggercord/pentax_settings.json b/pktriggercord/pentax_settings.json new file mode 100644 index 0000000..992b3e5 --- /dev/null +++ b/pktriggercord/pentax_settings.json @@ -0,0 +1,61 @@ +{ + "0x13222": { + "fields": [ + { "name" : "bulb_mode_press_press", "type": "boolean", "address": "0x178" }, + { "name" : "one_push_bracketing", "type": "boolean", "address": "0x17e"}, + { "name" : "bulb_timer", "type": "boolean", "address": "0x133"}, + { "name" : "bulb_timer_sec", "type": "uint16", "address": "0x134"}, + { "name" : "using_aperture_ring", "type": "boolean", "address": "0x18c"}, + { "name" : "shake_reduction", "type": "boolean!", "address": "0x07d"}, + { "name" : "astrotracer", "type": "boolean", "address": "0x087"}, + { "name" : "horizon_correction", "type": "boolean!", "address": "0x080"} + ] + }, + + "0x12dfe": { + "fields": [ + { "name" : "bulb_mode_press_press", "type": "boolean", "value": "false" }, + { "name" : "one_push_bracketing", "type": "boolean", "value": "false"}, + { "name" : "bulb_timer", "type": "boolean", "value": "false"}, + { "name" : "bulb_timer_sec", "type": "uint16", "value": 0 }, + { "name" : "using_aperture_ring", "type": "boolean", "address": "0x142"}, + { "name" : "shake_reduction", "type": "boolean!", "address": "0x065"}, + { "name" : "astrotracer", "type": "boolean", "value": "false"}, + { "name" : "astrotracer_timer_sec", "type": "uint16", "value": "0"}, + { "name" : "horizon_correction", "type": "boolean", "value": "false"} + ] + }, + + "0x12fb6": { + "fields": [ + { "name" : "bulb_mode_press_press", "type": "boolean", "address": "0x0f2" } + ] + }, + + "0x12ef8": { + "fields": [ + { "name" : "bulb_mode_press_press", "type": "boolean", "address": "0x0f2" } + ] + }, + + "0x13092": { + "fields": [ + { "name" : "bulb_timer", "type": "boolean", "address": "0x131"}, + { "name" : "bulb_timer_sec", "type": "uint16", "address": "0x132"} + ] + }, + + "0x1309c": { + "fields": [ + { "name" : "astrotracer", "type": "boolean", "address": "0x1ac"}, + { "name" : "astrotracer_timer_sec", "type": "uint16", "address": "0x1ad"} + ] + }, + + "0x13240": { + "fields": [ + { "name" : "bulb_timer", "type": "boolean", "address": "0x131"}, + { "name" : "bulb_timer_sec", "type": "uint16", "address": "0x132"} + ] + } +} diff --git a/pktriggercord/pktriggercord-cli.exe b/pktriggercord/pktriggercord-cli.exe index dd24910..565efa3 100644 Binary files a/pktriggercord/pktriggercord-cli.exe and b/pktriggercord/pktriggercord-cli.exe differ diff --git a/pktriggercord/pktriggercord.exe b/pktriggercord/pktriggercord.exe index 16556aa..85f2f39 100644 Binary files a/pktriggercord/pktriggercord.exe and b/pktriggercord/pktriggercord.exe differ diff --git a/pktriggercord/pktriggercord.ui b/pktriggercord/pktriggercord.ui index d3f42e5..b115bb1 100644 --- a/pktriggercord/pktriggercord.ui +++ b/pktriggercord/pktriggercord.ui @@ -132,10 +132,17 @@ True menu_buffer_window - _Preview Buffer + _Thumbnails + + + menu_histogram_window + Thumbnail _Histogram + + + True @@ -144,13 +151,6 @@ - - - menu_histogram_window - _Histogram - - - menuitem4 @@ -169,19 +169,8 @@ - - @@ -816,6 +805,21 @@ Library. 3 + + + Settings Info + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + True + True + 4 + + False @@ -993,7 +997,7 @@ Library. True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 4 + 5 2 6 2 @@ -1016,7 +1020,7 @@ Library. - + True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1030,7 +1034,7 @@ Library. - + True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1056,7 +1060,7 @@ Library. - + True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/pktriggercord/pktriggercord_commandline.html b/pktriggercord/pktriggercord_commandline.html index 325a782..78760c3 100644 --- a/pktriggercord/pktriggercord_commandline.html +++ b/pktriggercord/pktriggercord_commandline.html @@ -1,5 +1,5 @@ - + @@ -72,12 +72,12 @@

SYNOPSIS [--auto_focus] [--reconnect] [--green] [--warnings | --nowarnings ] [--version | --help | --dust_removal | --status | ---status_hex | --settings_hex | ---read_datetime | --read_firmware_version | ---dump_memory SIZE | --frames -NUMBER [ --delay SECONDS ] | ---noshutter | --servermode [ ---servermode_timeout SECONDS] | +--status_hex | --settings | +--settings_hex | --read_datetime | +--read_firmware_version | --dump_memory +SIZE | --frames NUMBER [ --delay +SECONDS ] | --noshutter | --servermode +[ --servermode_timeout SECONDS] | --pentax_debug_mode VALUE] [ --file_format FORMAT ] [ --output_file FILENAME ] [--debug]

@@ -137,7 +137,8 @@

Work mode

Without -specifying work mode the program takes 1 picture.

+specifying work mode the program prints out the status +info.

-F, --frames NUMBER

@@ -184,8 +185,14 @@

Work mode

Print raw (hexadecimal) and human readable status info and do not take pictures.

+

-S, +--settings

+ +

Print human readable settings +info and do not take pictures.

-

--status_hex

+ +

--settings_hex

Print raw (hexadecimal) settings info and do not take pictures. Since the size of @@ -309,7 +316,8 @@

Setting exposure parameters

Specify the autofocus point selection mode. Valid values are: Auto-5, Auto-11, Select, -Spot.

+Spot. It is also possible to specify the raw numerical +value.

--ae_metering @@ -359,8 +367,8 @@

Output file specification

Specify the name of the output file prefix. Frame number and extension will be -automatically added. If not specified the file will be sent -to standard output.

+automatically added. Use ’-’ to output to +stdout.

--file_format diff --git a/refs/Interop.PortableDeviceApiLib.dll b/refs/Interop.PortableDeviceApiLib.dll index f80ea7d..15311ab 100644 Binary files a/refs/Interop.PortableDeviceApiLib.dll and b/refs/Interop.PortableDeviceApiLib.dll differ diff --git a/refs/Interop.PortableDeviceApiLib.dll.old b/refs/Interop.PortableDeviceApiLib.dll.old new file mode 100644 index 0000000..f80ea7d Binary files /dev/null and b/refs/Interop.PortableDeviceApiLib.dll.old differ diff --git a/refs/Interop.PortableDeviceTypesLib.dll b/refs/Interop.PortableDeviceTypesLib.dll index 53e6e50..0809ffe 100644 Binary files a/refs/Interop.PortableDeviceTypesLib.dll and b/refs/Interop.PortableDeviceTypesLib.dll differ diff --git a/refs/Interop.PortableDeviceTypesLib.dll.old b/refs/Interop.PortableDeviceTypesLib.dll.old new file mode 100644 index 0000000..53e6e50 Binary files /dev/null and b/refs/Interop.PortableDeviceTypesLib.dll.old differ diff --git a/refs/Interop.WIA.dll b/refs/Interop.WIA.dll index 5872520..85ff59b 100644 Binary files a/refs/Interop.WIA.dll and b/refs/Interop.WIA.dll differ diff --git a/refs/Interop.WIA.dll.old b/refs/Interop.WIA.dll.old new file mode 100644 index 0000000..5872520 Binary files /dev/null and b/refs/Interop.WIA.dll.old differ