From 3f08cb807c1490af423450e3eb03a46aa11caf2f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 16:14:35 -0500 Subject: Colored terminal text --- ShiftOS.WinForms/Tools/ControlManager.cs | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 5cc4813..52663d7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -152,6 +152,48 @@ namespace ShiftOS.WinForms.Tools } } + internal static Color ConvertColor(ConsoleColor cCol) + { + switch (cCol) + { + case ConsoleColor.Black: + return Color.Black; + case ConsoleColor.Gray: + return Color.Gray; + case ConsoleColor.DarkGray: + return Color.DarkGray; + case ConsoleColor.Blue: + return Color.Blue; + case ConsoleColor.Cyan: + return Color.Cyan; + case ConsoleColor.DarkBlue: + return Color.DarkBlue; + case ConsoleColor.DarkCyan: + return Color.DarkCyan; + case ConsoleColor.DarkGreen: + return Color.DarkGreen; + case ConsoleColor.DarkMagenta: + return Color.DarkMagenta; + case ConsoleColor.DarkRed: + return Color.DarkRed; + case ConsoleColor.DarkYellow: + return Color.YellowGreen; + case ConsoleColor.Yellow: + return Color.Yellow; + case ConsoleColor.Green: + return Color.Green; + case ConsoleColor.Magenta: + return Color.Magenta; + case ConsoleColor.Red: + return Color.Red; + case ConsoleColor.White: + return Color.White; + default: + return Color.Black; + } + + } + public static void SetCursor(Control ctrl) { #if STUPID -- cgit v1.2.3 From f43f6fe17d054f83c686b552201d6b4bfc83524d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 3 Apr 2017 18:36:13 -0400 Subject: LOADS of optimizations and Pong fixes. --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 - ShiftOS.Objects/ShiftOSMenuRenderer.cs | 51 ------- ShiftOS.WinForms/Applications/Pong.Designer.cs | 177 +++++++++++++------------ ShiftOS.WinForms/Applications/Pong.cs | 36 ++++- ShiftOS.WinForms/Oobe.cs | 30 ++++- ShiftOS.WinForms/Tools/ControlManager.cs | 107 +++------------ ShiftOS.WinForms/WinformsDesktop.cs | 13 +- ShiftOS.WinForms/WinformsWindowManager.cs | 17 +-- ShiftOS_TheReturn/Shiftorium.cs | 28 +++- 9 files changed, 217 insertions(+), 243 deletions(-) delete mode 100644 ShiftOS.Objects/ShiftOSMenuRenderer.cs (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 3dc0c33..4514b68 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -54,7 +54,6 @@ - diff --git a/ShiftOS.Objects/ShiftOSMenuRenderer.cs b/ShiftOS.Objects/ShiftOSMenuRenderer.cs deleted file mode 100644 index c76bd35..0000000 --- a/ShiftOS.Objects/ShiftOSMenuRenderer.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ShiftOS.Objects -{ - class ShiftOSMenuRenderer : ToolStripProfessionalRenderer - { - public ShiftOSMenuRenderer() : base(new ShiftOSColorTable()) - { - - } - - protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) - { - - } - } - - public class ShiftOSColorTable : ProfessionalColorTable - { - - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index faaf0f5..e619eaa 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -79,6 +79,11 @@ namespace ShiftOS.WinForms.Applications this.tmrcountdown = new System.Windows.Forms.Timer(this.components); this.tmrstoryline = new System.Windows.Forms.Timer(this.components); this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); + this.pnlhighscore = new System.Windows.Forms.Panel(); + this.lbhighscore = new System.Windows.Forms.ListBox(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.button2 = new System.Windows.Forms.Button(); + this.label10 = new System.Windows.Forms.Label(); this.pnlgamestats = new System.Windows.Forms.Panel(); this.button1 = new System.Windows.Forms.Button(); this.label12 = new System.Windows.Forms.Label(); @@ -91,9 +96,6 @@ namespace ShiftOS.WinForms.Applications this.btncashout = new System.Windows.Forms.Button(); this.Label2 = new System.Windows.Forms.Label(); this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListBox(); - this.label10 = new System.Windows.Forms.Label(); this.pnlfinalstats = new System.Windows.Forms.Panel(); this.btnplayagain = new System.Windows.Forms.Button(); this.lblfinalcodepoints = new System.Windows.Forms.Label(); @@ -122,16 +124,14 @@ namespace ShiftOS.WinForms.Applications this.lblstatscodepoints = new System.Windows.Forms.Label(); this.lblstatsY = new System.Windows.Forms.Label(); this.lblstatsX = new System.Windows.Forms.Label(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); this.pgcontents.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); this.pnlhighscore.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.pnlgamestats.SuspendLayout(); this.pnlfinalstats.SuspendLayout(); this.pnllose.SuspendLayout(); this.pnlintro.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // gameTimer @@ -174,11 +174,67 @@ namespace ShiftOS.WinForms.Applications this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; this.pgcontents.Location = new System.Drawing.Point(0, 0); this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(700, 400); + this.pgcontents.Size = new System.Drawing.Size(1867, 819); this.pgcontents.TabIndex = 20; this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); // + // pnlhighscore + // + this.pnlhighscore.Controls.Add(this.lbhighscore); + this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); + this.pnlhighscore.Controls.Add(this.label10); + this.pnlhighscore.Location = new System.Drawing.Point(688, 302); + this.pnlhighscore.Name = "pnlhighscore"; + this.pnlhighscore.Size = new System.Drawing.Size(539, 311); + this.pnlhighscore.TabIndex = 14; + this.pnlhighscore.Visible = false; + // + // lbhighscore + // + this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbhighscore.FormattingEnabled = true; + this.lbhighscore.Location = new System.Drawing.Point(0, 36); + this.lbhighscore.MultiColumn = true; + this.lbhighscore.Name = "lbhighscore"; + this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None; + this.lbhighscore.Size = new System.Drawing.Size(539, 246); + this.lbhighscore.TabIndex = 1; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.button2); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); + this.flowLayoutPanel1.TabIndex = 2; + // + // button2 + // + this.button2.AutoSize = true; + this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.button2.Location = new System.Drawing.Point(476, 3); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(60, 23); + this.button2.TabIndex = 0; + this.button2.Text = "{CLOSE}"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label10 + // + this.label10.Dock = System.Windows.Forms.DockStyle.Top; + this.label10.Location = new System.Drawing.Point(0, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(539, 36); + this.label10.TabIndex = 0; + this.label10.Text = "{HIGH_SCORES}"; + this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // // pnlgamestats // this.pnlgamestats.Controls.Add(this.button1); @@ -192,7 +248,7 @@ namespace ShiftOS.WinForms.Applications this.pnlgamestats.Controls.Add(this.btncashout); this.pnlgamestats.Controls.Add(this.Label2); this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(56, 76); + this.pnlgamestats.Location = new System.Drawing.Point(104, 375); this.pnlgamestats.Name = "pnlgamestats"; this.pnlgamestats.Size = new System.Drawing.Size(466, 284); this.pnlgamestats.TabIndex = 6; @@ -307,38 +363,6 @@ namespace ShiftOS.WinForms.Applications this.lbllevelreached.TabIndex = 0; this.lbllevelreached.Text = "You Reached Level 2!"; // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(67, 29); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.FormattingEnabled = true; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.MultiColumn = true; - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // // pnlfinalstats // this.pnlfinalstats.Controls.Add(this.btnplayagain); @@ -373,6 +397,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcodepoints.Name = "lblfinalcodepoints"; this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); this.lblfinalcodepoints.TabIndex = 15; + this.lblfinalcodepoints.Tag = "header1"; this.lblfinalcodepoints.Text = "134 CP"; this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -384,6 +409,7 @@ namespace ShiftOS.WinForms.Applications this.Label11.Name = "Label11"; this.Label11.Size = new System.Drawing.Size(33, 33); this.Label11.TabIndex = 14; + this.Label11.Tag = "header2"; this.Label11.Text = "+"; this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -394,6 +420,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); this.lblfinalcomputerreward.TabIndex = 12; + this.lblfinalcomputerreward.Tag = "header2"; this.lblfinalcomputerreward.Text = "34"; this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -413,6 +440,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinallevelreward.Name = "lblfinallevelreward"; this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); this.lblfinallevelreward.TabIndex = 10; + this.lblfinallevelreward.Tag = "header2"; this.lblfinallevelreward.Text = "100"; this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -432,6 +460,7 @@ namespace ShiftOS.WinForms.Applications this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); this.lblfinalcodepointswithtext.TabIndex = 1; + this.lblfinalcodepointswithtext.Tag = "header2"; this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -502,10 +531,11 @@ namespace ShiftOS.WinForms.Applications this.pnlintro.Controls.Add(this.Label6); this.pnlintro.Controls.Add(this.btnstartgame); this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(52, 29); + this.pnlintro.Location = new System.Drawing.Point(1139, 41); this.pnlintro.Name = "pnlintro"; this.pnlintro.Size = new System.Drawing.Size(595, 303); this.pnlintro.TabIndex = 13; + this.pnlintro.Tag = "header2"; // // Label6 // @@ -548,6 +578,7 @@ namespace ShiftOS.WinForms.Applications this.lblbeatai.Name = "lblbeatai"; this.lblbeatai.Size = new System.Drawing.Size(600, 30); this.lblbeatai.TabIndex = 8; + this.lblbeatai.Tag = "header2"; this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblbeatai.Visible = false; @@ -577,7 +608,6 @@ namespace ShiftOS.WinForms.Applications // this.paddleHuman.BackColor = System.Drawing.Color.Black; this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); this.paddleHuman.Name = "paddleHuman"; this.paddleHuman.Size = new System.Drawing.Size(20, 100); this.paddleHuman.TabIndex = 3; @@ -587,7 +617,7 @@ namespace ShiftOS.WinForms.Applications // this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(666, 134); + this.paddleComputer.Location = new System.Drawing.Point(1833, 134); this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); this.paddleComputer.Name = "paddleComputer"; this.paddleComputer.Size = new System.Drawing.Size(20, 100); @@ -599,69 +629,52 @@ namespace ShiftOS.WinForms.Applications this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(700, 22); + this.lbllevelandtime.Size = new System.Drawing.Size(1867, 22); this.lbllevelandtime.TabIndex = 4; + this.lbllevelandtime.Tag = "header1"; this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatscodepoints // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatscodepoints.AutoSize = true; this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 356); + this.lblstatscodepoints.Location = new System.Drawing.Point(239, 775); this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(219, 35); + this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); this.lblstatscodepoints.TabIndex = 12; + this.lblstatscodepoints.Tag = "header2"; this.lblstatscodepoints.Text = "Codepoints: "; this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatsY // this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatsY.AutoSize = true; this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(542, 356); + this.lblstatsY.Location = new System.Drawing.Point(1395, 775); this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(144, 35); + this.lblstatsY.Size = new System.Drawing.Size(76, 23); this.lblstatsY.TabIndex = 11; + this.lblstatsY.Tag = "header2"; this.lblstatsY.Text = "Yspeed:"; this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lblstatsX // this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblstatsX.AutoSize = true; this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 356); + this.lblstatsX.Location = new System.Drawing.Point(3, 775); this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(144, 35); + this.lblstatsX.Size = new System.Drawing.Size(83, 23); this.lblstatsX.TabIndex = 5; + this.lblstatsX.Tag = "header2"; this.lblstatsX.Text = "Xspeed: "; this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // // Pong // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -670,23 +683,23 @@ namespace ShiftOS.WinForms.Applications this.Controls.Add(this.pgcontents); this.DoubleBuffered = true; this.Name = "Pong"; - this.Text = "{PONG_NAME}"; - this.Size = new System.Drawing.Size(820, 500); + this.Size = new System.Drawing.Size(1867, 819); this.Load += new System.EventHandler(this.Pong_Load); this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); this.pgcontents.ResumeLayout(false); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); + this.pgcontents.PerformLayout(); this.pnlhighscore.ResumeLayout(false); this.pnlhighscore.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + this.pnlgamestats.ResumeLayout(false); + this.pnlgamestats.PerformLayout(); this.pnlfinalstats.ResumeLayout(false); this.pnlfinalstats.PerformLayout(); this.pnllose.ResumeLayout(false); this.pnlintro.ResumeLayout(false); this.pnlintro.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 157ce8c..a7b1aeb 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -83,6 +84,26 @@ namespace ShiftOS.WinForms.Applications paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); } + private void CenterPanels() + { + pnlfinalstats.CenterParent(); + pnlgamestats.CenterParent(); + pnlhighscore.CenterParent(); + pnlintro.CenterParent(); + pnllose.CenterParent(); + lblcountdown.CenterParent(); + lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; + SetupStats(); + } + + public void SetupStats() + { + lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); + lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); + lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; + lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; + } + // ERROR: Handles clauses are not supported in C# private void gameTimer_Tick(object sender, EventArgs e) @@ -102,7 +123,7 @@ namespace ShiftOS.WinForms.Applications //Set the computer player to move according to the ball's position. if (aiShouldIsbeEnabled) - if (ball.Location.X > 500 - xVel * 10 && xVel > 0) + if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) { if (ball.Location.Y > paddleComputer.Location.Y + 50) { @@ -116,12 +137,12 @@ namespace ShiftOS.WinForms.Applications } else { - //used to be me.location.y + //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) { paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); } - //used to be me.location.y + //Rylan is hot. Used to be //used to be me.location.y if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) { paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); @@ -269,6 +290,7 @@ namespace ShiftOS.WinForms.Applications } lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); } + SetupStats(); } public void SendHighscores() @@ -652,10 +674,17 @@ namespace ShiftOS.WinForms.Applications pnlhighscore.Hide(); pnlgamestats.Hide(); pnlfinalstats.Hide(); + CenterPanels(); + lblbeatai.Hide(); } public void OnSkinLoad() { + CenterPanels(); + this.SizeChanged += (o, a) => + { + CenterPanels(); + }; } public bool OnUnload() @@ -665,6 +694,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + CenterPanels(); } private void button2_Click(object sender, EventArgs e) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 898f60b..d6d3b92 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -64,7 +64,10 @@ namespace ShiftOS.WinForms { while(typing == true) { + //JESUS CHRIST PAST MICHAEL. + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } charcount = texttotype.Length; @@ -452,6 +455,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and type 'sos.help' to see a list of commands."); while (TutorialProgress == 0) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("As you can see, sos.help gives you a list of all commands in the system."); @@ -461,6 +468,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); while (TutorialProgress == 1) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available."); @@ -478,6 +489,10 @@ namespace ShiftOS.WinForms TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); while (TutorialProgress == 2) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } Clear(); @@ -502,13 +517,21 @@ namespace ShiftOS.WinForms TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID."); while (TutorialProgress == 3) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!"); Thread.Sleep(500); TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!"); while (!Shiftorium.UpgradeInstalled("mud_fundamentals")) - { + { //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); + } TextType("Hooray! You now have the MUD Fundamentals upgrade."); @@ -520,6 +543,10 @@ namespace ShiftOS.WinForms TextType("Just run win.open without arguments, and this tutorial will be completed!"); while (TutorialProgress == 4) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); @@ -528,6 +555,7 @@ namespace ShiftOS.WinForms { OnComplete?.Invoke(this, EventArgs.Empty); SaveSystem.CurrentSave.StoryPosition = 2; + this.Close(); SaveSystem.SaveGame(); AppearanceManager.SetupWindow(new Applications.Terminal()); }); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 52663d7..a2a76b7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -67,91 +67,6 @@ namespace ShiftOS.WinForms.Tools } - public static void SetupWindows() - { - if (SaveSystem.CurrentSave != null) - { - int screen_height_start = 0; - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - } - else if (Shiftorium.UpgradeInstalled("wm_4_windows")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height_half = (Screen.PrimaryScreen.Bounds.Height - screen_height_start) / 2; - - for (int i = 0; i < OpenForms.Count; i++) - { - var frm = OpenForms[i] as WindowBorder; - - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - case 2: - frm.Location = new System.Drawing.Point(0, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 3) ? screen_width_half : screen_width_half * 2, screen_height_half); - break; - case 3: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - } - } - - } - else if (Shiftorium.UpgradeInstalled("window_manager")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height = (Screen.PrimaryScreen.Bounds.Height) - screen_height_start; - - - - for (int i = 0; i < OpenForms.Count; i++) - { - - - var frm = OpenForms[i] as WindowBorder; - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, screen_height); - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, screen_height); - break; - } - OpenForms[i] = frm; - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - internal static Color ConvertColor(ConsoleColor cCol) { switch (cCol) @@ -214,9 +129,22 @@ namespace ShiftOS.WinForms.Tools #endif } + /// + /// Centers the control along its parent. + /// + /// The control to center (this is an extension method - you can call it on a control as though it was a method in that control) + public static void CenterParent(this Control ctrl) + { + ctrl.Location = new Point( + (ctrl.Parent.Width - ctrl.Width) / 2, + (ctrl.Parent.Height - ctrl.Height) / 2 + ); + } + public static void SetupControl(Control ctrl) { SuspendDrawing(ctrl); + ctrl.SuspendLayout(); SetCursor(ctrl); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { @@ -270,13 +198,7 @@ namespace ShiftOS.WinForms.Tools a.SuppressKeyPress = true; - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } + Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); } ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); @@ -293,6 +215,7 @@ namespace ShiftOS.WinForms.Tools } MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); ResumeDrawing(ctrl); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 06f103e..033802e 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -664,10 +664,17 @@ namespace ShiftOS.WinForms /// Act. public void InvokeOnWorkerThread(Action act) { - this.Invoke(new Action(()=> + try { - act?.Invoke(); - })); + this.Invoke(new Action(() => + { + act?.Invoke(); + })); + } + catch + { + + } } public void OpenAppLauncher(Point loc) diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 26438bf..cfcb6d3 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -184,20 +184,21 @@ namespace ShiftOS.WinForms if (maxWindows > 0) { - List formstoclose = new List(); - - for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++) + var windows = new List(); + foreach(var WB in AppearanceManager.OpenForms) { - var frm = AppearanceManager.OpenForms[i] as WindowBorder; - if(!frm.IsDialog) - formstoclose.Add(frm); - + if (WB is WindowBorder) + windows.Add(WB as WindowBorder); } + List formstoclose = new List(windows.Where(x => x.IsDialog == false).ToArray()); + while (formstoclose.Count > maxWindows - 1) { - formstoclose[0].Close(); + this.Close(formstoclose[0].ParentWindow); + AppearanceManager.OpenForms.Remove(formstoclose[0]); formstoclose.RemoveAt(0); + } } } diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 0bdd9f4..4556cd6 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -46,6 +46,23 @@ namespace ShiftOS.Engine Installed?.Invoke(); } + public static string GetCategory(string id) + { + var upg = GetDefaults().FirstOrDefault(x => x.ID == id); + if (upg == null) + return "Other"; + return (upg.Category == null) ? "Other" : upg.Category; + } + + public static IEnumerable GetAllInCategory(string cat) + { + return GetDefaults().Where(x => x.Category == cat); + } + + public static bool IsCategoryEmptied(string cat) + { + return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; + } public static bool Buy(string id, int cost) { @@ -278,8 +295,15 @@ namespace ShiftOS.Engine public string Description { get; set; } public int Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } - public string Id { get; } - + public string Id { get; set; } + public string Category { get; set; } + public bool Installed + { + get + { + return Shiftorium.UpgradeInstalled(ID); + } + } public string Dependencies { get; set; } } } -- cgit v1.2.3 From fb481614fc2cd64357d60c4459adb5b65072bbce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 10:50:05 -0400 Subject: Dramatic speed-up of window loading. --- ShiftOS.WinForms/Applications/Artpad.cs | 371 +++---------------------------- ShiftOS.WinForms/Controls/TerminalBox.cs | 5 + ShiftOS.WinForms/Tools/ControlManager.cs | 106 ++++++--- ShiftOS.WinForms/WindowBorder.cs | 6 +- 4 files changed, 114 insertions(+), 374 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Artpad.cs b/ShiftOS.WinForms/Applications/Artpad.cs index 71f7afb..7ef66aa 100644 --- a/ShiftOS.WinForms/Applications/Artpad.cs +++ b/ShiftOS.WinForms/Applications/Artpad.cs @@ -38,6 +38,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.WinForms.Tools; using ShiftOS.Engine; +using System.Diagnostics; namespace ShiftOS.WinForms.Applications { @@ -55,8 +56,11 @@ namespace ShiftOS.WinForms.Applications { try { + Stopwatch sw = new Stopwatch(); + sw.Start(); InitializeComponent(); - + sw.Stop(); + Console.WriteLine("ArtPad construction timespan:" + sw.Elapsed.ToString()); } catch (Exception ex) { @@ -141,17 +145,7 @@ namespace ShiftOS.WinForms.Applications private void Template_Load(object sender, EventArgs e) { - justopened = true; - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - setuppreview(); - settoolcolours(); - loadcolors(); - AddFonts(); - setuptoolbox(); - determinevisiblepalettes(); - tmrsetupui.Start(); + //Moved to the engine "OnLoad" method. } @@ -171,55 +165,24 @@ namespace ShiftOS.WinForms.Applications needtosave = false; } + //PHILCODE: I just reduced this function's amount of Windows Forms calls by 66%. public void setuptoolbox() { - btnpixelplacer.Hide(); - btnpencil.Hide(); - btnfloodfill.Hide(); - btnoval.Hide(); - btnsquare.Hide(); - btnlinetool.Hide(); - btnpaintbrush.Hide(); - btntexttool.Hide(); - btneracer.Hide(); - btnnew.Hide(); - btnopen.Hide(); - btnsave.Hide(); - btnundo.Hide(); - btnredo.Hide(); - btnpixelplacermovementmode.Hide(); - - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true) - btnpixelplacer.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true) - btnpencil.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true) - btnfloodfill.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true) - btnoval.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true) - btnsquare.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true) - btnlinetool.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true) - btnpaintbrush.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true) - btntexttool.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true) - btneracer.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true) - btnnew.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true) - btnopen.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true) - btnsave.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true) - btnundo.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true) - btnredo.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true) - btnpixelplacermovementmode.Show(); - + btnpixelplacer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true); + btnpencil.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true); + btnfloodfill.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true); + btnoval.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true); + btnsquare.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true); + btnlinetool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true); + btnpaintbrush.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true); + btntexttool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true); + btneracer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true); + btnnew.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true); + btnopen.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true); + btnsave.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true); + btnundo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true); + btnredo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true); + btnpixelplacermovementmode.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true); } private void AddFonts() @@ -688,290 +651,6 @@ namespace ShiftOS.WinForms.Applications } } - // - public void loadcolors() - { - /*bool allwhite = true; - for (int i = 0; i <= 127; i++) - { - if (ShiftOSDesktop.artpad_colour_palettes(i) == null) - { - } - else { - allwhite = false; - } - } - if (allwhite == true) - { - for (i = 0; i <= 127; i++) - { - ShiftOSDesktop.artpad_colour_palettes(i) = Color.Black; - } - } - colourpalette1.BackColor = ShiftOSDesktop.artpad_colour_palettes(0); - colourpalette2.BackColor = ShiftOSDesktop.artpad_colour_palettes(1); - colourpalette3.BackColor = ShiftOSDesktop.artpad_colour_palettes(2); - colourpalette4.BackColor = ShiftOSDesktop.artpad_colour_palettes(3); - colourpalette5.BackColor = ShiftOSDesktop.artpad_colour_palettes(4); - colourpalette6.BackColor = ShiftOSDesktop.artpad_colour_palettes(5); - colourpalette7.BackColor = ShiftOSDesktop.artpad_colour_palettes(6); - colourpalette8.BackColor = ShiftOSDesktop.artpad_colour_palettes(7); - colourpalette9.BackColor = ShiftOSDesktop.artpad_colour_palettes(8); - colourpalette10.BackColor = ShiftOSDesktop.artpad_colour_palettes(9); - colourpalette11.BackColor = ShiftOSDesktop.artpad_colour_palettes(10); - colourpalette12.BackColor = ShiftOSDesktop.artpad_colour_palettes(11); - colourpalette13.BackColor = ShiftOSDesktop.artpad_colour_palettes(12); - colourpalette14.BackColor = ShiftOSDesktop.artpad_colour_palettes(13); - colourpalette15.BackColor = ShiftOSDesktop.artpad_colour_palettes(14); - colourpalette16.BackColor = ShiftOSDesktop.artpad_colour_palettes(15); - colourpalette17.BackColor = ShiftOSDesktop.artpad_colour_palettes(16); - colourpalette18.BackColor = ShiftOSDesktop.artpad_colour_palettes(17); - colourpalette19.BackColor = ShiftOSDesktop.artpad_colour_palettes(18); - colourpalette20.BackColor = ShiftOSDesktop.artpad_colour_palettes(19); - colourpalette21.BackColor = ShiftOSDesktop.artpad_colour_palettes(20); - colourpalette22.BackColor = ShiftOSDesktop.artpad_colour_palettes(21); - colourpalette23.BackColor = ShiftOSDesktop.artpad_colour_palettes(22); - colourpalette24.BackColor = ShiftOSDesktop.artpad_colour_palettes(23); - colourpalette25.BackColor = ShiftOSDesktop.artpad_colour_palettes(24); - colourpalette26.BackColor = ShiftOSDesktop.artpad_colour_palettes(25); - colourpalette27.BackColor = ShiftOSDesktop.artpad_colour_palettes(26); - colourpalette28.BackColor = ShiftOSDesktop.artpad_colour_palettes(27); - colourpalette29.BackColor = ShiftOSDesktop.artpad_colour_palettes(28); - colourpalette30.BackColor = ShiftOSDesktop.artpad_colour_palettes(29); - colourpalette31.BackColor = ShiftOSDesktop.artpad_colour_palettes(30); - colourpalette32.BackColor = ShiftOSDesktop.artpad_colour_palettes(31); - colourpalette33.BackColor = ShiftOSDesktop.artpad_colour_palettes(32); - colourpalette34.BackColor = ShiftOSDesktop.artpad_colour_palettes(33); - colourpalette35.BackColor = ShiftOSDesktop.artpad_colour_palettes(34); - colourpalette36.BackColor = ShiftOSDesktop.artpad_colour_palettes(35); - colourpalette37.BackColor = ShiftOSDesktop.artpad_colour_palettes(36); - colourpalette38.BackColor = ShiftOSDesktop.artpad_colour_palettes(37); - colourpalette39.BackColor = ShiftOSDesktop.artpad_colour_palettes(38); - colourpalette40.BackColor = ShiftOSDesktop.artpad_colour_palettes(39); - colourpalette41.BackColor = ShiftOSDesktop.artpad_colour_palettes(40); - colourpalette42.BackColor = ShiftOSDesktop.artpad_colour_palettes(41); - colourpalette43.BackColor = ShiftOSDesktop.artpad_colour_palettes(42); - colourpalette44.BackColor = ShiftOSDesktop.artpad_colour_palettes(43); - colourpalette45.BackColor = ShiftOSDesktop.artpad_colour_palettes(44); - colourpalette46.BackColor = ShiftOSDesktop.artpad_colour_palettes(45); - colourpalette47.BackColor = ShiftOSDesktop.artpad_colour_palettes(46); - colourpalette48.BackColor = ShiftOSDesktop.artpad_colour_palettes(47); - colourpalette49.BackColor = ShiftOSDesktop.artpad_colour_palettes(48); - colourpalette50.BackColor = ShiftOSDesktop.artpad_colour_palettes(49); - colourpalette51.BackColor = ShiftOSDesktop.artpad_colour_palettes(50); - colourpalette52.BackColor = ShiftOSDesktop.artpad_colour_palettes(51); - colourpalette53.BackColor = ShiftOSDesktop.artpad_colour_palettes(52); - colourpalette54.BackColor = ShiftOSDesktop.artpad_colour_palettes(53); - colourpalette55.BackColor = ShiftOSDesktop.artpad_colour_palettes(54); - colourpalette56.BackColor = ShiftOSDesktop.artpad_colour_palettes(55); - colourpalette57.BackColor = ShiftOSDesktop.artpad_colour_palettes(56); - colourpalette58.BackColor = ShiftOSDesktop.artpad_colour_palettes(57); - colourpalette59.BackColor = ShiftOSDesktop.artpad_colour_palettes(58); - colourpalette60.BackColor = ShiftOSDesktop.artpad_colour_palettes(59); - colourpalette61.BackColor = ShiftOSDesktop.artpad_colour_palettes(60); - colourpalette62.BackColor = ShiftOSDesktop.artpad_colour_palettes(61); - colourpalette63.BackColor = ShiftOSDesktop.artpad_colour_palettes(62); - colourpalette64.BackColor = ShiftOSDesktop.artpad_colour_palettes(63); - colourpalette65.BackColor = ShiftOSDesktop.artpad_colour_palettes(64); - colourpalette66.BackColor = ShiftOSDesktop.artpad_colour_palettes(65); - colourpalette67.BackColor = ShiftOSDesktop.artpad_colour_palettes(66); - colourpalette68.BackColor = ShiftOSDesktop.artpad_colour_palettes(67); - colourpalette69.BackColor = ShiftOSDesktop.artpad_colour_palettes(68); - colourpalette70.BackColor = ShiftOSDesktop.artpad_colour_palettes(69); - colourpalette71.BackColor = ShiftOSDesktop.artpad_colour_palettes(70); - colourpalette72.BackColor = ShiftOSDesktop.artpad_colour_palettes(71); - colourpalette73.BackColor = ShiftOSDesktop.artpad_colour_palettes(72); - colourpalette74.BackColor = ShiftOSDesktop.artpad_colour_palettes(73); - colourpalette75.BackColor = ShiftOSDesktop.artpad_colour_palettes(74); - colourpalette76.BackColor = ShiftOSDesktop.artpad_colour_palettes(75); - colourpalette77.BackColor = ShiftOSDesktop.artpad_colour_palettes(76); - colourpalette78.BackColor = ShiftOSDesktop.artpad_colour_palettes(77); - colourpalette79.BackColor = ShiftOSDesktop.artpad_colour_palettes(78); - colourpalette80.BackColor = ShiftOSDesktop.artpad_colour_palettes(79); - colourpalette81.BackColor = ShiftOSDesktop.artpad_colour_palettes(80); - colourpalette82.BackColor = ShiftOSDesktop.artpad_colour_palettes(81); - colourpalette83.BackColor = ShiftOSDesktop.artpad_colour_palettes(82); - colourpalette84.BackColor = ShiftOSDesktop.artpad_colour_palettes(83); - colourpalette85.BackColor = ShiftOSDesktop.artpad_colour_palettes(84); - colourpalette86.BackColor = ShiftOSDesktop.artpad_colour_palettes(85); - colourpalette87.BackColor = ShiftOSDesktop.artpad_colour_palettes(86); - colourpalette88.BackColor = ShiftOSDesktop.artpad_colour_palettes(87); - colourpalette89.BackColor = ShiftOSDesktop.artpad_colour_palettes(88); - colourpalette90.BackColor = ShiftOSDesktop.artpad_colour_palettes(89); - colourpalette91.BackColor = ShiftOSDesktop.artpad_colour_palettes(90); - colourpalette92.BackColor = ShiftOSDesktop.artpad_colour_palettes(91); - colourpalette93.BackColor = ShiftOSDesktop.artpad_colour_palettes(92); - colourpalette94.BackColor = ShiftOSDesktop.artpad_colour_palettes(93); - colourpalette95.BackColor = ShiftOSDesktop.artpad_colour_palettes(94); - colourpalette96.BackColor = ShiftOSDesktop.artpad_colour_palettes(95); - colourpalette97.BackColor = ShiftOSDesktop.artpad_colour_palettes(96); - colourpalette98.BackColor = ShiftOSDesktop.artpad_colour_palettes(97); - colourpalette99.BackColor = ShiftOSDesktop.artpad_colour_palettes(98); - colourpalette100.BackColor = ShiftOSDesktop.artpad_colour_palettes(99); - colourpalette101.BackColor = ShiftOSDesktop.artpad_colour_palettes(100); - colourpalette102.BackColor = ShiftOSDesktop.artpad_colour_palettes(101); - colourpalette103.BackColor = ShiftOSDesktop.artpad_colour_palettes(102); - colourpalette104.BackColor = ShiftOSDesktop.artpad_colour_palettes(103); - colourpalette105.BackColor = ShiftOSDesktop.artpad_colour_palettes(104); - colourpalette106.BackColor = ShiftOSDesktop.artpad_colour_palettes(105); - colourpalette107.BackColor = ShiftOSDesktop.artpad_colour_palettes(106); - colourpalette108.BackColor = ShiftOSDesktop.artpad_colour_palettes(107); - colourpalette109.BackColor = ShiftOSDesktop.artpad_colour_palettes(108); - colourpalette110.BackColor = ShiftOSDesktop.artpad_colour_palettes(109); - colourpalette111.BackColor = ShiftOSDesktop.artpad_colour_palettes(110); - colourpalette112.BackColor = ShiftOSDesktop.artpad_colour_palettes(111); - colourpalette113.BackColor = ShiftOSDesktop.artpad_colour_palettes(112); - colourpalette114.BackColor = ShiftOSDesktop.artpad_colour_palettes(113); - colourpalette115.BackColor = ShiftOSDesktop.artpad_colour_palettes(114); - colourpalette116.BackColor = ShiftOSDesktop.artpad_colour_palettes(115); - colourpalette117.BackColor = ShiftOSDesktop.artpad_colour_palettes(116); - colourpalette118.BackColor = ShiftOSDesktop.artpad_colour_palettes(117); - colourpalette119.BackColor = ShiftOSDesktop.artpad_colour_palettes(118); - colourpalette120.BackColor = ShiftOSDesktop.artpad_colour_palettes(119); - colourpalette121.BackColor = ShiftOSDesktop.artpad_colour_palettes(120); - colourpalette122.BackColor = ShiftOSDesktop.artpad_colour_palettes(121); - colourpalette123.BackColor = ShiftOSDesktop.artpad_colour_palettes(122); - colourpalette124.BackColor = ShiftOSDesktop.artpad_colour_palettes(123); - colourpalette125.BackColor = ShiftOSDesktop.artpad_colour_palettes(124); - colourpalette126.BackColor = ShiftOSDesktop.artpad_colour_palettes(125); - colourpalette127.BackColor = ShiftOSDesktop.artpad_colour_palettes(126); - colourpalette128.BackColor = ShiftOSDesktop.artpad_colour_palettes(127); - */ - } - - public void savecolors() - {/* - ShiftOSDesktop.artpad_colour_palettes(0) = colourpalette1.BackColor; - ShiftOSDesktop.artpad_colour_palettes(1) = colourpalette2.BackColor; - ShiftOSDesktop.artpad_colour_palettes(2) = colourpalette3.BackColor; - ShiftOSDesktop.artpad_colour_palettes(3) = colourpalette4.BackColor; - ShiftOSDesktop.artpad_colour_palettes(4) = colourpalette5.BackColor; - ShiftOSDesktop.artpad_colour_palettes(5) = colourpalette6.BackColor; - ShiftOSDesktop.artpad_colour_palettes(6) = colourpalette7.BackColor; - ShiftOSDesktop.artpad_colour_palettes(7) = colourpalette8.BackColor; - ShiftOSDesktop.artpad_colour_palettes(8) = colourpalette9.BackColor; - ShiftOSDesktop.artpad_colour_palettes(9) = colourpalette10.BackColor; - ShiftOSDesktop.artpad_colour_palettes(10) = colourpalette11.BackColor; - ShiftOSDesktop.artpad_colour_palettes(11) = colourpalette12.BackColor; - ShiftOSDesktop.artpad_colour_palettes(12) = colourpalette13.BackColor; - ShiftOSDesktop.artpad_colour_palettes(13) = colourpalette14.BackColor; - ShiftOSDesktop.artpad_colour_palettes(14) = colourpalette15.BackColor; - ShiftOSDesktop.artpad_colour_palettes(15) = colourpalette16.BackColor; - ShiftOSDesktop.artpad_colour_palettes(16) = colourpalette17.BackColor; - ShiftOSDesktop.artpad_colour_palettes(17) = colourpalette18.BackColor; - ShiftOSDesktop.artpad_colour_palettes(18) = colourpalette19.BackColor; - ShiftOSDesktop.artpad_colour_palettes(19) = colourpalette20.BackColor; - ShiftOSDesktop.artpad_colour_palettes(20) = colourpalette21.BackColor; - ShiftOSDesktop.artpad_colour_palettes(21) = colourpalette22.BackColor; - ShiftOSDesktop.artpad_colour_palettes(22) = colourpalette23.BackColor; - ShiftOSDesktop.artpad_colour_palettes(23) = colourpalette24.BackColor; - ShiftOSDesktop.artpad_colour_palettes(24) = colourpalette25.BackColor; - ShiftOSDesktop.artpad_colour_palettes(25) = colourpalette26.BackColor; - ShiftOSDesktop.artpad_colour_palettes(26) = colourpalette27.BackColor; - ShiftOSDesktop.artpad_colour_palettes(27) = colourpalette28.BackColor; - ShiftOSDesktop.artpad_colour_palettes(28) = colourpalette29.BackColor; - ShiftOSDesktop.artpad_colour_palettes(29) = colourpalette30.BackColor; - ShiftOSDesktop.artpad_colour_palettes(30) = colourpalette31.BackColor; - ShiftOSDesktop.artpad_colour_palettes(31) = colourpalette32.BackColor; - ShiftOSDesktop.artpad_colour_palettes(32) = colourpalette33.BackColor; - ShiftOSDesktop.artpad_colour_palettes(33) = colourpalette34.BackColor; - ShiftOSDesktop.artpad_colour_palettes(34) = colourpalette35.BackColor; - ShiftOSDesktop.artpad_colour_palettes(35) = colourpalette36.BackColor; - ShiftOSDesktop.artpad_colour_palettes(36) = colourpalette37.BackColor; - ShiftOSDesktop.artpad_colour_palettes(37) = colourpalette38.BackColor; - ShiftOSDesktop.artpad_colour_palettes(38) = colourpalette39.BackColor; - ShiftOSDesktop.artpad_colour_palettes(39) = colourpalette40.BackColor; - ShiftOSDesktop.artpad_colour_palettes(40) = colourpalette41.BackColor; - ShiftOSDesktop.artpad_colour_palettes(41) = colourpalette42.BackColor; - ShiftOSDesktop.artpad_colour_palettes(42) = colourpalette43.BackColor; - ShiftOSDesktop.artpad_colour_palettes(43) = colourpalette44.BackColor; - ShiftOSDesktop.artpad_colour_palettes(44) = colourpalette45.BackColor; - ShiftOSDesktop.artpad_colour_palettes(45) = colourpalette46.BackColor; - ShiftOSDesktop.artpad_colour_palettes(46) = colourpalette47.BackColor; - ShiftOSDesktop.artpad_colour_palettes(47) = colourpalette48.BackColor; - ShiftOSDesktop.artpad_colour_palettes(48) = colourpalette49.BackColor; - ShiftOSDesktop.artpad_colour_palettes(49) = colourpalette50.BackColor; - ShiftOSDesktop.artpad_colour_palettes(50) = colourpalette51.BackColor; - ShiftOSDesktop.artpad_colour_palettes(51) = colourpalette52.BackColor; - ShiftOSDesktop.artpad_colour_palettes(52) = colourpalette53.BackColor; - ShiftOSDesktop.artpad_colour_palettes(53) = colourpalette54.BackColor; - ShiftOSDesktop.artpad_colour_palettes(54) = colourpalette55.BackColor; - ShiftOSDesktop.artpad_colour_palettes(55) = colourpalette56.BackColor; - ShiftOSDesktop.artpad_colour_palettes(56) = colourpalette57.BackColor; - ShiftOSDesktop.artpad_colour_palettes(57) = colourpalette58.BackColor; - ShiftOSDesktop.artpad_colour_palettes(58) = colourpalette59.BackColor; - ShiftOSDesktop.artpad_colour_palettes(59) = colourpalette60.BackColor; - ShiftOSDesktop.artpad_colour_palettes(60) = colourpalette61.BackColor; - ShiftOSDesktop.artpad_colour_palettes(61) = colourpalette62.BackColor; - ShiftOSDesktop.artpad_colour_palettes(62) = colourpalette63.BackColor; - ShiftOSDesktop.artpad_colour_palettes(63) = colourpalette64.BackColor; - ShiftOSDesktop.artpad_colour_palettes(64) = colourpalette65.BackColor; - ShiftOSDesktop.artpad_colour_palettes(65) = colourpalette66.BackColor; - ShiftOSDesktop.artpad_colour_palettes(66) = colourpalette67.BackColor; - ShiftOSDesktop.artpad_colour_palettes(67) = colourpalette68.BackColor; - ShiftOSDesktop.artpad_colour_palettes(68) = colourpalette69.BackColor; - ShiftOSDesktop.artpad_colour_palettes(69) = colourpalette70.BackColor; - ShiftOSDesktop.artpad_colour_palettes(70) = colourpalette71.BackColor; - ShiftOSDesktop.artpad_colour_palettes(71) = colourpalette72.BackColor; - ShiftOSDesktop.artpad_colour_palettes(72) = colourpalette73.BackColor; - ShiftOSDesktop.artpad_colour_palettes(73) = colourpalette74.BackColor; - ShiftOSDesktop.artpad_colour_palettes(74) = colourpalette75.BackColor; - ShiftOSDesktop.artpad_colour_palettes(75) = colourpalette76.BackColor; - ShiftOSDesktop.artpad_colour_palettes(76) = colourpalette77.BackColor; - ShiftOSDesktop.artpad_colour_palettes(77) = colourpalette78.BackColor; - ShiftOSDesktop.artpad_colour_palettes(78) = colourpalette79.BackColor; - ShiftOSDesktop.artpad_colour_palettes(79) = colourpalette80.BackColor; - ShiftOSDesktop.artpad_colour_palettes(80) = colourpalette81.BackColor; - ShiftOSDesktop.artpad_colour_palettes(81) = colourpalette82.BackColor; - ShiftOSDesktop.artpad_colour_palettes(82) = colourpalette83.BackColor; - ShiftOSDesktop.artpad_colour_palettes(83) = colourpalette84.BackColor; - ShiftOSDesktop.artpad_colour_palettes(84) = colourpalette85.BackColor; - ShiftOSDesktop.artpad_colour_palettes(85) = colourpalette86.BackColor; - ShiftOSDesktop.artpad_colour_palettes(86) = colourpalette87.BackColor; - ShiftOSDesktop.artpad_colour_palettes(87) = colourpalette88.BackColor; - ShiftOSDesktop.artpad_colour_palettes(88) = colourpalette89.BackColor; - ShiftOSDesktop.artpad_colour_palettes(89) = colourpalette90.BackColor; - ShiftOSDesktop.artpad_colour_palettes(90) = colourpalette91.BackColor; - ShiftOSDesktop.artpad_colour_palettes(91) = colourpalette92.BackColor; - ShiftOSDesktop.artpad_colour_palettes(92) = colourpalette93.BackColor; - ShiftOSDesktop.artpad_colour_palettes(93) = colourpalette94.BackColor; - ShiftOSDesktop.artpad_colour_palettes(94) = colourpalette95.BackColor; - ShiftOSDesktop.artpad_colour_palettes(95) = colourpalette96.BackColor; - ShiftOSDesktop.artpad_colour_palettes(96) = colourpalette97.BackColor; - ShiftOSDesktop.artpad_colour_palettes(97) = colourpalette98.BackColor; - ShiftOSDesktop.artpad_colour_palettes(98) = colourpalette99.BackColor; - ShiftOSDesktop.artpad_colour_palettes(99) = colourpalette100.BackColor; - ShiftOSDesktop.artpad_colour_palettes(100) = colourpalette101.BackColor; - ShiftOSDesktop.artpad_colour_palettes(101) = colourpalette102.BackColor; - ShiftOSDesktop.artpad_colour_palettes(102) = colourpalette103.BackColor; - ShiftOSDesktop.artpad_colour_palettes(103) = colourpalette104.BackColor; - ShiftOSDesktop.artpad_colour_palettes(104) = colourpalette105.BackColor; - ShiftOSDesktop.artpad_colour_palettes(105) = colourpalette106.BackColor; - ShiftOSDesktop.artpad_colour_palettes(106) = colourpalette107.BackColor; - ShiftOSDesktop.artpad_colour_palettes(107) = colourpalette108.BackColor; - ShiftOSDesktop.artpad_colour_palettes(108) = colourpalette109.BackColor; - ShiftOSDesktop.artpad_colour_palettes(109) = colourpalette110.BackColor; - ShiftOSDesktop.artpad_colour_palettes(110) = colourpalette111.BackColor; - ShiftOSDesktop.artpad_colour_palettes(111) = colourpalette112.BackColor; - ShiftOSDesktop.artpad_colour_palettes(112) = colourpalette113.BackColor; - ShiftOSDesktop.artpad_colour_palettes(113) = colourpalette114.BackColor; - ShiftOSDesktop.artpad_colour_palettes(114) = colourpalette115.BackColor; - ShiftOSDesktop.artpad_colour_palettes(115) = colourpalette116.BackColor; - ShiftOSDesktop.artpad_colour_palettes(116) = colourpalette117.BackColor; - ShiftOSDesktop.artpad_colour_palettes(117) = colourpalette118.BackColor; - ShiftOSDesktop.artpad_colour_palettes(118) = colourpalette119.BackColor; - ShiftOSDesktop.artpad_colour_palettes(119) = colourpalette120.BackColor; - ShiftOSDesktop.artpad_colour_palettes(120) = colourpalette121.BackColor; - ShiftOSDesktop.artpad_colour_palettes(121) = colourpalette122.BackColor; - ShiftOSDesktop.artpad_colour_palettes(122) = colourpalette123.BackColor; - ShiftOSDesktop.artpad_colour_palettes(123) = colourpalette124.BackColor; - ShiftOSDesktop.artpad_colour_palettes(124) = colourpalette125.BackColor; - ShiftOSDesktop.artpad_colour_palettes(125) = colourpalette126.BackColor; - ShiftOSDesktop.artpad_colour_palettes(126) = colourpalette127.BackColor; - ShiftOSDesktop.artpad_colour_palettes(127) = colourpalette128.BackColor; - */ - } - // public void settoolcolours() { @@ -1859,6 +1538,12 @@ namespace ShiftOS.WinForms.Applications ctrl.Tag = "keepbg"; ctrl.BackColor = Color.Black; } + setuppreview(); + settoolcolours(); + AddFonts(); + setuptoolbox(); + determinevisiblepalettes(); + } public void OnSkinLoad() diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index df820f7..cdb0965 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -118,5 +118,10 @@ namespace ShiftOS.WinForms.Controls } base.OnMouseUp(mevent); } + + public TerminalBox() : base() + { + this.Tag = "keepbg keepfg keepfont"; + } } } diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index a2a76b7..781e045 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -28,6 +28,7 @@ using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; @@ -143,9 +144,11 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - SuspendDrawing(ctrl); - ctrl.SuspendLayout(); - SetCursor(ctrl); + Desktop.InvokeOnWorkerThread(new Action(() => + { + SuspendDrawing(ctrl); + ctrl.SuspendLayout(); + })); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { string tag = ""; @@ -160,32 +163,52 @@ namespace ShiftOS.WinForms.Tools { if (ctrl.BackColor != Control.DefaultBackColor) { - ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; + Desktop.InvokeOnWorkerThread(() => + { + ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; + }); } } - ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; - - ctrl.Font = SkinEngine.LoadedSkin.MainFont; - - if (tag.Contains("header1")) + if (!tag.Contains("keepfont")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; + ctrl.Font = SkinEngine.LoadedSkin.MainFont; + }); + if (tag.Contains("header1")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - } + if (tag.Contains("header2")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.Header2Font; + }); + } - if (tag.Contains("header3")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - } + if (tag.Contains("header3")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.Header3Font; + }); + } + } try { - ctrl.Text = Localization.Parse(ctrl.Text); + string ctrlText = Localization.Parse(ctrl.Text); + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Text = ctrlText; + }); } catch { @@ -206,19 +229,31 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - (ctrl as Button).FlatStyle = FlatStyle.Flat; + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as Button).FlatStyle = FlatStyle.Flat; + }); } else if (ctrl is WindowBorder) { - (ctrl as WindowBorder).Setup(); + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as WindowBorder).Setup(); + }); } } + Desktop.InvokeOnWorkerThread(() => + { - MakeDoubleBuffered(ctrl); - ctrl.ResumeLayout(); - ResumeDrawing(ctrl); + MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); + ResumeDrawing(ctrl); + }); + ControlSetup?.Invoke(ctrl); } + public static event Action ControlSetup; + public static void MakeDoubleBuffered(Control c) { if (System.Windows.Forms.SystemInformation.TerminalServerSession) @@ -234,13 +269,28 @@ namespace ShiftOS.WinForms.Tools } - public static void SetupControls(Control frm) + public static void SetupControls(Control frm, bool runInThread = true) { SetupControl(frm); - for (int i = 0; i < frm.Controls.Count; i++) + ThreadStart ts = () => + { + for (int i = 0; i < frm.Controls.Count; i++) + { + SetupControls(frm.Controls[i], false); + } + + }; + + if (runInThread == true) + { + var t = new Thread(ts); + t.IsBackground = true; + t.Start(); + } + else { - SetupControls(frm.Controls[i]); + ts?.Invoke(); } } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 4babbbd..e716803 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -146,8 +146,6 @@ namespace ShiftOS.WinForms }; - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; if (!this.IsDialog) { @@ -171,7 +169,6 @@ namespace ShiftOS.WinForms })); }; - ParentWindow.OnLoad(); } /// @@ -208,6 +205,9 @@ namespace ShiftOS.WinForms public void WindowBorder_Load(object sender, EventArgs e) { this.DoubleBuffered = true; + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; + ParentWindow.OnLoad(); this._parentWindow.Show(); } -- cgit v1.2.3 From 6ec8e375c4b756bcd323df6babd4a4a74cd75904 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 13:06:13 -0400 Subject: Desktop preview --- ShiftOS.WinForms/Applications/Shifter.Designer.cs | 275 ++++++++++++++++++++++ ShiftOS.WinForms/Applications/Shifter.cs | 158 +++++++++++++ ShiftOS.WinForms/Applications/Shifter.resx | 39 +-- ShiftOS.WinForms/Tools/ControlManager.cs | 2 +- ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs | 14 +- ShiftOS.WinForms/WindowBorder.cs | 2 +- ShiftOS_TheReturn/ServerManager.cs | 12 +- 7 files changed, 478 insertions(+), 24 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.Designer.cs b/ShiftOS.WinForms/Applications/Shifter.Designer.cs index f919834..593f43d 100644 --- a/ShiftOS.WinForms/Applications/Shifter.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shifter.Designer.cs @@ -95,6 +95,29 @@ namespace ShiftOS.WinForms.Applications this.pnlintro = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); + this.pnldesktoppreview = new System.Windows.Forms.Panel(); + this.pnlscreensaver = new System.Windows.Forms.Panel(); + this.pnlssicon = new System.Windows.Forms.Panel(); + this.desktoppanel = new System.Windows.Forms.Panel(); + this.lbtime = new System.Windows.Forms.Label(); + this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); + this.sysmenuholder = new System.Windows.Forms.Panel(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.apps = new System.Windows.Forms.ToolStripMenuItem(); + this.pnladvancedal = new System.Windows.Forms.Panel(); + this.flapps = new System.Windows.Forms.FlowLayoutPanel(); + this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); + this.pnlalsystemactions = new System.Windows.Forms.Panel(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlstatus = new System.Windows.Forms.Panel(); + this.lbalstatus = new System.Windows.Forms.Label(); + this.item1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.shutdownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.separatorToolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.panel1.SuspendLayout(); this.pnlpreview.SuspendLayout(); this.pnlwindow.SuspendLayout(); @@ -106,6 +129,14 @@ namespace ShiftOS.WinForms.Applications this.mspreview.SuspendLayout(); this.tspreview.SuspendLayout(); this.pnlintro.SuspendLayout(); + this.pnldesktoppreview.SuspendLayout(); + this.pnlscreensaver.SuspendLayout(); + this.desktoppanel.SuspendLayout(); + this.sysmenuholder.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.pnladvancedal.SuspendLayout(); + this.pnlalsystemactions.SuspendLayout(); + this.pnlstatus.SuspendLayout(); this.SuspendLayout(); // // panel1 @@ -121,6 +152,7 @@ namespace ShiftOS.WinForms.Applications // // pnlpreview // + this.pnlpreview.Controls.Add(this.pnldesktoppreview); this.pnlpreview.Controls.Add(this.pnlintro); this.pnlpreview.Controls.Add(this.pnlwindow); this.pnlpreview.Dock = System.Windows.Forms.DockStyle.Fill; @@ -500,6 +532,214 @@ namespace ShiftOS.WinForms.Applications this.label2.Text = resources.GetString("label2.Text"); this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // pnldesktoppreview + // + this.pnldesktoppreview.Controls.Add(this.pnlscreensaver); + this.pnldesktoppreview.Controls.Add(this.desktoppanel); + this.pnldesktoppreview.Controls.Add(this.pnladvancedal); + this.pnldesktoppreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnldesktoppreview.Location = new System.Drawing.Point(0, 0); + this.pnldesktoppreview.Name = "pnldesktoppreview"; + this.pnldesktoppreview.Size = new System.Drawing.Size(757, 286); + this.pnldesktoppreview.TabIndex = 2; + // + // pnlscreensaver + // + this.pnlscreensaver.Controls.Add(this.pnlssicon); + this.pnlscreensaver.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlscreensaver.Location = new System.Drawing.Point(0, 24); + this.pnlscreensaver.Name = "pnlscreensaver"; + this.pnlscreensaver.Size = new System.Drawing.Size(757, 262); + this.pnlscreensaver.TabIndex = 3; + this.pnlscreensaver.Visible = false; + // + // pnlssicon + // + this.pnlssicon.Location = new System.Drawing.Point(303, 495); + this.pnlssicon.Name = "pnlssicon"; + this.pnlssicon.Size = new System.Drawing.Size(200, 100); + this.pnlssicon.TabIndex = 0; + // + // desktoppanel + // + this.desktoppanel.BackColor = System.Drawing.Color.Green; + this.desktoppanel.Controls.Add(this.lbtime); + this.desktoppanel.Controls.Add(this.panelbuttonholder); + this.desktoppanel.Controls.Add(this.sysmenuholder); + this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; + this.desktoppanel.Location = new System.Drawing.Point(0, 0); + this.desktoppanel.Name = "desktoppanel"; + this.desktoppanel.Size = new System.Drawing.Size(757, 24); + this.desktoppanel.TabIndex = 2; + // + // lbtime + // + this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbtime.AutoSize = true; + this.lbtime.Location = new System.Drawing.Point(-536, 0); + this.lbtime.Name = "lbtime"; + this.lbtime.Size = new System.Drawing.Size(35, 13); + this.lbtime.TabIndex = 0; + this.lbtime.Text = "label1"; + this.lbtime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // panelbuttonholder + // + this.panelbuttonholder.AutoSize = true; + this.panelbuttonholder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.panelbuttonholder.Location = new System.Drawing.Point(107, -77); + this.panelbuttonholder.Name = "panelbuttonholder"; + this.panelbuttonholder.Size = new System.Drawing.Size(0, 0); + this.panelbuttonholder.TabIndex = 2; + // + // sysmenuholder + // + this.sysmenuholder.Controls.Add(this.menuStrip1); + this.sysmenuholder.Location = new System.Drawing.Point(12, 5); + this.sysmenuholder.Name = "sysmenuholder"; + this.sysmenuholder.Size = new System.Drawing.Size(68, 24); + this.sysmenuholder.TabIndex = 1; + // + // menuStrip1 + // + this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Fill; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.apps}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(0); + this.menuStrip1.Size = new System.Drawing.Size(68, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // apps + // + this.apps.AutoSize = false; + this.apps.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.item1ToolStripMenuItem, + this.item2ToolStripMenuItem, + this.item3ToolStripMenuItem, + this.item4ToolStripMenuItem, + this.item5ToolStripMenuItem, + this.separatorToolStripMenuItem1, + this.shutdownToolStripMenuItem}); + this.apps.Name = "apps"; + this.apps.Padding = new System.Windows.Forms.Padding(0); + this.apps.Size = new System.Drawing.Size(58, 20); + this.apps.Tag = "applauncherbutton"; + this.apps.Text = "ShiftOS"; + // + // pnladvancedal + // + this.pnladvancedal.Controls.Add(this.flapps); + this.pnladvancedal.Controls.Add(this.flcategories); + this.pnladvancedal.Controls.Add(this.pnlalsystemactions); + this.pnladvancedal.Controls.Add(this.pnlstatus); + this.pnladvancedal.Location = new System.Drawing.Point(0, -53); + this.pnladvancedal.Name = "pnladvancedal"; + this.pnladvancedal.Size = new System.Drawing.Size(433, 417); + this.pnladvancedal.TabIndex = 4; + this.pnladvancedal.Visible = false; + // + // flapps + // + this.flapps.Dock = System.Windows.Forms.DockStyle.Fill; + this.flapps.Location = new System.Drawing.Point(221, 58); + this.flapps.Name = "flapps"; + this.flapps.Size = new System.Drawing.Size(212, 328); + this.flapps.TabIndex = 3; + // + // flcategories + // + this.flcategories.Dock = System.Windows.Forms.DockStyle.Left; + this.flcategories.Location = new System.Drawing.Point(0, 58); + this.flcategories.Name = "flcategories"; + this.flcategories.Size = new System.Drawing.Size(221, 328); + this.flcategories.TabIndex = 2; + // + // pnlalsystemactions + // + this.pnlalsystemactions.Controls.Add(this.btnshutdown); + this.pnlalsystemactions.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlalsystemactions.Location = new System.Drawing.Point(0, 386); + this.pnlalsystemactions.Name = "pnlalsystemactions"; + this.pnlalsystemactions.Size = new System.Drawing.Size(433, 31); + this.pnlalsystemactions.TabIndex = 1; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnshutdown.Location = new System.Drawing.Point(363, 3); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(67, 25); + this.btnshutdown.TabIndex = 0; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + // + // pnlstatus + // + this.pnlstatus.Controls.Add(this.lbalstatus); + this.pnlstatus.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlstatus.Location = new System.Drawing.Point(0, 0); + this.pnlstatus.Name = "pnlstatus"; + this.pnlstatus.Size = new System.Drawing.Size(433, 58); + this.pnlstatus.TabIndex = 0; + // + // lbalstatus + // + this.lbalstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbalstatus.Location = new System.Drawing.Point(0, 0); + this.lbalstatus.Name = "lbalstatus"; + this.lbalstatus.Size = new System.Drawing.Size(433, 58); + this.lbalstatus.TabIndex = 0; + this.lbalstatus.Text = "michael@system\r\n0 Codepoints\r\n0 installed, 0 available"; + this.lbalstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // item1ToolStripMenuItem + // + this.item1ToolStripMenuItem.Name = "item1ToolStripMenuItem"; + this.item1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item1ToolStripMenuItem.Text = "Item 1"; + // + // item2ToolStripMenuItem + // + this.item2ToolStripMenuItem.Name = "item2ToolStripMenuItem"; + this.item2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item2ToolStripMenuItem.Text = "Item 2"; + // + // item3ToolStripMenuItem + // + this.item3ToolStripMenuItem.Name = "item3ToolStripMenuItem"; + this.item3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item3ToolStripMenuItem.Text = "Item 3"; + // + // item4ToolStripMenuItem + // + this.item4ToolStripMenuItem.Name = "item4ToolStripMenuItem"; + this.item4ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item4ToolStripMenuItem.Text = "Item 4"; + // + // item5ToolStripMenuItem + // + this.item5ToolStripMenuItem.Name = "item5ToolStripMenuItem"; + this.item5ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item5ToolStripMenuItem.Text = "Item 5"; + // + // shutdownToolStripMenuItem + // + this.shutdownToolStripMenuItem.Name = "shutdownToolStripMenuItem"; + this.shutdownToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.shutdownToolStripMenuItem.Text = "Shutdown"; + // + // separatorToolStripMenuItem1 + // + this.separatorToolStripMenuItem1.Name = "separatorToolStripMenuItem1"; + this.separatorToolStripMenuItem1.Size = new System.Drawing.Size(149, 6); + // // Shifter // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -523,6 +763,18 @@ namespace ShiftOS.WinForms.Applications this.tspreview.ResumeLayout(false); this.tspreview.PerformLayout(); this.pnlintro.ResumeLayout(false); + this.pnldesktoppreview.ResumeLayout(false); + this.pnlscreensaver.ResumeLayout(false); + this.desktoppanel.ResumeLayout(false); + this.desktoppanel.PerformLayout(); + this.sysmenuholder.ResumeLayout(false); + this.sysmenuholder.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.pnladvancedal.ResumeLayout(false); + this.pnlalsystemactions.ResumeLayout(false); + this.pnlalsystemactions.PerformLayout(); + this.pnlstatus.ResumeLayout(false); this.ResumeLayout(false); } @@ -571,5 +823,28 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.Panel pnlintro; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel pnldesktoppreview; + private System.Windows.Forms.Panel pnlscreensaver; + private System.Windows.Forms.Panel pnlssicon; + private System.Windows.Forms.Panel desktoppanel; + private System.Windows.Forms.Label lbtime; + private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; + private System.Windows.Forms.Panel sysmenuholder; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem apps; + private System.Windows.Forms.Panel pnladvancedal; + private System.Windows.Forms.FlowLayoutPanel flapps; + private System.Windows.Forms.FlowLayoutPanel flcategories; + private System.Windows.Forms.Panel pnlalsystemactions; + private System.Windows.Forms.Button btnshutdown; + private System.Windows.Forms.Panel pnlstatus; + private System.Windows.Forms.Label lbalstatus; + private System.Windows.Forms.ToolStripMenuItem item1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item3ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item4ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item5ToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem shutdownToolStripMenuItem; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index e22956f..600a9b2 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -47,6 +47,164 @@ namespace ShiftOS.WinForms.Applications PopulateShifter(); } + [ShifterMeta("Desktop")] + public void ResetDesktop() + { + pnldesktoppreview.BringToFront(); + pnldesktoppreview.Tag = "keepbg"; + SetupDesktop(); + } + + /// + /// Populates the panel buttons. + /// + /// The panel buttons. + public void PopulatePanelButtons() + { + if (DesktopFunctions.ShowDefaultElements == true) + { + panelbuttonholder.Controls.Clear(); + if (Shiftorium.IsInitiated == true) + { + if (Shiftorium.UpgradeInstalled("wm_panel_buttons")) + { + + var pnlbtn = new Panel(); + pnlbtn.Margin = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0); + pnlbtn.BackColor = LoadedSkin.PanelButtonColor; + pnlbtn.BackgroundImage = GetImage("panelbutton"); + pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton"); + + var pnlbtntext = new Label(); + pnlbtntext.Text = "Panel Button Text"; + pnlbtntext.AutoSize = true; + pnlbtntext.Location = LoadedSkin.PanelButtonFromLeft; + pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor; + pnlbtntext.BackColor = Color.Transparent; + + pnlbtn.BackColor = LoadedSkin.PanelButtonColor; + if (pnlbtn.BackgroundImage != null) + { + pnlbtntext.BackColor = Color.Transparent; + } + pnlbtn.Size = LoadedSkin.PanelButtonSize; + pnlbtn.Tag = "keepbg"; + pnlbtntext.Tag = "keepbg"; + pnlbtn.Controls.Add(pnlbtntext); + this.panelbuttonholder.Controls.Add(pnlbtn); + pnlbtn.Show(); + pnlbtntext.Show(); + + pnlbtntext.Font = LoadedSkin.PanelButtonFont; + + + + + } + } + } + + } + + /// + /// Setups the desktop. + /// + /// The desktop. + public void SetupDesktop() + { + if (DesktopFunctions.ShowDefaultElements == true) + { + desktoppanel.BackColor = Color.Green; + + //upgrades + + if (Shiftorium.IsInitiated == true) + { + desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); + lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); + + //skinning + lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + + panelbuttonholder.Top = 0; + panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; + panelbuttonholder.Height = desktoppanel.Height; + panelbuttonholder.BackColor = Color.Transparent; + panelbuttonholder.Margin = new Padding(0, 0, 0, 0); + + sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher"); + + //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. + //To compensate, we must recreate the desktop color and make the alpha channel '255'. + pnldesktoppreview.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); + //Not doing this will cause an ArgumentException. + + DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => + { + pnldesktoppreview.BackgroundImage = img; + })); + pnldesktoppreview.BackgroundImageLayout = GetImageLayout("desktopbackground"); + desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; + + var pnlimg = GetImage("desktoppanel"); + if (pnlimg != null) + { + var bmp = new Bitmap(pnlimg); + bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); + pnlimg = bmp; + } + + desktoppanel.BackgroundImage = pnlimg; + if (desktoppanel.BackgroundImage != null) + { + desktoppanel.BackColor = Color.Transparent; + } + var appimg = GetImage("applauncher"); + if (appimg != null) + { + var bmp = new Bitmap(appimg); + bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); + appimg = bmp; + } + menuStrip1.BackgroundImage = appimg; + lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + lbtime.Font = LoadedSkin.DesktopPanelClockFont; + if (desktoppanel.BackgroundImage == null) + { + lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; + } + else + { + lbtime.BackColor = Color.Transparent; + } + apps.Text = LoadedSkin.AppLauncherText; + sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; + sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; + apps.Size = sysmenuholder.Size; + menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable(LoadedSkin)); + desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); + desktoppanel.Height = LoadedSkin.DesktopPanelHeight; + if (LoadedSkin.DesktopPanelPosition == 1) + { + desktoppanel.Dock = DockStyle.Bottom; + } + else + { + desktoppanel.Dock = DockStyle.Top; + } + } + } + else + { + desktoppanel.Hide(); + } + + PopulatePanelButtons(); + } + + + + [ShifterMeta("Windows")] public void SetupWindowPreview() { diff --git a/ShiftOS.WinForms/Applications/Shifter.resx b/ShiftOS.WinForms/Applications/Shifter.resx index 9533980..c18f92a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.resx +++ b/ShiftOS.WinForms/Applications/Shifter.resx @@ -117,20 +117,23 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - The Shifter is a brilliant application for ShiftOS that allows you to customize almost every aspect of the user interface. - -To use the Shifter, simply select a category from the left, then a list of sub-categories will show up. Choose a sub-category, then a list of settings will appear. You can modify any one of these settings. A live preview of what you are editing will show, and you can use it to see what your new user experience will look like. - -When you are done, hit Apply Changes to apply your changes! - -You can also earn Codepoints through the Shifter. The more you tweak and customize, the more Codepoints you'll earn! Go nuts! Shift it your way! - + + 230, 17 + + + 127, 17 + + + 17, 17 + + + 17, 17 + 127, 17 - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -145,7 +148,7 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -160,7 +163,7 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -175,7 +178,13 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - 17, 17 - + + The Shifter is a brilliant application for ShiftOS that allows you to customize almost every aspect of the user interface. + +To use the Shifter, simply select a category from the left, then a list of sub-categories will show up. Choose a sub-category, then a list of settings will appear. You can modify any one of these settings. A live preview of what you are editing will show, and you can use it to see what your new user experience will look like. + +When you are done, hit Apply Changes to apply your changes! + +You can also earn Codepoints through the Shifter. The more you tweak and customize, the more Codepoints you'll earn! Go nuts! Shift it your way! + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 781e045..1c6f40c 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -277,7 +277,7 @@ namespace ShiftOS.WinForms.Tools { for (int i = 0; i < frm.Controls.Count; i++) { - SetupControls(frm.Controls[i], false); + SetupControls(frm.Controls[i], false); } }; diff --git a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs index a31edd9..81e8c89 100644 --- a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs +++ b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs @@ -364,14 +364,18 @@ namespace ShiftOS.WinForms.Tools return SkinEngine.GetImage(id); } - public Skin LoadedSkin + public AppLauncherColorTable() { - get - { - return SkinEngine.LoadedSkin; - } + LoadedSkin = SkinEngine.LoadedSkin; + } + + public AppLauncherColorTable(Skin skn) + { + LoadedSkin = skn; } + public Skin LoadedSkin { get; private set; } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index e716803..e809f90 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -129,6 +129,7 @@ namespace ShiftOS.WinForms this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; + this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); ParentWindow.OnSkinLoad(); @@ -208,7 +209,6 @@ namespace ShiftOS.WinForms this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; ParentWindow.OnLoad(); - this._parentWindow.Show(); } /// diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 4fce247..d356600 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -34,6 +34,7 @@ using System.Threading; using ShiftOS; using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; +using System.Net.Sockets; namespace ShiftOS.Engine { @@ -191,8 +192,15 @@ namespace ShiftOS.Engine } }; - client.Connect(mud_address, port); - + try + { + client.Connect(mud_address, port); + } + catch(SocketException ex) + { + System.Diagnostics.Debug.Print(ex.ToString()); + Initiate(mud_address, port); + } } public static void SendMessage(string name, string contents) -- cgit v1.2.3 From 0bc8eef195e7da04ea89481ede327bf37d591659 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 19:08:25 -0400 Subject: Fix UI setup bug. --- ShiftOS.WinForms/Tools/ControlManager.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 1c6f40c..d12e54a 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -146,7 +146,6 @@ namespace ShiftOS.WinForms.Tools { Desktop.InvokeOnWorkerThread(new Action(() => { - SuspendDrawing(ctrl); ctrl.SuspendLayout(); })); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) @@ -247,7 +246,6 @@ namespace ShiftOS.WinForms.Tools MakeDoubleBuffered(ctrl); ctrl.ResumeLayout(); - ResumeDrawing(ctrl); }); ControlSetup?.Invoke(ctrl); } -- cgit v1.2.3 From 56e216a430694d86c242df763484deba682f3302 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 15 Apr 2017 20:21:11 -0400 Subject: Hide AL when clicking on window ctrls --- .../Applications/MUDControlCentre.Designer.cs | 184 ++++++++--------- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 + ShiftOS.WinForms/Tools/ControlManager.cs | 5 +- ShiftOS.WinForms/WindowBorder.cs | 12 ++ ShiftOS.WinForms/WinformsDesktop.cs | 112 +++++++---- ShiftOS_TheReturn/Desktop.cs | 8 + ShiftOS_TheReturn/Skinning.cs | 224 ++++++++++++++++----- 7 files changed, 358 insertions(+), 194 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs index e2c0af3..125ea99 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs @@ -66,9 +66,13 @@ namespace ShiftOS.WinForms.Applications this.createLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.joinLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.myLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.joinAChatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.pnlclasses = new System.Windows.Forms.Panel(); + this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnchooseclass = new System.Windows.Forms.Button(); + this.lbclasses = new System.Windows.Forms.ListBox(); + this.lbclassdesc = new System.Windows.Forms.Label(); + this.lbclasstitle = new System.Windows.Forms.Label(); this.you_systemstatus = new System.Windows.Forms.Panel(); this.btndeletesave = new System.Windows.Forms.Button(); this.lblsysstatus = new System.Windows.Forms.Label(); @@ -144,16 +148,12 @@ namespace ShiftOS.WinForms.Applications this.you_memos = new System.Windows.Forms.Panel(); this.flmemos = new System.Windows.Forms.FlowLayoutPanel(); this.label3 = new System.Windows.Forms.Label(); - this.pnlclasses = new System.Windows.Forms.Panel(); - this.lbclasstitle = new System.Windows.Forms.Label(); - this.lbclassdesc = new System.Windows.Forms.Label(); - this.lbclasses = new System.Windows.Forms.ListBox(); - this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); - this.btnchooseclass = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); + this.pnlclasses.SuspendLayout(); + this.flowLayoutPanel6.SuspendLayout(); this.you_systemstatus.SuspendLayout(); this.shop_all.SuspendLayout(); this.shop_view.SuspendLayout(); @@ -178,8 +178,6 @@ namespace ShiftOS.WinForms.Applications this.panel3.SuspendLayout(); this.flowLayoutPanel2.SuspendLayout(); this.you_memos.SuspendLayout(); - this.pnlclasses.SuspendLayout(); - this.flowLayoutPanel6.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -188,8 +186,7 @@ namespace ShiftOS.WinForms.Applications this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.youToolStripMenuItem, this.shopsToolStripMenuItem, - this.legionsToolStripMenuItem, - this.chatToolStripMenuItem}); + this.legionsToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(756, 24); @@ -289,21 +286,6 @@ namespace ShiftOS.WinForms.Applications this.myLegionToolStripMenuItem.Text = "My Legion"; this.myLegionToolStripMenuItem.Click += new System.EventHandler(this.myLegionToolStripMenuItem_Click); // - // chatToolStripMenuItem - // - this.chatToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.joinAChatToolStripMenuItem}); - this.chatToolStripMenuItem.Name = "chatToolStripMenuItem"; - this.chatToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.chatToolStripMenuItem.Text = "Chat"; - // - // joinAChatToolStripMenuItem - // - this.joinAChatToolStripMenuItem.Name = "joinAChatToolStripMenuItem"; - this.joinAChatToolStripMenuItem.Size = new System.Drawing.Size(130, 22); - this.joinAChatToolStripMenuItem.Text = "Join a chat"; - this.joinAChatToolStripMenuItem.Click += new System.EventHandler(this.joinAChatToolStripMenuItem_Click); - // // toolStripContainer1 // // @@ -331,6 +313,75 @@ namespace ShiftOS.WinForms.Applications // this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1); // + // pnlclasses + // + this.pnlclasses.Controls.Add(this.flowLayoutPanel6); + this.pnlclasses.Controls.Add(this.lbclasses); + this.pnlclasses.Controls.Add(this.lbclassdesc); + this.pnlclasses.Controls.Add(this.lbclasstitle); + this.pnlclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlclasses.Location = new System.Drawing.Point(0, 0); + this.pnlclasses.Name = "pnlclasses"; + this.pnlclasses.Size = new System.Drawing.Size(756, 464); + this.pnlclasses.TabIndex = 3; + // + // flowLayoutPanel6 + // + this.flowLayoutPanel6.AutoSize = true; + this.flowLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel6.Controls.Add(this.btnchooseclass); + this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 415); + this.flowLayoutPanel6.Name = "flowLayoutPanel6"; + this.flowLayoutPanel6.Padding = new System.Windows.Forms.Padding(10); + this.flowLayoutPanel6.Size = new System.Drawing.Size(756, 49); + this.flowLayoutPanel6.TabIndex = 3; + // + // btnchooseclass + // + this.btnchooseclass.AutoSize = true; + this.btnchooseclass.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnchooseclass.Location = new System.Drawing.Point(13, 13); + this.btnchooseclass.Name = "btnchooseclass"; + this.btnchooseclass.Size = new System.Drawing.Size(53, 23); + this.btnchooseclass.TabIndex = 0; + this.btnchooseclass.Text = "Choose"; + this.btnchooseclass.UseVisualStyleBackColor = true; + this.btnchooseclass.Click += new System.EventHandler(this.btnchooseclass_Click); + // + // lbclasses + // + this.lbclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbclasses.FormattingEnabled = true; + this.lbclasses.Location = new System.Drawing.Point(0, 66); + this.lbclasses.Name = "lbclasses"; + this.lbclasses.Size = new System.Drawing.Size(756, 398); + this.lbclasses.TabIndex = 2; + // + // lbclassdesc + // + this.lbclassdesc.AutoSize = true; + this.lbclassdesc.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclassdesc.Location = new System.Drawing.Point(0, 33); + this.lbclassdesc.Name = "lbclassdesc"; + this.lbclassdesc.Padding = new System.Windows.Forms.Padding(10); + this.lbclassdesc.Size = new System.Drawing.Size(727, 33); + this.lbclassdesc.TabIndex = 1; + this.lbclassdesc.Text = "A class is a way for the multi-user domain to better understand you. It defines w" + + "ho you are as a sentient being, what you do, what you like, and so on."; + // + // lbclasstitle + // + this.lbclasstitle.AutoSize = true; + this.lbclasstitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclasstitle.Location = new System.Drawing.Point(0, 0); + this.lbclasstitle.Name = "lbclasstitle"; + this.lbclasstitle.Padding = new System.Windows.Forms.Padding(10); + this.lbclasstitle.Size = new System.Drawing.Size(82, 33); + this.lbclasstitle.TabIndex = 0; + this.lbclasstitle.Tag = "header1"; + this.lbclasstitle.Text = "Join a class"; + // // you_systemstatus // this.you_systemstatus.Controls.Add(this.btndeletesave); @@ -1191,75 +1242,6 @@ namespace ShiftOS.WinForms.Applications this.label3.Tag = "header1"; this.label3.Text = "Memos"; // - // pnlclasses - // - this.pnlclasses.Controls.Add(this.flowLayoutPanel6); - this.pnlclasses.Controls.Add(this.lbclasses); - this.pnlclasses.Controls.Add(this.lbclassdesc); - this.pnlclasses.Controls.Add(this.lbclasstitle); - this.pnlclasses.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlclasses.Location = new System.Drawing.Point(0, 0); - this.pnlclasses.Name = "pnlclasses"; - this.pnlclasses.Size = new System.Drawing.Size(756, 464); - this.pnlclasses.TabIndex = 3; - // - // lbclasstitle - // - this.lbclasstitle.AutoSize = true; - this.lbclasstitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbclasstitle.Location = new System.Drawing.Point(0, 0); - this.lbclasstitle.Name = "lbclasstitle"; - this.lbclasstitle.Padding = new System.Windows.Forms.Padding(10); - this.lbclasstitle.Size = new System.Drawing.Size(82, 33); - this.lbclasstitle.TabIndex = 0; - this.lbclasstitle.Tag = "header1"; - this.lbclasstitle.Text = "Join a class"; - // - // lbclassdesc - // - this.lbclassdesc.AutoSize = true; - this.lbclassdesc.Dock = System.Windows.Forms.DockStyle.Top; - this.lbclassdesc.Location = new System.Drawing.Point(0, 33); - this.lbclassdesc.Name = "lbclassdesc"; - this.lbclassdesc.Padding = new System.Windows.Forms.Padding(10); - this.lbclassdesc.Size = new System.Drawing.Size(727, 33); - this.lbclassdesc.TabIndex = 1; - this.lbclassdesc.Text = "A class is a way for the multi-user domain to better understand you. It defines w" + - "ho you are as a sentient being, what you do, what you like, and so on."; - // - // lbclasses - // - this.lbclasses.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbclasses.FormattingEnabled = true; - this.lbclasses.Location = new System.Drawing.Point(0, 66); - this.lbclasses.Name = "lbclasses"; - this.lbclasses.Size = new System.Drawing.Size(756, 398); - this.lbclasses.TabIndex = 2; - // - // flowLayoutPanel6 - // - this.flowLayoutPanel6.AutoSize = true; - this.flowLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel6.Controls.Add(this.btnchooseclass); - this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 415); - this.flowLayoutPanel6.Name = "flowLayoutPanel6"; - this.flowLayoutPanel6.Padding = new System.Windows.Forms.Padding(10); - this.flowLayoutPanel6.Size = new System.Drawing.Size(756, 49); - this.flowLayoutPanel6.TabIndex = 3; - // - // btnchooseclass - // - this.btnchooseclass.AutoSize = true; - this.btnchooseclass.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnchooseclass.Location = new System.Drawing.Point(13, 13); - this.btnchooseclass.Name = "btnchooseclass"; - this.btnchooseclass.Size = new System.Drawing.Size(53, 23); - this.btnchooseclass.TabIndex = 0; - this.btnchooseclass.Text = "Choose"; - this.btnchooseclass.UseVisualStyleBackColor = true; - this.btnchooseclass.Click += new System.EventHandler(this.btnchooseclass_Click); - // // MUDControlCentre // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1276,6 +1258,10 @@ namespace ShiftOS.WinForms.Applications this.toolStripContainer1.TopToolStripPanel.PerformLayout(); this.toolStripContainer1.ResumeLayout(false); this.toolStripContainer1.PerformLayout(); + this.pnlclasses.ResumeLayout(false); + this.pnlclasses.PerformLayout(); + this.flowLayoutPanel6.ResumeLayout(false); + this.flowLayoutPanel6.PerformLayout(); this.you_systemstatus.ResumeLayout(false); this.you_systemstatus.PerformLayout(); this.shop_all.ResumeLayout(false); @@ -1320,10 +1306,6 @@ namespace ShiftOS.WinForms.Applications this.flowLayoutPanel2.PerformLayout(); this.you_memos.ResumeLayout(false); this.you_memos.PerformLayout(); - this.pnlclasses.ResumeLayout(false); - this.pnlclasses.PerformLayout(); - this.flowLayoutPanel6.ResumeLayout(false); - this.flowLayoutPanel6.PerformLayout(); this.ResumeLayout(false); } @@ -1418,8 +1400,6 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.Button btnremoveitem; private System.Windows.Forms.Button btnedititem; private System.Windows.Forms.Button btneditshop; - private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem joinAChatToolStripMenuItem; private System.Windows.Forms.Button btndeletesave; private System.Windows.Forms.Panel pnlclasses; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6; diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index fd03677..2260198 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -197,6 +197,13 @@ Category: "Device Drivers", Dependencies: "color_depth_dithering" }, + { + Name: "Shift Advanced App Launcher", + Cost: 150, + Description: "So you got yourself one of those fancy Advanced App Launchers. Well, it ain't so advanced if it can't be customized! This upgrade will add some settings to the Shifter so you can customize the Advanced App Launcher and its behaviour.", + Dependencies: "advanced_app_launcher;shifter", + Category: "Customization" + }, { Name: "Color Depth 2 bits", Cost: 2000, diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index d12e54a..6d60f9d 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -270,7 +270,10 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { SetupControl(frm); - + frm.Click += (o, a) => + { + Desktop.HideAppLauncher(); + }; ThreadStart ts = () => { for (int i = 0; i < frm.Controls.Count; i++) diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index e809f90..64f2da4 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -92,6 +92,16 @@ namespace ShiftOS.WinForms lbtitletext.Text = title; } + public void SetupControls(Control ctrl) + { + foreach (Control c in ctrl.Controls) + SetupControls(c); + ctrl.Click += (o, a) => + { + Desktop.HideAppLauncher(); + }; + } + /// /// Initializes a new instance of the class. /// @@ -127,6 +137,8 @@ namespace ShiftOS.WinForms this.Width = LoadedSkin.LeftBorderWidth + _parentWindow.Width + LoadedSkin.RightBorderWidth; this.Height = LoadedSkin.TitlebarHeight + _parentWindow.Height + LoadedSkin.BottomBorderWidth; + SetupControls(this); + this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; this._parentWindow.Show(); diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 8704b94..d50be53 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -244,45 +244,6 @@ namespace ShiftOS.WinForms private void ShowScreensaver() { - if (Shiftorium.UpgradeInstalled("screensavers")) - { - this.Invoke(new Action(() => - { - pnlscreensaver.Show(); - this.TopMost = true; - pnlssicon.Show(); - pnlssicon.BackColor = Color.Green; - pnlssicon.BackgroundImage = GetImage("screensaver"); - pnlssicon.BackgroundImageLayout = GetImageLayout("screensaver"); - - if (pnlssicon.BackgroundImage != null) - { - pnlssicon.Size = pnlssicon.BackgroundImage.Size; - } - - Cursor.Hide(); - - var t = new Thread(() => - { - var rnd = new Random(); - while (InScreensaver == true) - { - int x = rnd.Next(0, this.Width); - int y = rnd.Next(0, this.Height); - - this.Invoke(new Action(() => - { - pnlssicon.Location = new Point(x, y); - })); - - Thread.Sleep(5000); - } - ResetDesktop = true; - }); - t.IsBackground = true; - t.Start(); - })); - } } @@ -498,12 +459,47 @@ namespace ShiftOS.WinForms { if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) { - ControlManager.SetupControls(pnladvancedal); pnladvancedal.Visible = false; flapps.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; flcategories.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - pnlalsystemactions.BackColor = LoadedSkin.DesktopPanelColor; - lbalstatus.BackColor = LoadedSkin.DesktopPanelColor; + pnlalsystemactions.BackColor = LoadedSkin.SystemPanelBackground; + lbalstatus.BackColor = LoadedSkin.ALStatusPanelBackColor; + //Fonts + lbalstatus.Font = LoadedSkin.ALStatusPanelFont; + btnshutdown.Font = LoadedSkin.ShutdownFont; + + //Upgrades + btnshutdown.Visible = Shiftorium.UpgradeInstalled("al_shutdown"); + + //Alignments and positions. + lbalstatus.TextAlign = LoadedSkin.ALStatusPanelAlignment; + if (LoadedSkin.ShutdownButtonStyle == 2) + btnshutdown.Hide(); + else if (LoadedSkin.ShutdownButtonStyle == 1) + { + btnshutdown.Parent = pnlstatus; + btnshutdown.BringToFront(); + } + else + btnshutdown.Parent = pnlalsystemactions; + if (LoadedSkin.ShutdownOnLeft) + { + btnshutdown.Location = LoadedSkin.ShutdownButtonFromSide; + } + else + { + btnshutdown.Left = (btnshutdown.Parent.Width - btnshutdown.Width) - LoadedSkin.ShutdownButtonFromSide.X; + btnshutdown.Top = LoadedSkin.ShutdownButtonFromSide.Y; + } + + //Images + lbalstatus.BackgroundImage = GetImage("al_bg_status"); + lbalstatus.BackgroundImageLayout = GetImageLayout("al_bg_status"); + + pnlalsystemactions.BackgroundImage = GetImage("al_bg_system"); + pnlalsystemactions.BackgroundImageLayout = GetImageLayout("al_bg_system"); + if (pnlalsystemactions.BackgroundImage != null) + btnshutdown.BackColor = Color.Transparent; } @@ -563,6 +559,7 @@ namespace ShiftOS.WinForms if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) { var catbtn = new Button(); + catbtn.Font = LoadedSkin.AdvALItemFont; catbtn.FlatStyle = FlatStyle.Flat; catbtn.FlatAppearance.BorderSize = 0; catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; @@ -600,7 +597,25 @@ namespace ShiftOS.WinForms TerminalBackend.InvokeCommand("sos.shutdown"); }; apps.DropDownItems.Add(item); - + if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) + { + if (LoadedSkin.ShutdownButtonStyle == 2) { + var catbtn = new Button(); + catbtn.Font = LoadedSkin.AdvALItemFont; + catbtn.FlatStyle = FlatStyle.Flat; + catbtn.FlatAppearance.BorderSize = 0; + catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; + catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin; + catbtn.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; + catbtn.TextAlign = ContentAlignment.MiddleLeft; + catbtn.Text = "Shutdown"; + catbtn.Width = flcategories.Width; + catbtn.Height = 24; + flcategories.Controls.Add(catbtn); + catbtn.Show(); + catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown"); + } + } } } } @@ -614,6 +629,7 @@ namespace ShiftOS.WinForms foreach(var app in LauncherItemList[cat]) { var catbtn = new Button(); + catbtn.Font = LoadedSkin.AdvALItemFont; catbtn.FlatStyle = FlatStyle.Flat; catbtn.FlatAppearance.BorderSize = 0; catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; @@ -622,8 +638,8 @@ namespace ShiftOS.WinForms catbtn.TextAlign = ContentAlignment.MiddleLeft; catbtn.Text = (app is LuaLauncherItem) ? app.DisplayData.Name : NameChangerBackend.GetNameRaw(app.LaunchType); catbtn.Width = flapps.Width; + catbtn.ImageAlign = ContentAlignment.MiddleRight; catbtn.Height = 24; - catbtn.ImageAlign = ContentAlignment.MiddleLeft; catbtn.Image = (app.LaunchType == null) ? null : SkinEngine.GetIcon(app.LaunchType.Name); flapps.Controls.Add(catbtn); @@ -830,6 +846,14 @@ namespace ShiftOS.WinForms { TerminalBackend.InvokeCommand("sos.shutdown"); } + + public void HideAppLauncher() + { + this.Invoke(new Action(() => + { + pnladvancedal.Hide(); + })); + } } [ShiftOS.Engine.Scripting.Exposed("desktop")] diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index 19be5f4..b72f0cc 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -76,6 +76,9 @@ namespace ShiftOS.Engine string DesktopName { get; } void SetupDesktop(); + + void HideAppLauncher(); + void PopulateAppLauncher(LauncherItem[] items); void ShowWindow(IWindowBorder border); void KillWindow(IWindowBorder border); @@ -161,6 +164,11 @@ namespace ShiftOS.Engine { _desktop.OpenAppLauncher(loc); } + + public static void HideAppLauncher() + { + _desktop.HideAppLauncher(); + } } // sorry i almost killed everything :P } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 48b7c0b..cee18d8 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -35,7 +35,8 @@ using static ShiftOS.Engine.SaveSystem; using ShiftOS.Objects.ShiftFS; using System.Reflection; using ShiftOS.Engine.Scripting; -namespace ShiftOS.Engine { +namespace ShiftOS.Engine +{ [Exposed("skinning")] public class SkinFunctions @@ -43,7 +44,7 @@ namespace ShiftOS.Engine { public void loadSkin() { SkinEngine.LoadSkin(); - } + } public dynamic getSkin() { @@ -63,7 +64,8 @@ namespace ShiftOS.Engine { } - public static class SkinEngine { + public static class SkinEngine + { public static ImageLayout GetImageLayout(string img) { if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) @@ -77,14 +79,19 @@ namespace ShiftOS.Engine { } } - public static System.Drawing.Image GetImage(string img) { + public static System.Drawing.Image GetImage(string img) + { var type = typeof(Skin); - foreach (var field in type.GetFields()) { - foreach (var attr in field.GetCustomAttributes(false)) { - if (attr is ImageAttribute) { + foreach (var field in type.GetFields()) + { + foreach (var attr in field.GetCustomAttributes(false)) + { + if (attr is ImageAttribute) + { var iattr = attr as ImageAttribute; - if (iattr.Name == img) { + if (iattr.Name == img) + { byte[] image = (byte[])field.GetValue(LoadedSkin); return ImageFromBinary(image); } @@ -100,7 +107,8 @@ namespace ShiftOS.Engine { _iconProber = prober; } - public static Image ImageFromBinary(byte[] image) { + public static Image ImageFromBinary(byte[] image) + { if (image == null) return null; Image img = (Bitmap)((new ImageConverter()).ConvertFrom(image)); @@ -121,32 +129,40 @@ namespace ShiftOS.Engine { } } - public static void Init() { - Application.ApplicationExit += (o, a) => { + public static void Init() + { + Application.ApplicationExit += (o, a) => + { SaveSkin(); }; - if (!Utils.FileExists(Paths.GetPath("skin.json"))) { + if (!Utils.FileExists(Paths.GetPath("skin.json"))) + { LoadedSkin = new ShiftOS.Engine.Skin(); SaveSkin(); - } else { + } + else + { LoadSkin(); } - if (SaveSystem.CurrentSave != null) { + if (SaveSystem.CurrentSave != null) + { SkinLoaded?.Invoke(); } } public static event EmptyEventHandler SkinLoaded; - public static void LoadSkin() { + public static void LoadSkin() + { LoadedSkin = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("skin.json"))); SkinLoaded?.Invoke(); Desktop.ResetPanelButtons(); Desktop.PopulateAppLauncher(); } - public static void SaveSkin() { + public static void SaveSkin() + { Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin, Formatting.Indented)); } @@ -160,20 +176,20 @@ namespace ShiftOS.Engine { } else { - foreach(var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - if(f.EndsWith(".exe") || f.EndsWith(".dll")) + if (f.EndsWith(".exe") || f.EndsWith(".dll")) { try { var asm = Assembly.LoadFile(f); - foreach(var type in asm.GetTypes()) + foreach (var type in asm.GetTypes()) { - if(type.Name == id) + if (type.Name == id) { - foreach(var attr in type.GetCustomAttributes(true)) + foreach (var attr in type.GetCustomAttributes(true)) { - if(attr is DefaultIconAttribute) + if (attr is DefaultIconAttribute) { return _iconProber.GetIcon(attr as DefaultIconAttribute); } @@ -202,7 +218,7 @@ namespace ShiftOS.Engine { return Image.FromStream(sr); } } - + } } @@ -221,7 +237,8 @@ namespace ShiftOS.Engine { public string ID { get; private set; } } - public class Skin { + public class Skin + { //borrowing from the discourse theme for the default skin private static readonly Color DefaultBackground = Color.FromArgb(0, 0x44, 0x00); private static readonly Color DefaultForeground = Color.FromArgb(0xDD, 0xDD, 0xDD); @@ -278,8 +295,8 @@ namespace ShiftOS.Engine { [ShifterName("System Font")] [ShifterDescription("The font style used by the system.")] public Font MainFont = SysFont; - - [ShifterEnumMask(new[] { "Right", "Left"})] + + [ShifterEnumMask(new[] { "Right", "Left" })] [ShifterMeta("Windows")] [ShifterCategory("Title Buttons")] [ShifterName("Title button position")] @@ -1068,25 +1085,126 @@ namespace ShiftOS.Engine { [ShifterName("App icon from side")] [ShifterDescription("How far from the side should the icon be?")] [RequiresUpgrade("shift_titlebar;app_icons")] - public Point TitlebarIconFromSide = new Point(4,4); + public Point TitlebarIconFromSide = new Point(4, 4); + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Status Panel Font")] + [ShifterDescription("The font used by the status panel in the Advanced App Launcher.")] + public Font ALStatusPanelFont = SysFont; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Status Panel Text Color")] + [ShifterDescription("The text color for the AL status panel.")] + public Color ALStatusPanelTextColor = Skin.DefaultForeground; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Status Panel Background")] + [ShifterDescription("The status panel's background color.")] + public Color ALStatusPanelBackColor = TitleBG; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Status Panel Text Alignment")] + [ShifterDescription("What part of the panel should the status text stick to?")] + public ContentAlignment ALStatusPanelAlignment = ContentAlignment.MiddleCenter; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("skinning;shift_advanced_app_launcher")] + [ShifterName("Status Panel Background Image")] + [ShifterDescription("Use an image for the App Launcher Status Panel")] + [Image("al_bg_status")] + public byte[] ALStatusPanelBG = null; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterEnumMask(new[] { "Button, bottom panel", "Button, top panel", "Category Item" })] + [ShifterName("Shutdown Button position")] + [ShifterDescription("Change the position and layout of the App Launcher Shutdown button.")] + public int ShutdownButtonStyle = 0; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Shutdown Button from side")] + [ShifterDescription("The location relative to the side of the system panel that the shutdown button should reside from.")] + public Point ShutdownButtonFromSide = new Point(2, 2); + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Align shutdown button to left?")] + [ShifterDescription("Should the location of the shutdown button be calculated relative to the left of the system panel?")] + public bool ShutdownOnLeft = false; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Shutdown Button Font")] + [ShifterDescription("The font of the Shutdown Button")] + public Font ShutdownFont = SysFont; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("Shutdown Text Color")] + [ShifterDescription("The foreground color of the Shutdown button")] + public Color ShutdownForeColor = DefaultForeground; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("System Panel background color")] + [ShifterDescription("The background color of the App Launcher System Panel.")] + public Color SystemPanelBackground = TitleBG; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("skinning;shift_advanced_app_launcher")] + [ShifterName("System Panel Background Image")] + [ShifterDescription("The background image of the System Panel.")] + [Image("al_bg_system")] + public byte[] SystemPanelBG = null; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("App Launcher Item Font")] + [ShifterDescription("Select the font to use for the items in the App Launcher.")] + public Font AdvALItemFont = SysFont2; } - public class ShifterHiddenAttribute : Attribute { + public class ShifterHiddenAttribute : Attribute + { } - public class ShifterFlagAttribute : Attribute { - public ShifterFlagAttribute(string flag, bool expected) { + public class ShifterFlagAttribute : Attribute + { + public ShifterFlagAttribute(string flag, bool expected) + { Expected = expected; Flag = flag; } public bool Expected { get; set; } public string Flag { get; set; } - public bool IsTrue(Skin skn) { - foreach (var f in skn.GetType().GetFields()) { - if (f.Name == Flag) { - if (f.FieldType == typeof(bool)) { + public bool IsTrue(Skin skn) + { + foreach (var f in skn.GetType().GetFields()) + { + if (f.Name == Flag) + { + if (f.FieldType == typeof(bool)) + { return (bool)f.GetValue(skn) == Expected; } } @@ -1095,12 +1213,14 @@ namespace ShiftOS.Engine { } } - public class ImageAttribute : Attribute { + public class ImageAttribute : Attribute + { /// /// Attribute a byte array within the Skin object with this attribute and the engine and Shifter will see it as an image and you'll be able to grab the image by calling SkinEngine.GetImage() passing the name you input here. /// /// The name you want to reference this image as in the code. - public ImageAttribute(string name) { + public ImageAttribute(string name) + { Name = name; } @@ -1108,8 +1228,10 @@ namespace ShiftOS.Engine { } - public class ShifterEnumMaskAttribute : Attribute { - public ShifterEnumMaskAttribute(string[] items) { + public class ShifterEnumMaskAttribute : Attribute + { + public ShifterEnumMaskAttribute(string[] items) + { Items = items; } @@ -1118,37 +1240,45 @@ namespace ShiftOS.Engine { - public class ShifterNameAttribute : Attribute { - public ShifterNameAttribute(string name) { + public class ShifterNameAttribute : Attribute + { + public ShifterNameAttribute(string name) + { Name = name; } public string Name { get; set; } } - public class ShifterDescriptionAttribute : Attribute { - public ShifterDescriptionAttribute(string description) { + public class ShifterDescriptionAttribute : Attribute + { + public ShifterDescriptionAttribute(string description) + { Description = description; } public string Description { get; set; } } - public class ShifterCategoryAttribute : Attribute { + public class ShifterCategoryAttribute : Attribute + { - public ShifterCategoryAttribute(string category) { + public ShifterCategoryAttribute(string category) + { Category = category; } public string Category { get; set; } } - public class ShifterMetaAttribute : Attribute { + public class ShifterMetaAttribute : Attribute + { - public ShifterMetaAttribute(string meta) { + public ShifterMetaAttribute(string meta) + { Meta = meta; } public string Meta { get; set; } } -} +} \ No newline at end of file -- cgit v1.2.3 From 14c5ba260fad4a9751630c5f5fc322bf7963602b Mon Sep 17 00:00:00 2001 From: william341 Date: Tue, 2 May 2017 17:52:10 -0700 Subject: fix some nres --- ShiftOS.Objects/ShiftFS.cs | 6 +++++- ShiftOS.WinForms/Tools/ControlManager.cs | 1 + ShiftOS.WinForms/WFLanguageProvider.cs | 7 ------- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index 713bd17..c2121f0 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -230,7 +230,11 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + try + { + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + } + catch { } } else { diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 6d60f9d..3d66b2b 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -154,6 +154,7 @@ namespace ShiftOS.WinForms.Tools try { + if(ctrl.Tag != null) tag = ctrl.Tag.ToString(); } catch { } diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs index c11b6dc..2a431f8 100644 --- a/ShiftOS.WinForms/WFLanguageProvider.cs +++ b/ShiftOS.WinForms/WFLanguageProvider.cs @@ -44,14 +44,7 @@ namespace ShiftOS.WinForms { try { - switch (SaveSystem.CurrentSave.Language) - { - case "deutsch": - return Properties.Resources.strings_de; - default: return getDefault(); - - } } catch (NullReferenceException) { -- cgit v1.2.3 From 7919afa133561da65304f01498db5993510702e8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 14 May 2017 13:15:12 -0400 Subject: Custom buttons and progress bars. --- .../Applications/AudioPlayer.Designer.cs | 2 - .../Applications/Installer.Designer.cs | 2 - .../Applications/ShiftoriumFrontend.Designer.cs | 2 - .../Applications/UpdateManager.Designer.cs | 2 - .../Applications/VideoPlayer.Designer.cs | 2 - ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 91 +++++++++++++--- .../DesktopWidgets/UpgradePercentage.Designer.cs | 2 - ShiftOS.WinForms/DownloadControl.Designer.cs | 2 - ShiftOS.WinForms/Resources/Shiftorium.txt | 14 +++ ShiftOS.WinForms/Tools/ControlManager.cs | 43 ++++++++ ShiftOS_TheReturn/Skinning.cs | 121 +++++++++++++++++++++ 11 files changed, 251 insertions(+), 32 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs index 6263ff7..d7f03a0 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs @@ -141,12 +141,10 @@ namespace ShiftOS.WinForms.Applications // // 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"; diff --git a/ShiftOS.WinForms/Applications/Installer.Designer.cs b/ShiftOS.WinForms/Applications/Installer.Designer.cs index 48f9146..b01986d 100644 --- a/ShiftOS.WinForms/Applications/Installer.Designer.cs +++ b/ShiftOS.WinForms/Applications/Installer.Designer.cs @@ -118,12 +118,10 @@ // this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pginstall.BlockSize = 5; this.pginstall.Location = new System.Drawing.Point(17, 161); this.pginstall.Maximum = 100; this.pginstall.Name = "pginstall"; this.pginstall.Size = new System.Drawing.Size(414, 23); - this.pginstall.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pginstall.TabIndex = 2; this.pginstall.Text = "shiftedProgressBar1"; this.pginstall.Value = 0; diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs index f9d0bb4..dc107c4 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs @@ -242,12 +242,10 @@ namespace ShiftOS.WinForms.Applications // this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pgupgradeprogress.BlockSize = 5; this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390); this.pgupgradeprogress.Maximum = 100; this.pgupgradeprogress.Name = "pgupgradeprogress"; this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23); - this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgupgradeprogress.TabIndex = 1; this.pgupgradeprogress.Value = 25; // diff --git a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs index 0b23b8e..d30e2df 100644 --- a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs +++ b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs @@ -64,12 +64,10 @@ // 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; diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs index d915c31..1d93047 100644 --- a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs @@ -91,12 +91,10 @@ // // 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"; diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index e5a2c33..ceaff02 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -31,6 +31,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ShiftOS.Engine; namespace ShiftOS.WinForms.Controls { @@ -46,7 +47,7 @@ namespace ShiftOS.WinForms.Controls t.Interval = 100; t.Tick += (o, a) => { - if(this._style == ProgressBarStyle.Marquee) + if(this.Style == ProgressBarStyle.Marquee) { if(_marqueePos >= this.Width) { @@ -89,46 +90,100 @@ namespace ShiftOS.WinForms.Controls } } - public ProgressBarStyle _style = ProgressBarStyle.Continuous; - public ProgressBarStyle Style { - get { return _style; } - set { _style = value; this.Refresh(); } + get + { + return SkinEngine.LoadedSkin.ProgressBarStyle; + } } - private int _blocksize = 5; - public int BlockSize { - get { return _blocksize; } - set + get { - _blocksize = value; - this.Refresh(); + return SkinEngine.LoadedSkin.ProgressBarBlockSize; + } + } + + public Color RealBackColor + { + get + { + return SkinEngine.LoadedSkin.ProgressBarBackgroundColor; + } + } + + public Image RealBackgroundImage + { + get + { + return SkinEngine.GetImage("progressbarbg"); + } + } + + public Image ProgressImage + { + get + { + return SkinEngine.GetImage("progress"); + } + } + + public Color ProgressColor + { + get + { + return SkinEngine.LoadedSkin.ProgressColor; } } protected override void OnPaint(PaintEventArgs pe) { - pe.Graphics.Clear(Color.Black); - switch (_style) + pe.Graphics.Clear(this.RealBackColor); + if(RealBackgroundImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + } + switch (Style) { case ProgressBarStyle.Continuous: double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new RectangleF(0, 0, (float)width, this.Height)); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); + } break; case ProgressBarStyle.Blocks: - int block_count = this.Width / (this._blocksize + 2); + int block_count = this.Width / (this.BlockSize + 2); int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); for(int i = 0; i < blocks - 1; i++) { - int position = i * (_blocksize + 2); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(position, 0, _blocksize, this.Height)); + int position = i * (BlockSize + 2); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + } } break; case ProgressBarStyle.Marquee: - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + } break; } } diff --git a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs index ca0d587..4867c8d 100644 --- a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs +++ b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs @@ -34,13 +34,11 @@ // // pgupgrades // - this.pgupgrades.BlockSize = 5; this.pgupgrades.Dock = System.Windows.Forms.DockStyle.Bottom; this.pgupgrades.Location = new System.Drawing.Point(0, 99); this.pgupgrades.Maximum = 100; this.pgupgrades.Name = "pgupgrades"; this.pgupgrades.Size = new System.Drawing.Size(227, 23); - this.pgupgrades.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgupgrades.TabIndex = 0; this.pgupgrades.Text = "shiftedProgressBar1"; this.pgupgrades.Value = 0; diff --git a/ShiftOS.WinForms/DownloadControl.Designer.cs b/ShiftOS.WinForms/DownloadControl.Designer.cs index 2587b93..69c828d 100644 --- a/ShiftOS.WinForms/DownloadControl.Designer.cs +++ b/ShiftOS.WinForms/DownloadControl.Designer.cs @@ -83,12 +83,10 @@ namespace ShiftOS.WinForms // this.pgprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pgprogress.BlockSize = 5; this.pgprogress.Location = new System.Drawing.Point(4, 52); this.pgprogress.Maximum = 100; this.pgprogress.Name = "pgprogress"; this.pgprogress.Size = new System.Drawing.Size(371, 23); - this.pgprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgprogress.TabIndex = 0; this.pgprogress.Text = "shiftedProgressBar1"; this.pgprogress.Value = 0; diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c3d27ae..cc68c6f 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,20 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "Shift Progress Bar", + Cost: 150, + Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground and background color of the progress bar, and many more things!.", + Dependencies: "shifter;shift_buttons", + Category: "Customization" + }, + { + Name: "Shift Buttons", + Cost: 150, + Description: "Want to customize the look of all ShiftOS buttons? This Shifter upgrade gives you a new \"Buttons\" category in the System category to do just that.", + Dependencies: "shifter", + Category: "Customization" + }, { Name: "GUI Based Login Screen", Cost: 500, diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 3d66b2b..4f888ab 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -214,6 +214,49 @@ namespace ShiftOS.WinForms.Tools { } + + if(ctrl is Button) + { + Desktop.InvokeOnWorkerThread(() => + { + Button b = ctrl as Button; + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; + b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + + b.MouseEnter += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonHoverColor; + b.BackgroundImage = SkinEngine.GetImage("buttonhover"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonhover"); + }; + b.MouseLeave += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + }; + b.MouseUp += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + }; + + b.MouseDown += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonPressedColor; + b.BackgroundImage = SkinEngine.GetImage("buttonpressed"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); + + }; + }); + } + ctrl.KeyDown += (o, a) => { if (a.Control && a.KeyCode == Keys.T) diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4340f1a..c2f47fa 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -276,6 +276,127 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar;skinning")] + [Image("progressbarbg")] + [ShifterName("Progress Bar Background Image")] + [ShifterDescription("Set an image for the background of a progress bar.")] + public byte[] ProgressBarBG = null; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar;skinning")] + [Image("progress")] + [ShifterName("Progress Image")] + [ShifterDescription("Set the image for the progress inside a progress bar.")] + public byte[] Progress = null; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar foreground color")] + [ShifterDescription("Set the color of the progress indicator.")] + public Color ProgressColor = Accent1; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar background color")] + [ShifterDescription("The background color of the progress bar.")] + public Color ProgressBarBackgroundColor = Color.Black; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar block size")] + [ShifterDescription("If the progress bar style is set to Blocks, this determines how wide each block should be.")] + public int ProgressBarBlockSize = 15; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterDescription("Set the style of a progress bar.\r\nMarquee: The progress bar will render a box that moves from the left to the right in a loop.\r\nContinuous: Progress is shown by a single, continuous box.\r\nBlocks: Just like Continuous, but the box is split into even smaller boxes of a set width.")] + [ShifterName("Progress bar style")] + public ProgressBarStyle ProgressBarStyle = ProgressBarStyle.Continuous; + + + + + + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button background color")] + [ShifterDescription("Set the background color for each button's Idle state.")] + public Color ButtonBackgroundColor = Skin.DefaultBackground; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons;skinning")] + [Image("buttonhover")] + [ShifterName("Button hover image")] + [ShifterDescription("Set the image that's displayed when the mouse hovers over a button.")] + public byte[] ButtonHoverImage = null; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("skinning;shift_buttons")] + [Image("buttonpressed")] + [ShifterName("Button pressed image")] + [ShifterDescription("Select an image to show when the user presses a button.")] + public byte[] ButtonPressedImage = null; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button hover color")] + [ShifterDescription("Choose the color that displays on a button when the mouse hovers over it.")] + public Color ButtonHoverColor = Skin.Accent1; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button pressed color")] + [ShifterDescription("Select the background color for the button when the mouse clicks it.")] + public Color ButtonPressedColor = Skin.Accent2; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button foreground color")] + [ShifterDescription("Select the text and border color for each button.")] + public Color ButtonForegroundColor = Skin.DefaultForeground; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button border width")] + [ShifterDescription("Set the width, in pixels, of the button's border.")] + public int ButtonBorderWidth = 2; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button font")] + [ShifterDescription("Select the font for the button's text.")] + public Font ButtonTextFont = Skin.SysFont; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons;skinning")] + [Image("buttonidle")] + [ShifterName("Button background color")] + [ShifterDescription("Select an image to show as the button's Idle state.")] + public byte[] ButtonBG = null; + + [Image("panelclockbg")] [ShifterMeta("Desktop")] [ShifterCategory("Panel Clock")] -- cgit v1.2.3 From 6747c63e2c8c5a274846da7200c50a444b725d28 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 16:09:50 -0400 Subject: Tiny skinning fixes. --- ShiftOS.WinForms/Applications/Shifter.cs | 7 +- ShiftOS.WinForms/Tools/ControlManager.cs | 33 +++- ShiftOS_TheReturn/UserManagementCommands.cs | 238 ++++++++++++++++++++++++++++ 3 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 ShiftOS_TheReturn/UserManagementCommands.cs (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index edc3703..acb64a5 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -814,15 +814,12 @@ namespace ShiftOS.WinForms.Applications ControlManager.SetupControl(color); color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); - color.BackColorChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, color.BackColor); - }; color.Click += (o, a) => { - AppearanceManager.SetupDialog(new ColorPicker(color.BackColor, c.Name, new Action((col) => + AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => { color.BackColor = col; + c.Field.SetValue(LoadedSkin, col); CodepointValue += 300; InvokeSetup(cat); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 4f888ab..fc9567d 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -220,13 +220,22 @@ namespace ShiftOS.WinForms.Tools Desktop.InvokeOnWorkerThread(() => { Button b = ctrl as Button; - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; - b.BackgroundImage = SkinEngine.GetImage("buttonidle"); - b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + if (!b.Tag.ToString().ToLower().Contains("keepbg")) + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + } b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; - b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; - b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; - b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + if (!b.Tag.ToString().ToLower().Contains("keepfg")) + { + b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + } + if(!b.Tag.ToString().ToLower().Contains("keepfont")) + b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + + Color orig_bg = b.BackColor; b.MouseEnter += (o, a) => { @@ -236,13 +245,13 @@ namespace ShiftOS.WinForms.Tools }; b.MouseLeave += (o, a) => { - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackColor = orig_bg; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); }; b.MouseUp += (o, a) => { - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackColor = orig_bg; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); }; @@ -257,6 +266,14 @@ namespace ShiftOS.WinForms.Tools }); } + if(ctrl is TextBox) + { + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; + }); + } + ctrl.KeyDown += (o, a) => { if (a.Control && a.KeyCode == Keys.T) diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs new file mode 100644 index 0000000..a64c99c --- /dev/null +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + /// + /// Administrative user management terminal commands. + /// + [Namespace("admin")] + [KernelMode] + [RequiresUpgrade("mud_fundamentals")] + public static class AdminUserManagementCommands + { + /// + /// Add a user to the system. + /// + /// Command arguments. + /// Command result. + [Command("add", description = "Add a user to the system.", usage ="name:")] + [RequiresArgument("name")] + public static bool AddUser(Dictionary args) + { + string name = args["name"].ToString(); + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==name) != null) + { + Console.WriteLine("Error: User already exists."); + return true; + } + + var user = new ClientSave + { + Username = name, + Password = "", + Permissions = UserPermissions.User + }; + SaveSystem.CurrentSave.Users.Add(user); + Console.WriteLine($"Creating new user \"{name}\" with no password and User permissions."); + SaveSystem.SaveGame(); + return true; + } + + /// + /// Remove a user from the system. + /// + /// Command arguments. + /// Command result. + + [Command("remove", description = "Remove a user from the system.", usage = "name:")] + [RequiresArgument("name")] + public static bool RemoveUser(Dictionary args) + { + string name = args["name"].ToString(); + if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) == null) + { + Console.WriteLine("Error: User doesn't exist."); + return true; + } + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); + if(user.Username != SaveSystem.CurrentUser.Username) + { + Console.WriteLine("Error: Cannot remove yourself."); + return true; + } + SaveSystem.CurrentSave.Users.Remove(user); + Console.WriteLine($"Removing user \"{name}\" from system..."); + SaveSystem.SaveGame(); + return true; + } + + + + /// + /// Set access control level for a user. + /// + /// Command arguments. + /// Command result. + + [Command("set_acl")] + [RequiresArgument("user")] + [RequiresArgument("val")] + public static bool SetUserPermission(Dictionary args) + { + int permission = 0; + string username = args["user"].ToString(); + try + { + permission = Convert.ToInt32(args["val"].ToString()); + } + catch + { + Console.WriteLine("Error: Permission value must be an integer."); + return true; + } + + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) + { + Console.WriteLine("Error: User not found."); + return true; + } + + UserPermissions uperm = UserPermissions.Guest; + + switch (permission) + { + case 0: + uperm = UserPermissions.Guest; + break; + case 1: + uperm = UserPermissions.User; + break; + case 2: + uperm = UserPermissions.Admin; + break; + case 3: + uperm = UserPermissions.Root; + break; + default: + Console.WriteLine("Permission value must be between 0 and 4."); + return true; + } + + //Permissions are backwards... oops... + if(uperm < SaveSystem.CurrentUser.Permissions) + { + Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + return true; + } + + var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; + if (SaveSystem.CurrentUser.Permissions > oldperm) + { + Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + return true; + } + + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; + Console.WriteLine("User permissions updated."); + return true; + } + + /// + /// List all users in the system. + /// + /// Command arguments. + /// Command result. + + [Command("users", description = "Get a list of all users on the system.")] + public static bool GetUsers() + { + foreach (var u in SaveSystem.CurrentSave.Users) + { + if (u.Username == SaveSystem.CurrentUser.Username) + { + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + } + else + { + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + } + Console.WriteLine(u.Username); + } + return true; + } + } + + /// + /// Non-administrative user management terminal commands. + /// + [Namespace("user")] + [RequiresUpgrade("mud_fundamentals")] + public static class UserManagementCommands + { + /// + /// Log in as another user. + /// + /// Command arguments. + /// Command result. + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } + + /// + /// Set the password for the current user. + /// + /// Command arguments. + /// Command result. + [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] + [RequiresArgument("old")] + [RequiresArgument("new")] + public static bool SetPassword(Dictionary args) + { + string old = args["old"].ToString(); + string newpass = args["new"].ToString(); + + if(old == SaveSystem.CurrentUser.Password) + { + SaveSystem.CurrentUser.Password = newpass; + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == SaveSystem.CurrentUser.Username).Password = newpass; + Console.WriteLine("Password set successfully."); + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Passwords do not match."); + } + return true; + } + } +} -- cgit v1.2.3 From 97e22b35ada5898fdcb2556628f764d927cff913 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 26 May 2017 17:06:38 -0400 Subject: SLIGHT optimizations? --- ShiftOS.WinForms/Applications/Shifter.cs | 679 ++++++++++++----------- ShiftOS.WinForms/Applications/Terminal.cs | 4 + ShiftOS.WinForms/Servers/RemoteTerminalServer.cs | 161 ++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/Tools/ControlManager.cs | 13 +- ShiftOS_TheReturn/Localization.cs | 4 - ShiftOS_TheReturn/Server.cs | 40 ++ ShiftOS_TheReturn/ServerManager.cs | 62 +++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/TerminalBackend.cs | 9 +- 10 files changed, 635 insertions(+), 339 deletions(-) create mode 100644 ShiftOS.WinForms/Servers/RemoteTerminalServer.cs create mode 100644 ShiftOS_TheReturn/Server.cs (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index acb64a5..1a59c80 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -31,6 +31,8 @@ using System.Reflection; using System.Windows.Forms; using ShiftOS.Engine; using ShiftOS.WinForms.Tools; +using System.Linq; +using System.Threading; namespace ShiftOS.WinForms.Applications { @@ -540,400 +542,425 @@ namespace ShiftOS.WinForms.Applications { flbody.Controls.Clear(); - List cats = new List(); + IEnumerable cats = this.settings.Where(x => x.SubCategory == subcat && x.Category == cat && x.Field.FlagFullfilled(LoadedSkin)).OrderBy(x=>x.Name); - foreach (var c in this.settings) + new Thread(() => { - if (c.SubCategory == subcat && c.Category == cat) + foreach (var c in cats) { - if (c.Field.FlagFullfilled(LoadedSkin)) + Label lbl = null; + int labelHeight = 0; + Desktop.InvokeOnWorkerThread(() => { - if (!cats.Contains(c)) - { - cats.Add(c); - } - } - } - } - - foreach(var c in cats) - { - var lbl = new Label(); - int labelHeight = 0; - lbl.AutoSize = true; - lbl.Text = c.Name + ":"; - flbody.Controls.Add(lbl); - lbl.TextAlign = ContentAlignment.MiddleLeft; - lbl.Show(); - //Cool - label's in. - if(c.Field.FieldType == typeof(Point)) - { - var width = new TextBox(); - var height = new TextBox(); - labelHeight = width.Height; //irony? - width.Width = 30; - height.Width = width.Width; - width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); - height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); - flbody.SetFlowBreak(height, true); - ControlManager.SetupControl(width); - ControlManager.SetupControl(height); - - flbody.Controls.Add(width); - width.Show(); - flbody.Controls.Add(height); - height.Show(); - - EventHandler tc = (o, a) => + lbl = new Label(); + lbl.AutoSize = true; + lbl.Text = c.Name + ":"; + flbody.Controls.Add(lbl); + lbl.TextAlign = ContentAlignment.MiddleLeft; + lbl.Show(); + }); + //Cool - label's in. + if (c.Field.FieldType == typeof(Point)) { - try + TextBox width = null; + TextBox height = null; + Desktop.InvokeOnWorkerThread(() => { - int x = Convert.ToInt32(width.Text); - int y = Convert.ToInt32(height.Text); + width = new TextBox(); + height = new TextBox(); + labelHeight = width.Height; //irony? + width.Width = 30; + height.Width = width.Width; + width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); + height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); + flbody.SetFlowBreak(height, true); + ControlManager.SetupControl(width); + ControlManager.SetupControl(height); - int oldx = ((Point)c.Field.GetValue(this.LoadedSkin)).X; - int oldy = ((Point)c.Field.GetValue(this.LoadedSkin)).Y; + flbody.Controls.Add(width); + width.Show(); + flbody.Controls.Add(height); + height.Show(); - if(x != oldx || y != oldy) + EventHandler tc = (o, a) => { - c.Field.SetValue(LoadedSkin, new Point(x, y)); - CodepointValue += 200; - } - } - catch - { - width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); - height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); - } - InvokeSetup(cat); - }; + try + { + int x = Convert.ToInt32(width.Text); + int y = Convert.ToInt32(height.Text); - width.TextChanged += tc; - height.TextChanged += tc; + int oldx = ((Point)c.Field.GetValue(this.LoadedSkin)).X; + int oldy = ((Point)c.Field.GetValue(this.LoadedSkin)).Y; - } - else if(c.Field.FieldType == typeof(string)) - { - var str = new TextBox(); - str.Width = 120; - ControlManager.SetupControl(str); - labelHeight = str.Height; - str.Text = c.Field.GetValue(LoadedSkin).ToString(); - flbody.SetFlowBreak(str, true); - str.TextChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + if (x != oldx || y != oldy) + { + c.Field.SetValue(LoadedSkin, new Point(x, y)); + CodepointValue += 200; + } + } + catch + { + width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); + height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); + } + InvokeSetup(cat); + }; - InvokeSetup(cat); - }; - flbody.Controls.Add(str); - str.Show(); - } - else if(c.Field.FieldType == typeof(byte[])) - { - //We'll assume that this is an image file. - var color = new Button(); - color.Width = 40; - labelHeight = color.Height; - //just so it's flat like the system. - ControlManager.SetupControl(color); - flbody.SetFlowBreak(color, true); - - color.BackgroundImage = SkinEngine.ImageFromBinary((byte[])c.Field.GetValue(this.LoadedSkin)); - color.Click += (o, a) => + width.TextChanged += tc; + height.TextChanged += tc; + }); + } + else if (c.Field.FieldType == typeof(string)) { - AppearanceManager.SetupDialog(new GraphicPicker(color.BackgroundImage, c.Name, GetLayout(c.Field.GetImageName()), new Action((col, gdiImg, layout) => + Desktop.InvokeOnWorkerThread(() => { - c.Field.SetValue(LoadedSkin, col); - color.BackgroundImage = SkinEngine.ImageFromBinary(col); - color.BackgroundImageLayout = layout; - LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; - CodepointValue += 700; - InvokeSetup(cat); - - }))); - }; - flbody.Controls.Add(color); - color.Show(); - } - else if (c.Field.FieldType == typeof(Size)) - { - var width = new TextBox(); - var height = new TextBox(); - width.Width = 30; - height.Width = width.Width; - labelHeight = width.Height; - flbody.SetFlowBreak(height, true); - - width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); - height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); - ControlManager.SetupControl(width); - ControlManager.SetupControl(height); - - flbody.Controls.Add(width); - width.Show(); - flbody.Controls.Add(height); - height.Show(); - - EventHandler tc = (o, a) => + var str = new TextBox(); + str.Width = 120; + ControlManager.SetupControl(str); + labelHeight = str.Height; + str.Text = c.Field.GetValue(LoadedSkin).ToString(); + flbody.SetFlowBreak(str, true); + str.TextChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + + InvokeSetup(cat); + }; + flbody.Controls.Add(str); + str.Show(); + }); + } + else if (c.Field.FieldType == typeof(byte[])) { - try + Desktop.InvokeOnWorkerThread(() => { - int x = Convert.ToInt32(width.Text); - int y = Convert.ToInt32(height.Text); - - int oldx = ((Size)c.Field.GetValue(this.LoadedSkin)).Width; - int oldy = ((Size)c.Field.GetValue(this.LoadedSkin)).Height; - - if (x != oldx || y != oldy) + //We'll assume that this is an image file. + var color = new Button(); + color.Width = 40; + labelHeight = color.Height; + //just so it's flat like the system. + ControlManager.SetupControl(color); + flbody.SetFlowBreak(color, true); + + color.BackgroundImage = SkinEngine.ImageFromBinary((byte[])c.Field.GetValue(this.LoadedSkin)); + color.Click += (o, a) => { - c.Field.SetValue(LoadedSkin, new Size(x, y)); - CodepointValue += 200; - } - } - catch + AppearanceManager.SetupDialog(new GraphicPicker(color.BackgroundImage, c.Name, GetLayout(c.Field.GetImageName()), new Action((col, gdiImg, layout) => + { + c.Field.SetValue(LoadedSkin, col); + color.BackgroundImage = SkinEngine.ImageFromBinary(col); + color.BackgroundImageLayout = layout; + LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; + CodepointValue += 700; + InvokeSetup(cat); + + }))); + }; + flbody.Controls.Add(color); + color.Show(); + }); + } + else if (c.Field.FieldType == typeof(Size)) + { + Desktop.InvokeOnWorkerThread(() => { + var width = new TextBox(); + var height = new TextBox(); + width.Width = 30; + height.Width = width.Width; + labelHeight = width.Height; + flbody.SetFlowBreak(height, true); + width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); - } - InvokeSetup(cat); + ControlManager.SetupControl(width); + ControlManager.SetupControl(height); - }; + flbody.Controls.Add(width); + width.Show(); + flbody.Controls.Add(height); + height.Show(); - width.TextChanged += tc; - height.TextChanged += tc; + EventHandler tc = (o, a) => + { + try + { + int x = Convert.ToInt32(width.Text); + int y = Convert.ToInt32(height.Text); - } - else if(c.Field.FieldType == typeof(bool)) - { - var check = new CheckBox(); - check.Checked = ((bool)c.Field.GetValue(LoadedSkin)); - labelHeight = check.Height; - check.CheckedChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, check.Checked); - CodepointValue += 50; - InvokeSetup(cat); + int oldx = ((Size)c.Field.GetValue(this.LoadedSkin)).Width; + int oldy = ((Size)c.Field.GetValue(this.LoadedSkin)).Height; - }; - flbody.SetFlowBreak(check, true); + if (x != oldx || y != oldy) + { + c.Field.SetValue(LoadedSkin, new Size(x, y)); + CodepointValue += 200; + } + } + catch + { + width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); + height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); + } + InvokeSetup(cat); - flbody.Controls.Add(check); - check.Show(); - } - else if(c.Field.FieldType == typeof(Font)) - { - var name = new ComboBox(); - var size = new TextBox(); - var style = new ComboBox(); - - name.Width = 120; - labelHeight = name.Height; - size.Width = 40; - style.Width = 80; - flbody.SetFlowBreak(style, true); - - ControlManager.SetupControl(name); - ControlManager.SetupControl(size); - ControlManager.SetupControl(style); - - //populate the font name box - foreach(var font in FontFamily.Families) - { - name.Items.Add(font.Name); + }; + + width.TextChanged += tc; + height.TextChanged += tc; + }); } - name.Text = ((Font)c.Field.GetValue(LoadedSkin)).Name; + else if (c.Field.FieldType == typeof(bool)) + { + Desktop.InvokeOnWorkerThread(() => + { + var check = new CheckBox(); + check.Checked = ((bool)c.Field.GetValue(LoadedSkin)); + labelHeight = check.Height; + check.CheckedChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, check.Checked); + CodepointValue += 50; + InvokeSetup(cat); - size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); + }; + flbody.SetFlowBreak(check, true); - //populate the style box - foreach(var s in (FontStyle[])Enum.GetValues(typeof(FontStyle))) - { - style.Items.Add(s.ToString()); + flbody.Controls.Add(check); + check.Show(); + }); } - style.Text = ((Font)c.Field.GetValue(LoadedSkin)).Style.ToString(); - - name.SelectedIndexChanged += (o, a) => + else if (c.Field.FieldType == typeof(Font)) { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + Desktop.InvokeOnWorkerThread(() => + { + var name = new ComboBox(); + var size = new TextBox(); + var style = new ComboBox(); + + name.Width = 120; + labelHeight = name.Height; + size.Width = 40; + style.Width = 80; + flbody.SetFlowBreak(style, true); + + ControlManager.SetupControl(name); + ControlManager.SetupControl(size); + ControlManager.SetupControl(style); + + //populate the font name box + foreach (var font in FontFamily.Families) + { + name.Items.Add(font.Name); + } + name.Text = ((Font)c.Field.GetValue(LoadedSkin)).Name; - var f = en[style.SelectedIndex]; + size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - CodepointValue += 100; - InvokeSetup(cat); + //populate the style box + foreach (var s in (FontStyle[])Enum.GetValues(typeof(FontStyle))) + { + style.Items.Add(s.ToString()); + } + style.Text = ((Font)c.Field.GetValue(LoadedSkin)).Style.ToString(); - }; + name.SelectedIndexChanged += (o, a) => + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - style.SelectedIndexChanged += (o, a) => - { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + var f = en[style.SelectedIndex]; - var f = en[style.SelectedIndex]; + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + CodepointValue += 100; + InvokeSetup(cat); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - CodepointValue += 50; - InvokeSetup(cat); + }; - }; + style.SelectedIndexChanged += (o, a) => + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - size.TextChanged += (o, a) => - { - try - { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + var f = en[style.SelectedIndex]; - var f = en[style.SelectedIndex]; + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + CodepointValue += 50; + InvokeSetup(cat); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - } - catch - { - size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); - } - CodepointValue += 50; - InvokeSetup(cat); + }; - }; + size.TextChanged += (o, a) => + { + try + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - flbody.Controls.Add(name); - flbody.Controls.Add(size); - flbody.Controls.Add(style); + var f = en[style.SelectedIndex]; - name.Show(); - size.Show(); - style.Show(); + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + } + catch + { + size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); + } + CodepointValue += 50; + InvokeSetup(cat); - } - else if(c.Field.FieldType == typeof(Color)) - { - var color = new Button(); - color.Width = 40; - labelHeight = color.Height; - //just so it's flat like the system. - ControlManager.SetupControl(color); - - color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); - color.Click += (o, a) => - { - AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => - { - color.BackColor = col; - c.Field.SetValue(LoadedSkin, col); - CodepointValue += 300; - InvokeSetup(cat); - - }))); - }; - flbody.SetFlowBreak(color, true); - color.Tag = "keepbg"; - flbody.Controls.Add(color); - color.Show(); - } - else if(c.Field.FieldType.IsEnum == true) - { - var cBox = new ComboBox(); - cBox.Width = 150; - ControlManager.SetupControl(cBox); + }; + + flbody.Controls.Add(name); + flbody.Controls.Add(size); + flbody.Controls.Add(style); - foreach(var itm in Enum.GetNames(c.Field.FieldType)) + name.Show(); + size.Show(); + style.Show(); + }); + } + else if (c.Field.FieldType == typeof(Color)) { - cBox.Items.Add(itm); + Desktop.InvokeOnWorkerThread(() => + { + var color = new Button(); + color.Width = 40; + labelHeight = color.Height; + //just so it's flat like the system. + ControlManager.SetupControl(color); + + color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); + color.Click += (o, a) => + { + AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => + { + color.BackColor = col; + c.Field.SetValue(LoadedSkin, col); + CodepointValue += 300; + InvokeSetup(cat); + + }))); + }; + flbody.SetFlowBreak(color, true); + color.Tag = "keepbg"; + flbody.Controls.Add(color); + color.Show(); + }); } - - cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); - - cBox.SelectedIndexChanged += (o, a) => + else if (c.Field.FieldType.IsEnum == true) { - c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); - InvokeSetup(cat); + Desktop.InvokeOnWorkerThread(() => + { + var cBox = new ComboBox(); + cBox.Width = 150; + ControlManager.SetupControl(cBox); - }; + foreach (var itm in Enum.GetNames(c.Field.FieldType)) + { + cBox.Items.Add(itm); + } - labelHeight = cBox.Height; + cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); - flbody.Controls.Add(cBox); - cBox.Show(); - flbody.SetFlowBreak(cBox, true); - } - else if(c.Field.FieldType == typeof(int)) - { - if (c.Field.HasShifterEnumMask()) - { - var name = new ComboBox(); - name.Width = 120; - ControlManager.SetupControl(name); - string[] items = c.Field.GetShifterEnumMask(); - foreach(var item in items) - { - name.Items.Add(item); - } - name.SelectedIndex = (int)c.Field.GetValue(LoadedSkin); - name.SelectedIndexChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, name.SelectedIndex); - CodepointValue += 75; - InvokeSetup(cat); + cBox.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + InvokeSetup(cat); + + }; - }; - labelHeight = name.Height; - flbody.Controls.Add(name); - name.Show(); - flbody.SetFlowBreak(name, true); + labelHeight = cBox.Height; + flbody.Controls.Add(cBox); + cBox.Show(); + flbody.SetFlowBreak(cBox, true); + }); } - else + else if (c.Field.FieldType == typeof(int)) { - var width = new TextBox(); - width.Width = 30; - width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); - ControlManager.SetupControl(width); - labelHeight = width.Height; - flbody.Controls.Add(width); - width.Show(); - - EventHandler tc = (o, a) => + Desktop.InvokeOnWorkerThread(() => { - try + if (c.Field.HasShifterEnumMask()) { - int x = Convert.ToInt32(width.Text); - - int oldx = ((int)c.Field.GetValue(this.LoadedSkin)); - - if (x != oldx) + var name = new ComboBox(); + name.Width = 120; + ControlManager.SetupControl(name); + string[] items = c.Field.GetShifterEnumMask(); + foreach (var item in items) { - c.Field.SetValue(LoadedSkin, x); - CodepointValue += 75; + name.Items.Add(item); } + name.SelectedIndex = (int)c.Field.GetValue(LoadedSkin); + name.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, name.SelectedIndex); + CodepointValue += 75; + InvokeSetup(cat); + + }; + labelHeight = name.Height; + flbody.Controls.Add(name); + name.Show(); + flbody.SetFlowBreak(name, true); + } - catch + else { + var width = new TextBox(); + width.Width = 30; width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); - } - InvokeSetup(cat); + ControlManager.SetupControl(width); + labelHeight = width.Height; + flbody.Controls.Add(width); + width.Show(); + + EventHandler tc = (o, a) => + { + try + { + int x = Convert.ToInt32(width.Text); + + int oldx = ((int)c.Field.GetValue(this.LoadedSkin)); - }; + if (x != oldx) + { + c.Field.SetValue(LoadedSkin, x); + CodepointValue += 75; + } + } + catch + { + width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); + } + InvokeSetup(cat); - width.TextChanged += tc; - flbody.SetFlowBreak(width, true); + }; + width.TextChanged += tc; + flbody.SetFlowBreak(width, true); + + } + }); } - } - lbl.AutoSize = false; - lbl.Width = (int)this.CreateGraphics().MeasureString(lbl.Text, SkinEngine.LoadedSkin.MainFont).Width + 15; - lbl.Height = labelHeight; - lbl.TextAlign = ContentAlignment.MiddleLeft; + Desktop.InvokeOnWorkerThread(() => + { + lbl.AutoSize = false; + lbl.Width = (int)this.CreateGraphics().MeasureString(lbl.Text, SkinEngine.LoadedSkin.MainFont).Width + 15; + lbl.Height = labelHeight; + lbl.TextAlign = ContentAlignment.MiddleLeft; + }); - if (!string.IsNullOrWhiteSpace(c.Description)) - { - var desc = new Label(); - flbody.SetFlowBreak(desc, true); - desc.Text = c.Description; - desc.AutoSize = true; - flbody.Controls.Add(desc); - desc.Show(); + if (!string.IsNullOrWhiteSpace(c.Description)) + { + Desktop.InvokeOnWorkerThread(() => + { + var desc = new Label(); + flbody.SetFlowBreak(desc, true); + desc.Text = c.Description; + desc.AutoSize = true; + flbody.Controls.Add(desc); + desc.Show(); + }); + } } - } + }).Start(); } public ImageLayout GetLayout(string name) diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 664b657..ea24686 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -442,6 +442,10 @@ namespace ShiftOS.WinForms.Applications }).Start(); } + public static string RemoteSystemName { get; set; } + public static string RemoteUser { get; set; } + public static string RemotePass { get; set; } + [Story("first_steps")] public static void FirstSteps() { diff --git a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs new file mode 100644 index 0000000..d57e28f --- /dev/null +++ b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects; + +namespace ShiftOS.WinForms.Servers +{ + [Namespace("rts")] + [Server("Remote Terminal Server", 21)] + //[RequiresUpgrade("story_hacker101_breakingthebonds")] //Uncomment when story is implemented. + public class RemoteTerminalServer : Server + { + public void MessageReceived(ServerMessage msg) + { + var rtsMessage = JsonConvert.DeserializeObject(msg.Contents); + if (msg.Name == "disconnected") + { + if (Applications.Terminal.IsInRemoteSystem == true) + { + if (Applications.Terminal.RemoteSystemName == rtsMessage.SenderSystemName) + { + if(Applications.Terminal.RemoteUser == rtsMessage.Username) + if(Applications.Terminal.RemotePass == rtsMessage.Password) + { + Applications.Terminal.IsInRemoteSystem = false; + Applications.Terminal.RemoteSystemName = ""; + Applications.Terminal.RemoteUser = ""; + Applications.Terminal.RemotePass = ""; + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + } + } + } + return; + } + + string currentUserName = SaveSystem.CurrentUser.Username; + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == rtsMessage.Username && x.Password == rtsMessage.Password); + + if(user == null) + { + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 0, "Access denied.", "The username and password you have provided was denied."); + return; + } + else + { + SaveSystem.CurrentUser = user; + + string cmd = rtsMessage.Namespace + "." + rtsMessage.Command + JsonConvert.SerializeObject(rtsMessage.Arguments); + TerminalBackend.InvokeCommand(cmd, true); + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 1, "writeline", TerminalBackend.LastCommandBuffer); + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 1, "write", $"{rtsMessage.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + + SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == currentUserName); + } + } + + [Command("connect")] + [RequiresArgument("sysname")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool Connect(Dictionary args) + { + string sysname = args["sysname"].ToString(); + string username = args["username"].ToString(); + string password = args["password"].ToString(); + + bool connectionFinished = false; + + + new Thread(() => + { + Thread.Sleep(10000); + if (connectionFinished == false) + { + Applications.Terminal.IsInRemoteSystem = false; + Applications.Terminal.RemoteSystemName = ""; + Applications.Terminal.RemoteUser = ""; + Applications.Terminal.RemotePass = ""; + TerminalBackend.PrefixEnabled = true; + Console.WriteLine("[rts] Connection failed, target system did not respond."); + TerminalBackend.PrintPrompt(); + + } + }).Start(); + + ServerMessageReceived smr = null; + smr = (msg) => + { + if (msg.Name == "msgtosys") + { + var m = JsonConvert.DeserializeObject(msg.Contents); + if (m.GUID.Split('|')[2] != ServerManager.thisGuid.ToString()) + { + connectionFinished = true; + ServerManager.MessageReceived -= smr; + } + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessageToIngameServer(sysname, 21, "cmd", JsonConvert.SerializeObject(new RTSMessage + { + SenderSystemName = SaveSystem.CurrentSave.SystemName, + Username = username, + Password = password, + Namespace = "trm", + Command = "clear" + })); + Applications.Terminal.IsInRemoteSystem = true; + Applications.Terminal.RemoteSystemName = sysname; + Applications.Terminal.RemoteUser = username; + Applications.Terminal.RemotePass = password; + TerminalBackend.PrefixEnabled = false; + return true; + } + } + + [Server("Generic port 0", 0)] + public class InfoboxServer : Server + { + public void MessageReceived(ServerMessage msg) + { + Infobox.Show(msg.Name, msg.Contents); + } + } + + [Server("Generic port 1", 1)] + public class ConsoleServer : Server + { + public void MessageReceived(ServerMessage msg) + { + switch (msg.Name) + { + case "write": + Console.Write(msg.Contents); + break; + case "writeline": + Console.WriteLine(msg.Contents); + break; + } + } + } + + public class RTSMessage + { + public string SenderSystemName { get; set; } + + public string Namespace { get; set; } + public string Command { get; set; } + public Dictionary Arguments { get; set; } + + public string Username { get; set; } + public string Password { get; set; } + } +} diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9675744..da8eafc 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -363,6 +363,7 @@ Resources.resx + UserControl diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index fc9567d..1643b23 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -144,10 +144,7 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - Desktop.InvokeOnWorkerThread(new Action(() => - { - ctrl.SuspendLayout(); - })); + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { string tag = ""; @@ -306,7 +303,6 @@ namespace ShiftOS.WinForms.Tools { MakeDoubleBuffered(ctrl); - ctrl.ResumeLayout(); }); ControlSetup?.Invoke(ctrl); } @@ -330,17 +326,18 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { - SetupControl(frm); frm.Click += (o, a) => { Desktop.HideAppLauncher(); }; ThreadStart ts = () => { - for (int i = 0; i < frm.Controls.Count; i++) + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - SetupControls(frm.Controls[i], false); + SetupControls(ctrls[i]); } + SetupControl(frm); }; diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 2c701c9..5d848b0 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -117,10 +117,6 @@ namespace ShiftOS.Engine } List orphaned = new List(); - if (Utils.FileExists("0:/dev_orphaned_lang.txt")) - { - orphaned = JsonConvert.DeserializeObject>(Utils.ReadAllText("0:/dev_orphaned_lang.txt")); // if this file exists read from it and put in list orphaned - } int start_index = 0; diff --git a/ShiftOS_TheReturn/Server.cs b/ShiftOS_TheReturn/Server.cs new file mode 100644 index 0000000..ddbd15b --- /dev/null +++ b/ShiftOS_TheReturn/Server.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public interface Server + { + /// + /// Occurs when someone sends a message to the server. + /// + /// The message from the client. + void MessageReceived(ServerMessage msg); + } + + [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] + public class ServerAttribute : Attribute + { + public ServerAttribute(string name, int port) + { + Name = name; + Port = port; + } + + + /// + /// Gets the name of the server. + /// + public string Name { get; } + + /// + /// Gets the port of the server. + /// + public int Port { get; } + + } +} diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 95e86e9..217b9ee 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -36,6 +36,8 @@ using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; using System.Net.Sockets; using System.Diagnostics; +using System.IO; +using System.Reflection; namespace ShiftOS.Engine { @@ -104,6 +106,43 @@ Ping: {ServerManager.DigitalSocietyPing} ms /// public static event Action GUIDReceived; + private static void delegateToServer(ServerMessage msg) + { + string[] split = msg.GUID.Split('|'); + bool finished = false; + foreach (var exec in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(Server)))) + { + var attrib = type.GetCustomAttributes().FirstOrDefault(x => x is ServerAttribute) as ServerAttribute; + if(attrib != null) + { + if(split[0] == SaveSystem.CurrentSave.SystemName && split[1] == attrib.Port.ToString()) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + type.GetMethods(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(x => x.Name == "MessageReceived")?.Invoke(Activator.CreateInstance(type), null); + finished = true; + } + } + } + } + } + catch { } + } + } + if (finished == false) + { + Forward(split[2], "Error", $"{split[0]}:{split[1]}: connection refused"); + } + } + + private static void ServerManager_MessageReceived(ServerMessage msg) { switch(msg.Name) @@ -119,12 +158,35 @@ Ping: {ServerManager.DigitalSocietyPing} ms })); } break; + case "msgtosys": + try + { + var m = JsonConvert.DeserializeObject(msg.Contents); + if(m.GUID.Split('|')[2] != thisGuid.ToString()) + { + delegateToServer(m); + } + } + catch { } + break; case "getguid_reply": GUIDReceived?.Invoke(msg.Contents); break; } } + public static void SendMessageToIngameServer(string sysname, int port, string title, string contents) + { + var smsg = new ServerMessage + { + Name = title, + GUID = $"{sysname}|{port}|{thisGuid.ToString()}", + Contents = contents + }; + Forward("all", "msgtosys", JsonConvert.SerializeObject(smsg)); + + } + public static void Detach_ServerManager_MessageReceived() { MessageReceived -= new ServerMessageReceived(ServerManager_MessageReceived); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 8b48023..9d7d696 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -124,6 +124,7 @@ + diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index c8619b5..b18e27c 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -84,6 +84,11 @@ namespace ShiftOS.Engine /// public static string LastCommand = ""; + /// + /// Gets the output of the last command. + /// + public static string LastCommandBuffer { get; private set; } + /// /// Invokes a ShiftOS terminal command. /// @@ -395,8 +400,10 @@ namespace ShiftOS.Engine } string buffer = tw.ToString(); + LastCommandBuffer = buffer; Console.SetOut(new TerminalTextWriter()); - Console.Write(buffer); + if(!isRemote) + Console.Write(buffer); } -- cgit v1.2.3 From 03ebdf42d9f12b678d48f954736664f6f3eb1f84 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 12:40:06 -0400 Subject: Funny, disabling localization makes things easier... --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Terminal.cs | 6 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 5 +- ShiftOS.WinForms/Tools/ControlManager.cs | 139 +++++++++++------------------- ShiftOS.WinForms/WinformsDesktop.cs | 10 ++- ShiftOS_TheReturn/Localization.cs | 45 +--------- ShiftOS_TheReturn/TerminalTextWriter.cs | 1 + 7 files changed, 72 insertions(+), 135 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index f9e601f..7a2de81 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -41,6 +41,7 @@ namespace ShiftOS.WinForms.Applications [WinOpen("simplesrc")] [Launcher("SimpleSRC Client", false, null, "Networking")] [DefaultTitle("SimpleSRC Client")] + [AppscapeEntry("SimpleSRC", "A simple ShiftOS Relay Chat client that allows you to talk with other ShiftOS users from all over the world.", 300, 145, "file_skimmer", "Networking")] public partial class Chat : UserControl, IShiftOSWindow { public Chat() diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index bfc4425..3d17d35 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -504,11 +504,11 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); Console.WriteLine("As you know, ShiftOS doesn't have very many features."); Thread.Sleep(2000); - Console.WriteLine("Using the applications you have, I need you to earn 50,000 Codepoints."); + Console.WriteLine("Using the applications you have, I need you to earn as many Codepoints as you can."); Thread.Sleep(2000); - Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn Codepoints."); + Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn even more Codepoints."); Thread.Sleep(2000); - Console.WriteLine("Start small, try to earn 500. Once you do, I'll contact you with more details."); + Console.WriteLine("Once you earn 1,000 Codepoints, I will check back with you and see how well you've done."); Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 41b50a7..0eac58e 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -283,7 +283,7 @@ Name: "AL Widget Manager", Cost: 125, Description: "Desktop Widgets are a huge advancement in ShiftOS technology, allowing access to system information, and quick control of your system, without even opening a window. However, we still need to be able to modify each widget. This upgrade adds an App Launcher entry for the Desktop Widget Manager.", - Description: "app_launcher;desktop_widgets", + Dependencies: "app_launcher;desktop_widgets", Category: "GUI" }, { @@ -704,7 +704,8 @@ Name: "Artpad", Cost: 7500, Category: "Applications", - Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!" + Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!", + Dependencies: "color_depth_8_bits" }, { Name: "AL Artpad", diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 1643b23..83ab7fe 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,3 +1,5 @@ +#define SLOW_LOCALIZATION + /* * MIT License * @@ -144,77 +146,66 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) + Desktop.InvokeOnWorkerThread(() => { - string tag = ""; - - try + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { - if(ctrl.Tag != null) - tag = ctrl.Tag.ToString(); - } - catch { } + string tag = ""; - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) + try { - Desktop.InvokeOnWorkerThread(() => + if (ctrl.Tag != null) + tag = ctrl.Tag.ToString(); + } + catch { } + + if (!tag.Contains("keepbg")) + { + if (ctrl.BackColor != Control.DefaultBackColor) { ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - }); + } } - } - if (!tag.Contains("keepfont")) - { - Desktop.InvokeOnWorkerThread(() => + if (!tag.Contains("keepfont")) { ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; ctrl.Font = SkinEngine.LoadedSkin.MainFont; - }); - if (tag.Contains("header1")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header1")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - }); - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header2")) { ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - }); - } + } - if (tag.Contains("header3")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header3")) { ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - }); + } } - } - try - { - string ctrlText = Localization.Parse(ctrl.Text); - Desktop.InvokeOnWorkerThread(() => + try + { +#if !SLOW_LOCALIZATION + if (!string.IsNullOrWhiteSpace(ctrl.Text)) + { + string ctrlText = Localization.Parse(ctrl.Text); + ctrl.Text = ctrlText; + } +#endif + } + catch { - ctrl.Text = ctrlText; - }); - } - catch - { - } + } - if(ctrl is Button) - { - Desktop.InvokeOnWorkerThread(() => + if (ctrl is Button) { Button b = ctrl as Button; if (!b.Tag.ToString().ToLower().Contains("keepbg")) @@ -229,7 +220,7 @@ namespace ShiftOS.WinForms.Tools b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if(!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!b.Tag.ToString().ToLower().Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; @@ -260,15 +251,12 @@ namespace ShiftOS.WinForms.Tools b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); }; - }); + } } - if(ctrl is TextBox) + if (ctrl is TextBox) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; - }); + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; } ctrl.KeyDown += (o, a) => @@ -286,27 +274,19 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - }); + (ctrl as Button).FlatStyle = FlatStyle.Flat; } else if (ctrl is WindowBorder) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as WindowBorder).Setup(); - }); + (ctrl as WindowBorder).Setup(); } - } - Desktop.InvokeOnWorkerThread(() => - { - MakeDoubleBuffered(ctrl); + ControlSetup?.Invoke(ctrl); }); - ControlSetup?.Invoke(ctrl); } + + public static event Action ControlSetup; public static void MakeDoubleBuffered(Control c) @@ -330,27 +310,12 @@ namespace ShiftOS.WinForms.Tools { Desktop.HideAppLauncher(); }; - ThreadStart ts = () => - { - var ctrls = frm.Controls.ToList(); - for (int i = 0; i < ctrls.Count(); i++) - { - SetupControls(ctrls[i]); - } - SetupControl(frm); - - }; - - if (runInThread == true) - { - var t = new Thread(ts); - t.IsBackground = true; - t.Start(); - } - else + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - ts?.Invoke(); + SetupControls(ctrls[i]); } + SetupControl(frm); } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6ce8cc9..85eab55 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -202,13 +202,21 @@ namespace ShiftOS.WinForms { if (SaveSystem.CurrentSave.Codepoints != lastcp) lastcp = SaveSystem.CurrentSave.Codepoints; - if (lastcp >= 10000) + if (lastcp >= 2500) { if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) { Story.Start("victortran_shiftnet"); } } + if(lastcp >= 5000) + { + if(Shiftorium.UpgradeInstalled("triwrite") && Shiftorium.UpgradeInstalled("simplesrc") && Shiftorium.UpgradeInstalled("victortran_shiftnet") && Shiftorium.UpgradeInstalled("story_hacker101_breakingthebonds")) + { + if (!Shiftorium.UpgradeInstalled("story_thefennfamily")) + Story.Start("story_thefennfamily"); + } + } } } while (!SaveSystem.ShuttingDown); }); diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 5d848b0..c542c2a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -111,50 +111,11 @@ namespace ShiftOS.Engine localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english } - foreach (var kv in localizationStrings) + foreach (var kv in localizationStrings.Where(x=>original.Contains(x.Key))) { original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks } - List orphaned = new List(); - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - // start paying attenion when you see a "{" - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - // stop paying attention when you see a "}" after seeing a "{" - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); //format if from this txt file - } - //string original2 = Parse(original); string usernameReplace = ""; @@ -203,13 +164,13 @@ namespace ShiftOS.Engine }; // actually do the replacement - foreach (KeyValuePair replacement in replace) + foreach (KeyValuePair replacement in replace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, Parse(replacement.Value)); } // do the replacement but default - foreach (KeyValuePair replacement in defaultReplace) + foreach (KeyValuePair replacement in defaultReplace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, replacement.Value); } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 4c0c3a0..63e88eb 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -42,6 +42,7 @@ namespace ShiftOS.Engine { ConsoleEx.OnFlush = () => { + System.Diagnostics.Debug.WriteLine("[terminal] " + buffer); Desktop.InvokeOnWorkerThread(() => { UnderlyingControl?.Write(buffer); -- cgit v1.2.3 From 6123e06842ec9eea60bd2d73588ac6c545d0ea99 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 13:36:28 -0400 Subject: make localization 50 billion times faster --- ShiftOS.WinForms/Applications/Pong.cs | 10 +++++----- ShiftOS.WinForms/Tools/ControlManager.cs | 1 - ShiftOS_TheReturn/Localization.cs | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 02d9963..84177b7 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -343,10 +343,10 @@ namespace ShiftOS.WinForms.Applications if (IsLeader) { //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy - lblstatsX.Text = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); + lblstatsX.Text = "X vel: " + xveldec; + lblstatsY.Text = "Y vel: " + yveldec; + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left"; if (xVel > 20 || xVel < -20) { @@ -634,7 +634,7 @@ namespace ShiftOS.WinForms.Applications CompleteLevel(); } - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); } } SetupStats(); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 83ab7fe..fe77884 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,4 +1,3 @@ -#define SLOW_LOCALIZATION /* * MIT License diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index c542c2a..8adfa5a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -160,7 +160,9 @@ namespace ShiftOS.Engine {"%domain", domainReplace}, {"%ns", namespaceReplace}, {"%cmd", commandReplace}, - {"%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, +#if LOCALIZE_CODEPOINTS + { "%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, +#endif }; // actually do the replacement -- cgit v1.2.3 From 9914c18456a0c08019e778479ce727ac937b1e57 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 14:40:42 -0400 Subject: Fuck --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 6 +++ ShiftOS.WinForms/Tools/ControlManager.cs | 6 +-- ShiftOS_TheReturn/SaveSystem.cs | 64 +++++++++++++++---------------- ShiftOS_TheReturn/ServerManager.cs | 17 -------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 4 -- 6 files changed, 42 insertions(+), 56 deletions(-) (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3d17d35..de4888b 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -232,6 +232,7 @@ namespace ShiftOS.WinForms.Applications var text = txt.Lines.ToArray(); var text2 = text[text.Length - 1]; var text3 = ""; + Console.WriteLine(); var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); if (IsInRemoteSystem == true) diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 25f7144..c188321 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,6 +64,9 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } @@ -85,6 +88,9 @@ namespace ShiftOS.WinForms.Controls { Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.Select(this.TextLength, 0); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index fe77884..92482fa 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -207,19 +207,19 @@ namespace ShiftOS.WinForms.Tools if (ctrl is Button) { Button b = ctrl as Button; - if (!b.Tag.ToString().ToLower().Contains("keepbg")) + if (!tag.Contains("keepbg")) { b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); } b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; - if (!b.Tag.ToString().ToLower().Contains("keepfg")) + if (!tag.Contains("keepfg")) { b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if (!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!tag.Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 489b718..55f5cd5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -153,50 +153,50 @@ namespace ShiftOS.Engine } } - if (defaultConf.ConnectToMud == true) + + + bool guidReceived = false; + ServerManager.GUIDReceived += (str) => { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); - }; + Console.WriteLine("[inetd] Connection successful."); + }; - try - { - - ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); - } - catch (Exception ex) + try + { + + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) { - //No errors, this never gets called. - Console.WriteLine("[inetd] SEVERE: " + ex.Message); - Thread.Sleep(3000); - ServerManager.StartLANServer(); - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); + Thread.Sleep(10); } + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); + FinishBootstrap(); } - else + catch (Exception ex) { - ServerManager.StartLANServer(); + //No errors, this never gets called. + Console.WriteLine("[inetd] SEVERE: " + ex.Message); + Thread.Sleep(3000); + Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 4..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 3..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 2..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 1..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] Bye bye."); + System.Diagnostics.Process.GetCurrentProcess().Kill(); } //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - + })); thread.IsBackground = true; thread.Start(); diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 217b9ee..f0acaa2 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -316,23 +316,6 @@ Ping: {ServerManager.DigitalSocietyPing} ms private static bool singleplayer = false; public static bool IsSingleplayer { get { return singleplayer; } } - public static void StartLANServer() - { - singleplayer = true; - ShiftOS.Server.Program.ServerStarted += (address) => - { - Console.WriteLine($"Connecting to {address}..."); - Initiate(address, 13370); - }; - Disconnected += () => - { - ShiftOS.Server.Program.Stop(); - }; - ShiftOS.Server.Program.Main(new[] { "" }); - - - } - /// /// Occurs when the server sends a message to this client. /// diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 9d7d696..4cbce72 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -162,10 +162,6 @@ {A069089A-8962-4607-B2B2-4CF4A371066E} ShiftOS.Objects - - {226C63B4-E60D-4949-B4E7-7A2DDBB96776} - ShiftOS.Server - -- cgit v1.2.3