From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Visual_Studio/Tango.FileSystem/FileItem.cs | 132 --------------------- 1 file changed, 132 deletions(-) delete mode 100644 Software/Visual_Studio/Tango.FileSystem/FileItem.cs (limited to 'Software/Visual_Studio/Tango.FileSystem/FileItem.cs') diff --git a/Software/Visual_Studio/Tango.FileSystem/FileItem.cs b/Software/Visual_Studio/Tango.FileSystem/FileItem.cs deleted file mode 100644 index cbc90ce06..000000000 --- a/Software/Visual_Studio/Tango.FileSystem/FileItem.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Interop; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using Tango.Core.IO; - -namespace Tango.FileSystem -{ - public class FileItem : FileSystemItem - { - private static Dictionary iconCache; - private static Dictionary smallIconCache; - private static Dictionary typeDescriptionCache; - - static FileItem() - { - iconCache = new Dictionary(); - smallIconCache = new Dictionary(); - typeDescriptionCache = new Dictionary(); - } - - public FileItem() - { - Type = FileSystemItemType.File; - } - - public String Extension - { - get { return System.IO.Path.GetExtension(Path); } - } - - private BitmapSource _icon; - public BitmapSource Icon - { - get - { - if (_icon == null) - { - _icon = GetFileIcon(); - } - - return _icon; - } - } - - private BitmapSource _smallIcon; - public BitmapSource SmallIcon - { - get - { - if (_smallIcon == null) - { - _smallIcon = GetSmallFileIcon(); - } - - return _smallIcon; - } - } - - public override string Description - { - get - { - if (typeDescriptionCache.ContainsKey(Extension)) - { - return typeDescriptionCache[Extension]; - } - else - { - var tempFile = TemporaryManager.Default.CreateFile(Extension); - var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); - var text = shellFile.Properties.System.ItemTypeText.Value.ToStringSafe(); - shellFile.Dispose(); - tempFile.Delete(); - typeDescriptionCache.Add(Extension, text); - return text; - } - } - } - - protected BitmapSource GetFileIcon() - { - if (iconCache.ContainsKey(Extension)) - { - return iconCache[Extension]; - } - else - { - var tempFile = TemporaryManager.Default.CreateFile(Extension); - var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); - var source = shellFile.Thumbnail.MediumBitmapSource; - shellFile.Dispose(); - tempFile.Delete(); - iconCache.Add(Extension, source); - return source; - } - } - - private BitmapSource GetSmallFileIcon() - { - if (smallIconCache.ContainsKey(Extension)) - { - return smallIconCache[Extension]; - } - else - { - var tempFile = TemporaryManager.Default.CreateFile(Extension); - var shellFile = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(tempFile); - var source = shellFile.Thumbnail.SmallBitmapSource; - shellFile.Dispose(); - tempFile.Delete(); - smallIconCache.Add(Extension, source); - return source; - } - } - - private BitmapSource IconToBitmapSource(Icon icon) - { - var imageSource = Imaging.CreateBitmapSourceFromHIcon( - icon.Handle, - Int32Rect.Empty, - BitmapSizeOptions.FromEmptyOptions()); - return imageSource; - } - } -} -- cgit v1.3.1