Beispiel #1
0
        /// <summary>
        /// Registers a keyed image in three standard icon resolutions</summary>
        /// <param name="id">Image identifier</param>
        /// <param name="image16">16 x 16 image</param>
        /// <param name="image24">24 x 24 image</param>
        /// <param name="image32">32 x 32 image</param>
        /// <remarks>Null may be passed if no image is available, but at least one
        /// image must be non-null</remarks>
        public static void RegisterImage(string id, Image image16, Image image24, Image image32)
        {
            Image bestImage = null;

            if (image16 != null)
            {
                image16 = GdiUtil.ResizeImage(image16, 16);
                s_images16.Images.Add(id, image16);
                bestImage = image16;
            }

            if (image24 != null)
            {
                image24 = GdiUtil.ResizeImage(image24, 24);
                s_images24.Images.Add(id, image24);
                bestImage = image24;
            }

            if (image32 != null)
            {
                image32 = GdiUtil.ResizeImage(image32, 32);
                s_images32.Images.Add(id, image32);
                bestImage = image32;
            }

            if (bestImage == null)
            {
                throw new ArgumentNullException("at least one image must be non-null");
            }

            s_images[id] = bestImage;
        }
Beispiel #2
0
        /// <summary>
        /// Gets a registered 32 x 32 image, given an ID</summary>
        /// <param name="id">Image identifier</param>
        /// <returns>Registered image, or scaled image, or null if not found</returns>
        public static Image GetImage32(string id)
        {
            Image image = s_images32.Images[id];

            if (image == null)
            {
                image = GetImage(id);
                if (image != null)
                {
                    image = GdiUtil.ResizeImage(image, 32);
                }
            }
            return(image);
        }
Beispiel #3
0
        /// <summary>
        /// Gets a registered 32 x 32 image, given an ID</summary>
        /// <param name="id">Image identifier</param>
        /// <returns>Registered image, or scaled image, or null if not found</returns>
        public static Image GetImage32(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("Image id is null. Call Sce.Atf.WinForms.Resources.Register() to force registration of image resources.");
            }

            Image image = s_images32.Images[id];

            if (image == null)
            {
                image = GetImage(id);
                if (image != null)
                {
                    image = GdiUtil.ResizeImage(image, 32);
                }
            }
            return(image);
        }