Beispiel #1
0
        /// <summary>
        /// Loads an image from a resource
        /// </summary>
        /// <returns>An image</returns>
        /// <param name="assembly">The assembly from which to load the image</param>
        /// <param name="resource">Resource name</param>
        /// <remarks>
        /// This method will look for alternative versions of the image with different resolutions.
        /// For example, if a resource is named "foo.png", this method will load
        /// other resources with the name "*****@*****.**", where XXX can be any arbitrary string. For example "*****@*****.**".
        /// Each of those resources will be considered different versions of the same image.
        /// </remarks>
        public static Image FromResource(Assembly assembly, string resource)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            var toolkit = Toolkit.CurrentEngine;

            if (toolkit == null)
            {
                throw new ToolkitNotInitializedException();
            }

            var loader = new ResourceImageLoader(toolkit, assembly);

            return(LoadImage(loader, resource, null));
        }
Beispiel #2
0
        /// <summary>
        /// Loads an image from a resource
        /// </summary>
        /// <returns>An image</returns>
        /// <param name="assembly">The assembly from which to load the image</param>
        /// <param name="resource">Resource name</param>
        /// <remarks>
        /// This method will look for alternative versions of the image with different resolutions.
        /// For example, if a resource is named "foo.png", this method will load
        /// other resources with the name "*****@*****.**", where XXX can be any arbitrary string. For example "*****@*****.**".
        /// Each of those resources will be considered different versions of the same image.
        /// </remarks>
        public static Image FromResource(Assembly assembly, string resource)
        {
            if (assembly == null)
                throw new ArgumentNullException ("assembly");
            if (resource == null)
                throw new ArgumentNullException ("resource");

            var toolkit = Toolkit.CurrentEngine;
            if (toolkit == null)
                throw new ToolkitNotInitializedException ();

            var loader = new ResourceImageLoader (toolkit, assembly);
            return LoadImage (loader, resource, null);
        }