Exemplo n.º 1
0
        // 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));
            }
            }
        }
Exemplo n.º 2
0
 /// <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);
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
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>);
 }
Exemplo n.º 5
0
 /// <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);
Exemplo n.º 6
0
 /// <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));
 }
Exemplo n.º 7
0
 /// <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));
 }
Exemplo n.º 8
0
 /// <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);
 }
Exemplo n.º 9
0
        internal IShellProperty CreateTypedProperty <T>(PropertyKey propKey)
        {
            ShellPropertyDescription desc = ShellPropertyDescriptionsCache.Cache.GetPropertyDescription(propKey);

            return(new ShellProperty <T>(propKey, desc, ParentShellObject));
        }
Exemplo n.º 10
0
 internal static extern HRESULT PSGetPropertyDescription(
     ref PropertyKey propkey,
     ref Guid riid,
     [Out, MarshalAs(UnmanagedType.Interface)] out IPropertyDescription ppv
     );
Exemplo n.º 11
0
 internal static extern int PSGetPropertyKeyFromName(
     [In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName,
     out PropertyKey propkey
     );
Exemplo n.º 12
0
 internal static extern int PSGetNameFromPropertyKey(
     ref PropertyKey propkey,
     [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszCanonicalName
     );
Exemplo n.º 13
0
 // 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));
 }
Exemplo n.º 14
0
 /// <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));
 }
Exemplo n.º 15
0
 /// <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);
 }
Exemplo n.º 16
0
 internal IShellProperty CreateTypedProperty(PropertyKey propKey)
 {
     return(ShellPropertyFactory.CreateShellProperty(propKey, ParentShellObject));
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 /// <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));
 }