Beispiel #1
0
        public System.Drawing.Image GetLargeImage(Core.IO.FileSystemInfo file)
        {
            /*String cacheDir = System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.APK_IMAGE_CACHE);
             *
             *      AaptBrandingCommandResult result = CommandRunner.Instance.GetApkInformationFromLocalCache(item.FullPath, cacheDir);
             *      lvi = new ApkFileSystemInfoListViewItem(item, result);
             *
             *      keyName = lvi.FileSystemInfo.FullPath;
             *      if(keyName.StartsWith("/")) {
             *              keyName = keyName.Substring(1);
             *      }
             *      keyName = keyName.Replace("/", ".");
             *
             *      if(!SystemImageListHost.Instance.SystemIcons.ContainsKey(keyName)) {
             *              // get apk and extract the app icon
             *              Image img = CommandRunner.Instance.GetApkIconImageFromCache(lvi.FileSystemInfo.FullPath, cacheDir);
             *
             *              if(img == null) {
             *                      img = DroidExplorer.Resources.Images.apk32;
             *              }
             *              SystemImageListHost.Instance.AddFileTypeImage(keyName, img, img);
             *      }
             *
             *      if(this.InvokeRequired) {
             *              this.Invoke(new SetListViewItemImageIndexDelegate(this.SetListViewItemImageIndex), new object[] { lvi, Program.SystemIcons[keyName] });
             *      } else {
             *              SetListViewItemImageIndex(lvi, Program.SystemIcons[keyName]);
             *      }
             */



            var key = GetKeyName(file);

            if (!Cache.Exists(Cache.APK_IMAGE_CACHE, key))
            {
                var img = CommandRunner.Instance.GetApkIconImage(file.FullPath);
                if (img == null)
                {
                    return(DefaultLargeImage);
                }
                var path      = Cache.GetPath(Cache.APK_IMAGE_CACHE);
                var cacheFile = Cache.Save(System.IO.Path.Combine(path, key), img);
                return(Image.FromFile(cacheFile.FullName).Resize(32, 32));
            }
            else
            {
                return(System.Drawing.Image.FromFile(Cache.Get(Cache.APK_IMAGE_CACHE, key).FullName));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the large image.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <returns></returns>
        public System.Drawing.Image GetLargeImage(Core.IO.FileSystemInfo file)
        {
            var key = GetKeyName(file);

            if (!Cache.Exists(Cache.ICON_IMAGE_CACHE, key))
            {
                var temp  = CommandRunner.Instance.PullFile(CommandRunner.Instance.DefaultDevice, file.FullPath);
                var cache = Cache.GetPath(Cache.ICON_IMAGE_CACHE);
                using (var img = System.Drawing.Image.FromFile(temp.FullName).Resize(32, 32)) {
                    img.Save(System.IO.Path.Combine(cache, temp.Name));
                }
                return(System.Drawing.Image.FromFile(System.IO.Path.Combine(cache, temp.Name)));
            }
            else
            {
                return(System.Drawing.Image.FromFile(Cache.Get(Cache.ICON_IMAGE_CACHE, key).FullName));
            }
        }
Beispiel #3
0
        public static string ToSafeFileName(this Core.IO.FileSystemInfo fsi)
        {
            var invalid = new string(System.IO.Path.GetInvalidFileNameChars());

            return(fsi.Name.REReplace("[{0}]".With(invalid), ""));
        }
Beispiel #4
0
 public string GetKeyName(Core.IO.FileSystemInfo file)
 {
     return(Cache.GetCacheKey(file));
 }
Beispiel #5
0
 public System.Drawing.Image GetSmallImage(Core.IO.FileSystemInfo file)
 {
     return(GetLargeImage(file).Resize(16, 16));
 }