Address Book can now save data!

This commit is contained in:
Alex-TIMEHACK 2017-11-04 17:48:05 +00:00
parent 4af08fc6e3
commit cc07981aa3
7 changed files with 180 additions and 75 deletions

View file

@ -12,27 +12,27 @@ public static class FileDialogBoxManager
{ {
public static bool IsInOpenDialog = false; public static bool IsInOpenDialog = false;
public static bool IsInSaveDialog = false; public static bool IsInSaveDialog = false;
public static string OnlyViewExtension = ""; public static List<string> OnlyViewExtension = new List<string>();
public static void ActivateOpenFileDialog(string ExtensionToView) public static void ActivateOpenFileDialog(params string[] ExtensionToView)
{ {
IsInOpenDialog = true; IsInOpenDialog = true;
IsInSaveDialog = false; IsInSaveDialog = false;
OnlyViewExtension = ExtensionToView; OnlyViewExtension = ExtensionToView.ToList();
} }
public static void ActivateSaveFileDialog(string ExtensionToView) public static void ActivateSaveFileDialog(params string[] ExtensionToView)
{ {
IsInOpenDialog = false; IsInOpenDialog = false;
IsInSaveDialog = true; IsInSaveDialog = true;
OnlyViewExtension = ExtensionToView; OnlyViewExtension = ExtensionToView.ToList();
} }
public static void DeactivateFileDialog() public static void DeactivateFileDialog()
{ {
IsInOpenDialog = false; IsInOpenDialog = false;
IsInSaveDialog = false; IsInSaveDialog = false;
OnlyViewExtension = ""; OnlyViewExtension = new List<string>();
} }
public static string ReadTextFile(string path) public static string ReadTextFile(string path)

View file

@ -34,7 +34,7 @@ public override string Text
public static Color _lightBack = Color.Silver; public static Color _lightBack = Color.Silver;
public static Color _darkBack = Color.Silver; public static Color _darkBack = Color.Silver;
public List<string> items = new List<string> { "TestItem" }; public List<string> Items { get; set; } = new List<string>();
public ClassicDropDown() public ClassicDropDown()
{ {
@ -117,7 +117,7 @@ public void ShowHideDropDown()
} else { } else {
thisOverlay = new DropDownOverlay(); thisOverlay = new DropDownOverlay();
int applyHeight = 0; int applyHeight = 0;
foreach (string str in items) foreach (string str in Items)
{ {
DropDownItem itm = new DropDownItem(); DropDownItem itm = new DropDownItem();
itm.ChangeText(str, Font); itm.ChangeText(str, Font);

View file

@ -22,14 +22,12 @@ public partial class Win95WindowsExplorer : UserControl
{ {
public bool IsFileOpenDialog = false; public bool IsFileOpenDialog = false;
public bool IsFileSaveDialog = false; public bool IsFileSaveDialog = false;
public string onlyViewExtension = ""; public List<string> onlyViewExtension = new List<string>();
string ToReplaceWith = ProfileDirectory; string ToReplaceWith = ProfileDirectory;
public string CurrentDirectory = ProfileMyComputerDirectory; public string CurrentDirectory = ProfileMyComputerDirectory;
string OldLabelText; string OldLabelText;
string CurrentCopyFile; string CurrentCopyFile;
int fileType = 6;
//string attemptedDirectory = ""; //string attemptedDirectory = "";
WindowManager wm = new WindowManager(); WindowManager wm = new WindowManager();
@ -89,7 +87,8 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e)
Properties.Resources.TimeDistorter1, Properties.Resources.TimeDistorter1,
Properties.Resources.WinClassicGTN, Properties.Resources.WinClassicGTN,
Properties.Resources.WinClassicFTP, Properties.Resources.WinClassicFTP,
Properties.Resources.WinClassicRtfFile}); //20 Properties.Resources.WinClassicRtfFile, // 20
Properties.Resources.WinClassicAddressBook});
program.BringToFront(); program.BringToFront();
@ -124,6 +123,9 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e)
} }
onlyViewExtension = FileDialogBoxManager.OnlyViewExtension; onlyViewExtension = FileDialogBoxManager.OnlyViewExtension;
foreach (string str in onlyViewExtension)
cmbType.Items.Add(str);
} }
string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) { string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) {
@ -162,7 +164,7 @@ private void RefreshAll()
{ {
if (!(Path.GetFileName(str) == "_data.info")) if (!(Path.GetFileName(str) == "_data.info"))
{ {
if (new FileInfo(str).Extension == onlyViewExtension) if (onlyViewExtension.Contains(new FileInfo(str).Extension))
{ {
itm = this.mainView.Items.Add(Path.GetFileName(str)); itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str; itm.Tag = str;
@ -232,8 +234,7 @@ public void OpenFile(string fileDir)
{ {
try try
{ {
ReturnType(new FileInfo(fileDir).Extension); switch (ReturnType(new FileInfo(fileDir).Extension))
switch (fileType)
{ {
case 1: case 1:
WinClassicNotepad np = new WinClassicNotepad(); WinClassicNotepad np = new WinClassicNotepad();
@ -501,7 +502,7 @@ void mainView_DoubleClick(object sender, EventArgs e)
{ // If it is a file { // If it is a file
if (IsFileOpenDialog || IsFileSaveDialog) if (IsFileOpenDialog || IsFileSaveDialog)
{ {
if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) if (onlyViewExtension.Contains(new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension))
{ {
Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
} }
@ -513,9 +514,7 @@ void mainView_DoubleClick(object sender, EventArgs e)
((Form)this.TopLevelControl).Close(); ((Form)this.TopLevelControl).Close();
} }
else else
{
OpenFile(mainView.FocusedItem.Tag.ToString()); OpenFile(mainView.FocusedItem.Tag.ToString());
}
} }
} catch { /* TODO: Illegal operation */ } } catch { /* TODO: Illegal operation */ }
} }
@ -595,7 +594,7 @@ private void btnSave_Click(object sender, EventArgs e)
if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK); if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK);
else else
{ {
if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); if (onlyViewExtension.Contains(new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension)) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
FileDialogBoxManager.IsInOpenDialog = false; FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false; FileDialogBoxManager.IsInSaveDialog = false;

View file

@ -7,12 +7,13 @@
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Histacom2.Engine;
namespace Histacom2.OS.Win95.Win95Apps namespace Histacom2.OS.Win95.Win95Apps
{ {
public partial class FRMWinClassicAddressBookNewContact : UserControl public partial class FRMWinClassicAddressBookNewContact : UserControl
{ {
WindowManager wm = new WindowManager();
public AddressBookContact toSet = new AddressBookContact(); public AddressBookContact toSet = new AddressBookContact();
public FRMWinClassicAddressBookNewContact() public FRMWinClassicAddressBookNewContact()
{ {
@ -37,7 +38,7 @@ private void button1_Click(object sender, EventArgs e)
Program.AddressBookSelectedContact = toSet; Program.AddressBookSelectedContact = toSet;
((Form)this.TopLevelControl).Close(); ((Form)this.TopLevelControl).Close();
} else { } else {
MessageBox.Show("Please fill out the First, Middle and Last name."); wm.StartInfobox95("Address Book", "Please fill out the First, Middle and Last name.", Engine.Template.InfoboxType.Info, Engine.Template.InfoboxButtons.OK);
} }
} }
@ -62,9 +63,6 @@ private void FRMWinClassicAddressBookNewContact_Load(object sender, EventArgs e)
emails.Items.Add(email); emails.Items.Add(email);
} }
} }
} else
{
MessageBox.Show("NULL CONTACT!");
} }
} }
} }

View file

@ -145,12 +145,14 @@ private void InitializeComponent()
this.importToolStripMenuItem.Name = "importToolStripMenuItem"; this.importToolStripMenuItem.Name = "importToolStripMenuItem";
this.importToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.importToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.importToolStripMenuItem.Text = "Import..."; this.importToolStripMenuItem.Text = "Import...";
this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click);
// //
// exportToolStripMenuItem // exportToolStripMenuItem
// //
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.exportToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exportToolStripMenuItem.Text = "Export..."; this.exportToolStripMenuItem.Text = "Export...";
this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click);
// //
// toolStripSeparator3 // toolStripSeparator3
// //

View file

@ -9,6 +9,9 @@
using System.Windows.Forms; using System.Windows.Forms;
using Histacom2.Engine; using Histacom2.Engine;
using Histacom2.Engine.Template; using Histacom2.Engine.Template;
using System.IO;
using static Histacom2.Engine.SaveSystem;
using static Histacom2.Engine.FileDialogBoxManager;
namespace Histacom2.OS.Win95.Win95Apps namespace Histacom2.OS.Win95.Win95Apps
{ {
@ -42,14 +45,30 @@ public WinClassicAddressBook()
{ {
new AddressBookContactList() new AddressBookContactList()
{ {
AttachedNode = treeView1.Nodes[0].Text NodePath = treeView1.Nodes[0].Text
} }
}; };
if (File.Exists(Path.Combine(ProfileWindowsDirectory, "Application Data", "Microsoft", "Address Book", $"{ProfileName}.wab")))
LoadData();
else
SaveData();
} }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{ {
UpdateContactListFromNodeName(treeView1.SelectedNode.Text); previousParent = treeView1.SelectedNode.Parent;
UpdateContactListFromNodeName(treeView1.SelectedNode);
// Remove the focus from contactsView
if (contactsView.SelectedItems.Count != 0)
contactsView.SelectedItems[0].Selected = false;
if (contactsView.FocusedItem != null)
contactsView.FocusedItem.Focused = false;
} }
//AddressBookContactList GetAddressBookContactListFromNode(string NodeText) //AddressBookContactList GetAddressBookContactListFromNode(string NodeText)
@ -71,14 +90,15 @@ private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
// return toReturn; // return toReturn;
//} //}
public void UpdateContactListFromNodeName(string NodeName) public void UpdateContactListFromNodeName(TreeNode Node)
{ {
previousParent = Node.Parent;
contactsView.Items.Clear(); contactsView.Items.Clear();
try try
{ {
foreach (AddressBookContactList ContactList in AddressBookObjects) foreach (AddressBookContactList ContactList in AddressBookObjects)
{ {
if (ContactList.AttachedNode == NodeName) if (ContactList.NodePath == FindNodePath(Node))
{ {
foreach (AddressBookContact contact in ContactList.Contacts) foreach (AddressBookContact contact in ContactList.Contacts)
{ {
@ -97,15 +117,29 @@ public void AddFolderToNode(TreeNode OldTreeNode, string NewNodeName)
{ {
if (OldTreeNode != null) if (OldTreeNode != null)
{ {
OldTreeNode.Nodes.Add(NewNodeName); TreeNode nde = OldTreeNode.Nodes.Add(NewNodeName);
AddressBookObjects.Add(new AddressBookContactList AddressBookObjects.Add(new AddressBookContactList
{ {
AttachedNode = NewNodeName, NodePath = FindNodePath(nde)
}); });
} }
} }
TreeNode previousParent;
public string FindNodePath(TreeNode nde)
{
if (nde != null)
{
string ret = nde.Text;
previousParent = nde.Parent;
while (previousParent != null)
ret = $"{FindNodePath(nde.Parent)}\\{ret}";
return ret;
}
else return "";
}
private void newFolderToolStripMenuItem_Click(object sender, EventArgs e) private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
{ {
NewFolder(); NewFolder();
@ -145,7 +179,7 @@ void NewContact()
{ {
foreach (AddressBookContactList ContactList in AddressBookObjects) foreach (AddressBookContactList ContactList in AddressBookObjects)
{ {
if (ContactList.AttachedNode == treeView1.SelectedNode.Text) if (ContactList.NodePath == FindNodePath(treeView1.SelectedNode))
{ {
ContactList.Contacts.Add(Program.AddressBookSelectedContact); ContactList.Contacts.Add(Program.AddressBookSelectedContact);
contactsView.Items.Add(Program.AddressBookSelectedContact.FirstName + " " + Program.AddressBookSelectedContact.MiddleName + " " + Program.AddressBookSelectedContact.LastName); contactsView.Items.Add(Program.AddressBookSelectedContact.FirstName + " " + Program.AddressBookSelectedContact.MiddleName + " " + Program.AddressBookSelectedContact.LastName);
@ -169,7 +203,7 @@ void OpenProperties()
{ {
foreach (AddressBookContactList ContactList in AddressBookObjects) foreach (AddressBookContactList ContactList in AddressBookObjects)
{ {
if (ContactList.AttachedNode == treeView1.SelectedNode.Text) if (ContactList.NodePath == FindNodePath(treeView1.SelectedNode))
{ {
foreach (AddressBookContact Contact in ContactList.Contacts) foreach (AddressBookContact Contact in ContactList.Contacts)
{ {
@ -195,7 +229,7 @@ void OpenProperties()
{ {
foreach (AddressBookContactList ContactList in AddressBookObjects) foreach (AddressBookContactList ContactList in AddressBookObjects)
{ {
if (ContactList.AttachedNode == treeView1.SelectedNode.Text) if (ContactList.NodePath == FindNodePath(treeView1.SelectedNode))
{ {
foreach (AddressBookContact Contact in ContactList.Contacts) foreach (AddressBookContact Contact in ContactList.Contacts)
{ {
@ -228,31 +262,31 @@ void DeleteContact()
{ {
try try
{ {
if (treeView1.SelectedNode != null) foreach (AddressBookContactList ContactList in AddressBookObjects)
{ {
foreach (AddressBookContactList ContactList in AddressBookObjects) if (ContactList.NodePath == FindNodePath(treeView1.SelectedNode))
{ {
if (ContactList.AttachedNode == treeView1.SelectedNode.Text) foreach (AddressBookContact Contact in ContactList.Contacts)
{ {
foreach (AddressBookContact Contact in ContactList.Contacts) if (contactsView.FocusedItem == null)
{ { // Most likely they are trying to delete a whole folder!
if (contactsView.FocusedItem == null) if (treeView1.SelectedNode.Text != "Shared Contacts")
{ // Most likely they are trying to delete a whole folder! if (treeView1.SelectedNode != null)
if (treeView1.SelectedNode.Text != "Shared Contacts")
if (treeView1.SelectedNode != null)
{
AddressBookObjects.Remove(ContactList);
treeView1.Nodes.Remove(treeView1.SelectedNode);
UpdateContactListFromNodeName("Shared Contacts");
}
}
else
{
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
{ {
ContactList.Contacts.Remove(Contact); AddressBookObjects.Remove(ContactList);
treeView1.Nodes.Remove(treeView1.SelectedNode);
previousParent = null;
UpdateContactListFromNodeName(treeView1.Nodes[0]);
} }
} }
else
{
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
{
ContactList.Contacts.Remove(Contact);
previousParent = treeView1.SelectedNode.Parent;
UpdateContactListFromNodeName(treeView1.SelectedNode);
}
} }
} }
} }
@ -310,14 +344,75 @@ private void WinClassicAddressBook_Load(object sender, EventArgs e)
public void SaveData() public void SaveData()
{ {
string toSave = Newtonsoft.Json.JsonConvert.SerializeObject(AddressBookObjects, Newtonsoft.Json.Formatting.Indented);
CreateWindowsFile(Path.Combine(ProfileWindowsDirectory, "Application Data", "Microsoft", "Address Book"), $"{ProfileName}.wab", toSave, 21, toSave.Length);
} }
public void SaveDataAs() public void SaveDataAs()
{ {
try
{
string toSave = Newtonsoft.Json.JsonConvert.SerializeObject(AddressBookObjects, Newtonsoft.Json.Formatting.Indented);
ActivateSaveFileDialog(".wab");
string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();
DeactivateFileDialog();
if (selectedPath != "")
CreateWindowsFile(new FileInfo(selectedPath).Directory.FullName, selectedPath.Split('\\').Last(), toSave, 21, toSave.Length);
} catch { }
}
public void LoadData()
{
AddressBookObjects = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AddressBookContactList>>(File.ReadAllText(Path.Combine(ProfileWindowsDirectory, "Application Data", "Microsoft", "Address Book", $"{ProfileName}.wab")));
foreach (AddressBookContactList lst in AddressBookObjects)
UpdateTreeView(lst);
} }
public void LoadDataAs()
{
ActivateOpenFileDialog(".wab");
string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();
DeactivateFileDialog();
if (selectedPath != "")
AddressBookObjects = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AddressBookContactList>>(File.ReadAllText(selectedPath));
foreach (AddressBookContactList lst in AddressBookObjects)
UpdateTreeView(lst);
}
TreeNode UpdatePrevParent;
public void UpdateTreeView(AddressBookContactList lst, int count = 0)
{
try
{
string[] parts = lst.NodePath.Split('\\');
if (count == 0) UpdatePrevParent = treeView1.Nodes[0];
if (lst.NodePath != FindNodePath(treeView1.Nodes[0]))
{
if (UpdatePrevParent.Nodes.ContainsKey(parts[count + 1]))
UpdatePrevParent.Nodes.RemoveByKey(parts[count + 1]);
TreeNode newNde = UpdatePrevParent.Nodes.Add(parts[count + 1], parts[count + 1]);
UpdatePrevParent = newNde;
if (count != parts.Length - 2) UpdateTreeView(lst, ++count);
}
} catch { }
}
private void importToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadDataAs();
}
private void exportToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveDataAs();
}
} }
public class AddressBookContact public class AddressBookContact
@ -330,7 +425,7 @@ public class AddressBookContact
public class AddressBookContactList public class AddressBookContactList
{ {
public string AttachedNode; public string NodePath;
public List<AddressBookContact> Contacts = new List<AddressBookContact>(); public List<AddressBookContact> Contacts = new List<AddressBookContact>();
} }
} }

View file

@ -22,13 +22,12 @@ public partial class WinClassicWindowsExplorer : UserControl
{ {
public bool IsFileOpenDialog = false; public bool IsFileOpenDialog = false;
public bool IsFileSaveDialog = false; public bool IsFileSaveDialog = false;
public string onlyViewExtension = ""; public List<string> onlyViewExtension = new List<string>();
string ToReplaceWith = ProfileDirectory; string ToReplaceWith = ProfileDirectory;
public string CurrentDirectory = ProfileMyComputerDirectory; public string CurrentDirectory = ProfileMyComputerDirectory;
string OldLabelText; string OldLabelText;
string CurrentCopyFile; string CurrentCopyFile;
int fileType = 6;
//string attemptedDirectory = ""; //string attemptedDirectory = "";
WindowManager wm = new WindowManager(); WindowManager wm = new WindowManager();
@ -82,7 +81,8 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e)
Properties.Resources.TimeDistorter1, Properties.Resources.TimeDistorter1,
Properties.Resources.WinClassicGTN, Properties.Resources.WinClassicGTN,
Properties.Resources.WinClassicFTP, Properties.Resources.WinClassicFTP,
Properties.Resources.WinClassicRtfFile}); //20 Properties.Resources.WinClassicRtfFile, // 20
Properties.Resources.WinClassicAddressBook});
program.BringToFront(); program.BringToFront();
@ -117,6 +117,11 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e)
} }
onlyViewExtension = FileDialogBoxManager.OnlyViewExtension; onlyViewExtension = FileDialogBoxManager.OnlyViewExtension;
foreach (string str in onlyViewExtension)
cmbType.Items.Add(str);
cmbType.Text = onlyViewExtension.FirstOrDefault();
} }
//'Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) //'Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs)
@ -157,6 +162,19 @@ void RefreshAll() {
//try { //try {
this.mainView.Items.Clear(); this.mainView.Items.Clear();
if (CurrentDirectory == ProfileFileSystemDirectory)
{
txtInfoTitle.Text = "My Computer";
pictureBox1.Image = Properties.Resources.Win95ComputerIcon;
} else if (CurrentDirectory == ProfileMyComputerDirectory) {
txtInfoTitle.Text = "C:";
pictureBox1.Image = Properties.Resources.WinClassicFolderSmall; // TODO: ADD DRIVE ICON
} else {
txtInfoTitle.Text = Path.GetFileName(CurrentDirectory);
pictureBox1.Image = Properties.Resources.WinClassicFolderSmall;
}
foreach (string str in Directory.GetDirectories(CurrentDirectory)) foreach (string str in Directory.GetDirectories(CurrentDirectory))
{ {
string label = ReadDataFile(str, false); string label = ReadDataFile(str, false);
@ -172,14 +190,14 @@ void RefreshAll() {
{ {
if (!(Path.GetFileName(str) == "_data.info")) if (!(Path.GetFileName(str) == "_data.info"))
{ {
if (new FileInfo(str).Extension == onlyViewExtension) if (onlyViewExtension.Contains(new FileInfo(str).Extension))
{ {
itm = this.mainView.Items.Add(Path.GetFileName(str)); itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str; itm.Tag = str;
} }
else break; else continue;
} }
else break; else continue;
} }
else else
{ {
@ -188,7 +206,7 @@ void RefreshAll() {
itm = this.mainView.Items.Add(Path.GetFileName(str)); itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str; itm.Tag = str;
} }
else break; else continue;
} }
FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(CurrentDirectory, "_data.info"))); FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(CurrentDirectory, "_data.info")));
foreach (var item in fsfi.Files) foreach (var item in fsfi.Files)
@ -244,8 +262,7 @@ public void OpenFile(string fileDir)
{ {
try try
{ {
ReturnType(new FileInfo(fileDir).Extension); switch (ReturnType(new FileInfo(fileDir).Extension))
switch (fileType)
{ {
case 1: case 1:
WinClassicNotepad np = new WinClassicNotepad(); WinClassicNotepad np = new WinClassicNotepad();
@ -452,7 +469,7 @@ void mainView_DoubleClick(object sender, EventArgs e)
{ // If it is a file { // If it is a file
if (IsFileOpenDialog || IsFileSaveDialog) if (IsFileOpenDialog || IsFileSaveDialog)
{ {
if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) if (onlyViewExtension.Contains(new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension))
{ {
Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
} }
@ -464,9 +481,7 @@ void mainView_DoubleClick(object sender, EventArgs e)
((Form)this.TopLevelControl).Close(); ((Form)this.TopLevelControl).Close();
} }
else else
{
OpenFile(mainView.FocusedItem.Tag.ToString()); OpenFile(mainView.FocusedItem.Tag.ToString());
}
} }
} catch { /* TODO: Illegal operation */ } } catch { /* TODO: Illegal operation */ }
} }
@ -477,7 +492,7 @@ void diskView_AfterSelect(object sender, EventArgs e)
{ {
if (diskView.SelectedNode != null) if (diskView.SelectedNode != null)
{ {
if (diskView.SelectedNode.Text == "My Computer") if (diskView.SelectedNode.Text == "My Computer" || diskView.SelectedNode.Text == "Desktop")
{ {
GoToDir(ProfileFileSystemDirectory); GoToDir(ProfileFileSystemDirectory);
} }
@ -491,11 +506,7 @@ void diskView_AfterSelect(object sender, EventArgs e)
{ {
// It is a directory: // It is a directory:
try GoToDir(diskView.SelectedNode.Tag.ToString());
{
GoToDir(diskView.SelectedNode.Tag.ToString());
}
catch { }
} }
} }
} }
@ -540,7 +551,7 @@ private void Button1_Click(object sender, EventArgs e)
if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK); if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK);
else else
{ {
if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); if (onlyViewExtension.Contains(new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension)) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
FileDialogBoxManager.IsInOpenDialog = false; FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false; FileDialogBoxManager.IsInSaveDialog = false;
@ -980,7 +991,7 @@ private void btnSave_Click(object sender, EventArgs e)
if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK); if (txtSave.Text == "") wm.StartInfobox95("Windows Explorer", "Please enter a filename", InfoboxType.Info, InfoboxButtons.OK);
else else
{ {
if (new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension == onlyViewExtension) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text); if (onlyViewExtension.Contains(new FileInfo(Path.Combine(CurrentDirectory, txtSave.Text)).Extension)) Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
FileDialogBoxManager.IsInOpenDialog = false; FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false; FileDialogBoxManager.IsInSaveDialog = false;