示例#1
0
        /// <summary>
        /// Returns the Icon of the specified size from the Cache.
        /// </summary>
        /// <param name="AFileName">File name of the Icon incl. full path</param>
        /// <param name="AIconSize">Desired size of the Icon to be returned (should
        /// this size not be availabe then the closest match will be returned).</param>
        /// <returns>Icon of the specified size or the closest matching size.</returns>
        public Bitmap GetIcon(string AFileName, TIconSize AIconSize)
        {
            Icon TheItem;

            if (AFileName == null)
            {
                return(null);
            }
            else
            {
                AFileName = Path.GetFullPath(AFileName.Replace('\\', '/'));

                try
                {
                    TheItem = (Icon)this[AFileName + AIconSize.ToString()];
                }
                catch (KeyNotFoundException)
                {
                    FLastIconRequestedWasReturnedFromCache = false;

                    throw new EIconNotInCacheException(String.Format(
                                                           "Icon with path {0} not yet loaded into cache; add it to the cache with AddIcon Method first", AFileName));
                }

                FLastIconRequestedWasReturnedFromCache = true;

                return(TheItem.ToBitmap());
            }
        }
示例#2
0
        private void ChangeState(object sender, EventArgs e)
        {
            var rnd   = new Random();
            var index = rnd.Next(0, 3);

            if (index == 0)
            {
                TheItem.LayoutTo(FirstState.Bounds);
            }
            if (index == 1)
            {
                TheItem.LayoutTo(SecondState.Bounds);
            }

            if (index == 2)
            {
                TheItem.LayoutTo(ThirdState.Bounds);
            }
        }