diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-07-22 11:57:13 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-07-22 11:57:13 +0100 |
| commit | 31c67063128fc0e5accf852bafd8aab7c7b6e37b (patch) | |
| tree | 6523293d48d50a915b8c85d22387025a281e88f6 /TimeHACK.Main/OS/Win95 | |
| parent | bc6a8c1ada9230cab511aa5bcc9bdfbf43956e7e (diff) | |
| download | histacom2-31c67063128fc0e5accf852bafd8aab7c7b6e37b.tar.gz histacom2-31c67063128fc0e5accf852bafd8aab7c7b6e37b.tar.bz2 histacom2-31c67063128fc0e5accf852bafd8aab7c7b6e37b.zip | |
Cleaned up some code!
Diffstat (limited to 'TimeHACK.Main/OS/Win95')
| -rw-r--r-- | TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs | 249 |
1 files changed, 121 insertions, 128 deletions
diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs index 1083975..a685fa6 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/Win95WindowsExplorer.cs @@ -22,8 +22,8 @@ namespace TimeHACK.OS.Win95.Win95Apps public string onlyViewExtension = ""; string ToReplaceWith = ProfileDirectory; - string currentDirectory = Path.Combine(ProfileDirectory, "folders", "Computer"); - string oldLabelText; + string CurrentDirectory = Path.Combine(ProfileDirectory, "folders", "Computer"); + string OldLabelText; int fileType = 6; //string attemptedDirectory = ""; WindowManager wm = new WindowManager(); @@ -33,18 +33,82 @@ namespace TimeHACK.OS.Win95.Win95Apps InitializeComponent(); } - //'Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) - //' mainView.Items.Clear() - //' Dim childamount As TreeNodeCollection - //' childamount = TreeView1.SelectedNode.Nodes - //' lblamountofobjects.Text = (childamount.Count & " objects(s)") - //' For Each TreeNode In TreeView1.SelectedNode.Nodes - //' If TreeNode.tag = "file" Then - //' TreeNode.forecolor = TreeView1.BackColor - //' End If - //' mainView.Items.Add(TreeNode.text) - //' Next - //'End Sub + void WinClassicWindowsExplorer_Load(object sender, EventArgs e) + { + diskView.ImageList = new ImageList(); + + diskView.ImageList.Images.Add(Properties.Resources.Win95DesktopIcon); + diskView.ImageList.Images.Add(Properties.Resources.Win95HardDiskIcon); + diskView.ImageList.Images.Add(Properties.Resources.WinClassicFolderSmall); + diskView.ImageList.Images.Add(Properties.Resources.WinClassicOpenFolderSmall); + diskView.ImageList.Images.Add(Properties.Resources.Win95ControlPanelIcon); + diskView.ImageList.Images.Add(Properties.Resources.Win95PrintersFolder); + diskView.ImageList.Images.Add(Properties.Resources.Win95ComputerIcon); + diskView.ImageList.Images.Add(Properties.Resources.Win95NetworkIcon); + diskView.ImageList.Images.Add(Properties.Resources.Win95RecycleIcon); + + program.BringToFront(); + + int loc = 0; + TreeNode[] folders = new TreeNode[new DirectoryInfo(CurrentDirectory).GetDirectories().Length]; + foreach (DirectoryInfo folder in new DirectoryInfo(CurrentDirectory).GetDirectories()) + { + if (folder.GetDirectories().Length > 0) + { + string label = ReadDataFile(folder.FullName, false); + TreeNode[] tn = createSubDirNodes(folder); + folders[loc] = new TreeNode(label ?? folder.Name, 2, 3, tn); + folders[loc].Tag = folder.FullName; + } + else + { + string label = ReadDataFile(folder.FullName, false); + folders[loc] = new TreeNode(label ?? folder.Name, 2, 3); + folders[loc].Tag = folder.FullName; + } + loc++; + } + TreeNode[] mypcarray = new TreeNode[3]; + mypcarray[0] = new TreeNode("(C:)", 1, 1, folders); + mypcarray[1] = new TreeNode("Control Panel", 4, 4); + mypcarray[2] = new TreeNode("Printers", 5, 5); + TreeNode[] desktoparray = new TreeNode[3]; + desktoparray[0] = new TreeNode("My Computer", 6, 6, mypcarray); + desktoparray[1] = new TreeNode("Network Neighborhood", 7, 7); + desktoparray[2] = new TreeNode("Recycle Bin", 8, 8); + diskView.Nodes.Add(new TreeNode("Desktop", 0, 0, desktoparray)); + + + //diskView.Items.Add("My Computer", 0); + Application.DoEvents(); + + RefreshAll(); + + if (FileDialogBoxManager.IsInOpenDialog) + { + IsFileOpenDialog = true; + } + else if (FileDialogBoxManager.IsInSaveDialog) + { + IsFileSaveDialog = true; + } + + if (IsFileOpenDialog == true) + { + pnlSave.Show(); + Button1.Text = "Open"; + } + else + { + if (IsFileSaveDialog == true) + { + pnlSave.Show(); + Button1.Text = "Save"; + } + } + + onlyViewExtension = FileDialogBoxManager.OnlyViewExtension; + } string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) { string Val = ""; @@ -76,19 +140,13 @@ namespace TimeHACK.OS.Win95.Win95Apps // diskView.Items.Add("", 0) // End If //Next - foreach (string str in Directory.GetDirectories(currentDirectory)) + foreach (string str in Directory.GetDirectories(CurrentDirectory)) { string label = ReadDataFile(str, false); - if (label == "") - { - ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str)); - itm.ImageKey = str; - } else { - ListViewItem itm = this.mainView.Items.Add(label); - itm.ImageKey = str; - } + ListViewItem itm = this.mainView.Items.Add(label ?? Path.GetFileName(str)); + itm.ImageKey = str; } - foreach (string str in Directory.GetFiles(currentDirectory)) + foreach (string str in Directory.GetFiles(CurrentDirectory)) { // Get the app Icon @@ -224,6 +282,10 @@ namespace TimeHACK.OS.Win95.Win95Apps fileType = 1; returnVal = "log text file \n createtext"; break; + case ".ini": + fileType = 1; + returnVal = "initialization \n createtext"; + break; case ".properties": fileType = 1; returnVal = "Config file \n createtext"; @@ -234,10 +296,6 @@ namespace TimeHACK.OS.Win95.Win95Apps break; case ".doc": fileType = 3; - returnVal = "Word Document (Old) \n word"; - break; - case ".docx": - fileType = 3; returnVal = "Word Document \n word"; break; case ".docm": @@ -246,18 +304,10 @@ namespace TimeHACK.OS.Win95.Win95Apps break; case ".xls": fileType = 4; - returnVal = "Excel Spreadsheets (Old) \n excel"; - break; - case ".xlsx": - fileType = 4; returnVal = "Excel Spreadsheets \n excel"; break; case ".ppt": fileType = 5; - returnVal = "Powerpoint Presentation (Old) \n powerpoint"; - break; - case ".pptx": - fileType = 5; returnVal = "Powerpoint Presentation \n powerpoint"; break; case ".pub": @@ -495,81 +545,6 @@ namespace TimeHACK.OS.Win95.Win95Apps //Private Sub windows_explorer_Closed(sender As Object, e As EventArgs) Handles Me.Closed // IsFileDialog = False //End Sub - void WinClassicWindowsExplorer_Load(object sender, EventArgs e) { - diskView.ImageList = new ImageList(); - - diskView.ImageList.Images.Add(Properties.Resources.Win95DesktopIcon); - diskView.ImageList.Images.Add(Properties.Resources.Win95HardDiskIcon); - diskView.ImageList.Images.Add(Properties.Resources.WinClassicFolderSmall); - diskView.ImageList.Images.Add(Properties.Resources.WinClassicOpenFolderSmall); - diskView.ImageList.Images.Add(Properties.Resources.Win95ControlPanelIcon); - diskView.ImageList.Images.Add(Properties.Resources.Win95PrintersFolder); - diskView.ImageList.Images.Add(Properties.Resources.Win95ComputerIcon); - diskView.ImageList.Images.Add(Properties.Resources.Win95NetworkIcon); - diskView.ImageList.Images.Add(Properties.Resources.Win95RecycleIcon); - - program.BringToFront(); - - int loc = 0; - TreeNode[] folders = new TreeNode[new DirectoryInfo(currentDirectory).GetDirectories().Length]; - foreach (DirectoryInfo folder in new DirectoryInfo(currentDirectory).GetDirectories()) - { - if (folder.GetDirectories().Length > 0) - { - string label = ReadDataFile(folder.FullName, false); - TreeNode[] tn = createSubDirNodes(folder); - folders[loc] = new TreeNode(label ?? folder.Name, 2, 3, tn); - folders[loc].Tag = folder.FullName; - } - else - { - string label = ReadDataFile(folder.FullName, false); - folders[loc] = new TreeNode(label ?? folder.Name, 2, 3); - folders[loc].Tag = folder.FullName; - } - loc++; - } - TreeNode[] mypcarray = new TreeNode[3]; - mypcarray[0] = new TreeNode("(C:)", 1, 1, folders); - mypcarray[1] = new TreeNode("Control Panel", 4, 4); - mypcarray[2] = new TreeNode("Printers", 5, 5); - TreeNode[] desktoparray = new TreeNode[3]; - desktoparray[0] = new TreeNode("My Computer", 6, 6, mypcarray); - desktoparray[1] = new TreeNode("Network Neighborhood", 7, 7); - desktoparray[2] = new TreeNode("Recycle Bin", 8, 8); - diskView.Nodes.Add(new TreeNode("Desktop", 0, 0, desktoparray)); - - - //diskView.Items.Add("My Computer", 0); - Application.DoEvents(); - - RefreshAll(); - - if (FileDialogBoxManager.IsInOpenDialog) - { - IsFileOpenDialog = true; - } - else if (FileDialogBoxManager.IsInSaveDialog) - { - IsFileSaveDialog = true; - } - - if (IsFileOpenDialog == true) - { - pnlSave.Show(); - Button1.Text = "Open"; - } - else - { - if (IsFileSaveDialog == true) - { - pnlSave.Show(); - Button1.Text = "Save"; - } - } - - onlyViewExtension = FileDialogBoxManager.OnlyViewExtension; - } void mainView_DoubleClick(object sender, EventArgs e) { @@ -577,15 +552,15 @@ namespace TimeHACK.OS.Win95.Win95Apps { if (mainView.FocusedItem.Tag == null) { // If it isn't a file - GoToDir(Path.Combine(currentDirectory, mainView.FocusedItem.ImageKey.ToString())); + GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.ImageKey.ToString())); } else { // If it is a file if (IsFileOpenDialog == true || IsFileSaveDialog == true) { - if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension) + if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) { - Program.WindowsExplorerReturnPath = Path.Combine(currentDirectory, txtSave.Text); + Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); } @@ -596,7 +571,7 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - OpenFile((string)mainView.FocusedItem.Tag); + OpenFile(mainView.FocusedItem.Tag.ToString()); } } } catch (Exception ex) { @@ -640,17 +615,17 @@ namespace TimeHACK.OS.Win95.Win95Apps { mainView.Show(); mainView.BringToFront(); - currentDirectory = dir; + CurrentDirectory = dir; RefreshAll(); } private void FolderToolStripMenuItem_Click(object sender, EventArgs e) { - if (File.Exists(currentDirectory + "\\New Folder")) { + if (File.Exists(CurrentDirectory + "\\New Folder")) { wm.StartInfobox95("Windows Explorer", "This directory already exists", Properties.Resources.Win95Info); } else { - Directory.CreateDirectory(currentDirectory + "\\New Folder"); - SaveDirectoryInfo(currentDirectory + "\\New Folder", false, "New Folder", true); + Directory.CreateDirectory(CurrentDirectory + "\\New Folder"); + SaveDirectoryInfo(CurrentDirectory + "\\New Folder", false, "New Folder", true); RefreshAll(); } @@ -665,7 +640,7 @@ namespace TimeHACK.OS.Win95.Win95Apps { if ((string)mainView.FocusedItem.Tag == "") { // If it isn't a file - GoToDir(Path.Combine(currentDirectory, mainView.FocusedItem.Tag.ToString())); + GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.Tag.ToString())); } else OpenFile = true; // If it is a file } @@ -678,10 +653,10 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension) + if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) { - Program.WindowsExplorerReturnPath = Path.Combine(currentDirectory, txtSave.Text); + Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); } @@ -701,14 +676,14 @@ namespace TimeHACK.OS.Win95.Win95Apps { try { - if (!FileOrDirectoryExists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) + if (!FileOrDirectoryExists(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text))) { wm.StartInfobox95("Windows Explorer", "This directory doesn't exist", Properties.Resources.Win95Info); } else { - if (Directory.Exists(Path.Combine(currentDirectory, mainView.FocusedItem.Text))) Directory.Delete(Path.Combine(currentDirectory, mainView.FocusedItem.Text), true); - else File.Delete(Path.Combine(currentDirectory, mainView.FocusedItem.Text)); + if (Directory.Exists(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text))) Directory.Delete(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text), true); + else File.Delete(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text)); RefreshAll(); } @@ -739,7 +714,7 @@ namespace TimeHACK.OS.Win95.Win95Apps try { // The AfterLabelEdit event will kick in after this - oldLabelText = mainView.FocusedItem.Text; + OldLabelText = mainView.FocusedItem.Text; mainView.LabelEdit = true; mainView.FocusedItem.BeginEdit(); } catch @@ -765,8 +740,26 @@ namespace TimeHACK.OS.Win95.Win95Apps } else { - Directory.Delete(Path.Combine(currentDirectory, oldLabelText), true); - Directory.CreateDirectory(Path.Combine(currentDirectory, setText)); + if (File.Exists(setText)) + { + wm.StartInfobox95("Windows Explorer", "That file already exists.", Properties.Resources.Win95Info); + } else { + if (File.Exists(OldLabelText)) + { + // It was a file + + File.Copy(Path.Combine(CurrentDirectory, OldLabelText), Path.Combine(CurrentDirectory, setText)); + File.Delete(Path.Combine(CurrentDirectory, OldLabelText)); + + } else { + // It was a directory + + Directory.CreateDirectory(Path.Combine(CurrentDirectory, setText)); + //File.Copy(Path.Combine(CurrentDirectory, OldLabelText, "*"), Path.Combine(CurrentDirectory, setText)); + Directory.Delete(Path.Combine(CurrentDirectory, OldLabelText)); + } + } + } } RefreshAll(); |
