SuperDesk now has a shiftnet site.

This commit is contained in:
Michael 2017-04-26 19:03:02 -04:00
parent 894320db54
commit 284216ac4c
13 changed files with 2896 additions and 1206 deletions

View file

@ -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;
}
}

View file

@ -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; }
}
}

View file

@ -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()

View file

@ -103,15 +103,15 @@ namespace ShiftOS.WinForms
foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory))
{
if(exe.EndsWith(".exe") || exe.EndsWith(".dll"))
if (exe.EndsWith(".exe") || exe.EndsWith(".dll"))
{
try
{
var asm = Assembly.LoadFile(exe);
foreach(var type in asm.GetTypes())
foreach (var type in asm.GetTypes())
{
var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute;
if(attrib != null)
if (attrib != null)
{
var upgrade = new ShiftoriumUpgrade
{
@ -124,7 +124,27 @@ namespace ShiftOS.WinForms
};
defaultList.Add(upgrade);
}
var sattrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents;
if (sattrib != null)
{
var upgrade = new ShiftoriumUpgrade
{
Id = sattrib.Upgrade,
Name = sattrib.Name,
Description = "This is a hidden dummy upgrade for the .stp file installation attribute \"" + sattrib.Name + "\".",
Cost = 0,
Category = "If this is shown, there's a bug in the Shiftorium Provider or the user is a supreme Shifter.",
Dependencies = "dummy_nodisplay"
};
defaultList.Add(upgrade);
}
}
}
catch { }
}

View file

@ -994,20 +994,22 @@ namespace ShiftOS.WinForms.Properties {
/// <summary>
/// Looks up a localized string similar to [
/// //TEMPORARY
/// {
/// Name: &quot;Desktop Widgets&quot;,
/// Cost: 0,
/// Description: &quot;Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.&quot;,
/// Dependencies: &quot;advanced_app_launcher;wm_free_placement&quot;,
/// Category: &quot;Work-in-progress&quot;
/// },
///
///
///
///// SCREENSAVER
/// {
/// Name: &quot;Screensavers&quot;,
/// Cost: 750,
/// Description: &quot;Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.&quot;,
/// Dependencies: &quot;desktop&quot;,
/// Category: &quot;Enhancements&quot;,
/// },
/// {
/// Name: &quot;Shift Screensavers&quot;,
/// Cost: 100,
/// Description: &quot;This Shifter upgrade will allow you to customize the screensaver.&quot;,
/// Dependencies: &quot;screensavers;shifter&quot;,
/// Category: &quot;Customiz [rest of string was truncated]&quot;;.
/// Description: &quot;Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.&quot; [rest of string was truncated]&quot;;.
/// </summary>
internal static string Shiftorium {
get {
@ -1183,6 +1185,16 @@ namespace ShiftOS.WinForms.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap SuperDesk_screenshot {
get {
object obj = ResourceManager.GetObject("SuperDesk screenshot", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,4 @@
[
//TEMPORARY
{
Name: "Desktop Widgets",
Cost: 0,
Description: "Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.",
Dependencies: "advanced_app_launcher;wm_free_placement",
Category: "Work-in-progress"
},
// SCREENSAVER
{
Name: "Screensavers",

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View file

@ -724,6 +724,7 @@
<None Include="Resources\infobox.wav" />
<None Include="Resources\typesound.wav" />
<None Include="Resources\writesound.wav" />
<None Include="Resources\SuperDesk screenshot.png" />
<Content Include="SystemIcons\iconArtpad.png" />
<Content Include="SystemIcons\iconAudioPlayer.png" />
<Content Include="SystemIcons\iconBitnoteDigger.png" />

View file

@ -28,18 +28,119 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DesktopWidgetWebsite));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lbltitle = new System.Windows.Forms.Label();
this.lbwhatissuperdesk = new System.Windows.Forms.Label();
this.lbthisissuperdesk = new System.Windows.Forms.Label();
this.lbgetthepackage = new System.Windows.Forms.Label();
this.lbpackagedesc = new System.Windows.Forms.Label();
this.lnkdownload = new System.Windows.Forms.LinkLabel();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = global::ShiftOS.WinForms.Properties.Resources.SuperDesk_screenshot;
this.pictureBox1.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.InitialImage")));
this.pictureBox1.Location = new System.Drawing.Point(15, 96);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(813, 414);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.WaitOnLoad = true;
//
// lbltitle
//
this.lbltitle.Dock = System.Windows.Forms.DockStyle.Top;
this.lbltitle.Location = new System.Drawing.Point(0, 0);
this.lbltitle.Name = "lbltitle";
this.lbltitle.Size = new System.Drawing.Size(754, 81);
this.lbltitle.TabIndex = 1;
this.lbltitle.Tag = "header1";
this.lbltitle.Text = "SuperDesk - Empower the ShiftOS Desktop!";
this.lbltitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lbwhatissuperdesk
//
this.lbwhatissuperdesk.AutoSize = true;
this.lbwhatissuperdesk.Location = new System.Drawing.Point(89, 536);
this.lbwhatissuperdesk.Name = "lbwhatissuperdesk";
this.lbwhatissuperdesk.Size = new System.Drawing.Size(105, 13);
this.lbwhatissuperdesk.TabIndex = 2;
this.lbwhatissuperdesk.Tag = "header2";
this.lbwhatissuperdesk.Text = "What is SuperDesk?";
//
// lbthisissuperdesk
//
this.lbthisissuperdesk.Location = new System.Drawing.Point(47, 589);
this.lbthisissuperdesk.Name = "lbthisissuperdesk";
this.lbthisissuperdesk.Size = new System.Drawing.Size(681, 123);
this.lbthisissuperdesk.TabIndex = 3;
this.lbthisissuperdesk.Text = resources.GetString("lbthisissuperdesk.Text");
this.lbthisissuperdesk.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lbgetthepackage
//
this.lbgetthepackage.AutoSize = true;
this.lbgetthepackage.Location = new System.Drawing.Point(319, 747);
this.lbgetthepackage.Name = "lbgetthepackage";
this.lbgetthepackage.Size = new System.Drawing.Size(87, 13);
this.lbgetthepackage.TabIndex = 4;
this.lbgetthepackage.Tag = "header2";
this.lbgetthepackage.Text = "Get the package";
//
// lbpackagedesc
//
this.lbpackagedesc.Location = new System.Drawing.Point(37, 773);
this.lbpackagedesc.Name = "lbpackagedesc";
this.lbpackagedesc.Size = new System.Drawing.Size(681, 53);
this.lbpackagedesc.TabIndex = 5;
this.lbpackagedesc.Text = "SuperDesk is currently in an alpha stage, and we are offering the open alpha for " +
"free. Simply download the .stp file and open it in your Installer to install the" +
" SuperDesk framework.";
this.lbpackagedesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lnkdownload
//
this.lnkdownload.AutoSize = true;
this.lnkdownload.Location = new System.Drawing.Point(192, 1055);
this.lnkdownload.Name = "lnkdownload";
this.lnkdownload.Size = new System.Drawing.Size(96, 13);
this.lnkdownload.TabIndex = 6;
this.lnkdownload.TabStop = true;
this.lnkdownload.Tag = "header3";
this.lnkdownload.Text = "Click to Download!";
this.lnkdownload.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkdownload_LinkClicked);
//
// DesktopWidgetWebsite
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lnkdownload);
this.Controls.Add(this.lbpackagedesc);
this.Controls.Add(this.lbgetthepackage);
this.Controls.Add(this.lbthisissuperdesk);
this.Controls.Add(this.lbwhatissuperdesk);
this.Controls.Add(this.lbltitle);
this.Controls.Add(this.pictureBox1);
this.Name = "DesktopWidgetWebsite";
this.Size = new System.Drawing.Size(436, 293);
this.Size = new System.Drawing.Size(754, 1151);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label lbltitle;
private System.Windows.Forms.Label lbwhatissuperdesk;
private System.Windows.Forms.Label lbthisissuperdesk;
private System.Windows.Forms.Label lbgetthepackage;
private System.Windows.Forms.Label lbpackagedesc;
private System.Windows.Forms.LinkLabel lnkdownload;
}
}

View file

@ -8,6 +8,10 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.WinForms.Tools;
using ShiftOS.WinForms.Applications;
using Newtonsoft.Json;
using static ShiftOS.Objects.ShiftFS.Utils;
namespace ShiftOS.WinForms.ShiftnetSites
{
@ -18,11 +22,7 @@ namespace ShiftOS.WinForms.ShiftnetSites
public DesktopWidgetWebsite()
{
InitializeComponent();
this.Click += (o, a) =>
{
GoToUrl?.Invoke("shiftnet/main");
Infobox.Show("Haha!", "You thought this would do something else. But no!");
};
}
public event Action GoBack;
@ -30,6 +30,34 @@ namespace ShiftOS.WinForms.ShiftnetSites
public void OnSkinLoad()
{
ControlManager.SetupControls(this);
this.pictureBox1.Left = (this.Width - pictureBox1.Width) / 2;
ControlManager.ControlSetup += (ctrl) =>
{
try
{
this.Invoke(new Action(() =>
{
lbwhatissuperdesk.Left = (this.Width - lbwhatissuperdesk.Width) / 2;
lbthisissuperdesk.Top = lbwhatissuperdesk.Top + lbwhatissuperdesk.Height + 10;
lbthisissuperdesk.Left = (this.Width - lbthisissuperdesk.Width) / 2;
lbgetthepackage.Top = lbthisissuperdesk.Top + lbthisissuperdesk.Height + 10;
lbgetthepackage.Left = (this.Width - lbgetthepackage.Width) / 2;
lbpackagedesc.Top = lbgetthepackage.Top + lbgetthepackage.Height + 10;
lbpackagedesc.Left = (this.Width - lbpackagedesc.Width) / 2;
lnkdownload.Top = lbpackagedesc.Top + lbpackagedesc.Height + 10;
lnkdownload.Left = (this.Width - lnkdownload.Width) / 2;
lnkdownload.LinkColor = lbpackagedesc.ForeColor;
}));
}
catch
{
}
};
}
public void OnUpgrade()
@ -38,7 +66,27 @@ namespace ShiftOS.WinForms.ShiftnetSites
public void Setup()
{
this.HorizontalScroll.Maximum = 0;
this.AutoScroll = false;
this.VerticalScroll.Visible = false;
this.AutoScroll = true;
}
private void lnkdownload_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var attrib = typeof(Applications.WidgetManagerFrontend).GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents;
if(attrib != null)
{
FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Save, (file) =>
{
WriteAllText(file, JsonConvert.SerializeObject(attrib));
});
}
else
{
Infobox.Show("Service not available.", "The Shiftnet service you requested is not available.");
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -59,21 +59,30 @@ namespace ShiftOS.Engine
{
title = Localization.Parse(title);
message = Localization.Parse(message);
_infobox.Open(title, message, callback);
Desktop.InvokeOnWorkerThread(() =>
{
_infobox.Open(title, message, callback);
});
}
public static void PromptText(string title, string message, Action<string> callback)
{
title = Localization.Parse(title);
message = Localization.Parse(message);
_infobox.PromptText(title, message, callback);
Desktop.InvokeOnWorkerThread(() =>
{
_infobox.PromptText(title, message, callback);
});
}
public static void PromptYesNo(string title, string message, Action<bool> callback)
{
title = Localization.Parse(title);
message = Localization.Parse(message);
_infobox.PromptYesNo(title, message, callback);
Desktop.InvokeOnWorkerThread(() =>
{
_infobox.PromptYesNo(title, message, callback);
});
}
/// <summary>