private void ReInitShutterSpeed() { lock (Locker) { try { ShutterSpeed.Clear(); var data = Camera.GetPropertyDescription(Edsdk.PropID_Tv); foreach (KeyValuePair <uint, string> keyValuePair in _shutterTable) { if (data.NumElements > 0) { if (ArrayContainValue(data.PropDesc, keyValuePair.Key)) { ShutterSpeed.AddValues(keyValuePair.Value, keyValuePair.Key); } } else { ShutterSpeed.AddValues(keyValuePair.Value, keyValuePair.Key); } } 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); } } }
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); }