diff options
| author | Jason <[email protected]> | 2017-07-23 20:35:08 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-07-23 20:35:08 +0200 |
| commit | a852b2c7f2bb372a89e78e805298c33c00ebe924 (patch) | |
| tree | 946806e40f8c7c377cde81bcd79b525d2edd687f /TimeHACK.Engine/DesktopController.cs | |
| parent | d42569b3e37e0a03835c7965d67cdf19e14ad4ba (diff) | |
| parent | eea369f5b5f8883b99a8371036cb09c3dd7ca774 (diff) | |
| download | histacom2-a852b2c7f2bb372a89e78e805298c33c00ebe924.tar.gz histacom2-a852b2c7f2bb372a89e78e805298c33c00ebe924.tar.bz2 histacom2-a852b2c7f2bb372a89e78e805298c33c00ebe924.zip | |
Merge pull request #136 from Alex-TIMEHACK/master
Realistic Desktop
Diffstat (limited to 'TimeHACK.Engine/DesktopController.cs')
| -rw-r--r-- | TimeHACK.Engine/DesktopController.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/TimeHACK.Engine/DesktopController.cs b/TimeHACK.Engine/DesktopController.cs new file mode 100644 index 0000000..f507ab8 --- /dev/null +++ b/TimeHACK.Engine/DesktopController.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; +using Newtonsoft.Json; + +namespace TimeHACK.Engine +{ + public static class DesktopController + { + public static string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) + { + string Val = ""; + string directoryFileInfo; + directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info")); + FileSystemFolderInfo toRead = new FileSystemFolderInfo(); + toRead = JsonConvert.DeserializeObject<FileSystemFolderInfo>(directoryFileInfo); + + if (returnYesIfProtected == true) + { + if (toRead.Isprotected == true) + { + return "yes"; + } + } + else + { + return toRead.label; + } + return Val; + } + + public static void RefreshDesktopIcons(ListViewItem[] baseIcons, ref ListView theView, string theDirectory) + { + theView.Items.Clear(); // This resets it to it's default + theView.Items.AddRange(baseIcons); + + foreach (string dir in Directory.GetDirectories(theDirectory)) + { + string label = ReadDataFile(dir); + theView.Items.Add(label ?? Path.GetFileName(dir), 1); + theView.FindItemWithText(Path.GetFileName(dir)).Tag = dir; + } + + foreach (string dir in Directory.GetFiles(theDirectory)) + { + if (Path.GetFileName(dir) != "_data.info") + { + int appIcon = 12; + + if (new FileInfo(dir).Extension == ".exe") appIcon = 8; + + theView.Items.Add(Path.GetFileName(dir), appIcon); + theView.FindItemWithText(Path.GetFileName(dir)).Tag = dir; + } + } + } + } +} |
