Ejemplo n.º 1
0
    /// <summary>
    ///     An Icon extension method that gets URL to use with the IconResourceHandler for the 32x32 icon.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>The URL to use with the IconResourceHanler for the 32x32 icon.</returns>
    public static string GetUrl32(this Z.IconLibrary.Icon @this)
    {
        Type      enumType   = typeof(Z.IconLibrary.Icon);
        FieldInfo fi         = enumType.GetField(@this.ToString());
        var       attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

        if (attributes.Length > 0)
        {
            return("z.axd?f=Icon32." + attributes[0].Description);
        }
        return(null);
    }
Ejemplo n.º 2
0
    /// <summary>
    ///     An Icon extension method that get the WebResourceUrl for the 32x32 icon.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>The WebResourceUrl for the 32x32 icon.</returns>
    public static string GetWebResourceUrl32(this Z.IconLibrary.Icon @this)
    {
        Type      enumType   = typeof(Z.IconLibrary.Icon);
        FieldInfo fi         = enumType.GetField(@this.ToString());
        var       attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

        if (attributes.Length > 0)
        {
            string webResource = "Z.IconLibrary.Icon32." + attributes[0].Description;
            return(((Page)System.Web.HttpContext.Current.Handler).ClientScript.GetWebResourceUrl(enumType, webResource));
        }
        return(null);
    }
Ejemplo n.º 3
0
    /// <summary>
    ///     An Icon extension method that get the 32x32 icon as Image.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>The 16x16 icon as Image.</returns>
    public static Image GetImage32(this Z.IconLibrary.Icon @this)
    {
        Type      enumType   = typeof(Z.IconLibrary.Icon);
        var       assembly   = enumType.Assembly;
        FieldInfo fi         = enumType.GetField(@this.ToString());
        var       attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

        if (attributes.Length > 0)
        {
            string path = attributes[0].Description;
            string assemblyResourceName = "Z.IconLibrary.Icon32." + path;

            using (Stream stream = assembly.GetManifestResourceStream(assemblyResourceName))
            {
                return(Image.FromStream(stream));
            }
        }
        return(null);
    }
Ejemplo n.º 4
0
    /// <summary>
    ///     An Icon extension method that get the 16x16 Icon.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>The 16x16 Icon.</returns>
    public static Icon GetIcon16(this  Z.IconLibrary.Icon @this)
    {
        Type      enumType   = typeof(Z.IconLibrary.Icon);
        Assembly  assembly   = enumType.Assembly;
        FieldInfo fi         = enumType.GetField(@this.ToString());
        var       attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

        if (attributes.Length > 0)
        {
            string path = attributes[0].Description;
            string assemblyResourceName = "Z.IconLibrary.Icon16." + path;
            using (Stream stream = assembly.GetManifestResourceStream(assemblyResourceName))
            {
                var bipmap = new Bitmap(stream);
                return(Icon.FromHandle(bipmap.GetHicon()));
            }
        }
        return(null);
    }
Ejemplo n.º 5
0
 /// <summary>
 ///     An Icon extension method that get the stylesheet css class for the 32x32 icon.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <returns>The stylesheet css class for the 32x32 icon.</returns>
 public static string GetCssClass32(this Z.IconLibrary.Icon @this)
 {
     return(string.Concat("Icon32_", @this.ToString()));
 }