// TODO - ShellProperties.cs also has a similar class that is used for creating // a ShellObject specific IShellProperty. These 2 methods should be combined or moved to a // common location. internal static IShellProperty CreateTypedProperty(PropertyKey propKey, IPropertyStore NativePropertyStore) { ShellPropertyDescription desc = ShellPropertyDescriptionsCache.Cache.GetPropertyDescription(propKey); switch (desc.VarEnumType) { case (VarEnum.VT_EMPTY): case (VarEnum.VT_NULL): { return(new ShellProperty <Object>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_UI1): { return(new ShellProperty <Byte?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_I2): { return(new ShellProperty <Int16?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_UI2): { return(new ShellProperty <UInt16?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_I4): { return(new ShellProperty <Int32?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_UI4): { return(new ShellProperty <UInt32?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_I8): { return(new ShellProperty <Int64?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_UI8): { return(new ShellProperty <UInt64?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_R8): { return(new ShellProperty <Double?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_BOOL): { return(new ShellProperty <Boolean?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_FILETIME): { return(new ShellProperty <DateTime?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_CLSID): { return(new ShellProperty <IntPtr?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_CF): { return(new ShellProperty <IntPtr?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_BLOB): { return(new ShellProperty <Byte[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_LPWSTR): { return(new ShellProperty <String>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_UNKNOWN): { return(new ShellProperty <IntPtr?>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_STREAM): { return(new ShellProperty <IStream>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_UI1): { return(new ShellProperty <Byte[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_I2): { return(new ShellProperty <Int16[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_UI2): { return(new ShellProperty <UInt16[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_I4): { return(new ShellProperty <Int32[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_UI4): { return(new ShellProperty <UInt32[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_I8): { return(new ShellProperty <Int64[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_UI8): { return(new ShellProperty <UInt64[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_R8): { return(new ShellProperty <Double[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_BOOL): { return(new ShellProperty <Boolean[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_FILETIME): { return(new ShellProperty <DateTime[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_CLSID): { return(new ShellProperty <IntPtr[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_CF): { return(new ShellProperty <IntPtr[]>(propKey, desc, NativePropertyStore)); } case (VarEnum.VT_VECTOR | VarEnum.VT_LPWSTR): { return(new ShellProperty <String[]>(propKey, desc, NativePropertyStore)); } default: { return(new ShellProperty <Object>(propKey, desc, NativePropertyStore)); } } }
/// <summary> /// Creates a generic ShellProperty. /// </summary> /// <param name="propKey">PropertyKey</param> /// <param name="store">IPropertyStore from which to get property</param> /// <returns>ShellProperty matching type of value in property.</returns> public static IShellProperty CreateShellProperty(PropertyKey propKey, IPropertyStore store) => GenericCreateShellProperty(propKey, store);
/// <summary> /// Checks if a property with the given property key is available. /// </summary> /// <param name="key">The property key.</param> /// <returns><B>True</B> if available, <B>false</B> otherwise.</returns> public bool Contains(PropertyKey key) { return(Items. Where(p => p.PropertyKey == key). Count() > 0); }
/// <summary> /// Returns a strongly typed property available in the default property collection using /// the given property key. /// </summary> /// <typeparam name="T">The type of property to retrieve.</typeparam> /// <param name="key">The property key.</param> /// <returns>A strongly-typed ShellProperty for the given property key.</returns> public ShellProperty <T> GetProperty <T>(PropertyKey key) { return(CreateTypedProperty(key) as ShellProperty <T>); }
/// <summary> /// Creates a generic ShellProperty. /// </summary> /// <param name="propKey">PropertyKey</param> /// <param name="shellObject">Shell object from which to get property</param> /// <returns>ShellProperty matching type of value in property.</returns> public static IShellProperty CreateShellProperty(PropertyKey propKey, ShellObject shellObject) => GenericCreateShellProperty(propKey, shellObject);
/// <summary> /// Creates a generic ShellProperty. /// </summary> /// <param name="propKey">PropertyKey</param> /// <param name="store">IPropertyStore from which to get property</param> /// <returns>ShellProperty matching type of value in property.</returns> public static IShellProperty CreateShellProperty(PropertyKey propKey, IPropertyStore store) { return(GenericCreateShellProperty(propKey, store)); }
/// <summary> /// Returns a property available in the default property collection using /// the given property key. /// </summary> /// <param name="key">The property key.</param> /// <returns>An IShellProperty.</returns> public IShellProperty GetProperty(PropertyKey key) { return(CreateTypedProperty(key)); }
/// <summary> /// Writes the given property key and value. /// </summary> /// <param name="key">The property key.</param> /// <param name="value">The value associated with the key.</param> public void WriteProperty(PropertyKey key, object value) { WriteProperty(key, value, true); }
internal IShellProperty CreateTypedProperty <T>(PropertyKey propKey) { ShellPropertyDescription desc = ShellPropertyDescriptionsCache.Cache.GetPropertyDescription(propKey); return(new ShellProperty <T>(propKey, desc, ParentShellObject)); }
internal static extern HRESULT PSGetPropertyDescription( ref PropertyKey propkey, ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IPropertyDescription ppv );
internal static extern int PSGetPropertyKeyFromName( [In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName, out PropertyKey propkey );
internal static extern int PSGetNameFromPropertyKey( ref PropertyKey propkey, [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszCanonicalName );
// TODO - ShellProperties.cs also has a similar class that is used for creating // a ShellObject specific IShellProperty. These 2 methods should be combined or moved to a // common location. public static IShellProperty CreateTypedProperty(PropertyKey propKey, IPropertyStore NativePropertyStore) { return(ShellPropertyFactory.CreateShellProperty(propKey, NativePropertyStore)); }
/// <summary> /// Checks if a property with the given property key is available. /// </summary> /// <param name="key">The property key.</param> /// <returns><B>True</B> if available, <B>false</B> otherwise.</returns> public bool Contains(PropertyKey key) { return(Items.Any(p => p.PropertyKey == key)); }
/// <summary> /// Sets a shell property for a given window /// </summary> /// <param name="propkey">The property to set</param> /// <param name="windowHandle">Handle to the window that the property will be set on</param> /// <param name="value">The value to set for the property</param> public static void SetWindowProperty(IntPtr windowHandle, PropertyKey propkey, string value) { TaskbarNativeMethods.SetWindowProperty(windowHandle, propkey, value); }
internal IShellProperty CreateTypedProperty(PropertyKey propKey) { return(ShellPropertyFactory.CreateShellProperty(propKey, ParentShellObject)); }
/// <summary> /// Sets a shell property for a given window /// </summary> /// <param name="propkey">The property to set</param> /// <param name="window">Window that the property will be set on</param> /// <param name="value">The value to set for the property</param> public static void SetWindowProperty(Window window, PropertyKey propkey, string value) { TaskbarNativeMethods.SetWindowProperty((new WindowInteropHelper(window)).Handle, propkey, value); }
/// <summary> /// Creates a generic ShellProperty. /// </summary> /// <param name="propKey">PropertyKey</param> /// <param name="shellObject">Shell object from which to get property</param> /// <returns>ShellProperty matching type of value in property.</returns> public static IShellProperty CreateShellProperty(PropertyKey propKey, ShellObject shellObject) { return(GenericCreateShellProperty(propKey, shellObject)); }