Exemple #1
0
 /// <summary>
 /// 最新のプロパティ情報を列挙します。
 /// </summary>
 public void UpdateValues()
 {
     foreach (var value in WpdPropertyValue.EnumValues(this.Id, this._properties))
     {
         if (value.Key.Equals(WpdProperties.WPD_OBJECT_NAME))
         {
             this.Name = value.ValueString;
         }
         else if (value.Key.Equals(WpdProperties.WPD_OBJECT_CONTENT_TYPE))
         {
             if (value.ValueGuid != null)
             {
                 this.ContentType = value.ValueGuid.Value;
             }
         }
         else if (value.Key.Equals(WpdProperties.WPD_OBJECT_FORMAT))
         {
             if (value.ValueGuid != null)
             {
                 this.Format = value.ValueGuid.Value;
             }
         }
         else if (value.Key.Equals(WpdProperties.WPD_OBJECT_SIZE))
         {
             if (value.ValueUInt64 != null)
             {
                 this.Size = value.ValueUInt64.Value;
             }
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="key">識別子。</param>
        /// <param name="info">プロパティ値の情報。</param>
        /// <param name="values">値。</param>
        internal WpdPropertyValue(_tagpropertykey key, tag_inner_PROPVARIANT info, IPortableDeviceValues values)
        {
            this.Key      = key;
            this.HasValue = true;

            switch (( PropVariantTypes )info.vt)
            {
            case PropVariantTypes.VT_BOOL:
                this.Type      = WpdPropertyValueType.Bool;
                this.ValueBool = WpdPropertyValue.ReadBool(key, values);
                break;

            case PropVariantTypes.VT_DATE:
                this.Type          = WpdPropertyValueType.DateTime;
                this.ValueDateTime = WpdPropertyValue.ReadDateTime(key, values);
                break;

            case PropVariantTypes.VT_CLSID:
                this.Type      = WpdPropertyValueType.Guid;
                this.ValueGuid = WpdPropertyValue.ReadGuid(key, values);
                break;

            case PropVariantTypes.VT_I4:
                this.Type       = WpdPropertyValueType.Int32;
                this.ValueInt32 = WpdPropertyValue.ReadInt32(key, values);
                break;

            case PropVariantTypes.VT_I8:
                this.Type       = WpdPropertyValueType.Int64;
                this.ValueInt64 = WpdPropertyValue.ReadInt64(key, values);
                break;

            case PropVariantTypes.VT_BSTR:
            case PropVariantTypes.VT_LPSTR:
            case PropVariantTypes.VT_LPWSTR:
                this.Type        = WpdPropertyValueType.String;
                this.ValueString = WpdPropertyValue.ReadString(key, values);
                break;

            case PropVariantTypes.VT_UI4:
                this.Type        = WpdPropertyValueType.UInt32;
                this.ValueUInt32 = WpdPropertyValue.ReadUInt32(key, values);
                break;

            case PropVariantTypes.VT_UI8:
                this.Type        = WpdPropertyValueType.UInt64;
                this.ValueUInt64 = WpdPropertyValue.ReadUInt64(key, values);
                break;

            default:
                this.Type     = WpdPropertyValueType.Unknown;
                this.HasValue = false;
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="values">イベント データのコレクション。</param>
        internal WpdEventArgs(IPortableDeviceValues values)
        {
            uint count = 0;

            values.GetCount(ref count);
            if (count < 1)
            {
                this.Values = new List <WpdPropertyValue>(0);
                return;
            }

            this.Values = new List <WpdPropertyValue>(( int )count);
            var key  = new _tagpropertykey();
            var info = new tag_inner_PROPVARIANT();

            for (uint i = 0; i < count; ++i)
            {
                values.GetAt(i, ref key, ref info);

                var value = new WpdPropertyValue(key, info, values);
                if (value.Key.Equals(WpdProperties.WPD_EVENT_PARAMETER_PNP_DEVICE_ID))
                {
                    this.DeviceId = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_OBJECT_ID))
                {
                    this.ObjectId = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_OBJECT_PARENT_ID))
                {
                    this.ParentObjectId = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_EVENT_PARAMETER_EVENT_ID))
                {
                    if (value.ValueGuid != null)
                    {
                        this.Type = TypeConvertUtility.GuidToEventType(value.ValueGuid.Value);
                    }
                }
                else
                {
                    this.Values.Add(value);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="values">イベント データのコレクション。</param>
        internal WpdEventArgs( IPortableDeviceValues values )
        {
            uint count = 0;
            values.GetCount( ref count );
            if( count < 1 )
            {
                this.Values = new List< WpdPropertyValue >( 0 );
                return;
            }

            this.Values = new List< WpdPropertyValue >( ( int )count );
            var key     = new _tagpropertykey();
            var info    = new tag_inner_PROPVARIANT();

            for( uint i = 0; i < count; ++i )
            {
                values.GetAt( i, ref key, ref info );

                var value = new WpdPropertyValue( key, info, values );
                if( value.Key.Equals( WpdProperties.WPD_EVENT_PARAMETER_PNP_DEVICE_ID ) )
                {
                    this.DeviceId = value.ValueString;
                }
                else if( value.Key.Equals( WpdProperties.WPD_OBJECT_ID ) )
                {
                    this.ObjectId = value.ValueString;
                }
                else if( value.Key.Equals( WpdProperties.WPD_OBJECT_PARENT_ID ) )
                {
                    this.ParentObjectId = value.ValueString;
                }
                else if( value.Key.Equals( WpdProperties.WPD_EVENT_PARAMETER_EVENT_ID ) )
                {
                    if( value.ValueGuid != null ) { this.Type = TypeConvertUtility.GuidToEventType( value.ValueGuid.Value ); }
                }
                else
                {
                    this.Values.Add( value );
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 最新のプロパティ情報を列挙します。
        /// </summary>
        private void UpdateValues()
        {
            IPortableDeviceContent content;

            this._device.Content(out content);

            IPortableDeviceProperties properties;

            content.Properties(out properties);

            foreach (var value in WpdPropertyValue.EnumValues(WpdDevice.DeviceObjectId, properties))
            {
                if (value.Key.Equals(WpdProperties.WPD_DEVICE_POWER_LEVEL))
                {
                    if (value.ValueInt32 != null)
                    {
                        this.BatteryLevel = value.ValueInt32.Value;
                    }
                }
                else if (value.Key.Equals(WpdProperties.WPD_DEVICE_FIRMWARE_VERSION))
                {
                    this.FirmwareVersion = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_DEVICE_FRIENDLY_NAME))
                {
                    this.FriendlyName = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_DEVICE_MODEL))
                {
                    this.Model = value.ValueString;
                }
                else if (value.Key.Equals(WpdProperties.WPD_DEVICE_SERIAL_NUMBER))
                {
                    this.SerialNumber = value.ValueString;
                }
            }
        }