Beispiel #1
0
        private void LoadFileTypesIcons()
        {
            SmallIconImageList.Images.Add("folder", Properties.Resources.Folder_16x16);
            LargeIconImageList.Images.Add("folder", Properties.Resources.Folder_32x32);

            var commonExtensions = new string[] { ".xml", ".png", ".lxfml", ".unknown" };

            foreach (var fileExtension in commonExtensions)
            {
                var smallIcon = FileTypeInfoHelper.GetFileTypeIconSmall($"text{fileExtension}");
                var largeIcon = FileTypeInfoHelper.GetFileTypeIconLarge($"text{fileExtension}");
                SmallIconImageList.Images.Add(fileExtension.ToUpper(), smallIcon.ToBitmap());
                LargeIconImageList.Images.Add(fileExtension.ToUpper(), largeIcon.ToBitmap());
                smallIcon.Dispose();
                largeIcon.Dispose();
            }
        }
Beispiel #2
0
        private void SetFileTypeIcon(LifFileInfo fileInfo)
        {
            if (SmallIconImageList.Images.ContainsKey(fileInfo.FileType))
            {
                fileInfo.ItemImageKey = fileInfo.FileType;
                return;
            }

            if (UnknownFileExtensions.Contains(fileInfo.FileType))
            {
                fileInfo.ItemImageKey = ".UNKNOWN";
                return;
            }

            var smallIcon = FileTypeInfoHelper.GetFileTypeIconSmall($"text{fileInfo.FileType}", out bool isKnownExt);

            if (!isKnownExt)
            {
                UnknownFileExtensions.Add(fileInfo.FileType);
                smallIcon.Dispose();
                fileInfo.ItemImageKey = ".UNKNOWN";
                return;
            }

            var largeIcon = FileTypeInfoHelper.GetFileTypeIconLarge($"text{fileInfo.FileType}");

            SmallIconImageList.Images.Add(fileInfo.FileType, smallIcon.ToBitmap());
            LargeIconImageList.Images.Add(fileInfo.FileType, largeIcon.ToBitmap());
            smallIcon.Dispose();
            largeIcon.Dispose();

            FolderListView.SmallImageList = SmallIconImageList;
            FolderListView.LargeImageList = LargeIconImageList;

            fileInfo.ItemImageKey = fileInfo.FileType;
        }