diff options
| author | Michael <[email protected]> | 2017-04-26 19:03:02 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-26 19:03:02 -0400 |
| commit | 284216ac4c991481da4cac38a476b16c45712317 (patch) | |
| tree | 1b07fc47b1a457b5740abaa3921ed72558e5bda7 /ShiftOS.WinForms/Applications | |
| parent | 894320db54760bc697f027809c59450987fd38d5 (diff) | |
| download | shiftos_thereturn-284216ac4c991481da4cac38a476b16c45712317.tar.gz shiftos_thereturn-284216ac4c991481da4cac38a476b16c45712317.tar.bz2 shiftos_thereturn-284216ac4c991481da4cac38a476b16c45712317.zip | |
SuperDesk now has a shiftnet site.
Diffstat (limited to 'ShiftOS.WinForms/Applications')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Installer.Designer.cs | 77 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/Installer.cs | 99 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/WidgetManagerFrontend.cs | 2 |
3 files changed, 166 insertions, 12 deletions
diff --git a/ShiftOS.WinForms/Applications/Installer.Designer.cs b/ShiftOS.WinForms/Applications/Installer.Designer.cs index 8b4ae81..48f9146 100644 --- a/ShiftOS.WinForms/Applications/Installer.Designer.cs +++ b/ShiftOS.WinForms/Applications/Installer.Designer.cs @@ -30,8 +30,13 @@ { this.lbtitle = new System.Windows.Forms.Label(); this.pnlselectfile = new System.Windows.Forms.Panel(); - this.pginstall = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.btnstart = new System.Windows.Forms.Button(); + this.btnbrowse = new System.Windows.Forms.Button(); + this.txtfilepath = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); this.lbprogress = new System.Windows.Forms.Label(); + this.pginstall = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.pnlselectfile.SuspendLayout(); this.SuspendLayout(); // // lbtitle @@ -49,12 +54,66 @@ this.pnlselectfile.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.pnlselectfile.Controls.Add(this.btnstart); + this.pnlselectfile.Controls.Add(this.btnbrowse); + this.pnlselectfile.Controls.Add(this.txtfilepath); + this.pnlselectfile.Controls.Add(this.label1); this.pnlselectfile.Location = new System.Drawing.Point(17, 48); this.pnlselectfile.Name = "pnlselectfile"; this.pnlselectfile.Size = new System.Drawing.Size(414, 85); this.pnlselectfile.TabIndex = 1; this.pnlselectfile.VisibleChanged += new System.EventHandler(this.pnlselectfile_VisibleChanged); // + // btnstart + // + this.btnstart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnstart.Location = new System.Drawing.Point(255, 59); + this.btnstart.Name = "btnstart"; + this.btnstart.Size = new System.Drawing.Size(75, 23); + this.btnstart.TabIndex = 3; + this.btnstart.Text = "Start"; + this.btnstart.UseVisualStyleBackColor = true; + this.btnstart.Click += new System.EventHandler(this.btnstart_Click); + // + // btnbrowse + // + this.btnbrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnbrowse.Location = new System.Drawing.Point(336, 60); + this.btnbrowse.Name = "btnbrowse"; + this.btnbrowse.Size = new System.Drawing.Size(75, 23); + this.btnbrowse.TabIndex = 2; + this.btnbrowse.Text = "Browse..."; + this.btnbrowse.UseVisualStyleBackColor = true; + this.btnbrowse.Click += new System.EventHandler(this.btnbrowse_Click); + // + // txtfilepath + // + this.txtfilepath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtfilepath.Location = new System.Drawing.Point(16, 34); + this.txtfilepath.Name = "txtfilepath"; + this.txtfilepath.Size = new System.Drawing.Size(395, 20); + this.txtfilepath.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(126, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Select a .stp file to install."; + // + // lbprogress + // + this.lbprogress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbprogress.AutoSize = true; + this.lbprogress.Location = new System.Drawing.Point(17, 140); + this.lbprogress.Name = "lbprogress"; + this.lbprogress.Size = new System.Drawing.Size(35, 13); + this.lbprogress.TabIndex = 3; + this.lbprogress.Text = "label1"; + // // pginstall // this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) @@ -69,16 +128,6 @@ this.pginstall.Text = "shiftedProgressBar1"; this.pginstall.Value = 0; // - // lbprogress - // - this.lbprogress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lbprogress.AutoSize = true; - this.lbprogress.Location = new System.Drawing.Point(17, 140); - this.lbprogress.Name = "lbprogress"; - this.lbprogress.Size = new System.Drawing.Size(35, 13); - this.lbprogress.TabIndex = 3; - this.lbprogress.Text = "label1"; - // // Installer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -89,6 +138,8 @@ this.Controls.Add(this.lbtitle); this.Name = "Installer"; this.Size = new System.Drawing.Size(447, 203); + this.pnlselectfile.ResumeLayout(false); + this.pnlselectfile.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -100,5 +151,9 @@ private System.Windows.Forms.Panel pnlselectfile; private Controls.ShiftedProgressBar pginstall; private System.Windows.Forms.Label lbprogress; + private System.Windows.Forms.Button btnstart; + private System.Windows.Forms.Button btnbrowse; + private System.Windows.Forms.TextBox txtfilepath; + private System.Windows.Forms.Label label1; } } diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs index 4d8b712..bd40a6d 100644 --- a/ShiftOS.WinForms/Applications/Installer.cs +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -9,6 +9,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Threading; +using static ShiftOS.Objects.ShiftFS.Utils; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -28,6 +30,9 @@ namespace ShiftOS.WinForms.Applications public void InitiateInstall(Installation install) { pnlselectfile.Hide(); + pginstall.Show(); + lbprogress.Show(); + lbtitle.Text = install.Name; install.ProgressReported += (p) => { Desktop.InvokeOnWorkerThread(new Action(() => @@ -62,6 +67,9 @@ namespace ShiftOS.WinForms.Applications public void OnLoad() { + btnstart.Hide(); + pginstall.Hide(); + lbprogress.Hide(); } private bool isInstalling = false; @@ -88,6 +96,28 @@ namespace ShiftOS.WinForms.Applications } } public event Action InstallCompleted; + + private void btnbrowse_Click(object sender, EventArgs e) + { + FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Open, (file) => + { + txtfilepath.Text = file; + btnstart.Show(); + }); + } + + private void btnstart_Click(object sender, EventArgs e) + { + if (FileExists(txtfilepath.Text)) + { + var install = new StpInstallation(txtfilepath.Text); + InitiateInstall(install); + } + else + { + Infobox.Show("File not found.", "The file you requested was not found on the system."); + } + } } public abstract class Installation @@ -154,7 +184,76 @@ namespace ShiftOS.WinForms.Applications protected abstract void Run(); } + public class StpInstallation : Installation + { + public StpInstallation(string stpfile) : base() + { + if (!FileExists(stpfile)) + throw new System.IO.FileNotFoundException("An attempt to install a ShiftOS setup package failed because the package was not found.", stpfile); + string json = ReadAllText(stpfile); + var contents = JsonConvert.DeserializeObject<StpContents>(json); + this.Name = contents.Name; + Contents = contents; + } + public StpContents Contents { get; set; } + protected override void Run() + { + if (Shiftorium.UpgradeInstalled(Contents.Upgrade)) + { + Infobox.Show("Installation failed.", "This package has already been installed."); + return; + } + + if (!string.IsNullOrWhiteSpace(Contents.Dependencies)) + { + SetStatus("Checking Shiftorium for dependencies..."); + string[] dependencies = Contents.Dependencies.Split(';'); + for (int i = 0; i < dependencies.Length; i++) + { + if (Shiftorium.UpgradeInstalled(dependencies[i])) + { + double percent = (i / dependencies.Length) * 100; + SetProgress((int)percent); + } + else + { + var upg = Shiftorium.GetDefaults().FirstOrDefault(x => x.Id == dependencies[i]); + Infobox.Show("Missing dependency!", $"You are missing the following Shiftorium Upgrade: {upg.Name}\r\n\r\nThe installation cannot continue."); + return; + } + Thread.Sleep(250); + } + } + SetStatus("Installing..."); + SetProgress(0); + for(int i = 0; i < 100; i++) + { + SetProgress(i); + Thread.Sleep(50); + } + Desktop.InvokeOnWorkerThread(() => + { + Shiftorium.Buy(Contents.Upgrade, 0); + Infobox.Show("Install complete.", "The installation has completed successfully."); + SaveSystem.SaveGame(); + }); + } + } + + public class StpContents : RequiresUpgradeAttribute + { + public StpContents(string name, string author, string dependencies = "") : base(name.ToLower().Replace(" ", "_")) + { + Name = name; + Author = author; + Dependencies = dependencies; + } + + public string Name { get; set; } + public string Author { get; set; } + public string Dependencies { get; set; } + } } diff --git a/ShiftOS.WinForms/Applications/WidgetManagerFrontend.cs b/ShiftOS.WinForms/Applications/WidgetManagerFrontend.cs index 6424710..b22d4c2 100644 --- a/ShiftOS.WinForms/Applications/WidgetManagerFrontend.cs +++ b/ShiftOS.WinForms/Applications/WidgetManagerFrontend.cs @@ -17,7 +17,7 @@ namespace ShiftOS.WinForms.Applications [WinOpen("desktop_widgets")] [Launcher("Widget Manager", true, "al_widget_manager", "Customization")] [DefaultTitle("Widget Manager")] - [RequiresUpgrade("desktop_widgets")] + [StpContents("Desktop Widgets", "SuperDesk Inc.", "desktop;wm_free_placement;shifter")] public partial class WidgetManagerFrontend : UserControl, IShiftOSWindow { public WidgetManagerFrontend() |
