Esempio n. 1
0
        /// <summary>
        /// Gets the item image.
        /// </summary>
        public Image GetImage()
        {
            if (!editing)
            {
                BeginEdit();
            }
            Image img = null;

            if (isVirtualItem)
            {
                VirtualItemImageEventArgs e = new VirtualItemImageEventArgs(mVirtualItemKey);
                mImageListView.RetrieveVirtualItemImageInternal(e);
                img = Image.FromFile(e.FileName);
            }
            else
            {
                try
                {
                    img = Image.FromFile(mFileName);
                }
                catch
                { }
            }
            if (!editing)
            {
                EndEdit();
            }
            return(img);
        }
 /// <summary>
 /// Starts editing a virtual item. While items are edited,
 /// their original images will be seperately cached
 /// instead of fetching them from the file.
 /// </summary>
 /// <param name="guid">The guid representing the item</param>
 public void BeginItemEdit(Guid guid)
 {
     lock (lockObject)
     {
         if (!editCache.ContainsKey(guid))
         {
             VirtualItemImageEventArgs e = new VirtualItemImageEventArgs(mImageListView.Items[guid].mVirtualItemKey);
             mImageListView.RetrieveVirtualItemImageInternal(e);
             if (!string.IsNullOrEmpty(e.FileName))
             {
                 editCache.Add(guid, Image.FromFile(e.FileName));
             }
         }
     }
 }