public StorageServicesAdapter(PortableDevice device) { this.device = device; portableDeviceClass = device.PortableDeviceClass; storages = new ObservableCollection <PortableDeviceFunctionalObject>(ExtractStorageServices()); Storages = new ReadOnlyObservableCollection <PortableDeviceFunctionalObject>(storages); }
/// <summary> /// Initialize an new instance of the <see cref="PortableDeviceEventCallback" /> class /// </summary> /// <param name="portableDevice"></param> internal PortableDeviceEventCallback(PortableDevice portableDevice) { if (portableDevice == null) throw new ArgumentNullException("portableDevice"); device = portableDevice; }
public StorageServicesAdapter(PortableDevice device) { this.device = device; portableDeviceClass = device.PortableDeviceClass; storages = new ObservableCollection<PortableDeviceFunctionalObject>(ExtractStorageServices()); Storages = new ReadOnlyObservableCollection<PortableDeviceFunctionalObject>(storages); }
/// <summary> /// Initialize an new instance of the <see cref="PortableDeviceEventCallback"/> class /// </summary> /// <param name="portableDevice"></param> internal PortableDeviceEventCallback(PortableDevice portableDevice) { if (portableDevice == null) { throw new ArgumentNullException("portableDevice"); } this.device = portableDevice; }
private void MenuItem_Click(object sender, RoutedEventArgs e) { DeviceInfo = new XmlDeviceData(); SelectDevice wnd = new SelectDevice(); wnd.ShowDialog(); if (wnd.DialogResult == true && wnd.SelectedDevice != null) { try { SelectedDevice = wnd.SelectedDevice; DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = SelectedDevice.DeviceId}; MtpProtocol device = new MtpProtocol(descriptor.WpdId); device.ConnectToDevice("MTPTester", 1, 0); descriptor.StillImageDevice = device; MTPCamera = new BaseMTPCamera(); MTPCamera.Init(descriptor); LoadDeviceData(MTPCamera.ExecuteReadDataEx(0x1001)); //LoadDeviceData(MTPCamera.ExecuteReadDataEx(0x9108)); PopulateProperties(); } catch (DeviceException exception) { MessageBox.Show("Error getting device information" + exception.Message); } catch (Exception exception) { MessageBox.Show("General error" + exception.Message); } if (DefaultDeviceInfo != null) { foreach (XmlCommandDescriptor command in DeviceInfo.AvaiableCommands) { command.Name = DefaultDeviceInfo.GetCommandName(command.Code); } foreach (XmlEventDescriptor avaiableEvent in DeviceInfo.AvaiableEvents) { avaiableEvent.Name = DefaultDeviceInfo.GetEventName(avaiableEvent.Code); } foreach (XmlPropertyDescriptor property in DeviceInfo.AvaiableProperties) { property.Name = DefaultDeviceInfo.GetPropName(property.Code); } } InitUi(); } }
/// <summary> /// Get the portable device by his id /// </summary> /// <param name="id"></param> /// <returns></returns> 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]); }
private void btn_get_value_Click(object sender, RoutedEventArgs e) { try { if (MTPCamera == null || MTPCamera.IsConnected == false) { DeviceInfo = new XmlDeviceData(); SelectDevice wnd = new SelectDevice(); wnd.ShowDialog(); if (wnd.DialogResult == true && wnd.SelectedDevice != null) { SelectedDevice = wnd.SelectedDevice; DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = SelectedDevice.DeviceId}; MTPCamera = new BaseMTPCamera(); MTPCamera.Init(descriptor); } else { return; } } XmlPropertyDescriptor propertyDescriptor = lst_prop.SelectedItem as XmlPropertyDescriptor; MTPDataResponse resp = MTPCamera.ExecuteReadDataEx(BaseMTPCamera.CONST_CMD_GetDevicePropValue, propertyDescriptor.Code); long val = GetValue(resp, 0, GetDataLength(propertyDescriptor.DataType)); XmlPropertyValue selected = null; foreach (XmlPropertyValue xmlPropertyValue in propertyDescriptor.Values) { if (xmlPropertyValue.Value == val) selected = xmlPropertyValue; } if(selected!=null) { lst_values.BeginInit(); lst_values.SelectedItem = selected; lst_values.EndInit(); } } catch (Exception exception) { MessageBox.Show("Error to get value " + exception.Message); } }
public PortableDevice Constructor(string deviceId) { // TODO: add assertions to method PortableDeviceTest.Constructor(String) PortableDevice target = new PortableDevice(deviceId); return target; }
private void ChangeCurrentDevice(ShowDeviceMessage msg) { this.PortableDevice = msg.Device; this.PortableDevice.RefreshContent(); }
/// <summary> /// Get the portable device by his id /// </summary> /// <param name="id"></param> /// <returns></returns> public PortableDevice GetPortableDeviceById(string id) { if (string.IsNullOrEmpty(id)) throw new ArgumentNullException("id"); if (!portableDevices.ContainsKey(id)) { var portableDevice = new PortableDevice(id); if (AutoConnectToPortableDevice) portableDevice.ConnectToDevice(appName, majorVersion, minorVersion); portableDevices.Add(id, portableDevice); } return portableDevices[id]; }
private void Button_Click(object sender, RoutedEventArgs e) { try { if (MTPCamera == null || MTPCamera.IsConnected == false) { DeviceInfo = new XmlDeviceData(); SelectDevice wnd = new SelectDevice(); wnd.ShowDialog(); if (wnd.DialogResult == true && wnd.SelectedDevice != null) { SelectedDevice = wnd.SelectedDevice; DeviceDescriptor descriptor = new DeviceDescriptor {WpdId = SelectedDevice.DeviceId}; MTPCamera = new BaseMTPCamera(); MTPCamera.Init(descriptor); } else { return; } } XmlPropertyValue property = lst_values.SelectedItem as XmlPropertyValue; XmlPropertyDescriptor propertyDescriptor = lst_prop.SelectedItem as XmlPropertyDescriptor; if (property != null) { MTPCamera.SetProperty(BaseMTPCamera.CONST_CMD_SetDevicePropValue, BitConverter.GetBytes(property.Value), propertyDescriptor.Code); } } catch (Exception exception) { MessageBox.Show("Error set property " + exception.Message); } }
private void button1_Click(object sender, RoutedEventArgs e) { SelectedDevice = (PortableDevice) cmb_devices.SelectedItem; DialogResult = true; }
private void ConnectToDevice(PortableDevice portableDevice) { portableDevice.ConnectToDevice(AppName, AppMajorVersionNumber, AppMinorVersionNumber); this.SelectedPortableDevice = portableDevice; }
private bool CanConnectToDevice(PortableDevice portableDevice) { return portableDevice != null && !portableDevice.IsConnected; }
public PropertiesHelper(PortableDevice device) { this.device = device; }