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,
                                                                  (int)propertyDescriptor.Code, -1);
         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);
     }
 }
 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), (int)propertyDescriptor.Code, -1);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error set property " + exception.Message);
     }
 }