Esempio n. 1
0
        internal void SetDateAuthored(DateTime value)
        {
            IPortableDeviceValues portableDeviceValues = new PortableDeviceValues() as IPortableDeviceValues;
            IPortableDeviceValues result;

            using (PropVariantFacade val = PropVariantFacade.DateTimeToPropVariant(value))
            {
                portableDeviceValues.SetValue(ref WPD.OBJECT_DATE_AUTHORED, ref val.Value);
                this.device.deviceProperties.SetValues(this.Id, portableDeviceValues, out result);
                ComTrace.WriteObject(result);
            }

            Refresh();
        }
Esempio n. 2
0
        public void Delete(bool recursive = false)
        {
            var objectIdCollection = (IPortableDevicePropVariantCollection) new PortableDeviceTypesLib.PortableDevicePropVariantCollection();

            var propVariantValue = PropVariant.StringToPropVariant(this.Id);

            objectIdCollection.Add(ref propVariantValue);

            IPortableDevicePropVariantCollection results = (PortableDeviceApiLib.IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection();

            // TODO: get the results back and handle failures correctly
            this.device.deviceContent.Delete(recursive ? PORTABLE_DEVICE_DELETE_WITH_RECURSION : PORTABLE_DEVICE_DELETE_NO_RECURSION, objectIdCollection, null);

            ComTrace.WriteObject(objectIdCollection);
        }
Esempio n. 3
0
        internal bool Rename(string newName)
        {
            IPortableDeviceValues portableDeviceValues = new PortableDeviceValues() as IPortableDeviceValues;
            IPortableDeviceValues result;

            // with OBJECT_NAME does not work for Amazon Kindle Paperwhite
            portableDeviceValues.SetStringValue(ref WPD.OBJECT_ORIGINAL_FILE_NAME, newName);
            this.device.deviceProperties.SetValues(this.Id, portableDeviceValues, out result);
            ComTrace.WriteObject(result);

            if (result.TryGetStringValue(WPD.OBJECT_ORIGINAL_FILE_NAME, out string check))
            {
                if (check == "Error: S_OK")
                {
                    // id can change on rename (e.g. Amazon Kindle Paperwhite) so find new one
                    var newItem = this.parent.GetChildren().FirstOrDefault(i => device.EqualsName(i.Name, newName));
                    this.Id = newItem.Id;

                    Refresh();
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
 public void WriteResults()
 {
     ComTrace.WriteObject(this.result);
 }