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
//'End Sub
String ReadDataFile(String reqDirectory, Boolean returnYesIfProtected = false) {
String Val = "";
String directoryFileInfo;
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);
@ -71,14 +71,14 @@ void RefreshAll() {
try {
// Refresh the right listview
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
// 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);
string label = ReadDataFile(str, false);
if (label == "")
{
this.mainView.Items.Add(Path.GetFileName(str));
@ -88,7 +88,7 @@ void RefreshAll() {
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
@ -97,7 +97,7 @@ void RefreshAll() {
switch (new FileInfo(str).Extension)
{
case ".exe":
String contents;
string contents;
contents = File.ReadAllText(str);
@ -139,7 +139,6 @@ void OpenFile(String filedir)
try
{
ReturnType(new FileInfo(filedir).Extension);
MessageBox.Show(fileType.ToString());
switch (fileType)
{
case 1:
@ -155,7 +154,6 @@ void OpenFile(String filedir)
break;
}
} catch {
MessageBox.Show("failed!");
}
}
@ -493,10 +491,12 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e) {
{
TreeNode[] tn = createSubDirNodes(folder);
folders[loc] = new TreeNode(folder.Name, 2, 3, tn);
folders[loc].Tag = folder.FullName;
}
else
{
folders[loc] = new TreeNode(folder.Name, 2, 3);
folders[loc].Tag = folder.FullName;
}
loc++;
}
@ -509,6 +509,8 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e) {
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();
@ -544,15 +546,20 @@ void mainView_DoubleClick(object sender, EventArgs e)
{
try
{
if ((String)mainView.FocusedItem.Tag != "")
if ((string)mainView.FocusedItem.Tag != "")
{ // If it isn't a file
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
{ // If it is a file
if (IsFileOpenDialog == true || IsFileSaveDialog == true)
{
MessageBox.Show("Nope!");
if (new FileInfo(Path.Combine(currentDirectory, txtSave.Text)).Extension == onlyViewExtension)
{
Program.WindowsExplorerReturnPath = currentDirectory + "\\" + txtSave.Text;
@ -563,12 +570,13 @@ void mainView_DoubleClick(object sender, EventArgs e)
FileDialogBoxManager.IsInSaveDialog = false;
((Form)this.TopLevelControl).Close();
} else {
MessageBox.Show("Yep!");
}
else
{
OpenFile((String)mainView.FocusedItem.Tag);
}
}
}
} catch {
}
@ -578,10 +586,30 @@ void diskView_AfterSelect(object sender, EventArgs e)
{
try
{
if (diskView.SelectedNode.Text == "My Computer") {
if (diskView.SelectedNode != null)
{
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 {
}
}
@ -610,10 +638,10 @@ private void Button1_Click(object sender, EventArgs e)
{
try
{
Boolean OpenFile = false;
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);
}
@ -695,7 +723,7 @@ private void RenameToolStripMenuItem_Click(object sender, EventArgs e)
private void mainView_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
String setText;
string setText;
setText = mainView.FocusedItem.Text;
if (setText == "")
{
@ -726,10 +754,12 @@ private TreeNode[] createSubDirNodes(DirectoryInfo folder)
{
TreeNode[] tn = createSubDirNodes(fold);
toReturn[loc] = new TreeNode(fold.Name, 2, 3, tn);
toReturn[loc].Tag = fold.FullName;
}
else
{
toReturn[loc] = new TreeNode(fold.Name, 2, 3);
toReturn[loc].Tag = fold.FullName;
}
loc++;
}