diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-07-21 18:10:05 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-07-21 18:10:05 +0100 |
| commit | 10dce4105839265a835ecd99b656616a2335e314 (patch) | |
| tree | a696d830d487f930ca2b400742902203167fa5f3 | |
| parent | 55e49fdaad9835c489d687736b3de0857d9c7a34 (diff) | |
| download | histacom2-10dce4105839265a835ecd99b656616a2335e314.tar.gz histacom2-10dce4105839265a835ecd99b656616a2335e314.tar.bz2 histacom2-10dce4105839265a835ecd99b656616a2335e314.zip | |
Made the File Explorer open EXE files
Not real ones though
| -rw-r--r-- | TimeHACK.Engine/FileAssociation.cs | 50 | ||||
| -rw-r--r-- | TimeHACK.Engine/SaveSystem.cs | 8 | ||||
| -rw-r--r-- | TimeHACK.Engine/TimeHACK.Engine.csproj | 1 | ||||
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95Apps/IE4Sites/IE4NoPage.resx | 2 | ||||
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs | 116 |
5 files changed, 63 insertions, 114 deletions
diff --git a/TimeHACK.Engine/FileAssociation.cs b/TimeHACK.Engine/FileAssociation.cs deleted file mode 100644 index 25fe895..0000000 --- a/TimeHACK.Engine/FileAssociation.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; -using Microsoft.Win32; - -namespace TimeHACK.Engine -{ - public class FileAssociation - { - // Associate file extension with progID, description, icon and application - public static void Associate(string extension, - string progID, string description, string icon, string application) - { - Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID); - if (progID != null && progID.Length > 0) - using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID)) - { - if (description != null) - key.SetValue("", description); - if (icon != null) - key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(icon)); - if (application != null) - key.CreateSubKey(@"Shell\Open\Command").SetValue("", - ToShortPathName(application) + " \"%1\""); - } - } - - // Return true if extension already associated in registry - public static bool IsAssociated(string extension) - { - return (Registry.ClassesRoot.OpenSubKey(extension, false) != null); - } - - [DllImport("Kernel32.dll")] - private static extern uint GetShortPathName(string lpszLongPath, - [Out] StringBuilder lpszShortPath, uint cchBuffer); - - // Return short path format of a file name - private static string ToShortPathName(string longName) - { - StringBuilder s = new StringBuilder(1000); - uint iSize = (uint)s.Capacity; - uint iRet = GetShortPathName(longName, s, iSize); - return s.ToString(); - } - } -} diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index cd8bb2f..6450fcb 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -15,8 +15,6 @@ namespace TimeHACK.Engine public static FileSystemFolderInfo filesystemflinfo { get; set; } public static bool DevMode = false; - public static FileAssociation IconChanger = new FileAssociation(); - public static Theme currentTheme { get; set; } public static string GameDirectory @@ -161,7 +159,7 @@ namespace TimeHACK.Engine Directory.CreateDirectory(ProfileFileSystemDirectory); SaveDirectoryInfo(ProfileFileSystemDirectory, false, "My Computer", false); - SaveDirectoryInfo(ProfileMyComputerDirectory, false, "Win95", true); + SaveDirectoryInfo(ProfileMyComputerDirectory, false, "Win95 (C:)", true); if (CurrentSave.CurrentOS == "95") SaveDirectoryInfo(ProfileDocumentsDirectory, false, "My Documents", true); if (CurrentSave.CurrentOS != "95") SaveDirectoryInfo(ProfileSettingsDirectory, false, "Documents and Settings", true); SaveDirectoryInfo(ProfileProgramsDirectory, true, "Program Files", true); @@ -179,8 +177,8 @@ namespace TimeHACK.Engine SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Help"), true, "Help", true); SaveDirectoryInfo(Path.Combine(ProfileWindowsDirectory, "Temp"), true, "Temp", true); - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "calc.exe"), "Calculator"); - CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "windowsexplorer"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "calc.exe"), "calc"); + CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "explorer.exe"), "explorer"); } public static void CreateWindowsFile(string filepath, string contents) diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj index 64867d5..a2352c2 100644 --- a/TimeHACK.Engine/TimeHACK.Engine.csproj +++ b/TimeHACK.Engine/TimeHACK.Engine.csproj @@ -48,7 +48,6 @@ <Compile Include="BSODCreator.cs" /> <None Include="packages.config" /> <None Include="Resources\WinClassic\Window\pjBg6mKP.bin" /> - <Compile Include="FileAssociation.cs" /> <Compile Include="FileDialogBoxManager.cs" /> <Compile Include="Paintbrush.cs" /> <Compile Include="SaveSystem.cs" /> diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/IE4Sites/IE4NoPage.resx b/TimeHACK.Main/OS/Win95/Win95Apps/IE4Sites/IE4NoPage.resx index a167a19..5f61137 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/IE4Sites/IE4NoPage.resx +++ b/TimeHACK.Main/OS/Win95/Win95Apps/IE4Sites/IE4NoPage.resx @@ -117,7 +117,7 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <data name="String1" xml:space="preserve"> + <data name="string1" xml:space="preserve"> <value>testy</value> </data> </root>
\ No newline at end of file diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs index 3d7a5b3..8a57563 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicWindowsExplorer.cs @@ -81,37 +81,39 @@ namespace TimeHACK.OS.Win95.Win95Apps string label = ReadDataFile(str, false); if (label == "") { - this.mainView.Items.Add(Path.GetFileName(str)); - this.mainView.FindItemWithText(Path.GetFileName(str)).Tag = Path.GetFileName(str); + ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str)); + itm.ImageKey = str; } else { - this.mainView.Items.Add(label); - this.mainView.FindItemWithText(label).Tag = Path.GetFileName(str); + ListViewItem itm = this.mainView.Items.Add(label); + itm.ImageKey = str; } } foreach (string str in Directory.GetFiles(currentDirectory)) { - // Get app Icon + // Get the app Icon - int AppIcon = 2; + //int AppIcon = 2; - switch (new FileInfo(str).Extension) - { - case ".exe": - string contents; + //switch (new FileInfo(str).Extension) + //{ + // case ".exe": + // string contents; + + // contents = File.ReadAllText(str); + + // switch (contents.ToLower()) + // { + // case "calc": + // AppIcon = 3; + // break; + // case "explorer": + // AppIcon = 4; + // break; + // } + // break; + //} - contents = File.ReadAllText(str); - switch (contents.ToLower()) - { - case "calculator": - AppIcon = 3; - break; - case "windowsexplorer": - AppIcon = 4; - break; - } - break; - } if (IsFileOpenDialog == true || IsFileSaveDialog == true) { @@ -119,12 +121,14 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (new FileInfo(str).Extension == onlyViewExtension) { - this.mainView.Items.Add(Path.GetFileName(str)); + ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str)); + itm.Tag = str; } } } else { if (!(Path.GetFileName(str) == "_data.info")) { - this.mainView.Items.Add(Path.GetFileName(str)); + ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str)); + itm.Tag = str; } } } @@ -134,23 +138,23 @@ namespace TimeHACK.OS.Win95.Win95Apps } } - void OpenFile(String filedir) + void OpenFile(string fileDir) { try { - ReturnType(new FileInfo(filedir).Extension); + ReturnType(new FileInfo(fileDir).Extension); switch (fileType) { case 1: WinClassicNotepad np = new WinClassicNotepad(); - np.mainText.Text = FileDialogBoxManager.ReadTextFile(filedir); + np.mainText.Text = FileDialogBoxManager.ReadTextFile(fileDir); WinClassic app = wm.StartWin95(np, "Notepad", Properties.Resources.Win95IconNotepad, true, true); Program.AddTaskbarItem(app, app.Tag.ToString(), "Notepad", Properties.Resources.Win95IconNotepad); break; case 12: - OpenApplication(FileDialogBoxManager.ReadTextFile(filedir)); + OpenApplication(FileDialogBoxManager.ReadTextFile(fileDir)); break; } } catch { @@ -158,18 +162,19 @@ namespace TimeHACK.OS.Win95.Win95Apps } - void OpenApplication(String appname) + void OpenApplication(string appname) { switch (appname.ToLower()) - { - case "windowsexplorer": - WinClassicWindowsExplorer we = new WinClassicWindowsExplorer(); - Engine.Template.WinClassic app = wm.StartWin95(we, "Windows Explorer", Properties.Resources.Win95Computer, true, true); - Program.AddTaskbarItem(app, app.Tag.ToString(), "Windows Explorer", Properties.Resources.Win95Computer); + { + case "explorer": + Engine.Template.WinClassic app = wm.StartWin95(new WinClassicWindowsExplorer(), "Windows Explorer", Properties.Resources.WinClassicFileExplorer, true, true); + Program.AddTaskbarItem(app, app.Tag.ToString(), "Windows Explorer", Properties.Resources.WinClassicFileExplorer); break; - case "calculator": - throw new NotImplementedException(); + case "calc": + Engine.Template.WinClassic appCalc = wm.StartWin95(new WinClassicCalculator(), "Windows Explorer", Properties.Resources.WinClassicCalc, true, true); + Program.AddTaskbarItem(appCalc, appCalc.Tag.ToString(), "Windows Explorer", Properties.Resources.WinClassicCalc); + break; } } @@ -489,13 +494,15 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (folder.GetDirectories().Length > 0) { + string label = ReadDataFile(folder.FullName, false); TreeNode[] tn = createSubDirNodes(folder); - folders[loc] = new TreeNode(folder.Name, 2, 3, tn); + folders[loc] = new TreeNode(label ?? folder.Name, 2, 3, tn); folders[loc].Tag = folder.FullName; } else { - folders[loc] = new TreeNode(folder.Name, 2, 3); + string label = ReadDataFile(folder.FullName, false); + folders[loc] = new TreeNode(label ?? folder.Name, 2, 3); folders[loc].Tag = folder.FullName; } loc++; @@ -546,23 +553,17 @@ namespace TimeHACK.OS.Win95.Win95Apps { try { - if ((string)mainView.FocusedItem.Tag != "") + if (mainView.FocusedItem.Tag == null) { // If it isn't a file - GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag); + GoToDir(Path.Combine(currentDirectory, mainView.FocusedItem.ImageKey.ToString())); } else { // If it is a file - if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension) - { - Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text; - } - else - { // If it is a file if (IsFileOpenDialog == true || IsFileSaveDialog == true) { if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension) { - Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text; + Program.WindowsExplorerReturnPath = Path.Combine(currentDirectory, txtSave.Text); } @@ -573,12 +574,11 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - OpenFile((String)mainView.FocusedItem.Tag); + OpenFile((string)mainView.FocusedItem.Tag); } - } } - } catch { - + } catch (Exception ex) { + MessageBox.Show(ex.Message); } } @@ -641,9 +641,9 @@ namespace TimeHACK.OS.Win95.Win95Apps bool OpenFile = false; if (mainView.FocusedItem != null) { - if ((string)mainView.FocusedItem.Tag != "") + if ((string)mainView.FocusedItem.Tag == "") { // If it isn't a file - GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag); + GoToDir(Path.Combine(currentDirectory, mainView.FocusedItem.Tag.ToString())); } else OpenFile = true; // If it is a file } @@ -656,10 +656,10 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - if (new FileInfo(currentDirectory + "\\" + txtSave.Text).Extension == onlyViewExtension) + if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension) { - Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text; + Program.WindowsExplorerReturnPath = Path.Combine(currentDirectory, txtSave.Text); } @@ -752,13 +752,15 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (fold.GetDirectories().Length > 0) { + string label = ReadDataFile(fold.FullName, false); TreeNode[] tn = createSubDirNodes(fold); - toReturn[loc] = new TreeNode(fold.Name, 2, 3, tn); + toReturn[loc] = new TreeNode(label ?? fold.Name, 2, 3, tn); toReturn[loc].Tag = fold.FullName; } else { - toReturn[loc] = new TreeNode(fold.Name, 2, 3); + string label = ReadDataFile(fold.FullName, false); + toReturn[loc] = new TreeNode(label ?? fold.Name, 2, 3); toReturn[loc].Tag = fold.FullName; } loc++; |
