diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index 2c6b28b..d35e5b7 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -173,6 +173,11 @@ namespace ShiftOS.Objects.ShiftFS t.Start(); } + public static event Action<string> DirectoryCreated; + public static event Action<string> DirectoryDeleted; + public static event Action<string> FileWritten; + public static event Action<string> FileDeleted; + public static void CreateDirectory(string path) { @@ -190,6 +195,7 @@ namespace ShiftOS.Objects.ShiftFS Name = pathlist[pathlist.Length - 1], permissions = CurrentUser, }); + DirectoryCreated?.Invoke(path); } else { @@ -231,7 +237,7 @@ namespace ShiftOS.Objects.ShiftFS var f = dir.FindFileByName(pathlist[pathlist.Length - 1]); f.Data = Encoding.UTF8.GetBytes(contents); } - + FileWritten?.Invoke(path); } @@ -248,10 +254,12 @@ namespace ShiftOS.Objects.ShiftFS if (FileExists(path)) { dir.RemoveFile(pathlist[pathlist.Length - 1]); + FileDeleted?.Invoke(path); } else { dir.RemoveDirectory(pathlist[pathlist.Length - 1]); + DirectoryDeleted?.Invoke(path); } } @@ -276,7 +284,7 @@ namespace ShiftOS.Objects.ShiftFS var f = dir.FindFileByName(pathlist[pathlist.Length - 1]); f.Data = contents; } - + FileWritten?.Invoke(path); } diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index b75f801..63b61cc 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -58,6 +58,9 @@ namespace ShiftOS.WinForms.Applications this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.newFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.connectToRemoteServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.panel1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -70,6 +73,8 @@ namespace ShiftOS.WinForms.Applications this.lvitems.Size = new System.Drawing.Size(634, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; + this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); + this.lvitems.SelectedIndexChanged += new System.EventHandler(this.lvitems_SelectedIndexChanged); this.lvitems.DoubleClick += new System.EventHandler(this.lvitems_DoubleClick); // // panel1 @@ -95,7 +100,10 @@ namespace ShiftOS.WinForms.Applications // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newFolderToolStripMenuItem, - this.deleteToolStripMenuItem}); + this.deleteToolStripMenuItem, + this.connectToRemoteServerToolStripMenuItem, + this.copyToolStripMenuItem, + this.moveToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(634, 24); @@ -115,6 +123,24 @@ namespace ShiftOS.WinForms.Applications this.deleteToolStripMenuItem.Size = new System.Drawing.Size(52, 20); this.deleteToolStripMenuItem.Text = "Delete"; // + // connectToRemoteServerToolStripMenuItem + // + this.connectToRemoteServerToolStripMenuItem.Name = "connectToRemoteServerToolStripMenuItem"; + this.connectToRemoteServerToolStripMenuItem.Size = new System.Drawing.Size(153, 20); + this.connectToRemoteServerToolStripMenuItem.Text = "Connect to remote server"; + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.copyToolStripMenuItem.Text = "Copy"; + // + // moveToolStripMenuItem + // + this.moveToolStripMenuItem.Name = "moveToolStripMenuItem"; + this.moveToolStripMenuItem.Size = new System.Drawing.Size(49, 20); + this.moveToolStripMenuItem.Text = "Move"; + // // FileSkimmer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -140,5 +166,8 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem newFolderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem connectToRemoteServerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index b9040ae..689c718 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -259,6 +259,9 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } private void newFolderToolStripMenuItem_Click(object sender, EventArgs e) @@ -283,6 +286,44 @@ namespace ShiftOS.WinForms.Applications } }); } + + private void lvitems_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (currentdir != "__system") + { + var itm = lvitems.SelectedItems[0]; + if (itm.Tag.ToString() != "__..") + { + if (DirectoryExists(currentdir + "/" + itm.Tag.ToString())) + { + moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move_folder"); + copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy_folder"); + } + else if (FileExists(currentdir + "/" + itm.Tag.ToString())) + { + moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move"); + copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy"); + } + } + } + } + catch + { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } + } + + private void lvitems_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) + { + if(lvitems.SelectedItems.Count == 0) + { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } + } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c70f849..2cd9680 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -77,6 +77,34 @@ Category: "Enhancements", Description: "You can add numbers together, but it must be tiring to add the same number over and over. This multiplication button will make it easier for you!" }, + { + Name: "FS Copy", + Cost: 75, + Dependencies: "file_skimmer", + Description: "It is cool to be able to browse your files, but what if you need a new copy of a file? This upgrade adds a button to the File Skimmer that allows you to copy single files to new locations.", + Category: "Enhancements" + }, + { + Name: "FS Move", + Cost: 75, + Dependencies: "file_skimmer", + Description: "Want to move files from one place to another? This upgrade adds a button to the File Skimmer that does just that!", + Category: "Enhancements" + }, + { + Name: "FS Copy Folder", + Cost: 100, + Dependencies: "fs_copy", + Description: "You can copy single files, but what if you have a lot of files in a folder that you need to get copied over? This upgrade adds the ability to copy a folder to a new location in the File Skimmer.", + Category: "Enhancements" + }, + { + Name: "FS Move Folder", + Cost: 100, + Dependencies: "fs_move", + Description: "Being able to move single files is great, but it takes time to move all the files in a folder to a new location. This upgrade will cut down on that time!", + Category: "Enhancements" + }, { Name: "Calc Divide Button", Cost: 800, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index b9e6910..9dc3593 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -295,6 +295,7 @@ <Compile Include="ScriptingTestFunctions.cs" /> <Compile Include="ShiftOSAudioProvider.cs" /> <Compile Include="ShiftOSConfigFile.cs" /> + <Compile Include="SkinCommands.cs" /> <Compile Include="Stories\LegionStory.cs" /> <Compile Include="Tools\ColorPickerDataBackend.cs" /> <Compile Include="Tools\ControlManager.cs" /> diff --git a/ShiftOS.WinForms/SkinCommands.cs b/ShiftOS.WinForms/SkinCommands.cs new file mode 100644 index 0000000..1f32d96 --- /dev/null +++ b/ShiftOS.WinForms/SkinCommands.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects.ShiftFS; + +namespace ShiftOS.WinForms +{ + [Namespace("skins")] + public static class SkinCommands + { + [Command("reset")] + [RequiresUpgrade("shifter")] + public static bool ResetSkin() + { + Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(new Skin())); + SkinEngine.LoadSkin(); + return true; + } + } +} diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 2fc55fd..a7d32e7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -40,7 +40,6 @@ namespace ShiftOS.Engine public static void Init() { Locations = new Dictionary<string, string>(); - Locations.Add("classic", "C:\\ShiftOS"); Locations.Add("root", "0:"); AddPath("root", "system"); @@ -133,6 +132,46 @@ namespace ShiftOS.Engine mount.Name = "Shared"; Utils.Mount(JsonConvert.SerializeObject(mount)); ScanForDirectories(SharedFolder, 1); + Utils.DirectoryCreated += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (!System.IO.Directory.Exists(real)) + System.IO.Directory.CreateDirectory(real); + } + }; + + Utils.DirectoryDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.Directory.Exists(real)) + System.IO.Directory.Delete(real, true); + } + }; + + Utils.FileWritten += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + System.IO.File.WriteAllBytes(real, ReadAllBytes(dir)); + } + }; + + Utils.FileDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.File.Exists(real)) + System.IO.File.Delete(real); + } + }; + + }