Esempio n. 1
0
        public void Load()
        {
            try
            {
                _asyncSource = ThumbnailGenerator.GenerateThumbnail(filename);
                _asyncSource.Freeze();

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate
                {
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs("AsyncSource"));
                    }

                    if (loaded != null)
                    {
                        loaded();
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.Error("An error has occured while trying to create an AsyncThumbnailImage. Filename = {0} Exception = {1}", LogSource.BackgroundTask, filename, ex);
            }
        }
        protected string GenerateThumbnail(ThumbnailGenerator generator, string originalFilePath,
            string imagesBasePath, string thumbnailName)
        {
            string thumbnailPathNoExtension = Path.Combine(imagesBasePath, thumbnailName);

            string fullThumbnailPath = generator.GenerateThumbnail(originalFilePath, thumbnailPathNoExtension);

            return Path.GetFileName(fullThumbnailPath);
        }
Esempio n. 3
0
 public void GetFileInfo(string Path)
 {
     if (!File.Exists(Path) && !Directory.Exists(Path))
     {
         this.Name                = this.Language.ErrorMessages.MissingInvalid + ": " + Path;
         this.Description         = this.Language.ErrorMessages.MissingInvalid + ": " + Path;
         this.RepresentativeImage = ImageResources.MissingIcon;
     }
     else
     {
         try
         {
             SHFileInfo sHFileInfo = default(SHFileInfo);
             Shell32API.SHGetFileInfo(Path, 0u, ref sHFileInfo, (uint)Marshal.SizeOf(sHFileInfo), (ShellGetFileInfoFlags)1536);
             this.Name                = sHFileInfo.szDisplayName;
             this.Description         = sHFileInfo.szTypeName;
             this.RepresentativeImage = null;
             try
             {
                 if (Environment.OSVersion.Version.Major < 6)
                 {
                     this.RepresentativeImage = this.GetThumbnail(Path);
                 }
                 if (this.RepresentativeImage == null)
                 {
                     this.RepresentativeImage = ThumbnailGenerator.GenerateThumbnail(Path);
                 }
                 if (this.RepresentativeImage == null)
                 {
                     this.RepresentativeImage = ImageListThumbnailGenerator.GetJumboLargeThumbnail(Path);
                 }
                 if (this.RepresentativeImage == null)
                 {
                     this.RepresentativeImage = ImageResources.MissingIcon;
                 }
             }
             catch (Exception)
             {
                 this.RepresentativeImage = ImageResources.MissingIcon;
             }
         }
         catch (Exception)
         {
             this.Name                = this.Language.ErrorMessages.MissingInvalid + ": " + Path;
             this.Description         = this.Language.ErrorMessages.MissingInvalid + ": " + Path;
             this.RepresentativeImage = ImageResources.MissingIcon;
         }
     }
 }