aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms/Applications')
-rw-r--r--ShiftOS.WinForms/Applications/Shiftnet.cs165
-rw-r--r--ShiftOS.WinForms/Applications/UpdateManager.Designer.cs130
-rw-r--r--ShiftOS.WinForms/Applications/UpdateManager.cs279
-rw-r--r--ShiftOS.WinForms/Applications/UpdateManager.resx120
4 files changed, 643 insertions, 51 deletions
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs
index c1c81d5..501fa56 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.cs
@@ -36,34 +36,53 @@ using Newtonsoft.Json;
using static ShiftOS.Engine.SkinEngine;
using ShiftOS.WinForms.Tools;
-namespace ShiftOS.WinForms.Applications {
+namespace ShiftOS.WinForms.Applications
+{
+ //OH MY GOD. I HAD TO CORRECT HEAPS OF BADLY PLACED CURLY BRACES.
+ //
+ //I DO NOT CARE WHAT THE BLUE SMILEY FACE SAYS. CURLY BRACES BELONG ON THEIR OWN LINE.
+ //
+ //READ THE DAMN SHIFTOS CODING GUIDELINES.
+
[Launcher("Shiftnet", false, null, "Networking")]
[MultiplayerOnly]
[DefaultIcon("iconShiftnet")]
- public partial class Shiftnet : UserControl, IShiftOSWindow {
- public Shiftnet() {
+ public partial class Shiftnet : UserControl, IShiftOSWindow
+ {
+ public Shiftnet()
+ {
InitializeComponent();
- ServerManager.MessageReceived += (msg) => {
- try {
- if (msg.Name == "shiftnet_file") {
- if (Objects.ShiftFS.Utils.FileExists("0:/md.txt")) {
- this.Invoke(new Action(() => {
+ ServerManager.MessageReceived += (msg) =>
+ {
+ try
+ {
+ if (msg.Name == "shiftnet_file")
+ {
+ if (Objects.ShiftFS.Utils.FileExists("0:/md.txt"))
+ {
+ this.Invoke(new Action(() =>
+ {
wbcanvas.DocumentText = ConstructHtml(Objects.ShiftFS.Utils.ReadAllText("0:/md.txt"));
}));
- } else {
+ }
+ else
+ {
this.Invoke(new Action(() =>
{
wbcanvas.DocumentText = ConstructHtml(msg.Contents);
}));
}
}
- } catch {
+ }
+ catch
+ {
}
};
}
- public string ConstructHtml(string markdown) {
+ public string ConstructHtml(string markdown)
+ {
var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC);
var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC);
string html = $@"<html>
@@ -105,7 +124,8 @@ namespace ShiftOS.WinForms.Applications {
</html>";
string body = CommonMark.CommonMarkConverter.Convert(markdown);
- for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed()) {
+ for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed())
+ {
//halt the page load until 'download' finishes.
}
html = html.Replace("<markdown/>", body);
@@ -115,12 +135,15 @@ namespace ShiftOS.WinForms.Applications {
public string CurrentUrl { get; set; }
- private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
+ private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e)
+ {
string Url = e.Url.ToString().Replace("http://", "");
- if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:")) {
+ if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:"))
+ {
e.Cancel = true;
Future.Clear();
- if (Url.StartsWith("runsyscmd/")) {
+ if (Url.StartsWith("runsyscmd/"))
+ {
ProcessShiftnetCmd(Url.Replace("runsyscmd/", ""));
}
@@ -128,16 +151,23 @@ namespace ShiftOS.WinForms.Applications {
}
}
- public void ProcessShiftnetCmd(string cmd) {
+ public void ProcessShiftnetCmd(string cmd)
+ {
var args = cmd.Split('/');
- switch (args[0]) {
+ switch (args[0])
+ {
case "setsnsub":
- for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++) {
- if (DownloadManager.GetAllSubscriptions()[i].Name == args[1]) {
+ for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++)
+ {
+ if (DownloadManager.GetAllSubscriptions()[i].Name == args[1])
+ {
var sub = DownloadManager.GetAllSubscriptions()[i];
- Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action<bool>((answer) => {
- if (answer == true) {
- if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth) {
+ Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action<bool>((answer) =>
+ {
+ if (answer == true)
+ {
+ if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth)
+ {
//Initial fee gets deducted.
SaveSystem.CurrentSave.Codepoints -= sub.CostPerMonth;
//Then we set the subscription.
@@ -147,7 +177,9 @@ namespace ShiftOS.WinForms.Applications {
//Then we send our save to the MUD.
SaveSystem.SaveGame();
- } else {
+ }
+ else
+ {
//User can't afford this subscription.
Infobox.Show("Shiftnet - Not enough Codepoints", $"You cannot afford to pay for this subscription at this time. You need {sub.CostPerMonth - SaveSystem.CurrentSave.Codepoints} more Codepoints.");
}
@@ -162,39 +194,51 @@ namespace ShiftOS.WinForms.Applications {
public Stack<string> History = new Stack<string>();
public Stack<string> Future = new Stack<string>();
- public void ShiftnetNavigate(string Url, bool pushHistory = true) {
- if (Url.EndsWith(".rnp") || !Url.Contains(".")) {
+ public void ShiftnetNavigate(string Url, bool pushHistory = true)
+ {
+ if (Url.EndsWith(".rnp") || !Url.Contains("."))
+ {
if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory)
History.Push(CurrentUrl);
CurrentUrl = Url;
- ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new {
+ ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new
+ {
url = Url
}));
txturl.Text = Url;
- } else {
+ }
+ else
+ {
ServerMessageReceived smr = null;
- smr = (msg) => {
- if (msg.Name == "download_meta") {
+ smr = (msg) =>
+ {
+ if (msg.Name == "download_meta")
+ {
var bytes = JsonConvert.DeserializeObject<byte[]>(msg.Contents);
string destPath = null;
string ext = Url.Split('.')[Url.Split('.').Length - 1];
- this.Invoke(new Action(() => {
- FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action<string>((file) => {
+ this.Invoke(new Action(() =>
+ {
+ FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action<string>((file) =>
+ {
destPath = file;
}));
}));
- while (string.IsNullOrEmpty(destPath)) {
+ while (string.IsNullOrEmpty(destPath))
+ {
}
- var d = new Download {
+ var d = new Download
+ {
ShiftnetUrl = Url,
Destination = destPath,
Bytes = bytes,
Progress = 0,
};
DownloadManager.StartDownload(d);
- this.Invoke(new Action(() => {
+ this.Invoke(new Action(() =>
+ {
AppearanceManager.SetupWindow(new Downloader());
}));
ServerManager.MessageReceived -= smr;
@@ -205,60 +249,79 @@ namespace ShiftOS.WinForms.Applications {
}
}
- public void OnLoad() {
+ public void OnLoad()
+ {
ShiftnetNavigate("shiftnet/main");
}
- public void OnSkinLoad() {
+ public void OnSkinLoad()
+ {
ShiftnetNavigate(CurrentUrl);
}
- public bool OnUnload() {
+ public bool OnUnload()
+ {
return true;
}
- public void OnUpgrade() {
+ public void OnUpgrade()
+ {
}
- private void btnback_Click(object sender, EventArgs e) {
- try {
+ private void btnback_Click(object sender, EventArgs e)
+ {
+ try
+ {
string hist = History.Pop();
- if (!string.IsNullOrEmpty(hist)) {
+ if (!string.IsNullOrEmpty(hist))
+ {
Future.Push(hist);
ShiftnetNavigate(hist, false);
}
- } catch {
+ }
+ catch
+ {
}
}
- private void btnforward_Click(object sender, EventArgs e) {
- try {
+ private void btnforward_Click(object sender, EventArgs e)
+ {
+ try
+ {
string fut = Future.Pop();
- if (!string.IsNullOrEmpty(fut)) {
+ if (!string.IsNullOrEmpty(fut))
+ {
ShiftnetNavigate(fut);
}
- } catch {
+ }
+ catch
+ {
}
}
- private void btngo_Click(object sender, EventArgs e) {
- if (!string.IsNullOrWhiteSpace(txturl.Text)) {
+ private void btngo_Click(object sender, EventArgs e)
+ {
+ if (!string.IsNullOrWhiteSpace(txturl.Text))
+ {
Future.Clear();
ShiftnetNavigate(txturl.Text);
}
}
- private void txturl_KeyDown(object sender, KeyEventArgs e) {
- if (e.KeyCode == Keys.Enter) {
+ private void txturl_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
btngo_Click(sender, EventArgs.Empty);
e.SuppressKeyPress = true;
}
}
- private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e) {
+ private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e)
+ {
}
}
}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs
new file mode 100644
index 0000000..466151a
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs
@@ -0,0 +1,130 @@
+namespace ShiftOS.WinForms.Applications
+{
+ partial class UpdateManager
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.lbupdatetitle = new System.Windows.Forms.Label();
+ this.pnlupdatebar = new System.Windows.Forms.Panel();
+ this.btnclose = new System.Windows.Forms.Button();
+ this.btnaction = new System.Windows.Forms.Button();
+ this.pgdownload = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
+ this.wbstatus = new System.Windows.Forms.WebBrowser();
+ this.pnlupdatebar.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // lbupdatetitle
+ //
+ this.lbupdatetitle.AutoSize = true;
+ this.lbupdatetitle.Dock = System.Windows.Forms.DockStyle.Top;
+ this.lbupdatetitle.Location = new System.Drawing.Point(0, 0);
+ this.lbupdatetitle.Margin = new System.Windows.Forms.Padding(10);
+ this.lbupdatetitle.Name = "lbupdatetitle";
+ this.lbupdatetitle.Size = new System.Drawing.Size(117, 13);
+ this.lbupdatetitle.TabIndex = 0;
+ this.lbupdatetitle.Tag = "header1";
+ this.lbupdatetitle.Text = "Checking for updates...";
+ //
+ // pnlupdatebar
+ //
+ this.pnlupdatebar.Controls.Add(this.pgdownload);
+ this.pnlupdatebar.Controls.Add(this.btnaction);
+ this.pnlupdatebar.Controls.Add(this.btnclose);
+ this.pnlupdatebar.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.pnlupdatebar.Location = new System.Drawing.Point(0, 426);
+ this.pnlupdatebar.Name = "pnlupdatebar";
+ this.pnlupdatebar.Size = new System.Drawing.Size(597, 33);
+ this.pnlupdatebar.TabIndex = 1;
+ //
+ // btnclose
+ //
+ this.btnclose.Location = new System.Drawing.Point(4, 4);
+ this.btnclose.Name = "btnclose";
+ this.btnclose.Size = new System.Drawing.Size(75, 23);
+ this.btnclose.TabIndex = 0;
+ this.btnclose.Text = "{CLOSE}";
+ this.btnclose.UseVisualStyleBackColor = true;
+ this.btnclose.Click += new System.EventHandler(this.btnclose_Click);
+ //
+ // btnaction
+ //
+ this.btnaction.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnaction.Location = new System.Drawing.Point(519, 4);
+ this.btnaction.Name = "btnaction";
+ this.btnaction.Size = new System.Drawing.Size(75, 23);
+ this.btnaction.TabIndex = 1;
+ this.btnaction.Text = "Update";
+ this.btnaction.UseVisualStyleBackColor = true;
+ //
+ // pgdownload
+ //
+ this.pgdownload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pgdownload.BlockSize = 5;
+ this.pgdownload.Location = new System.Drawing.Point(86, 4);
+ this.pgdownload.Maximum = 100;
+ this.pgdownload.Name = "pgdownload";
+ this.pgdownload.Size = new System.Drawing.Size(427, 23);
+ this.pgdownload.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+ this.pgdownload.TabIndex = 2;
+ this.pgdownload.Text = "Updating...";
+ this.pgdownload.Value = 0;
+ //
+ // wbstatus
+ //
+ this.wbstatus.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.wbstatus.Location = new System.Drawing.Point(0, 13);
+ this.wbstatus.MinimumSize = new System.Drawing.Size(20, 20);
+ this.wbstatus.Name = "wbstatus";
+ this.wbstatus.Size = new System.Drawing.Size(597, 413);
+ this.wbstatus.TabIndex = 2;
+ //
+ // UpdateManager
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.wbstatus);
+ this.Controls.Add(this.pnlupdatebar);
+ this.Controls.Add(this.lbupdatetitle);
+ this.Name = "UpdateManager";
+ this.Size = new System.Drawing.Size(597, 459);
+ this.pnlupdatebar.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label lbupdatetitle;
+ private System.Windows.Forms.Panel pnlupdatebar;
+ private Controls.ShiftedProgressBar pgdownload;
+ private System.Windows.Forms.Button btnaction;
+ private System.Windows.Forms.Button btnclose;
+ private System.Windows.Forms.WebBrowser wbstatus;
+ }
+}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.cs b/ShiftOS.WinForms/Applications/UpdateManager.cs
new file mode 100644
index 0000000..05ae9d0
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.cs
@@ -0,0 +1,279 @@
+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 ShiftOS.WinForms.Tools;
+using static ShiftOS.Engine.SkinEngine;
+using System.Net;
+using Newtonsoft.Json;
+using System.Reflection;
+using System.IO;
+using System.IO.Compression;
+
+namespace ShiftOS.WinForms.Applications
+{
+ [Launcher("Update Manager", true, "al_update_manager", "Networking")]
+ [DefaultTitle("Update Manager")]
+ [WinOpen("update_manager")]
+ public partial class UpdateManager : UserControl, IShiftOSWindow
+ {
+ public UpdateManager()
+ {
+ InitializeComponent();
+ btnaction.Click += (o, a) => OnActionButtonClick?.Invoke();
+ }
+
+ public void OnLoad()
+ {
+ CheckForUpdate();
+ }
+
+ public void CheckForUpdate()
+ {
+ ConstructHtml(@"ShiftOS is grabbing information on the latest version. Please be patient.");
+ pgdownload.Show();
+ btnaction.Show();
+ lbupdatetitle.Text = "Checking for updates...";
+ pgdownload.Value = 0;
+ pgdownload.Maximum = 100;
+
+ var wc = new WebClient();
+
+ wc.DownloadProgressChanged += (o, a) =>
+ {
+ this.Invoke(new Action(() =>
+ {
+ pgdownload.Text = "Grabbing update data from multi-user-domain...";
+ pgdownload.Value = a.ProgressPercentage;
+ }));
+ };
+
+ wc.DownloadStringCompleted += (o, a) =>
+ {
+ var releases = JsonConvert.DeserializeObject<ShiftOS.Objects.Unite.Download[]>(a.Result);
+
+ var download = releases.OrderByDescending(x => x.PostDate).First();
+
+ var thisBuildDate = Assembly.GetExecutingAssembly().GetBuildDate(TimeZoneInfo.Utc);
+
+ if(download.PostDate > thisBuildDate)
+ {
+ this.Invoke(new Action(() =>
+ {
+ //This build is more recent than the currently running ShiftOS client.
+ SetupBuildUpdate(download);
+ }));
+ }
+ else
+ {
+ if (thisBuildDate > download.PostDate)
+ {
+ this.Invoke(new Action(() => ConstructHtml($@"### Unreleased build.
+
+You are currently running an unreleased build of ShiftOS, compiled on {thisBuildDate}, after the latest released version, {download.Name}, compiled on {download.PostDate}.")));
+ }
+ else
+ {
+ this.Invoke(new Action(() => ConstructHtml($@"### Up to date.
+
+You are currently running {download.Name}, compiled on {download.PostDate}.")));
+
+ }
+ this.Invoke(new Action(() =>
+ {
+ lbupdatetitle.Text = "No update available";
+ pgdownload.Hide();
+ btnaction.Hide();
+ }));
+ }
+ };
+
+ wc.DownloadStringAsync(new Uri("http://getshiftos.ml/API/Releases?showUnstable=true&showObsolete=false"));
+ }
+
+ public void OnSkinLoad()
+ {
+ ConstructHtml(CurrentMD);
+ }
+
+ public bool OnUnload()
+ {
+ return true;
+ }
+
+ public void OnUpgrade()
+ {
+ ConstructHtml(CurrentMD);
+ }
+
+ public void SetupBuildUpdate(ShiftOS.Objects.Unite.Download download)
+ {
+ string devUpdate = "";
+ if (!string.IsNullOrEmpty(download.DevUpdateId))
+ {
+ devUpdate = $@"## Development update
+
+<iframe src=""http://youtube.com/embed/{download.DevUpdateId}"" allowfullscreen width=""720"" height=""480""></iframe>
+";
+ }
+
+ string screenshot = "";
+
+ if(!string.IsNullOrEmpty(download.ScreenshotUrl))
+ {
+ screenshot = $"<img src=\"http://getshiftos.ml{download.ScreenshotUrl}\" style=\"max-width:720px;width:auto;height:auto;\"/>";
+ }
+
+ lbupdatetitle.Text = download.Name;
+ string markdown = $@"**Built on {download.PostDate}**
+
+{devUpdate}
+
+{screenshot}
+
+## Changelog
+
+{download.Changelog}";
+
+ ConstructHtml(markdown);
+
+ pgdownload.Value = 0;
+ pgdownload.Text = "Waiting.";
+ btnaction.Text = "Update";
+ btnaction.Show();
+ OnActionButtonClick = () =>
+ {
+ pgdownload.Show();
+ var wc = new WebClient();
+ wc.DownloadProgressChanged += (o, a) =>
+ {
+ this.Invoke(new Action(() =>
+ {
+ pgdownload.Text = "Downloading " + download.Name + "...";
+ pgdownload.Value = a.ProgressPercentage;
+ }));
+ };
+
+ wc.DownloadDataCompleted += (o, a) =>
+ {
+ if (Directory.Exists("updater-work"))
+ Directory.Delete("updater-work", true);
+ Directory.CreateDirectory("updater-work");
+
+ string temp_guid = Guid.NewGuid().ToString();
+
+ File.WriteAllBytes($"{temp_guid}.zip", a.Result);
+
+ ZipFile.ExtractToDirectory($"{temp_guid}.zip", "updater-work");
+
+ File.Delete($"{temp_guid}.zip");
+
+ //Start the updater helper.
+ System.Diagnostics.Process.Start("ShiftOS.Updater.exe");
+
+ //Now we stop the engine.
+ TerminalBackend.InvokeCommand("sos.shutdown");
+
+ };
+
+ wc.DownloadDataAsync(new Uri($"http://getshiftos.ml{download.DownloadUrl}"));
+ };
+ }
+
+ public Action OnActionButtonClick = () => { };
+
+ public void ConstructHtml(string markdown)
+ {
+ CurrentMD = markdown;
+ var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC);
+ var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC);
+ string html = $@"<html>
+ <head>
+ <style>
+ body {{
+ background-color: rgb({LoadedSkin.ControlColor.R}, {LoadedSkin.ControlColor.G}, {LoadedSkin.ControlColor.B});
+ color: rgb({LoadedSkin.ControlTextColor.R}, {LoadedSkin.ControlTextColor.G}, {LoadedSkin.ControlTextColor.B});
+ font-family: ""{LoadedSkin.MainFont.Name}"";
+ font-size: {LoadedSkin.MainFont.SizeInPoints}pt;
+ }}
+
+ h1 {{
+ font-family: ""{LoadedSkin.HeaderFont.Name}"";
+ font-size: {LoadedSkin.HeaderFont.SizeInPoints}pt;
+ }}
+
+ h2 {{
+ font-family: ""{LoadedSkin.Header2Font.Name}"";
+ font-size: {LoadedSkin.Header2Font.SizeInPoints}pt;
+ }}
+
+ h3 {{
+ font-family: ""{LoadedSkin.Header3Font.Name}"";
+ font-size: {LoadedSkin.Header3Font.SizeInPoints}pt;
+ }}
+
+ pre, code {{
+ font-family: ""{LoadedSkin.TerminalFont.Name}"";
+ font-size: {LoadedSkin.TerminalFont.SizeInPoints}pt;
+ color: rgb({TerminalForeColor.R}, {TerminalForeColor.G}, {TerminalForeColor.B});
+ background-color: rgb({TerminalBackColor.R}, {TerminalBackColor.G}, {TerminalBackColor.B});
+ }}
+ </style>
+ </head>
+ <body>
+ <markdown/>
+ </body>
+</html>";
+
+ string body = CommonMark.CommonMarkConverter.Convert(markdown);
+
+ html = html.Replace("<markdown/>", body);
+ wbstatus.DocumentText = html;
+ }
+
+ public string CurrentMD = "";
+
+ private void btnclose_Click(object sender, EventArgs e)
+ {
+ AppearanceManager.Close(this);
+ }
+ }
+
+ public static class UpdateHelpers
+ {
+ /// <summary>
+ /// Grabs the build date from the assembly's PE header.
+ /// </summary>
+ /// <param name="assembly">The assembly to probe.</param>
+ /// <param name="target">The target timezone.</param>
+ /// <returns>The assembly's build date.</returns>
+ public static DateTime GetBuildDate(this Assembly assembly, TimeZoneInfo target = null)
+ {
+ var filePath = assembly.Location;
+ const int c_PeHeaderOffset = 60;
+ const int c_LinkerTimestampOffset = 8;
+
+ var buffer = new byte[2048];
+
+ using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
+ stream.Read(buffer, 0, 2048);
+
+ var offset = BitConverter.ToInt32(buffer, c_PeHeaderOffset);
+ var secondsSince1970 = BitConverter.ToInt32(buffer, offset + c_LinkerTimestampOffset);
+ var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ var linkTimeUtc = epoch.AddSeconds(secondsSince1970);
+
+ var tz = target ?? TimeZoneInfo.Local;
+ var localTime = TimeZoneInfo.ConvertTimeFromUtc(linkTimeUtc, tz);
+
+ return localTime;
+ }
+ }
+}
diff --git a/ShiftOS.WinForms/Applications/UpdateManager.resx b/ShiftOS.WinForms/Applications/UpdateManager.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/UpdateManager.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file