Example #1
0
        /// <summary>
        /// Second method associated with the item.
        /// It retrieves:
        ///	    file size,
        ///	    file creation date.
        /// </summary>
        /// <returns>true if succeded; otherwise, false.</returns>
        private bool EvalMethod1()
        {
            long fileSize = 0;
            long fileTime = 0;

            if (FileInfoRetriever.RetrieveFileSizeAndTime(_pidl, ref fileSize, ref fileTime))
            {
                fileSize = (long)System.Math.Ceiling((double)fileSize / 1024);
                string          strFileSize  = fileSize.ToString(System.Globalization.CultureInfo.CurrentCulture);
                System.DateTime creationTime = System.DateTime.FromFileTime(fileTime);

                string strFileTime = creationTime.ToShortDateString();
                lock (this)
                {
                    if (this.Texts[ThumbnailListItem.TextInfoIdFileSize] == null)
                    {
                        string strFileSizeFull = string.Empty;
                        if (_pidl.Type != PidlType.Folder)
                        {
                            strFileSizeFull = strFileSize + " " + _kilobytesText;
                        }
                        this.Texts.Add(ThumbnailListItem.TextInfoIdFileSize, strFileSizeFull);
                    }
                    if (this.Texts[ThumbnailListItem.TextInfoIdCreationDate] == null)
                    {
                        this.Texts.Add(ThumbnailListItem.TextInfoIdCreationDate, strFileTime);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// Third method associated with the item. It retrieves file thumbnail.
        /// </summary>
        /// <returns>true if succeded; otherwise, false.</returns>
        private bool EvalMethod2()
        {
            if (this.Parent == null)
            {
                return(false);
            }

            Aurigma.GraphicsMill.Bitmap image = null;
            System.IntPtr icon = System.IntPtr.Zero;

            try
            {
                if (this.Parent != null)
                {
                    ThumbnailImageList imageList = (ThumbnailImageList)this.Parent.GetImageList(View.Thumbnails);
                    FileInfoRetriever.RetrieveThumbnail(_pidl, imageList.ThumbnailSize.Width, imageList.ThumbnailSize.Height, ref image, ref icon);
                    if (image == null && icon != System.IntPtr.Zero)
                    {
                        image = ImageListBase.IconToAlphaBitmap(icon);
                    }

                    OnThumbnailLoaded(image);

                    lock (imageList)
                    {
                        lock (this)
                        {
                            _imageIndexKeys[View.Thumbnails] = this;

                            if (this.Parent != null)
                            {
                                _imageIndexKeys[View.Thumbnails] = this;
                                if (imageList.ContainsKey(this))
                                {
                                    imageList.SetImage(image, this);
                                }
                                else
                                {
                                    imageList.AddImage(image, this);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (image != null)
                {
                    image.Dispose();
                }

                NativeMethods.DestroyIcon(icon);
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// First method associated with the item.
        /// It retrieves:
        ///    object's display name,
        ///    object's type,
        ///    object's small icon index,
        ///    object's small icon handle,
        ///    object's large icon index,
        ///    object's large icon handle.
        /// </summary>
        /// <returns>true if succeded; otherwise, false.</returns>
        private bool EvalMethod0()
        {
            if (this.Parent == null)
            {
                return(false);
            }

            string displayName    = string.Empty;
            string type           = string.Empty;
            int    iconIndexSmall = -1;
            int    iconIndexLarge = -1;

            System.IntPtr iconSmall = System.IntPtr.Zero;
            System.IntPtr iconLarge = System.IntPtr.Zero;

            if (FileInfoRetriever.RetrieveFileInfo(_pidl, ref displayName, ref type, ref iconIndexSmall, ref iconSmall, ref iconIndexLarge, ref iconLarge) && this.Parent != null)
            {
                IImageList listImageList = this.Parent.GetImageList(View.List);
                IImageList iconImageList = this.Parent.GetImageList(View.Icons);

                if (listImageList != null)
                {
                    System.Threading.Monitor.Enter(listImageList);
                }

                try
                {
                    if (iconImageList != null)
                    {
                        System.Threading.Monitor.Enter(iconImageList);
                    }

                    try
                    {
                        lock (this)
                        {
                            try
                            {
                                // Saving display name
                                this.Texts[ThumbnailListItem.TextInfoIdDisplayName] = displayName;

                                // Saving file type
                                this.Texts[ThumbnailListItem.TextInfoIdFileType] = type;

                                if (this.Parent != null)
                                {
                                    // Adding small icon to control ImageList (for List & Details view)
                                    string indexKey = iconIndexSmall.ToString();
                                    _imageIndexKeys[View.List] = indexKey;
                                    listImageList.AddImage(iconSmall, indexKey);
                                    _imageIndexKeys[View.Details] = indexKey;

                                    // Adding large icon to control ImageList (for Icon view)
                                    indexKey = iconIndexLarge.ToString();
                                    iconImageList.AddImage(iconLarge, indexKey);
                                    _imageIndexKeys[View.Icons] = indexKey;
                                }
                            }
                            finally
                            {
                                NativeMethods.DestroyIcon(iconSmall);
                                NativeMethods.DestroyIcon(iconLarge);
                            }
                        }
                    }
                    finally
                    {
                        if (iconImageList != null)
                        {
                            System.Threading.Monitor.Exit(iconImageList);
                        }
                    }
                }
                finally
                {
                    if (listImageList != null)
                    {
                        System.Threading.Monitor.Exit(listImageList);
                    }
                }

                return(true);
            }

            return(false);
        }