forked from Gericom/EveryFileExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EveryFileExplorerUtil.cs
86 lines (77 loc) · 2.24 KB
/
EveryFileExplorerUtil.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using LibEveryFileExplorer.Files;
using System.Runtime.InteropServices;
namespace LibEveryFileExplorer
{
public class EveryFileExplorerUtil
{
public static dynamic Program = ((dynamic)new LibEveryFileExplorer.StaticDynamic(System.Reflection.Assembly.GetEntryAssembly().GetType("EveryFileExplorer.Program")));
public static void DisableFileDependencyDialog()
{
Program.FileManager.DisableFileDependencyDialog();
}
public static String[] GetFileCategories()
{
List<String> s = new List<string>();
foreach (dynamic p in Program.PluginManager.Plugins)
{
foreach (Type t in p.FileFormatTypes)
{
dynamic q = new StaticDynamic(t);
String v = q.Identifier.GetCategory();
if (!s.Contains(v)) s.Add(v);
}
}
s.Sort();
s.Insert(0, "Folders");
return s.ToArray();
}
public static Dictionary<String, Bitmap> GetFileIcons()
{
Dictionary<String, Bitmap> s = new Dictionary<string,Bitmap>();
foreach (dynamic p in Program.PluginManager.Plugins)
{
foreach (Type t in p.FileFormatTypes)
{
dynamic q = new StaticDynamic(t);
Bitmap v = q.Identifier.GetIcon();
if (v != null) s.Add(t.ToString(), v);
}
}
return s;
}
public static ListViewItem GetFileItem(EFEFile File)
{
Type[] formats = Program.FileManager.GetPossibleFormats(File);
ListViewItem i = new ListViewItem(File.Name);
StringBuilder b = new StringBuilder(50);
Win32Util.StrFormatByteSize(File.Data.Length, b, 50);
i.SubItems.Add(b.ToString());
if (formats.Length == 1)
{
i.ImageKey = formats[0].ToString();
dynamic q = new StaticDynamic(formats[0]);
i.Tag = q.Identifier.GetCategory();
}
if (File.IsCompressed) i.ForeColor = Color.Blue;
return i;
}
public static void OpenFile(EFEFile File, EFEFile Parent = null)
{
Program.FileManager.OpenFile(File, Parent);
}
public static ViewableFile[] GetOpenFilesOfType(Type FileType)
{
return Program.FileManager.GetOpenFilesOfType(FileType);
}
public static ViewableFile GetViewableFileFromFile(EFEFile File)
{
return Program.FileManager.GetViewableFileFromFile(File);
}
}
}