private static void PrintCapabilities(NikonDevice device) { Console.WriteLine("Capabilities:"); // Get 'info' struct for each supported capability NkMAIDCapInfo[] caps = device.GetCapabilityInfo(); // Iterate through all supported capabilities foreach (NkMAIDCapInfo cap in caps) { // Print ID, description and type Console.WriteLine($"{"Id",-14}: {cap.ulID.ToString()}"); Console.WriteLine($"{"Description",-14}: {cap.GetDescription()}"); Console.WriteLine($"{"Type",-14}: {cap.ulType.ToString()}"); // Try to get the capability value string value = null; // First, check if the capability is readable if (cap.CanGet()) { // Choose which 'Get' function to use, depending on the type switch (cap.ulType) { case eNkMAIDCapType.kNkMAIDCapType_Unsigned: value = device.GetUnsigned(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_Integer: value = device.GetInteger(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_String: value = device.GetString(cap.ulID); break; case eNkMAIDCapType.kNkMAIDCapType_Boolean: value = device.GetBoolean(cap.ulID).ToString(); break; // Note: There are more types - adding the rest is left // as an exercise for the reader. } } // Print the value if (value != null) { Console.WriteLine($"{"Value",-14}: {value}"); } // Print spacing between capabilities Console.WriteLine(); Console.WriteLine(); } }
public void Run() { try { // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/) NikonManager manager = new NikonManager("Type0003.md3"); // Listen for the 'DeviceAdded' event manager.DeviceAdded += manager_DeviceAdded; // Wait for a device to arrive _waitForDevice.WaitOne(); // Get 'info' struct for each supported capability NkMAIDCapInfo[] caps = _device.GetCapabilityInfo(); // Iterate through all supported capabilities foreach (NkMAIDCapInfo cap in caps) { // Print ID, description and type Console.WriteLine(string.Format("{0, -14}: {1}", "Id", cap.ulID.ToString())); Console.WriteLine(string.Format("{0, -14}: {1}", "Description", cap.GetDescription())); Console.WriteLine(string.Format("{0, -14}: {1}", "Type", cap.ulType.ToString())); // Try to get the capability value string value = null; // First, check if the capability is readable if (cap.CanGet()) { // Choose which 'Get' function to use, depending on the type switch (cap.ulType) { case eNkMAIDCapType.kNkMAIDCapType_Unsigned: value = _device.GetUnsigned(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_Integer: value = _device.GetInteger(cap.ulID).ToString(); break; case eNkMAIDCapType.kNkMAIDCapType_String: value = _device.GetString(cap.ulID); break; case eNkMAIDCapType.kNkMAIDCapType_Boolean: value = _device.GetBoolean(cap.ulID).ToString(); break; // Note: There are more types - adding the rest is left // as an exercise for the reader. } } // Print the value if (value != null) { Console.WriteLine(string.Format("{0, -14}: {1}", "Value", value)); } // Print spacing between capabilities Console.WriteLine(); Console.WriteLine(); } // Shutdown manager.Shutdown(); } catch (NikonException ex) { Console.WriteLine(ex.Message); } }