Quite Big revamp on Explorer Part 1

This commit is contained in:
Alex-TIMEHACK 2017-08-18 14:56:56 +01:00
parent 3399ab978c
commit 414133b35d
9 changed files with 149 additions and 113 deletions

View file

@ -13,6 +13,7 @@ public static class FileDialogBoxManager
public static bool IsInOpenDialog = false;
public static bool IsInSaveDialog = false;
public static string OnlyViewExtension = "";
public static void ActivateOpenFileDialog(string ExtensionToView)
{
IsInOpenDialog = true;
@ -36,5 +37,28 @@ public static string ReadTextFile(string path)
return "";
}
}
public static void SaveTextFile(string path, string contents, int fileIcon)
{
try
{
File.WriteAllText(path, contents);
FileSystemFolderInfo theDir = Newtonsoft.Json.JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(Path.GetPathRoot(path), "_data.info")));
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
theDir.Files.Add(new THFileInfo()
{
Name = Path.GetFileName(path),
ByteSize = (int)fs.Length,
FileIcon = fileIcon
});
}
} catch { }
}
}
}

View file

@ -36,7 +36,6 @@ private void InitializeComponent()
this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CreateShortcutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ShortcutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TextDocumentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BitmapImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DeleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -69,6 +68,7 @@ private void InitializeComponent()
// program
//
this.program.BackColor = System.Drawing.Color.Silver;
this.program.Controls.Add(this.pnlSave);
this.program.Controls.Add(this.mainView);
this.program.Controls.Add(this.diskView);
this.program.Controls.Add(this.MenuStrip1);
@ -76,7 +76,6 @@ private void InitializeComponent()
this.program.Controls.Add(this.bottomrightcorner);
this.program.Controls.Add(this.bottomleftcorner);
this.program.Controls.Add(this.topleftcorner);
this.program.Controls.Add(this.pnlSave);
this.program.Dock = System.Windows.Forms.DockStyle.Fill;
this.program.Location = new System.Drawing.Point(0, 0);
this.program.Name = "program";
@ -99,6 +98,9 @@ private void InitializeComponent()
//
// diskView
//
this.diskView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.diskView.Location = new System.Drawing.Point(3, 27);
this.diskView.Name = "diskView";
this.diskView.Size = new System.Drawing.Size(213, 444);
@ -128,63 +130,57 @@ private void InitializeComponent()
this.RenameToolStripMenuItem,
this.CloseToolStripMenuItem});
this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";
this.FileToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.FileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.FileToolStripMenuItem.Text = "File";
//
// CreateShortcutToolStripMenuItem
//
this.CreateShortcutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FolderToolStripMenuItem,
this.ShortcutToolStripMenuItem,
this.TextDocumentToolStripMenuItem,
this.BitmapImageToolStripMenuItem});
this.CreateShortcutToolStripMenuItem.Name = "CreateShortcutToolStripMenuItem";
this.CreateShortcutToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.CreateShortcutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.CreateShortcutToolStripMenuItem.Text = "New";
//
// FolderToolStripMenuItem
//
this.FolderToolStripMenuItem.Name = "FolderToolStripMenuItem";
this.FolderToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.FolderToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.FolderToolStripMenuItem.Text = "Folder";
this.FolderToolStripMenuItem.Click += new System.EventHandler(this.FolderToolStripMenuItem_Click);
//
// ShortcutToolStripMenuItem
//
this.ShortcutToolStripMenuItem.Name = "ShortcutToolStripMenuItem";
this.ShortcutToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.ShortcutToolStripMenuItem.Text = "Shortcut";
//
// TextDocumentToolStripMenuItem
//
this.TextDocumentToolStripMenuItem.Name = "TextDocumentToolStripMenuItem";
this.TextDocumentToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.TextDocumentToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.TextDocumentToolStripMenuItem.Text = "Text Document";
this.TextDocumentToolStripMenuItem.Click += new System.EventHandler(this.TextDocumentToolStripMenuItem_Click);
//
// BitmapImageToolStripMenuItem
//
this.BitmapImageToolStripMenuItem.Name = "BitmapImageToolStripMenuItem";
this.BitmapImageToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.BitmapImageToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.BitmapImageToolStripMenuItem.Text = "Bitmap Image";
//
// DeleteToolStripMenuItem
//
this.DeleteToolStripMenuItem.Name = "DeleteToolStripMenuItem";
this.DeleteToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.DeleteToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.DeleteToolStripMenuItem.Text = "Delete";
this.DeleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItem_Click);
//
// RenameToolStripMenuItem
//
this.RenameToolStripMenuItem.Name = "RenameToolStripMenuItem";
this.RenameToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.RenameToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.RenameToolStripMenuItem.Text = "Rename";
this.RenameToolStripMenuItem.Click += new System.EventHandler(this.RenameToolStripMenuItem_Click);
//
// CloseToolStripMenuItem
//
this.CloseToolStripMenuItem.Name = "CloseToolStripMenuItem";
this.CloseToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
this.CloseToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.CloseToolStripMenuItem.Text = "Close";
this.CloseToolStripMenuItem.Click += new System.EventHandler(this.CloseToolStripMenuItem_Click);
//
@ -196,34 +192,34 @@ private void InitializeComponent()
this.PasteToolStripMenuItem,
this.SellectAllCtrlAToolStripMenuItem});
this.EditToolStripMenuItem.Name = "EditToolStripMenuItem";
this.EditToolStripMenuItem.Size = new System.Drawing.Size(43, 20);
this.EditToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.EditToolStripMenuItem.Text = "Edit";
//
// CutCtrlXToolStripMenuItem
//
this.CutCtrlXToolStripMenuItem.Name = "CutCtrlXToolStripMenuItem";
this.CutCtrlXToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.CutCtrlXToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.CutCtrlXToolStripMenuItem.Text = "Cut Ctrl+X";
this.CutCtrlXToolStripMenuItem.Click += new System.EventHandler(this.CutCtrlXToolStripMenuItem_Click);
//
// CopyCtrlCToolStripMenuItem
//
this.CopyCtrlCToolStripMenuItem.Name = "CopyCtrlCToolStripMenuItem";
this.CopyCtrlCToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.CopyCtrlCToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.CopyCtrlCToolStripMenuItem.Text = "Copy Ctrl+C";
this.CopyCtrlCToolStripMenuItem.Click += new System.EventHandler(this.CopyCtrlCToolStripMenuItem_Click);
//
// PasteToolStripMenuItem
//
this.PasteToolStripMenuItem.Name = "PasteToolStripMenuItem";
this.PasteToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.PasteToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.PasteToolStripMenuItem.Text = "Paste Ctrl+V";
this.PasteToolStripMenuItem.Click += new System.EventHandler(this.PasteToolStripMenuItem_Click);
//
// SellectAllCtrlAToolStripMenuItem
//
this.SellectAllCtrlAToolStripMenuItem.Name = "SellectAllCtrlAToolStripMenuItem";
this.SellectAllCtrlAToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
this.SellectAllCtrlAToolStripMenuItem.Size = new System.Drawing.Size(197, 22);
this.SellectAllCtrlAToolStripMenuItem.Text = "Select All Ctrl+A";
this.SellectAllCtrlAToolStripMenuItem.Click += new System.EventHandler(this.SellectAllCtrlAToolStripMenuItem_Click);
//
@ -232,13 +228,13 @@ private void InitializeComponent()
this.ViewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.RefreshToolStripMenuItem});
this.ViewToolStripMenuItem.Name = "ViewToolStripMenuItem";
this.ViewToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.ViewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.ViewToolStripMenuItem.Text = "View";
//
// RefreshToolStripMenuItem
//
this.RefreshToolStripMenuItem.Name = "RefreshToolStripMenuItem";
this.RefreshToolStripMenuItem.Size = new System.Drawing.Size(121, 22);
this.RefreshToolStripMenuItem.Size = new System.Drawing.Size(113, 22);
this.RefreshToolStripMenuItem.Text = "Refresh";
this.RefreshToolStripMenuItem.Click += new System.EventHandler(this.RefreshToolStripMenuItem_Click);
//
@ -248,19 +244,19 @@ private void InitializeComponent()
this.HelpToolStripMenuItem1,
this.AboutWindows95ToolStripMenuItem});
this.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem";
this.HelpToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.HelpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.HelpToolStripMenuItem.Text = "Help";
//
// HelpToolStripMenuItem1
//
this.HelpToolStripMenuItem1.Name = "HelpToolStripMenuItem1";
this.HelpToolStripMenuItem1.Size = new System.Drawing.Size(188, 22);
this.HelpToolStripMenuItem1.Size = new System.Drawing.Size(174, 22);
this.HelpToolStripMenuItem1.Text = "Help Topics";
//
// AboutWindows95ToolStripMenuItem
//
this.AboutWindows95ToolStripMenuItem.Name = "AboutWindows95ToolStripMenuItem";
this.AboutWindows95ToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.AboutWindows95ToolStripMenuItem.Size = new System.Drawing.Size(174, 22);
this.AboutWindows95ToolStripMenuItem.Text = "About Windows 95";
this.AboutWindows95ToolStripMenuItem.Click += new System.EventHandler(this.AboutWindows95ToolStripMenuItem_Click);
//
@ -368,7 +364,6 @@ private void InitializeComponent()
internal System.Windows.Forms.ToolStripMenuItem FileToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem CreateShortcutToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem FolderToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem ShortcutToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem TextDocumentToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem BitmapImageToolStripMenuItem;
internal System.Windows.Forms.ToolStripMenuItem DeleteToolStripMenuItem;

View file

@ -69,7 +69,9 @@ void WinClassicWindowsExplorer_Load(object sender, EventArgs e)
Properties.Resources.WinClassicCalcBig,
Properties.Resources.WinClassicNotepadBig,
Properties.Resources.WinClassicRegedit, // 15
Properties.Resources.WinClassicWordpad });
Properties.Resources.WinClassicWordpad,
Properties.Resources.WinClassicTextFile,
Properties.Resources.WinClassicRtfFile});
program.BringToFront();
@ -605,7 +607,10 @@ void mainView_DoubleClick(object sender, EventArgs e)
{
if (new DirectoryInfo((string)mainView.FocusedItem.Tag).Extension == null || new DirectoryInfo((string)mainView.FocusedItem.Tag).Extension == "")
{ // If it isn't a file
GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text));
if (mainView.FocusedItem.Text == "C:")
GoToDir(Path.Combine(CurrentDirectory, "CDrive"));
else
GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text));
}
else
{ // If it is a file
@ -979,5 +984,10 @@ private void mainView_MouseClick(object sender, MouseEventArgs e)
{
}
private void TextDocumentToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}

View file

@ -12,6 +12,7 @@
using TimeHACK.Engine;
using Newtonsoft.Json;
using TimeHACK.Engine.Template;
using System.Diagnostics;
namespace TimeHACK.OS.Win95.Win95Apps
{
@ -123,81 +124,54 @@ string ReadDataFile(string reqDirectory, bool returnYesIfProtected = false) {
}
void RefreshAll() {
try {
//try {
this.mainView.Items.Clear();
this.mainView.Items.Clear();
foreach (string str in Directory.GetDirectories(CurrentDirectory))
{
string label = ReadDataFile(str, false);
ListViewItem itm = this.mainView.Items.Add(label ?? Path.GetFileName(str));
itm.ImageIndex = 1;
itm.Tag = str;
}
foreach (string str in Directory.GetFiles(CurrentDirectory))
{
ListViewItem itm;
// Update the WebView
if (CurrentDirectory == SaveSystem.ProfileMyComputerDirectory)
if (IsFileOpenDialog == true || IsFileSaveDialog == true)
{
pictureBox1.Image = Properties.Resources.Win95HardDiskIcon;
} else if (CurrentDirectory == SaveSystem.ProfileFileSystemDirectory) {
pictureBox1.Image = Properties.Resources.Win95Computer;
} else {
pictureBox1.Image = Properties.Resources.WinClassicFolder;
}
txtInfoTip.Show();
InfoDesc.Hide();
string weblabel = ReadDataFile(CurrentDirectory, false);
txtInfoTitle.Text = weblabel ?? new FileInfo(CurrentDirectory).Name;
foreach (string str in Directory.GetDirectories(CurrentDirectory))
{
string label = ReadDataFile(str, false);
ListViewItem itm = this.mainView.Items.Add(label ?? Path.GetFileName(str));
itm.ImageKey = str;
}
foreach (string str in Directory.GetFiles(CurrentDirectory))
{
// Get the app Icon
//int AppIcon = 2;
//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;
//}
if (IsFileOpenDialog == true || IsFileSaveDialog == true)
if (!(Path.GetFileName(str) == "_data.info"))
{
if (!(Path.GetFileName(str) == "_data.info"))
if (new FileInfo(str).Extension == onlyViewExtension)
{
if (new FileInfo(str).Extension == onlyViewExtension)
{
ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str;
}
}
} else {
if (!(Path.GetFileName(str) == "_data.info")) {
ListViewItem itm = this.mainView.Items.Add(Path.GetFileName(str));
itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str;
}
else break;
}
else break;
}
else
{
if (!(Path.GetFileName(str) == "_data.info"))
{
itm = this.mainView.Items.Add(Path.GetFileName(str));
itm.Tag = str;
}
else break;
}
FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(CurrentDirectory, "_data.info")));
foreach (var item in fsfi.Files)
{
Debug.Print(item.Name + " " + Path.GetFileName(str));
if (item.Name == Path.GetFileName(str)) { itm.ImageIndex = item.FileIcon; break; }
}
} catch (Exception ex) {
//wm.StartInfobox95("Exploring - C:", "Error with the file explorer \n" + ex.Message, Properties.Resources.Win95Info); add illegal operation dialog here later
((Form)this.TopLevelControl).Close();
}
/*
} catch (Exception ex) {
//wm.StartInfobox95("Exploring - C:", "Error with the file explorer \n" + ex.Message, Properties.Resources.Win95Info); add illegal operation dialog here later
((Form)this.TopLevelControl).Close();
}*/
}
void RefreshTreeNode()
@ -602,31 +576,36 @@ void mainView_DoubleClick(object sender, EventArgs e)
{
try
{
if (mainView.FocusedItem.Tag == null)
if (new DirectoryInfo((string)mainView.FocusedItem.Tag).Extension == null || new DirectoryInfo((string)mainView.FocusedItem.Tag).Extension == "")
{ // If it isn't a file
GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.ImageKey.ToString()));
if (mainView.FocusedItem.Text == "C:")
GoToDir(Path.Combine(CurrentDirectory, "CDrive"));
else
GoToDir(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text));
}
else
{ // If it is a file
if (IsFileOpenDialog == true || IsFileSaveDialog == true)
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);
}
FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false;
((Form)this.TopLevelControl).Close();
}
else
{
OpenFile(mainView.FocusedItem.Tag.ToString());
Program.WindowsExplorerReturnPath = Path.Combine(CurrentDirectory, txtSave.Text);
}
FileDialogBoxManager.IsInOpenDialog = false;
FileDialogBoxManager.IsInSaveDialog = false;
((Form)this.TopLevelControl).Close();
}
else
{
OpenFile(mainView.FocusedItem.Tag.ToString());
}
}
} catch (Exception ex) {
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

View file

@ -1580,6 +1580,16 @@ internal static System.Drawing.Bitmap WinClassicRegedit {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap WinClassicRtfFile {
get {
object obj = ResourceManager.GetObject("WinClassicRtfFile", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -1660,6 +1670,16 @@ internal static System.Drawing.Bitmap WinClassicTaskbarItem {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap WinClassicTextFile {
get {
object obj = ResourceManager.GetObject("WinClassicTextFile", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -804,4 +804,10 @@
<data name="IE3_StopHover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\IE3\IE3_StopHover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="WinClassicRtfFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\WinClassicRtfFile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="WinClassicTextFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\WinClassicTextFile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

View file

@ -615,6 +615,8 @@
<None Include="Resources\WinClassicGENERALApplicationToolBoxBackground.png" />
<None Include="Resources\Win2000WebBackground.png" />
<None Include="Resources\Win98WebBackground.png" />
<None Include="Resources\WinClassicTextFile.png" />
<None Include="Resources\WinClassicRtfFile.png" />
<Content Include="Resources\WinClassic\16Color.png" />
<Content Include="Resources\WinClassic\256Color.png" />
<None Include="Resources\WinClassic\tada.wav" />