forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.cs
134 lines (117 loc) · 4.24 KB
/
Global.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using System.IO;
using Eto.Drawing;
using Eto.Forms;
namespace MonoGame.Tools.Pipeline
{
static partial class Global
{
public static bool Linux { get; private set; }
public static bool UseHeaderBar { get; private set; }
public static bool Unix { get; private set; }
static Global()
{
Unix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX;
PlatformInit();
}
public static string NotAllowedCharacters
{
get
{
if (Global.Unix)
return Global.Linux ? "/" : ":";
return "/?<>\\:*|\"";
}
}
public static bool CheckString(string s)
{
var notAllowed = Path.GetInvalidFileNameChars();
for (int i = 0; i < notAllowed.Length; i++)
if (s.Contains(notAllowed[i].ToString()))
return false;
return true;
}
public static void ShowOpenWithDialog(string filePath)
{
try
{
PlatformShowOpenWithDialog(filePath);
}
catch
{
MainWindow.Instance.ShowError("Error", "The current platform does not have this dialog implemented.");
}
}
public static Image GetDirectoryIcon(bool exists)
{
try
{
return PlatformGetDirectoryIcon(exists);
}
catch { }
return exists ? Bitmap.FromResource("TreeView.Folder.png") : Bitmap.FromResource("TreeView.FolderMissing.png");
}
public static Image GetFileIcon(string path, bool exists)
{
try
{
return PlatformGetFileIcon(path, exists);
}
catch { }
return exists ? Bitmap.FromResource("TreeView.File.png") : Bitmap.FromResource("TreeView.FileMissing.png");
}
public static void SetIcon(Command cmd)
{
if (PlatformSetIcon(cmd))
return;
switch (cmd.MenuText)
{
case "New...":
cmd.Image = Icon.FromResource("Toolbar.New.png");
break;
case "Open...":
cmd.Image = Icon.FromResource("Toolbar.Open.png");
break;
case "Save...":
cmd.Image = Icon.FromResource("Toolbar.Save.png");
break;
case "Undo":
cmd.Image = Icon.FromResource("Toolbar.Undo.png");
break;
case "Redo":
cmd.Image = Icon.FromResource("Toolbar.Redo.png");
break;
case "New Item...":
cmd.Image = Icon.FromResource("Toolbar.NewItem.png");
break;
case "New Folder...":
cmd.Image = Icon.FromResource("Toolbar.NewFolder.png");
break;
case "Existing Item...":
cmd.Image = Icon.FromResource("Toolbar.ExistingItem.png");
break;
case "Existing Folder...":
cmd.Image = Icon.FromResource("Toolbar.ExistingFolder.png");
break;
case "Build":
cmd.Image = Icon.FromResource("Toolbar.Build.png");
break;
case "Rebuild":
cmd.Image = Icon.FromResource("Toolbar.Rebuild.png");
break;
case "Cancel Build":
cmd.Image = Icon.FromResource("Toolbar.CancelBuild.png");
break;
case "Clean":
cmd.Image = Icon.FromResource("Toolbar.Clean.png");
break;
case "Filter Output":
cmd.Image = Icon.FromResource("Toolbar.FilterOutput.png");
break;
}
}
}
}