Windows Explorer TreeView now works!

This commit is contained in:
Alex-TIMEHACK 2017-07-21 14:08:35 +01:00
parent 75c05d3553
commit 55e49fdaad

View file

@ -46,9 +46,9 @@ public WinClassicWindowsExplorer()
//' Next //' Next
//'End Sub //'End Sub
String ReadDataFile(String reqDirectory, Boolean returnYesIfProtected = false) { string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) {
String Val = ""; string Val = "";
String directoryFileInfo; string directoryFileInfo;
directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info")); directoryFileInfo = File.ReadAllText(Path.Combine(reqDirectory, "_data.info"));
FileSystemFolderInfo toRead = new FileSystemFolderInfo(); FileSystemFolderInfo toRead = new FileSystemFolderInfo();
toRead = JsonConvert.DeserializeObject<FileSystemFolderInfo>(directoryFileInfo); toRead = JsonConvert.DeserializeObject<FileSystemFolderInfo>(directoryFileInfo);
@ -71,14 +71,14 @@ void RefreshAll() {
try { try {
// Refresh the right listview // Refresh the right listview
this.mainView.Items.Clear(); this.mainView.Items.Clear();
// For Each drive As String In My.Computer.FileSystem.GetDirectories(GameMain.MyDocuments & "\HistacomVB\" & GameMain.SaveProfile & "\HistacomVB\Folders") // For Each drive As string In My.Computer.FileSystem.GetDirectories(GameMain.MyDocuments & "\HistacomVB\" & GameMain.SaveProfile & "\HistacomVB\Folders")
// If GetPropetiesForDir(drive)(4) = "isMyDocuments" Then // If GetPropetiesForDir(drive)(4) = "isMyDocuments" Then
// diskView.Items.Add("", 0) // diskView.Items.Add("", 0)
// End If // End If
//Next //Next
foreach (String str in Directory.GetDirectories(currentDirectory)) foreach (string str in Directory.GetDirectories(currentDirectory))
{ {
String label = ReadDataFile(str, false); string label = ReadDataFile(str, false);
if (label == "") if (label == "")
{ {
this.mainView.Items.Add(Path.GetFileName(str)); this.mainView.Items.Add(Path.GetFileName(str));
@ -88,7 +88,7 @@ void RefreshAll() {
this.mainView.FindItemWithText(label).Tag = Path.GetFileName(str); this.mainView.FindItemWithText(label).Tag = Path.GetFileName(str);
} }
} }
foreach (String str in Directory.GetFiles(currentDirectory)) foreach (string str in Directory.GetFiles(currentDirectory))
{ {
// Get app Icon // Get app Icon
@ -97,7 +97,7 @@ void RefreshAll() {
switch (new FileInfo(str).Extension) switch (new FileInfo(str).Extension)
{ {
case ".exe": case ".exe":
String contents; string contents;
contents = File.ReadAllText(str); contents = File.ReadAllText(str);
@ -139,7 +139,6 @@ void OpenFile(String filedir)
try try
{ {
ReturnType(new FileInfo(filedir).Extension); ReturnType(new FileInfo(filedir).Extension);
MessageBox.Show(fileType.ToString());
switch (fileType) switch (fileType)
{ {
case 1: case 1:
@ -155,7 +154,6 @@ void OpenFile(String filedir)
break; break;
} }
} catch { } catch {
MessageBox.Show("failed!");
} }
} }
@ -493,10 +491,12 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e) {
{ {
TreeNode[] tn = createSubDirNodes(folder); TreeNode[] tn = createSubDirNodes(folder);
folders[loc] = new TreeNode(folder.Name, 2, 3, tn); folders[loc] = new TreeNode(folder.Name, 2, 3, tn);
folders[loc].Tag = folder.FullName;
} }
else else
{ {
folders[loc] = new TreeNode(folder.Name, 2, 3); folders[loc] = new TreeNode(folder.Name, 2, 3);
folders[loc].Tag = folder.FullName;
} }
loc++; loc++;
} }
@ -509,6 +509,8 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e) {
desktoparray[1] = new TreeNode("Network Neighborhood", 7, 7); desktoparray[1] = new TreeNode("Network Neighborhood", 7, 7);
desktoparray[2] = new TreeNode("Recycle Bin", 8, 8); desktoparray[2] = new TreeNode("Recycle Bin", 8, 8);
diskView.Nodes.Add(new TreeNode("Desktop", 0, 0, desktoparray)); diskView.Nodes.Add(new TreeNode("Desktop", 0, 0, desktoparray));
//diskView.Items.Add("My Computer", 0); //diskView.Items.Add("My Computer", 0);
Application.DoEvents(); Application.DoEvents();
@ -544,31 +546,37 @@ void mainView_DoubleClick(object sender, EventArgs e)
{ {
try try
{ {
if ((String)mainView.FocusedItem.Tag != "") if ((string)mainView.FocusedItem.Tag != "")
{ // If it isn't a file { // If it isn't a file
GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag); GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag);
}
else
{ // If it is a file
if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension)
{
Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text;
} }
else else
{ // If it is a file { // If it is a file
if (IsFileOpenDialog == true || IsFileSaveDialog == true) if (IsFileOpenDialog == true || IsFileSaveDialog == true)
{
MessageBox.Show("Nope!");
if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension)
{ {
Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text; if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension)
{
Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text;
}
FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false;
((Form)this.TopLevelControl).Close();
}
else
{
OpenFile((String)mainView.FocusedItem.Tag);
} }
FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false;
((Form)this.TopLevelControl).Close();
} else {
MessageBox.Show("Yep!");
OpenFile((String)mainView.FocusedItem.Tag);
} }
} }
} catch { } catch {
} }
@ -578,10 +586,30 @@ void diskView_AfterSelect(object sender, EventArgs e)
{ {
try try
{ {
if (diskView.SelectedNode.Text == "My Computer") { if (diskView.SelectedNode != null)
GoToDir(ProfileFileSystemDirectory); {
} if (diskView.SelectedNode.Text == "My Computer")
{
GoToDir(ProfileFileSystemDirectory);
}
else if (diskView.SelectedNode.Text == "(C:)")
{
GoToDir(ProfileMyComputerDirectory);
}
else
{
if (diskView.SelectedNode.Tag != null)
{
// It is a directory:
try
{
GoToDir(diskView.SelectedNode.Tag.ToString());
}
catch { }
}
}
}
} catch { } catch {
} }
} }
@ -610,10 +638,10 @@ private void Button1_Click(object sender, EventArgs e)
{ {
try try
{ {
Boolean OpenFile = false; bool OpenFile = false;
if (mainView.FocusedItem != null) if (mainView.FocusedItem != null)
{ {
if ((String)mainView.FocusedItem.Tag != "") if ((string)mainView.FocusedItem.Tag != "")
{ // If it isn't a file { // If it isn't a file
GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag); GoToDir(currentDirectory + "\\" + mainView.FocusedItem.Tag);
} }
@ -695,7 +723,7 @@ private void RenameToolStripMenuItem_Click(object sender, EventArgs e)
private void mainView_AfterLabelEdit(object sender, LabelEditEventArgs e) private void mainView_AfterLabelEdit(object sender, LabelEditEventArgs e)
{ {
String setText; string setText;
setText = mainView.FocusedItem.Text; setText = mainView.FocusedItem.Text;
if (setText == "") if (setText == "")
{ {
@ -726,10 +754,12 @@ private TreeNode[] createSubDirNodes(DirectoryInfo folder)
{ {
TreeNode[] tn = createSubDirNodes(fold); TreeNode[] tn = createSubDirNodes(fold);
toReturn[loc] = new TreeNode(fold.Name, 2, 3, tn); toReturn[loc] = new TreeNode(fold.Name, 2, 3, tn);
toReturn[loc].Tag = fold.FullName;
} }
else else
{ {
toReturn[loc] = new TreeNode(fold.Name, 2, 3); toReturn[loc] = new TreeNode(fold.Name, 2, 3);
toReturn[loc].Tag = fold.FullName;
} }
loc++; loc++;
} }