From 114141b56e02857fa749cc130f16a2d6cc4c35f5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Apr 2017 08:54:38 -0400 Subject: [PATCH] Add FS delete functions --- .../Applications/FileSkimmer.Designer.cs | 1 + ShiftOS.WinForms/Applications/FileSkimmer.cs | 21 ++++++++- ShiftOS.WinForms/Resources/Shiftorium.txt | 14 ++++++ ShiftOS.WinForms/WinformsDesktop.cs | 10 +++- ShiftOS_TheReturn/Paths.cs | 46 +++++++++++++------ 5 files changed, 74 insertions(+), 18 deletions(-) diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index c917840..dd19108 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -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 // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 4b11d24..3b4b2e7 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -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 { } + } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 2cd9680..dadb022 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -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, diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 09703db..c458a4a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -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) diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index e756da7..a84271b 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -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.