コード例 #1
0
ファイル: Item.cs プロジェクト: chcg/MediaDevices
        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();
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: Code-Artist/MediaDevicesExt
        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);
        }
コード例 #3
0
ファイル: Item.cs プロジェクト: chcg/MediaDevices
        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);
        }
コード例 #4
0
ファイル: Command.cs プロジェクト: DaveCS1/MediaDevices
 public void WriteResults()
 {
     ComTrace.WriteObject(this.result);
 }