Exemplo n.º 1
0
        /// <summary>
        /// Gets an image from the given resource.
        /// </summary>
        /// <param name="asm"></param>
        /// <param name="resourceName"></param>
        /// <returns></returns>
        public int GetImageIndex(Assembly asm, string resourceName)
        {
            if (resourceName == null)
            {
                throw new ArgumentNullException("resourceName");
            }
            if (resourceName.Length == 0)
            {
                throw new ArgumentOutOfRangeException("'resourceName' is zero-length.");
            }

            // check...
            if (asm == null)
            {
                asm = DefaultAssembly;
                if (asm == null)
                {
                    throw new InvalidOperationException("asm is null.");
                }
            }

            // do we have it?
            ImagesForAssemblyLookup lookup = (ImagesForAssemblyLookup)AssemblyLookup[asm];

            if (lookup == null)
            {
                throw new InvalidOperationException("lookup is null.");
            }

            // get...
            return((int)lookup[resourceName]);
        }
Exemplo n.º 2
0
        private void _assemblyLookup_CreateItemValue(object sender, CreateLookupItemEventArgs e)
        {
            ImagesForAssemblyLookup newLookup = new ImagesForAssemblyLookup((Assembly)e.Key);

            newLookup.CreateItemValue += new CreateLookupItemEventHandler(newLookup_CreateItemValue);

            // return...
            e.NewValue = newLookup;
        }