Add FS delete functions

This commit is contained in:
Michael 2017-04-22 08:54:38 -04:00
parent 45b290efd9
commit 114141b56e
5 changed files with 74 additions and 18 deletions

View file

@ -122,6 +122,7 @@ namespace ShiftOS.WinForms.Applications
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// connectToRemoteServerToolStripMenuItem
//

View file

@ -261,7 +261,7 @@ namespace ShiftOS.WinForms.Applications
{
moveToolStripMenuItem.Visible = false;
copyToolStripMenuItem.Visible = false;
deleteToolStripMenuItem.Visible = false;
}
private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
@ -298,11 +298,13 @@ namespace ShiftOS.WinForms.Applications
{
if (DirectoryExists(currentdir + "/" + itm.Tag.ToString()))
{
deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_recursive_delete");
moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move_folder");
copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy_folder");
}
else if (FileExists(currentdir + "/" + itm.Tag.ToString()))
{
deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_delete");
moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move");
copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy");
}
@ -322,6 +324,7 @@ namespace ShiftOS.WinForms.Applications
{
moveToolStripMenuItem.Visible = false;
copyToolStripMenuItem.Visible = false;
deleteToolStripMenuItem.Visible = false;
}
}
@ -387,6 +390,22 @@ namespace ShiftOS.WinForms.Applications
}
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Infobox.PromptYesNo("Delete file", "Are you sure you want to delete " + lvitems.SelectedItems[0].Text + "?", (result) =>
{
if (result == true)
{
Delete(currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString());
ResetList();
}
});
}
catch { }
}
}

View file

@ -270,6 +270,20 @@
Category: "Device Drivers",
Dependencies: "color_depth_8_bits"
},
{
Name: "FS Delete",
Cost: 75,
Description: "Got some files that you want to get rid of? This upgrade adds a button to the File Skimmer for doing just that.",
Dependencies: "file_skimmer",
Category: "Enhancements",
},
{
Name: "FS Recursive Delete",
Cost: 100,
Description: "Deleting files is great, but what if you have an entire folder you need to get rid of? This upgrade allows the deletion of folders and all files and folders inside them. Just, don't delete your system folder!",
Dependencies: "fs_delete",
Category: "Enhancements"
},
{
Name: "Color Depth 24 Bits",
Cost: 24000,

View file

@ -61,6 +61,7 @@ namespace ShiftOS.WinForms
public WinformsDesktop()
{
InitializeComponent();
ControlManager.MakeDoubleBuffered(pnlwidgetlayer);
this.Click += (o, a) =>
{
HideAppLauncher();
@ -455,7 +456,7 @@ namespace ShiftOS.WinForms
UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null);
w.Location = WidgetManager.LoadLocation(w.GetType());
w.Top -= desktoppanel.Height;
pnlwidgetlayer.Controls.Add(w);
MakeWidgetMovable(w);
Widgets.Add(w as IDesktopWidget);
@ -466,6 +467,8 @@ namespace ShiftOS.WinForms
{
if (Shiftorium.UpgradeInstalled("desktop_widgets"))
{
widget.OnSkinLoad();
widget.OnUpgrade();
widget.Setup();
widget.Show();
}
@ -474,6 +477,9 @@ namespace ShiftOS.WinForms
widget.Hide();
}
}
pnlwidgetlayer.Show();
pnlwidgetlayer.BringToFront();
}
else
@ -520,7 +526,7 @@ namespace ShiftOS.WinForms
w.MouseUp += (o, a) =>
{
moving = false;
WidgetManager.SaveLocation(startCtrl.GetType(), w.Location);
WidgetManager.SaveLocation(startCtrl.GetType(), startCtrl.Location);
};
foreach (Control c in w.Controls)

View file

@ -135,41 +135,57 @@ namespace ShiftOS.Engine
//This event-based system allows us to sync the ramdisk from ShiftOS to the host OS.
Utils.DirectoryCreated += (dir) =>
{
if (dir.StartsWith("1:/"))
try
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (!System.IO.Directory.Exists(real))
System.IO.Directory.CreateDirectory(real);
if (dir.StartsWith("1:/"))
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (!System.IO.Directory.Exists(real))
System.IO.Directory.CreateDirectory(real);
}
}
catch { }
};
Utils.DirectoryDeleted += (dir) =>
{
if (dir.StartsWith("1:/"))
try
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (System.IO.Directory.Exists(real))
System.IO.Directory.Delete(real, true);
if (dir.StartsWith("1:/"))
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (System.IO.Directory.Exists(real))
System.IO.Directory.Delete(real, true);
}
}
catch { }
};
Utils.FileWritten += (dir) =>
{
if (dir.StartsWith("1:/"))
try
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
System.IO.File.WriteAllBytes(real, ReadAllBytes(dir));
if (dir.StartsWith("1:/"))
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
System.IO.File.WriteAllBytes(real, ReadAllBytes(dir));
}
}
catch { }
};
Utils.FileDeleted += (dir) =>
{
if (dir.StartsWith("1:/"))
try
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (System.IO.File.Exists(real))
System.IO.File.Delete(real);
if (dir.StartsWith("1:/"))
{
string real = dir.Replace("/", "\\").Replace("1:", SharedFolder);
if (System.IO.File.Exists(real))
System.IO.File.Delete(real);
}
}
catch { }
};
//This thread will sync the ramdisk from the host OS to ShiftOS.