From 5cb49f332856ac312e8840ec04c7869b892d4dd4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Apr 2017 14:18:02 -0400 Subject: Store widget locations in file --- ShiftOS_TheReturn/Paths.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'ShiftOS_TheReturn/Paths.cs') diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 4f535d6..2fc55fd 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -61,6 +61,7 @@ namespace ShiftOS.Engine AddPath("data", "user.dat"); AddPath("data", "notifications.dat"); AddPath("data", "skin"); + AddPath("skin", "widgets.dat"); AddPath("system", "programs"); AddPath("system", "kernel.sft"); AddPath("system", "conf.sft"); -- cgit v1.2.3 From db563c54aedf5e9d96ca70eec08c560ccbc42d8d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 21 Apr 2017 18:53:41 -0400 Subject: Add ShiftOS->Host Shared Persistence ShiftOS can now write to the shared folder when saving files/deleting files to the 1:/ drive. --- ShiftOS.Objects/ShiftFS.cs | 12 +++++-- .../Applications/FileSkimmer.Designer.cs | 31 +++++++++++++++- ShiftOS.WinForms/Applications/FileSkimmer.cs | 41 ++++++++++++++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 28 +++++++++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/SkinCommands.cs | 24 +++++++++++++ ShiftOS_TheReturn/Paths.cs | 41 +++++++++++++++++++++- 7 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 ShiftOS.WinForms/SkinCommands.cs (limited to 'ShiftOS_TheReturn/Paths.cs') 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 DirectoryCreated; + public static event Action DirectoryDeleted; + public static event Action FileWritten; + public static event Action 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 @@ + 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(); - 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); + } + }; + + } -- cgit v1.2.3 From 1e74f09670a89d8fdf51215aa7a275c335e80211 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 21 Apr 2017 18:58:58 -0400 Subject: Bidirectional Persistence! --- ShiftOS_TheReturn/Paths.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ShiftOS_TheReturn/Paths.cs') diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index a7d32e7..e756da7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -132,6 +132,7 @@ namespace ShiftOS.Engine mount.Name = "Shared"; Utils.Mount(JsonConvert.SerializeObject(mount)); ScanForDirectories(SharedFolder, 1); + //This event-based system allows us to sync the ramdisk from ShiftOS to the host OS. Utils.DirectoryCreated += (dir) => { if (dir.StartsWith("1:/")) @@ -171,7 +172,17 @@ namespace ShiftOS.Engine } }; - + //This thread will sync the ramdisk from the host OS to ShiftOS. + var t = new Thread(() => + { + while (!SaveSystem.ShuttingDown) + { + Thread.Sleep(15000); + ScanForDirectories(SharedFolder, 1); + } + }); + t.IsBackground = true; + t.Start(); } @@ -186,7 +197,8 @@ namespace ShiftOS.Engine foreach (var directory in System.IO.Directory.GetDirectories(folder)) { string mfsDir = directory.Replace(SharedFolder, $"{mount}:").Replace("\\", "/"); - CreateDirectory(mfsDir); + if(!DirectoryExists(mfsDir)) + CreateDirectory(mfsDir); ScanForDirectories(directory, mount); } } -- cgit v1.2.3 From 114141b56e02857fa749cc130f16a2d6cc4c35f5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Apr 2017 08:54:38 -0400 Subject: 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(-) (limited to 'ShiftOS_TheReturn/Paths.cs') 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. -- cgit v1.2.3 From cd29d582d90e0a31a9b21661a813c789b82468cc Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 25 Apr 2017 11:48:44 -0400 Subject: appscape fixes + video player --- .../Applications/VideoPlayer.Designer.cs | 168 +++++++++++++++++++++ ShiftOS.WinForms/Applications/VideoPlayer.cs | 132 ++++++++++++++++ ShiftOS.WinForms/Applications/VideoPlayer.resx | 134 ++++++++++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 70 +++++---- ShiftOS_TheReturn/Paths.cs | 3 +- 6 files changed, 486 insertions(+), 30 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/VideoPlayer.cs create mode 100644 ShiftOS.WinForms/Applications/VideoPlayer.resx (limited to 'ShiftOS_TheReturn/Paths.cs') diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs new file mode 100644 index 0000000..d915c31 --- /dev/null +++ b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs @@ -0,0 +1,168 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class VideoPlayer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayer)); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.flcontrols = new System.Windows.Forms.FlowLayoutPanel(); + this.btnplay = new System.Windows.Forms.Button(); + this.pgplaytime = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.addSongToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.wpaudio = new AxWMPLib.AxWindowsMediaPlayer(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); + this.flcontrols.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit(); + this.SuspendLayout(); + // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.wpaudio); + this.toolStripContainer1.ContentPanel.Controls.Add(this.flcontrols); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(805, 402); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.LeftToolStripPanelVisible = false; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.RightToolStripPanelVisible = false; + this.toolStripContainer1.Size = new System.Drawing.Size(805, 426); + this.toolStripContainer1.TabIndex = 3; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1); + // + // flcontrols + // + this.flcontrols.AutoSize = true; + this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flcontrols.Controls.Add(this.btnplay); + this.flcontrols.Controls.Add(this.pgplaytime); + this.flcontrols.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flcontrols.Location = new System.Drawing.Point(0, 373); + this.flcontrols.Name = "flcontrols"; + this.flcontrols.Size = new System.Drawing.Size(805, 29); + this.flcontrols.TabIndex = 0; + // + // btnplay + // + this.btnplay.AutoSize = true; + this.btnplay.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnplay.Location = new System.Drawing.Point(3, 3); + this.btnplay.Name = "btnplay"; + this.btnplay.Size = new System.Drawing.Size(37, 23); + this.btnplay.TabIndex = 0; + this.btnplay.Text = "Play"; + this.btnplay.UseVisualStyleBackColor = true; + this.btnplay.Click += new System.EventHandler(this.btnplay_Click); + // + // pgplaytime + // + this.pgplaytime.BlockSize = 5; + this.pgplaytime.Location = new System.Drawing.Point(46, 3); + this.pgplaytime.Maximum = 100; + this.pgplaytime.Name = "pgplaytime"; + this.pgplaytime.Size = new System.Drawing.Size(749, 23); + this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.pgplaytime.TabIndex = 1; + this.pgplaytime.Tag = "keepbg"; + this.pgplaytime.Text = "shiftedProgressBar1"; + this.pgplaytime.Value = 0; + this.pgplaytime.MouseDown += new System.Windows.Forms.MouseEventHandler(this.startScrub); + this.pgplaytime.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseMove); + this.pgplaytime.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseUp); + // + // menuStrip1 + // + this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addSongToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(805, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // addSongToolStripMenuItem + // + this.addSongToolStripMenuItem.Name = "addSongToolStripMenuItem"; + this.addSongToolStripMenuItem.Size = new System.Drawing.Size(81, 20); + this.addSongToolStripMenuItem.Text = "Open Video"; + this.addSongToolStripMenuItem.Click += new System.EventHandler(this.addSongToolStripMenuItem_Click); + // + // wpaudio + // + this.wpaudio.Dock = System.Windows.Forms.DockStyle.Fill; + this.wpaudio.Enabled = true; + this.wpaudio.Location = new System.Drawing.Point(0, 0); + this.wpaudio.Name = "wpaudio"; + this.wpaudio.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wpaudio.OcxState"))); + this.wpaudio.Size = new System.Drawing.Size(805, 373); + this.wpaudio.TabIndex = 2; + this.wpaudio.Visible = false; + // + // VideoPlayer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.toolStripContainer1); + this.Name = "VideoPlayer"; + this.Size = new System.Drawing.Size(805, 426); + this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.ContentPanel.PerformLayout(); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); + this.flcontrols.ResumeLayout(false); + this.flcontrols.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + private System.Windows.Forms.FlowLayoutPanel flcontrols; + private System.Windows.Forms.Button btnplay; + private Controls.ShiftedProgressBar pgplaytime; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem addSongToolStripMenuItem; + private AxWMPLib.AxWindowsMediaPlayer wpaudio; + } +} diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.cs b/ShiftOS.WinForms/Applications/VideoPlayer.cs new file mode 100644 index 0000000..29c318f --- /dev/null +++ b/ShiftOS.WinForms/Applications/VideoPlayer.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using System.IO; + +namespace ShiftOS.WinForms.Applications +{ + [AppscapeEntry("Video Player", "Play .mp4 files or .wmv files as videos inside ShiftOS! Perfect for a shifted movie night.", 1524, 1000, "file_skimmer", "Entertainment")] + [DefaultTitle("Video Player")] + [Launcher("Video Player", false, null, "Entertainment")] + [WinOpen("video_player")] + public partial class VideoPlayer : UserControl, IShiftOSWindow + { + public VideoPlayer() + { + InitializeComponent(); + } + + public void OnLoad() + { + tmr.Interval = 50; + tmr.Tick += (o, a) => + { + try + { + double end = wpaudio.currentMedia.duration; + double pos = wpaudio.Ctlcontrols.currentPosition; + pgplaytime.Maximum = (int)end; + pgplaytime.Value = (int)pos; + } + catch { } + }; + tmr.Start(); + } + + public void OnSkinLoad() + { + wpaudio.uiMode = "none"; + wpaudio.Show(); + pgplaytime.Width = flcontrols.Width - btnplay.Width - 25; + wpaudio.enableContextMenu = false; + } + + public bool OnUnload() + { + if(!string.IsNullOrWhiteSpace(filePath)) + if (File.Exists(filePath)) + File.Delete(filePath); + tmr.Stop(); + return true; + } + + public void OnUpgrade() + { + } + + Timer tmr = new Timer(); + + string filePath = null; + + private void addSongToolStripMenuItem_Click(object sender, EventArgs e) + { + FileSkimmerBackend.GetFile(new[] { ".mp4", ".wmv" }, FileOpenerStyle.Open, (result) => + { + var finf = ShiftOS.Objects.ShiftFS.Utils.GetFileInfo(result); + File.WriteAllBytes(finf.Name, ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(result)); + filePath = finf.Name; + wpaudio.URL = filePath; + wpaudio.Ctlcontrols.play(); + btnplay.Text = "Pause"; + }); + } + + private void btnplay_Click(object sender, EventArgs e) + { + if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying) + { + wpaudio.Ctlcontrols.pause(); + btnplay.Text = "Play"; + } + else if(wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused) + { + wpaudio.Ctlcontrols.play(); + btnplay.Text = "Pause"; + } + } + + bool scrubbing = false; + + private void startScrub(object sender, MouseEventArgs e) + { + scrubbing = true; + } + + static public double linear(double x, double x0, double x1, double y0, double y1) + { + if ((x1 - x0) == 0) + { + return (y0 + y1) / 2; + } + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + private void pgplaytime_MouseMove(object sender, MouseEventArgs e) + { + if (wpaudio.playState == WMPLib.WMPPlayState.wmppsPlaying || wpaudio.playState == WMPLib.WMPPlayState.wmppsPaused) + try + { + if (scrubbing) + { + double end = wpaudio.currentMedia.duration; + double result = linear(e.X, 0, pgplaytime.Width, 0, end); + wpaudio.Ctlcontrols.currentPosition = result; + } + } + catch { } + } + + private void pgplaytime_MouseUp(object sender, MouseEventArgs e) + { + scrubbing = false; + } + + } +} diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.resx b/ShiftOS.WinForms/Applications/VideoPlayer.resx new file mode 100644 index 0000000..d484b91 --- /dev/null +++ b/ShiftOS.WinForms/Applications/VideoPlayer.resx @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB + AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA + AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAbgBvAG4AZQAAAAsA + AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAelIAAK4w + AAAL + + + + 17, 17 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index dac803d..7c39078 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -244,6 +244,12 @@ UpdateManager.cs + + UserControl + + + VideoPlayer.cs + UserControl @@ -459,6 +465,9 @@ UpdateManager.cs + + VideoPlayer.cs + WidgetManagerFrontend.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 17a6e4c..84783e5 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -79,6 +79,7 @@ namespace ShiftOS.WinForms.ShiftnetSites var fl = new FlowLayoutPanel(); fl.Dock = DockStyle.Fill; pnlappslist.Controls.Add(fl); + fl.AutoScroll = true; fl.Show(); foreach(var upg in upgrades) { @@ -148,6 +149,20 @@ namespace ShiftOS.WinForms.ShiftnetSites } } + public bool DependenciesInstalled(ShiftoriumUpgrade upg) + { + string[] split = upg.Dependencies.Split(';'); + foreach(var u in split) + { + if (!u.StartsWith("appscape_handled")) + { + if (!Shiftorium.UpgradeInstalled(u)) + return false; + } + } + return true; + } + public void ViewMoreInfo(ShiftoriumUpgrade upg) { lbtitle.Text = upg.Name; @@ -178,11 +193,11 @@ namespace ShiftOS.WinForms.ShiftnetSites if (cp_value.Text != "Already Purchased.") { var more_info = new Button(); - more_info.Text = "More info"; + more_info.Text = "Buy"; more_info.Click += (o, a) => { //Detect if dependencies are installed. - if (Shiftorium.DependenciesInstalled(upg)) + if (DependenciesInstalled(upg)) { //Detect sufficient codepoints if (SaveSystem.CurrentSave.Codepoints >= upg.Cost) @@ -210,6 +225,7 @@ namespace ShiftOS.WinForms.ShiftnetSites var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID); AppearanceManager.SetupWindow(installer); installer.InitiateInstall(installation); + return; } } } @@ -237,6 +253,7 @@ namespace ShiftOS.WinForms.ShiftnetSites more_info.Left = cp_display.Width - more_info.Width - 5; cp_display.Controls.Add(more_info); more_info.Show(); + ControlManager.SetupControls(pnlappslist); } var desc = new Label(); @@ -311,38 +328,33 @@ namespace ShiftOS.WinForms.ShiftnetSites public string ShiftoriumId { get; private set; } public int Size { get; private set; } - public string Name { get; private set; } - + protected override void Run() { this.SetStatus("Downloading..."); SetProgress(0); - new Thread(() => + int i = 0; + while (i <= Size) { - int i = 0; - while (i <= Size) - { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(100); - } - SetProgress(0); - SetStatus("Installing..."); - i = 0; - while (i <= Size) - { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(50); - } - Shiftorium.Buy(ShiftoriumId, 0); - Desktop.InvokeOnWorkerThread(() => - { - Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); - SaveSystem.SaveGame(); - }); - }) - { IsBackground = true }.Start(); + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(100); + } + SetProgress(0); + SetStatus("Installing..."); + i = 0; + while (i <= Size) + { + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(50); + } + Shiftorium.Buy(ShiftoriumId, 0); + Desktop.InvokeOnWorkerThread(() => + { + Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); + SaveSystem.SaveGame(); + }); } } } diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index a84271b..10fd7d7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -208,7 +208,8 @@ namespace ShiftOS.Engine foreach (var file in System.IO.Directory.GetFiles(folder)) { string mfsDir = file.Replace(SharedFolder, $"{mount}:").Replace("\\", "/"); - WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file)); + if (!FileExists(mfsDir)) + WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file)); } foreach (var directory in System.IO.Directory.GetDirectories(folder)) { -- cgit v1.2.3 From ca40871a6312998b99664b92c12a45a2683d95db Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 19 May 2017 21:47:02 -0400 Subject: document paths system --- ShiftOS_TheReturn/Paths.cs | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'ShiftOS_TheReturn/Paths.cs') diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 10fd7d7..5b75ae6 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -35,8 +35,14 @@ using System.Threading; namespace ShiftOS.Engine { + /// + /// Management class for ShiftFS path variables. + /// public static class Paths { + /// + /// Initiate the path system. + /// public static void Init() { Locations = new Dictionary(); @@ -88,6 +94,10 @@ namespace ShiftOS.Engine } + /// + /// Gets all full paths without their keynames. + /// + /// A string array representing all paths. public static string[] GetAllWithoutKey() { List strings = new List(); @@ -99,11 +109,19 @@ namespace ShiftOS.Engine } + /// + /// Get the full path using a path key. + /// + /// The path key (folder/filename) for the path. + /// The full path. public static string GetPath(string id) { return Locations[id]; } + /// + /// Checks all directories in the path system to see if they exist, and if not, creates them. + /// private static void CheckPathExistence() { foreach(var path in Locations) @@ -119,8 +137,14 @@ namespace ShiftOS.Engine } } + /// + /// Gets or sets a representing all paths in the system. + /// private static Dictionary Locations { get; set; } + /// + /// Mounts the ShiftOS shared directory to 1:/, creating the directory if it does not exist. + /// public static void CreateAndMountSharedFolder() { if (!System.IO.Directory.Exists(SharedFolder)) @@ -201,9 +225,7 @@ namespace ShiftOS.Engine t.Start(); } - - - public static void ScanForDirectories(string folder, int mount) + private static void ScanForDirectories(string folder, int mount) { foreach (var file in System.IO.Directory.GetFiles(folder)) { @@ -220,10 +242,27 @@ namespace ShiftOS.Engine } } + /// + /// Gets the ShiftOS shared folder. + /// public static string SharedFolder { get { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ShiftOS_Shared"; } } + + /// + /// Gets the location of the ShiftOS.mfs file. + /// public static string SaveFile { get { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ShiftOS.mfs"; } } + + /// + /// Gets the path of the inner save file. + /// + [Obsolete("Not used.")] public static string SaveFileInner { get { return Locations["save.json"]; } } + /// + /// Add a path to the system. + /// + /// The path's parent directory. + /// The filename for the path. public static void AddPath(string parent, string path) { Locations.Add(path, Locations[parent] + "/" + path); -- cgit v1.2.3