From bbe37edb68f9e7535216bff80ba3e6b16cbca398 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 2 Feb 2017 09:47:23 -0500 Subject: Shiftnet, and audio fixes --- ShiftOS.WinForms/Applications/Shiftnet.Designer.cs | 139 +++++++++++++++++ ShiftOS.WinForms/Applications/Shiftnet.cs | 167 +++++++++++++++++++++ ShiftOS.WinForms/Applications/Shiftnet.resx | 120 +++++++++++++++ ShiftOS.WinForms/FakeSetupScreen.Designer.cs | 110 +++++++++++++- ShiftOS.WinForms/FakeSetupScreen.cs | 10 ++ ShiftOS.WinForms/Oobe.cs | 9 +- ShiftOS.WinForms/Program.cs | 4 +- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 13 ++ ShiftOS.WinForms/ShiftOSAudioProvider.cs | 16 +- ShiftOS.WinForms/Tools/ControlManager.cs | 9 +- ShiftOS.WinForms/packages.config | 1 + 11 files changed, 590 insertions(+), 8 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/Shiftnet.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/Shiftnet.cs create mode 100644 ShiftOS.WinForms/Applications/Shiftnet.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs new file mode 100644 index 0000000..8ac9ea5 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs @@ -0,0 +1,139 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class Shiftnet + { + /// + /// 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() + { + this.flcontrols = new System.Windows.Forms.FlowLayoutPanel(); + this.btnback = new System.Windows.Forms.Button(); + this.btnforward = new System.Windows.Forms.Button(); + this.txturl = new System.Windows.Forms.TextBox(); + this.btngo = new System.Windows.Forms.Button(); + this.wbcanvas = new System.Windows.Forms.WebBrowser(); + this.flcontrols.SuspendLayout(); + this.SuspendLayout(); + // + // flcontrols + // + this.flcontrols.AutoSize = true; + this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flcontrols.Controls.Add(this.btnback); + this.flcontrols.Controls.Add(this.btnforward); + this.flcontrols.Controls.Add(this.txturl); + this.flcontrols.Controls.Add(this.btngo); + this.flcontrols.Dock = System.Windows.Forms.DockStyle.Top; + this.flcontrols.Location = new System.Drawing.Point(0, 0); + this.flcontrols.Name = "flcontrols"; + this.flcontrols.Size = new System.Drawing.Size(805, 29); + this.flcontrols.TabIndex = 0; + // + // btnback + // + this.btnback.AutoSize = true; + this.btnback.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnback.Location = new System.Drawing.Point(3, 3); + this.btnback.Name = "btnback"; + this.btnback.Size = new System.Drawing.Size(23, 23); + this.btnback.TabIndex = 0; + this.btnback.Text = "<"; + this.btnback.UseVisualStyleBackColor = true; + this.btnback.Click += new System.EventHandler(this.btnback_Click); + // + // btnforward + // + this.btnforward.AutoSize = true; + this.btnforward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnforward.Location = new System.Drawing.Point(32, 3); + this.btnforward.Name = "btnforward"; + this.btnforward.Size = new System.Drawing.Size(23, 23); + this.btnforward.TabIndex = 1; + this.btnforward.Text = ">"; + this.btnforward.UseVisualStyleBackColor = true; + this.btnforward.Click += new System.EventHandler(this.btnforward_Click); + // + // txturl + // + this.txturl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txturl.Location = new System.Drawing.Point(61, 3); + this.txturl.Name = "txturl"; + this.txturl.Size = new System.Drawing.Size(702, 20); + this.txturl.TabIndex = 2; + this.txturl.WordWrap = false; + this.txturl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txturl_KeyDown); + // + // btngo + // + this.btngo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btngo.AutoSize = true; + this.btngo.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btngo.Location = new System.Drawing.Point(769, 3); + this.btngo.Name = "btngo"; + this.btngo.Size = new System.Drawing.Size(31, 23); + this.btngo.TabIndex = 3; + this.btngo.Text = "Go"; + this.btngo.UseVisualStyleBackColor = true; + this.btngo.Click += new System.EventHandler(this.btngo_Click); + // + // wbcanvas + // + this.wbcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.wbcanvas.IsWebBrowserContextMenuEnabled = false; + this.wbcanvas.Location = new System.Drawing.Point(0, 29); + this.wbcanvas.MinimumSize = new System.Drawing.Size(20, 20); + this.wbcanvas.Name = "wbcanvas"; + this.wbcanvas.ScriptErrorsSuppressed = true; + this.wbcanvas.Size = new System.Drawing.Size(805, 510); + this.wbcanvas.TabIndex = 1; + this.wbcanvas.WebBrowserShortcutsEnabled = false; + this.wbcanvas.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.wbcanvas_Navigating); + // + // Shiftnet + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.wbcanvas); + this.Controls.Add(this.flcontrols); + this.Name = "Shiftnet"; + this.Size = new System.Drawing.Size(805, 539); + this.flcontrols.ResumeLayout(false); + this.flcontrols.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flcontrols; + private System.Windows.Forms.Button btnback; + private System.Windows.Forms.Button btnforward; + private System.Windows.Forms.TextBox txturl; + private System.Windows.Forms.Button btngo; + private System.Windows.Forms.WebBrowser wbcanvas; + } +} diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs new file mode 100644 index 0000000..d4183a4 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -0,0 +1,167 @@ +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 Newtonsoft.Json; +using static ShiftOS.Engine.SkinEngine; + +namespace ShiftOS.WinForms.Applications +{ + [Launcher("Shiftnet", false)] + public partial class Shiftnet : UserControl, IShiftOSWindow + { + public Shiftnet() + { + InitializeComponent(); + ServerManager.MessageReceived += (msg) => + { + try + { + if (msg.Name == "shiftnet_file") + { + this.Invoke(new Action(() => + { + wbcanvas.DocumentText = ConstructHtml(msg.Contents); + })); + } + } + catch + { + + } + }; + } + + public string ConstructHtml(string markdown) + { + string html = $@" + + + + + + +"; + + string body = CommonMark.CommonMarkConverter.Convert(markdown); + + html = html.Replace("", body); + return html; + } + + public string CurrentUrl { get; set; } + + + private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e) + { + if (CurrentUrl != e.Url.ToString()) + { + e.Cancel = true; + Future.Clear(); + ShiftnetNavigate(e.Url.ToString()); + } + } + + public Stack History = new Stack(); + public Stack Future = new Stack(); + + public void ShiftnetNavigate(string Url, bool pushHistory = true) + { + if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory) + History.Push(CurrentUrl); + CurrentUrl = Url; + + ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new + { + url = Url + })); + } + + public void OnLoad() + { + ShiftnetNavigate("shiftnet/main"); + } + + public void OnSkinLoad() + { + ShiftnetNavigate(CurrentUrl); + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + + private void btnback_Click(object sender, EventArgs e) + { + string hist = History.Pop(); + if (!string.IsNullOrEmpty(hist)) + { + Future.Push(hist); + ShiftnetNavigate(hist, false); + } + } + + private void btnforward_Click(object sender, EventArgs e) + { + string fut = Future.Pop(); + if (!string.IsNullOrEmpty(fut)) + { + ShiftnetNavigate(fut); + } + } + + 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) + { + btngo_Click(sender, EventArgs.Empty); + e.SuppressKeyPress = true; + } + } + } +} diff --git a/ShiftOS.WinForms/Applications/Shiftnet.resx b/ShiftOS.WinForms/Applications/Shiftnet.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Shiftnet.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs b/ShiftOS.WinForms/FakeSetupScreen.Designer.cs index b54737f..8fc7708 100644 --- a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs +++ b/ShiftOS.WinForms/FakeSetupScreen.Designer.cs @@ -60,6 +60,14 @@ this.label9 = new System.Windows.Forms.Label(); this.txtrsys = new System.Windows.Forms.TextBox(); this.label11 = new System.Windows.Forms.Label(); + this.pglogin = new System.Windows.Forms.Panel(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.label12 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); this.flbuttons.SuspendLayout(); this.page1.SuspendLayout(); this.page2.SuspendLayout(); @@ -68,6 +76,8 @@ this.page4.SuspendLayout(); this.pgrereg.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); + this.pglogin.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); this.SuspendLayout(); // // pnlheader @@ -403,11 +413,97 @@ this.label11.TabIndex = 3; this.label11.Text = "User information"; // + // pglogin + // + this.pglogin.Controls.Add(this.tableLayoutPanel3); + this.pglogin.Controls.Add(this.label15); + this.pglogin.Controls.Add(this.button1); + this.pglogin.Dock = System.Windows.Forms.DockStyle.Fill; + this.pglogin.Location = new System.Drawing.Point(138, 0); + this.pglogin.Name = "pglogin"; + this.pglogin.Size = new System.Drawing.Size(352, 300); + this.pglogin.TabIndex = 9; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.AutoSize = true; + this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel3.ColumnCount = 2; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel3.Controls.Add(this.label12, 0, 0); + this.tableLayoutPanel3.Controls.Add(this.textBox1, 1, 0); + this.tableLayoutPanel3.Controls.Add(this.label13, 0, 1); + this.tableLayoutPanel3.Controls.Add(this.textBox2, 1, 1); + this.tableLayoutPanel3.Location = new System.Drawing.Point(20, 61); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 3; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(212, 72); + this.tableLayoutPanel3.TabIndex = 4; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(3, 0); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(58, 13); + this.label12.TabIndex = 0; + this.label12.Text = "Username:"; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(109, 3); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(100, 20); + this.textBox1.TabIndex = 1; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(3, 26); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(56, 13); + this.label13.TabIndex = 2; + this.label13.Text = "Password:"; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(109, 29); + this.textBox2.Name = "textBox2"; + this.textBox2.PasswordChar = '*'; + this.textBox2.Size = new System.Drawing.Size(100, 20); + this.textBox2.TabIndex = 3; + // + // label15 + // + this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); + this.label15.Location = new System.Drawing.Point(16, 9); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(321, 26); + this.label15.TabIndex = 3; + this.label15.Text = "User information"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(129, 142); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 21); + this.button1.TabIndex = 4; + this.button1.Text = "Register"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // FakeSetupScreen // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(490, 329); + this.Controls.Add(this.pglogin); this.Controls.Add(this.pgrereg); this.Controls.Add(this.page3); this.Controls.Add(this.page4); @@ -420,7 +516,7 @@ this.MinimizeBox = false; this.Name = "FakeSetupScreen"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "FakeSetupScreen"; + this.Text = "ShiftOS"; this.TopMost = true; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FakeSetupScreen_FormClosing); this.flbuttons.ResumeLayout(false); @@ -436,6 +532,10 @@ this.pgrereg.PerformLayout(); this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); + this.pglogin.ResumeLayout(false); + this.pglogin.PerformLayout(); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -475,5 +575,13 @@ private System.Windows.Forms.Label label9; private System.Windows.Forms.TextBox txtrsys; private System.Windows.Forms.Label label11; + private System.Windows.Forms.Panel pglogin; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.Button button1; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/FakeSetupScreen.cs b/ShiftOS.WinForms/FakeSetupScreen.cs index cc38d9b..a30b66c 100644 --- a/ShiftOS.WinForms/FakeSetupScreen.cs +++ b/ShiftOS.WinForms/FakeSetupScreen.cs @@ -191,6 +191,9 @@ So make sure your password is secure enough that it can't be guessed, but easy f this.CanClose = true; this.Close(); break; + case 10: + pglogin.BringToFront(); + break; } } @@ -262,5 +265,12 @@ So make sure your password is secure enough that it can't be guessed, but easy f currentPage++; SetupUI(); } + + private void button1_Click(object sender, EventArgs e) + { + ShiftOS.Objects.ShiftFS.Utils.Delete(Paths.GetPath("user.dat")); + System.IO.File.WriteAllText(Paths.SaveFile, ShiftOS.Objects.ShiftFS.Utils.ExportMount(0)); + Application.Restart(); + } } } diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index e4fc510..761aa29 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -249,7 +249,14 @@ namespace ShiftOS.WinForms public void PromptForLogin() { - throw new NotImplementedException(); + this.Show(); + this.TopMost = true; + lblHijack.Text = ""; + textgeninput = lblhackwords; + + var fsw = new FakeSetupScreen(this, 10); + fsw.Show(); + fsw.TopMost = true; } public void StartTrailer() diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 30a29e2..144dc56 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -36,13 +36,13 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms { - static class Program + public static class Program { /// /// The main entry point for the application. /// [STAThread] - static void Main() + public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 3cc3b4f..0b247f3 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -33,6 +33,10 @@ 4 + + ..\packages\CommonMark.NET.0.15.0\lib\net45\CommonMark.dll + True + @@ -143,6 +147,12 @@ Shifter.cs + + UserControl + + + Shiftnet.cs + UserControl @@ -264,6 +274,9 @@ Shifter.cs + + Shiftnet.cs + ShiftoriumFrontend.cs diff --git a/ShiftOS.WinForms/ShiftOSAudioProvider.cs b/ShiftOS.WinForms/ShiftOSAudioProvider.cs index f217325..52cbc92 100644 --- a/ShiftOS.WinForms/ShiftOSAudioProvider.cs +++ b/ShiftOS.WinForms/ShiftOSAudioProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using ShiftOS.Engine; @@ -19,18 +20,27 @@ namespace ShiftOS.WinForms } } - private float _vol = 1.0f; public float Volume { get { - return _vol; + if (SaveSystem.CurrentSave == null) + return 1.0f; + try + { + return SaveSystem.CurrentSave.Settings.audioVolume; + } + catch + { + SaveSystem.CurrentSave.Settings.audioVolume = 1.0f; + return 1.0f; + } } set { - _vol = value; + SaveSystem.CurrentSave.Settings.audioVolume = value; } } diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 456e46d..78d3534 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -180,7 +180,14 @@ namespace ShiftOS.WinForms.Tools ctrl.Font = SkinEngine.LoadedSkin.Header3Font; } - ctrl.Text = Localization.Parse(ctrl.Text); + try + { + ctrl.Text = Localization.Parse(ctrl.Text); + } + catch + { + + } ctrl.KeyDown += (o, a) => { if (a.Control && a.KeyCode == Keys.T) diff --git a/ShiftOS.WinForms/packages.config b/ShiftOS.WinForms/packages.config index 51393a5..b591ab5 100644 --- a/ShiftOS.WinForms/packages.config +++ b/ShiftOS.WinForms/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file -- cgit v1.2.3