diff options
| author | Michael VanOverbeek <[email protected]> | 2016-04-09 13:16:39 -0400 |
|---|---|---|
| committer | Michael VanOverbeek <[email protected]> | 2016-04-09 13:16:39 -0400 |
| commit | 14edb9eade65806b531e51a0ed1fba7c62ba848e (patch) | |
| tree | b8a0124d66ca9d414870a27de103e7be9a748081 /source/WindowsFormsApplication1/OSInfo.cs | |
| parent | cfb8690c6fbbb0595f8a3a4cd9f3210054a9680d (diff) | |
| download | shiftos-c--14edb9eade65806b531e51a0ed1fba7c62ba848e.tar.gz shiftos-c--14edb9eade65806b531e51a0ed1fba7c62ba848e.tar.bz2 shiftos-c--14edb9eade65806b531e51a0ed1fba7c62ba848e.zip | |
Uploaded source code for ShiftOS 0.1.1 Beta 2.3
Initial commit of repository.
Diffstat (limited to 'source/WindowsFormsApplication1/OSInfo.cs')
| -rw-r--r-- | source/WindowsFormsApplication1/OSInfo.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/source/WindowsFormsApplication1/OSInfo.cs b/source/WindowsFormsApplication1/OSInfo.cs new file mode 100644 index 0000000..53e51dc --- /dev/null +++ b/source/WindowsFormsApplication1/OSInfo.cs @@ -0,0 +1,72 @@ +using System; + +namespace ShiftOS +{ + public class OSInfo + { + + /// <summary> + /// System directory separator charactor. + /// </summary> + public static string DirectorySeparator + { + get + { + switch(GetPlatformID()) + { + case "microsoft": + return "\\"; + default: + return "/"; + } + } + } + + /// <summary> + /// Selects a default, monospace font name from the OS. This is typically used for creating ingame terminals. + /// </summary> + /// <returns>The monospace font.</returns> + public static string GetMonospaceFont() { + string fname = null; + switch (GetPlatformID ()) { + case "microsoft": + fname = "Lucida Console"; + break; + case "unix": + fname = "Monospace"; + break; + case "macosx": + fname = "Menlo"; + break; + } + return fname; + } + + /// <summary> + /// This refers to the Home directory of the current user. For example, if the user's name is 'Michael', and the user is on Windows Vista/7/8/10, this value would be 'C:\Users\Michael'. + /// </summary> + public static string homePath () + { + return (Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == PlatformID.MacOSX) + ? Environment.GetEnvironmentVariable ("HOME") + : Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%"); + } + + /// <summary> + /// Is it Linux? Is it Mac OS? Did Microsoft make it? + /// </summary> + /// <returns>The platform ID.</returns> + public static string GetPlatformID() { + switch (Environment.OSVersion.Platform) { + case PlatformID.Unix: + return "unix"; + case PlatformID.MacOSX: + return "macosx"; + default: + return "microsoft"; + } + } + } +} + |
