-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzurag.cs
62 lines (53 loc) · 1.95 KB
/
zurag.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace FileExplorer
{
class zurag
{
private Dictionary<string, int> iconCashe = new Dictionary<string, int>();
private int reserveRange = 4;
public int GetIconIndexByExtention(string extention)
{
List<string> extentions = iconCashe.Keys.ToList<string>();
if (extention == null || extention.Length == 0 || extention == ".exe" || extentions.IndexOf(extention) == -1)
{
return -1;
}
return iconCashe[extention];
}
public int AddIconForFile(FileInfo file, ImageList smallIconList, ImageList largeIconList)
{
string fileExtention = file.Extension.ToLower();
Icon fileIcon = Icon.ExtractAssociatedIcon(file.FullName);
if (fileIcon == null)
{
return 0;
}
smallIconList.Images.Add(fileIcon);
largeIconList.Images.Add(fileIcon);
if (fileExtention != ".exe" && fileExtention.Length != 0)
{
iconCashe.Add(fileExtention, smallIconList.Images.Count - 1);
}
return smallIconList.Images.Count - 1;
}
public void ClearIconCashAndLists(ImageList smallIconList, ImageList largeIconList)
{
iconCashe.Clear();
for (int i = reserveRange; i < smallIconList.Images.Count; i++)
{
smallIconList.Images.RemoveAt(i);
largeIconList.Images.RemoveAt(i);
}
}
}
}