From bb4a3801623579296cf081f4e9172080d852bc7b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 28 Feb 2017 17:01:14 -0500 Subject: Beginning screensaver work --- ShiftOS_TheReturn/Skinning.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4837dcd..43e0b5d 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -246,6 +246,21 @@ namespace ShiftOS.Engine { [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [RequiresUpgrade("shift_screensaver")] + [ShifterMeta("System")] + [ShifterCategory("Screen saver")] + [ShifterName("Screen saver wait (milliseconds)")] + [ShifterDescription("How long do you have to stay idle before the screensaver activates?")] + public int ScreensaverWait = 300000; + + [RequiresUpgrade("skinning;shift_screensaver")] + [ShifterMeta("System")] + [ShifterCategory("Screen saver")] + [ShifterName("Screen saver image")] + [ShifterDescription("What image should appear on the screen saver?")] + public byte[] ScreensaverImage = null; + + [ShifterMeta("Windows")] [ShifterCategory("Titlebar")] -- cgit v1.2.3 From a9b08eb21676a6c59b0c8bb6046b40bd42e078d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 18:15:29 -0500 Subject: FULLY COMPLETE TERMINAL COLORS --- ShiftOS.WinForms/Applications/Shifter.cs | 24 ++++++++++++++++++++++++ ShiftOS.WinForms/Applications/Shiftnet.cs | 7 +++++-- ShiftOS.WinForms/Applications/Terminal.cs | 12 ++++++------ ShiftOS_TheReturn/Skinning.cs | 4 ++-- ShiftOS_TheReturn/TerminalBackend.cs | 3 ++- 5 files changed, 39 insertions(+), 11 deletions(-) (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 4d29cf8..1adc75a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -446,6 +446,30 @@ namespace ShiftOS.WinForms.Applications flbody.Controls.Add(color); color.Show(); } + else if(c.Field.FieldType.IsEnum == true) + { + var cBox = new ComboBox(); + cBox.Width = 150; + ControlManager.SetupControl(cBox); + + foreach(var itm in Enum.GetNames(c.Field.FieldType)) + { + cBox.Items.Add(itm); + } + + cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); + + cBox.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + }; + + labelHeight = cBox.Height; + + flbody.Controls.Add(cBox); + cBox.Show(); + flbody.SetFlowBreak(cBox, true); + } else if(c.Field.FieldType == typeof(int)) { if (c.Field.HasShifterEnumMask()) diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 9540794..45f37d4 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using static ShiftOS.Engine.SkinEngine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [Launcher("Shiftnet", false, null, "Networking")] @@ -62,6 +63,8 @@ namespace ShiftOS.WinForms.Applications { } public string ConstructHtml(string markdown) { + var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC); + var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC); string html = $@" diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 65a8f0f..06a6e8d 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -43,6 +43,7 @@ using System.Collections; using static ShiftOS.Engine.SkinEngine; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -350,8 +351,8 @@ namespace ShiftOS.WinForms.Applications txt.Focus(); txt.Font = LoadedSkin.TerminalFont; - txt.ForeColor = LoadedSkin.TerminalForeColor; - txt.BackColor = LoadedSkin.TerminalBackColor; + txt.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); + txt.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); } @@ -391,8 +392,7 @@ namespace ShiftOS.WinForms.Applications rtbterm.Text = AppearanceManager.LastTerminalText; rtbterm.Select(rtbterm.TextLength, 0); } - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - + TerminalBackend.PrintPrompt(); } @@ -403,8 +403,8 @@ namespace ShiftOS.WinForms.Applications try { rtbterm.Font = LoadedSkin.TerminalFont; - rtbterm.ForeColor = LoadedSkin.TerminalForeColor; - rtbterm.BackColor = LoadedSkin.TerminalBackColor; + rtbterm.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); + rtbterm.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); } catch { diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 43e0b5d..800b107 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -865,12 +865,12 @@ namespace ShiftOS.Engine { [ShifterMeta("System")] [ShifterCategory("General")] [ShifterName("Terminal text color")] - public Color TerminalForeColor = DefaultForeground; + public ConsoleColor TerminalForeColorCC = ConsoleColor.White; [ShifterMeta("System")] [ShifterCategory("General")] [ShifterName("Terminal background color")] - public Color TerminalBackColor = DesktopBG; + public ConsoleColor TerminalBackColorCC = ConsoleColor.Black; [ShifterMeta("Desktop")] [ShifterCategory("Desktop Panel")] diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 841fd6a..5c08cfe 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -286,6 +286,7 @@ namespace ShiftOS.Engine public static void PrintPrompt() { + ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; ConsoleEx.Underline = false; @@ -311,7 +312,7 @@ namespace ShiftOS.Engine Console.Write("$"); ConsoleEx.Italic = false; ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; Console.Write(" "); } -- cgit v1.2.3 From 791290857f6feed7da6b583b8f39cb45698d69e8 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 10:03:28 -0400 Subject: Huge optimizations. Windows load A LOT faster, and Shifter has a preview. --- ShiftOS.WinForms/Applications/Shifter.Designer.cs | 467 +++++++++++++++++++--- ShiftOS.WinForms/Applications/Shifter.cs | 245 +++++++++++- ShiftOS.WinForms/Applications/Shifter.resx | 52 +++ ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs | 51 ++- ShiftOS.WinForms/WindowBorder.cs | 75 ++-- ShiftOS.WinForms/WinformsWindowManager.cs | 4 +- ShiftOS_TheReturn/Skinning.cs | 10 +- 7 files changed, 793 insertions(+), 111 deletions(-) (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.Designer.cs b/ShiftOS.WinForms/Applications/Shifter.Designer.cs index 44045b5..4520e2a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shifter.Designer.cs @@ -52,103 +52,284 @@ namespace ShiftOS.WinForms.Applications /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Shifter)); this.panel1 = new System.Windows.Forms.Panel(); - this.panel4 = new System.Windows.Forms.Panel(); + this.pnlpreview = new System.Windows.Forms.Panel(); + this.pnlwindow = new System.Windows.Forms.Panel(); + this.pnlcontents = new System.Windows.Forms.Panel(); + this.pnltitle = new System.Windows.Forms.Panel(); + this.pnlicon = new System.Windows.Forms.Panel(); + this.pnlminimize = new System.Windows.Forms.Panel(); + this.pnlmaximize = new System.Windows.Forms.Panel(); + this.pnlclose = new System.Windows.Forms.Panel(); + this.pnltitleleft = new System.Windows.Forms.Panel(); + this.pnltitleright = new System.Windows.Forms.Panel(); + this.lbtitletext = new System.Windows.Forms.Label(); + this.pnlbottom = new System.Windows.Forms.Panel(); + this.pnlbottomr = new System.Windows.Forms.Panel(); + this.pnlbottoml = new System.Windows.Forms.Panel(); + this.pnlright = new System.Windows.Forms.Panel(); + this.pnlleft = new System.Windows.Forms.Panel(); + this.pnlsettingsholder = new System.Windows.Forms.Panel(); this.flbody = new System.Windows.Forms.FlowLayoutPanel(); this.flcategory = new System.Windows.Forms.FlowLayoutPanel(); - this.panel3 = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.panel2 = new System.Windows.Forms.Panel(); + this.pnlcategoryholder = new System.Windows.Forms.Panel(); this.flmeta = new System.Windows.Forms.FlowLayoutPanel(); this.btnapply = new System.Windows.Forms.Button(); + this.mspreview = new System.Windows.Forms.MenuStrip(); + this.menuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuItem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuItem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subitem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.separatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator(); + this.menuItem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tspreview = new System.Windows.Forms.ToolStrip(); + this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox(); this.panel1.SuspendLayout(); - this.panel4.SuspendLayout(); - this.panel3.SuspendLayout(); - this.panel2.SuspendLayout(); + this.pnlpreview.SuspendLayout(); + this.pnlwindow.SuspendLayout(); + this.pnlcontents.SuspendLayout(); + this.pnltitle.SuspendLayout(); + this.pnlbottom.SuspendLayout(); + this.pnlsettingsholder.SuspendLayout(); + this.pnlcategoryholder.SuspendLayout(); + this.mspreview.SuspendLayout(); + this.tspreview.SuspendLayout(); this.SuspendLayout(); // // panel1 // - this.panel1.Controls.Add(this.panel4); - this.panel1.Controls.Add(this.panel3); - this.panel1.Controls.Add(this.panel2); + this.panel1.Controls.Add(this.pnlpreview); + this.panel1.Controls.Add(this.pnlsettingsholder); + this.panel1.Controls.Add(this.pnlcategoryholder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(893, 539); this.panel1.TabIndex = 0; // - // panel4 + // pnlpreview // - this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.pnlpreview.Controls.Add(this.pnlwindow); + this.pnlpreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlpreview.Location = new System.Drawing.Point(136, 0); + this.pnlpreview.Name = "pnlpreview"; + this.pnlpreview.Size = new System.Drawing.Size(757, 286); + this.pnlpreview.TabIndex = 1; + // + // pnlwindow + // + this.pnlwindow.Controls.Add(this.pnlcontents); + this.pnlwindow.Controls.Add(this.pnltitle); + this.pnlwindow.Controls.Add(this.pnlbottom); + this.pnlwindow.Controls.Add(this.pnlright); + this.pnlwindow.Controls.Add(this.pnlleft); + this.pnlwindow.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlwindow.Location = new System.Drawing.Point(0, 0); + this.pnlwindow.Name = "pnlwindow"; + this.pnlwindow.Size = new System.Drawing.Size(757, 286); + this.pnlwindow.TabIndex = 0; + // + // pnlcontents + // + this.pnlcontents.BackColor = System.Drawing.Color.Black; + this.pnlcontents.Controls.Add(this.tspreview); + this.pnlcontents.Controls.Add(this.mspreview); + this.pnlcontents.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcontents.ForeColor = System.Drawing.Color.White; + this.pnlcontents.Location = new System.Drawing.Point(2, 30); + this.pnlcontents.Name = "pnlcontents"; + this.pnlcontents.Size = new System.Drawing.Size(753, 254); + this.pnlcontents.TabIndex = 9; + // + // pnltitle + // + this.pnltitle.BackColor = System.Drawing.Color.Black; + this.pnltitle.Controls.Add(this.pnlicon); + this.pnltitle.Controls.Add(this.pnlminimize); + this.pnltitle.Controls.Add(this.pnlmaximize); + this.pnltitle.Controls.Add(this.pnlclose); + this.pnltitle.Controls.Add(this.pnltitleleft); + this.pnltitle.Controls.Add(this.pnltitleright); + this.pnltitle.Controls.Add(this.lbtitletext); + this.pnltitle.Dock = System.Windows.Forms.DockStyle.Top; + this.pnltitle.Location = new System.Drawing.Point(2, 0); + this.pnltitle.Name = "pnltitle"; + this.pnltitle.Size = new System.Drawing.Size(753, 30); + this.pnltitle.TabIndex = 5; + // + // pnlicon + // + this.pnlicon.Location = new System.Drawing.Point(9, -76); + this.pnlicon.Name = "pnlicon"; + this.pnlicon.Size = new System.Drawing.Size(200, 100); + this.pnlicon.TabIndex = 6; + // + // pnlminimize + // + this.pnlminimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlminimize.BackColor = System.Drawing.Color.Green; + this.pnlminimize.Location = new System.Drawing.Point(672, 3); + this.pnlminimize.Name = "pnlminimize"; + this.pnlminimize.Size = new System.Drawing.Size(24, 24); + this.pnlminimize.TabIndex = 3; + // + // pnlmaximize + // + this.pnlmaximize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlmaximize.BackColor = System.Drawing.Color.Yellow; + this.pnlmaximize.Location = new System.Drawing.Point(699, 3); + this.pnlmaximize.Name = "pnlmaximize"; + this.pnlmaximize.Size = new System.Drawing.Size(24, 24); + this.pnlmaximize.TabIndex = 2; + // + // pnlclose + // + this.pnlclose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlclose.BackColor = System.Drawing.Color.Red; + this.pnlclose.Location = new System.Drawing.Point(726, 3); + this.pnlclose.Name = "pnlclose"; + this.pnlclose.Size = new System.Drawing.Size(24, 24); + this.pnlclose.TabIndex = 1; + // + // pnltitleleft + // + this.pnltitleleft.Dock = System.Windows.Forms.DockStyle.Left; + this.pnltitleleft.Location = new System.Drawing.Point(0, 0); + this.pnltitleleft.Name = "pnltitleleft"; + this.pnltitleleft.Size = new System.Drawing.Size(2, 30); + this.pnltitleleft.TabIndex = 4; + // + // pnltitleright + // + this.pnltitleright.Dock = System.Windows.Forms.DockStyle.Right; + this.pnltitleright.Location = new System.Drawing.Point(751, 0); + this.pnltitleright.Name = "pnltitleright"; + this.pnltitleright.Size = new System.Drawing.Size(2, 30); + this.pnltitleright.TabIndex = 5; + // + // lbtitletext + // + this.lbtitletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.panel4.Controls.Add(this.flbody); - this.panel4.Controls.Add(this.flcategory); - this.panel4.Location = new System.Drawing.Point(154, 283); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(734, 253); - this.panel4.TabIndex = 2; + this.lbtitletext.AutoSize = true; + this.lbtitletext.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.lbtitletext.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Bold); + this.lbtitletext.ForeColor = System.Drawing.Color.White; + this.lbtitletext.Location = new System.Drawing.Point(75, 9); + this.lbtitletext.Name = "lbtitletext"; + this.lbtitletext.Size = new System.Drawing.Size(77, 14); + this.lbtitletext.TabIndex = 0; + this.lbtitletext.Text = "Title text"; + this.lbtitletext.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.lbtitletext.UseMnemonic = false; + // + // pnlbottom + // + this.pnlbottom.BackColor = System.Drawing.Color.Black; + this.pnlbottom.Controls.Add(this.pnlbottomr); + this.pnlbottom.Controls.Add(this.pnlbottoml); + this.pnlbottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlbottom.Location = new System.Drawing.Point(2, 284); + this.pnlbottom.Name = "pnlbottom"; + this.pnlbottom.Size = new System.Drawing.Size(753, 2); + this.pnlbottom.TabIndex = 6; + // + // pnlbottomr + // + this.pnlbottomr.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlbottomr.Location = new System.Drawing.Point(751, 0); + this.pnlbottomr.Name = "pnlbottomr"; + this.pnlbottomr.Size = new System.Drawing.Size(2, 2); + this.pnlbottomr.TabIndex = 3; + // + // pnlbottoml + // + this.pnlbottoml.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlbottoml.Location = new System.Drawing.Point(0, 0); + this.pnlbottoml.Name = "pnlbottoml"; + this.pnlbottoml.Size = new System.Drawing.Size(2, 2); + this.pnlbottoml.TabIndex = 2; + // + // pnlright + // + this.pnlright.BackColor = System.Drawing.Color.Black; + this.pnlright.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlright.Location = new System.Drawing.Point(755, 0); + this.pnlright.Name = "pnlright"; + this.pnlright.Size = new System.Drawing.Size(2, 286); + this.pnlright.TabIndex = 8; + // + // pnlleft + // + this.pnlleft.BackColor = System.Drawing.Color.Black; + this.pnlleft.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlleft.Location = new System.Drawing.Point(0, 0); + this.pnlleft.Name = "pnlleft"; + this.pnlleft.Size = new System.Drawing.Size(2, 286); + this.pnlleft.TabIndex = 7; + // + // pnlsettingsholder + // + this.pnlsettingsholder.Controls.Add(this.flbody); + this.pnlsettingsholder.Controls.Add(this.flcategory); + this.pnlsettingsholder.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlsettingsholder.Location = new System.Drawing.Point(136, 286); + this.pnlsettingsholder.Name = "pnlsettingsholder"; + this.pnlsettingsholder.Padding = new System.Windows.Forms.Padding(10); + this.pnlsettingsholder.Size = new System.Drawing.Size(757, 253); + this.pnlsettingsholder.TabIndex = 2; // // flbody // this.flbody.AutoScroll = true; this.flbody.Dock = System.Windows.Forms.DockStyle.Fill; - this.flbody.Location = new System.Drawing.Point(126, 0); + this.flbody.Location = new System.Drawing.Point(136, 10); this.flbody.Name = "flbody"; - this.flbody.Size = new System.Drawing.Size(608, 253); + this.flbody.Size = new System.Drawing.Size(611, 233); this.flbody.TabIndex = 3; // // flcategory // this.flcategory.Dock = System.Windows.Forms.DockStyle.Left; - this.flcategory.Location = new System.Drawing.Point(0, 0); + this.flcategory.Location = new System.Drawing.Point(10, 10); this.flcategory.Name = "flcategory"; - this.flcategory.Size = new System.Drawing.Size(126, 253); + this.flcategory.Size = new System.Drawing.Size(126, 233); this.flcategory.TabIndex = 2; // - // panel3 - // - this.panel3.Controls.Add(this.label1); - this.panel3.Location = new System.Drawing.Point(155, 12); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(640, 360); - this.panel3.TabIndex = 1; - // - // label1 - // - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(640, 360); - this.label1.TabIndex = 0; - this.label1.Text = "Preview not available."; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // pnlcategoryholder // - // panel2 - // - this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.panel2.Controls.Add(this.flmeta); - this.panel2.Controls.Add(this.btnapply); - this.panel2.Location = new System.Drawing.Point(12, 12); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(136, 511); - this.panel2.TabIndex = 0; + this.pnlcategoryholder.Controls.Add(this.flmeta); + this.pnlcategoryholder.Controls.Add(this.btnapply); + this.pnlcategoryholder.Dock = System.Windows.Forms.DockStyle.Left; + this.pnlcategoryholder.Location = new System.Drawing.Point(0, 0); + this.pnlcategoryholder.Name = "pnlcategoryholder"; + this.pnlcategoryholder.Padding = new System.Windows.Forms.Padding(10); + this.pnlcategoryholder.Size = new System.Drawing.Size(136, 539); + this.pnlcategoryholder.TabIndex = 0; // // flmeta // this.flmeta.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.flmeta.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flmeta.Location = new System.Drawing.Point(4, 4); + this.flmeta.Location = new System.Drawing.Point(14, 14); this.flmeta.Name = "flmeta"; - this.flmeta.Size = new System.Drawing.Size(126, 450); + this.flmeta.Size = new System.Drawing.Size(126, 458); this.flmeta.TabIndex = 1; // // btnapply // this.btnapply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnapply.Location = new System.Drawing.Point(3, 460); + this.btnapply.Location = new System.Drawing.Point(13, 478); this.btnapply.Name = "btnapply"; this.btnapply.Size = new System.Drawing.Size(127, 48); this.btnapply.TabIndex = 0; @@ -156,19 +337,155 @@ namespace ShiftOS.WinForms.Applications this.btnapply.UseVisualStyleBackColor = true; this.btnapply.Click += new System.EventHandler(this.btnapply_Click); // + // mspreview + // + this.mspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuToolStripMenuItem}); + this.mspreview.Location = new System.Drawing.Point(0, 0); + this.mspreview.Name = "mspreview"; + this.mspreview.Size = new System.Drawing.Size(753, 24); + this.mspreview.TabIndex = 0; + this.mspreview.Text = "menuStrip1"; + // + // menuToolStripMenuItem + // + this.menuToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuItem1ToolStripMenuItem, + this.menuItem2ToolStripMenuItem, + this.separatorToolStripMenuItem, + this.menuItem3ToolStripMenuItem}); + this.menuToolStripMenuItem.Name = "menuToolStripMenuItem"; + this.menuToolStripMenuItem.Size = new System.Drawing.Size(50, 20); + this.menuToolStripMenuItem.Text = "Menu"; + // + // menuItem1ToolStripMenuItem + // + this.menuItem1ToolStripMenuItem.Name = "menuItem1ToolStripMenuItem"; + this.menuItem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem1ToolStripMenuItem.Text = "Menu Item 1"; + // + // menuItem2ToolStripMenuItem + // + this.menuItem2ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.subitem1ToolStripMenuItem, + this.subitem2ToolStripMenuItem, + this.subitem3ToolStripMenuItem}); + this.menuItem2ToolStripMenuItem.Name = "menuItem2ToolStripMenuItem"; + this.menuItem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem2ToolStripMenuItem.Text = "Menu Item 2"; + // + // subitem1ToolStripMenuItem + // + this.subitem1ToolStripMenuItem.Name = "subitem1ToolStripMenuItem"; + this.subitem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem1ToolStripMenuItem.Text = "Subitem 1"; + // + // subitem2ToolStripMenuItem + // + this.subitem2ToolStripMenuItem.Name = "subitem2ToolStripMenuItem"; + this.subitem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem2ToolStripMenuItem.Text = "Subitem 2"; + // + // subitem3ToolStripMenuItem + // + this.subitem3ToolStripMenuItem.Name = "subitem3ToolStripMenuItem"; + this.subitem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.subitem3ToolStripMenuItem.Text = "Subitem 3"; + // + // separatorToolStripMenuItem + // + this.separatorToolStripMenuItem.Name = "separatorToolStripMenuItem"; + this.separatorToolStripMenuItem.Size = new System.Drawing.Size(149, 6); + // + // menuItem3ToolStripMenuItem + // + this.menuItem3ToolStripMenuItem.Name = "menuItem3ToolStripMenuItem"; + this.menuItem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.menuItem3ToolStripMenuItem.Text = "Menu Item 3"; + // + // tspreview + // + this.tspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripLabel1, + this.toolStripButton2, + this.toolStripButton3, + this.toolStripButton1, + this.toolStripSeparator1, + this.toolStripTextBox1}); + this.tspreview.Location = new System.Drawing.Point(0, 24); + this.tspreview.Name = "tspreview"; + this.tspreview.Size = new System.Drawing.Size(753, 25); + this.tspreview.TabIndex = 1; + this.tspreview.Text = "toolStrip1"; + // + // toolStripLabel1 + // + this.toolStripLabel1.Name = "toolStripLabel1"; + this.toolStripLabel1.Size = new System.Drawing.Size(81, 22); + this.toolStripLabel1.Text = "Toolbar Label:"; + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton1.Enabled = false; + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(56, 22); + this.toolStripButton1.Text = "Disabled"; + // + // toolStripButton2 + // + this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Size = new System.Drawing.Size(51, 22); + this.toolStripButton2.Text = "Regular"; + // + // toolStripButton3 + // + this.toolStripButton3.Checked = true; + this.toolStripButton3.CheckState = System.Windows.Forms.CheckState.Checked; + this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); + this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton3.Name = "toolStripButton3"; + this.toolStripButton3.Size = new System.Drawing.Size(57, 22); + this.toolStripButton3.Text = "Checked"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // toolStripTextBox1 + // + this.toolStripTextBox1.Name = "toolStripTextBox1"; + this.toolStripTextBox1.Size = new System.Drawing.Size(100, 25); + // // Shifter // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.panel1); this.Name = "Shifter"; - this.Text = "{SHIFTER_NAME}"; this.Size = new System.Drawing.Size(893, 539); this.Load += new System.EventHandler(this.Shifter_Load); this.panel1.ResumeLayout(false); - this.panel4.ResumeLayout(false); - this.panel3.ResumeLayout(false); - this.panel2.ResumeLayout(false); + this.pnlpreview.ResumeLayout(false); + this.pnlwindow.ResumeLayout(false); + this.pnlcontents.ResumeLayout(false); + this.pnlcontents.PerformLayout(); + this.pnltitle.ResumeLayout(false); + this.pnltitle.PerformLayout(); + this.pnlbottom.ResumeLayout(false); + this.pnlsettingsholder.ResumeLayout(false); + this.pnlcategoryholder.ResumeLayout(false); + this.mspreview.ResumeLayout(false); + this.mspreview.PerformLayout(); + this.tspreview.ResumeLayout(false); + this.tspreview.PerformLayout(); this.ResumeLayout(false); } @@ -176,13 +493,43 @@ namespace ShiftOS.WinForms.Applications #endregion private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel pnlcategoryholder; private System.Windows.Forms.FlowLayoutPanel flmeta; private System.Windows.Forms.Button btnapply; - private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.Panel pnlsettingsholder; private System.Windows.Forms.FlowLayoutPanel flbody; private System.Windows.Forms.FlowLayoutPanel flcategory; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel pnlpreview; + private System.Windows.Forms.Panel pnlwindow; + private System.Windows.Forms.Panel pnlcontents; + private System.Windows.Forms.Panel pnltitle; + private System.Windows.Forms.Panel pnlicon; + private System.Windows.Forms.Panel pnlminimize; + private System.Windows.Forms.Panel pnlmaximize; + private System.Windows.Forms.Panel pnlclose; + private System.Windows.Forms.Panel pnltitleleft; + private System.Windows.Forms.Panel pnltitleright; + private System.Windows.Forms.Label lbtitletext; + private System.Windows.Forms.Panel pnlbottom; + private System.Windows.Forms.Panel pnlbottomr; + private System.Windows.Forms.Panel pnlbottoml; + private System.Windows.Forms.Panel pnlright; + private System.Windows.Forms.Panel pnlleft; + private System.Windows.Forms.MenuStrip mspreview; + private System.Windows.Forms.ToolStripMenuItem menuToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subitem3ToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem menuItem3ToolStripMenuItem; + private System.Windows.Forms.ToolStrip tspreview; + private System.Windows.Forms.ToolStripLabel toolStripLabel1; + private System.Windows.Forms.ToolStripButton toolStripButton2; + private System.Windows.Forms.ToolStripButton toolStripButton3; + private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripTextBox toolStripTextBox1; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 02e2d0a..e7ad768 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -47,6 +47,193 @@ namespace ShiftOS.WinForms.Applications PopulateShifter(); } + [ShifterMeta("Windows")] + public void SetupWindowPreview() + { + pnlwindow.BringToFront(); + WBSetup(); + } + + [ShifterMeta("Menus")] + public void SetupMenusPreview() + { + SetupWindowPreview(); + } + + [ShifterMeta("System")] + public void SetupSystemPreview() + { + SetupWindowPreview(); + } + + /// + /// Setup this instance. + /// + public void WBSetup() + { + this.lbtitletext.Text = "Window Preview"; + + if (SaveSystem.CurrentSave != null) + { + this.pnltitle.Visible = Shiftorium.UpgradeInstalled("wm_titlebar"); + this.pnlclose.Visible = Shiftorium.UpgradeInstalled("close_button"); + this.pnlminimize.Visible = Shiftorium.UpgradeInstalled("minimize_button"); + this.pnlmaximize.Visible =Shiftorium.UpgradeInstalled("maximize_button"); + WBSetupSkin(); + } + else + { + this.pnltitle.Visible = false; + this.pnlclose.Visible = false; + this.pnlminimize.Visible = false; + this.pnlmaximize.Visible = false; + + } + } + + public Image GetImage(string id) + { + var type = typeof(ShiftOS.Engine.Skin); + foreach(var field in type.GetFields(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attrib in field.GetCustomAttributes(false)) + { + if(attrib is ImageAttribute) + { + var img = attrib as ImageAttribute; + if(img.Name == id) + { + return SkinEngine.ImageFromBinary((byte[])field.GetValue(LoadedSkin)); + } + } + } + } + return null; + } + + public ImageLayout GetImageLayout(string img) + { + if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) + { + return LoadedSkin.SkinImageLayouts[img]; + } + else + { + LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); + return ImageLayout.Tile; + } + + } + + /// + /// Setups the skin. + /// + /// The skin. + public void WBSetupSkin() + { + this.DoubleBuffered = true; + var renderer = new ShiftOSMenuRenderer(LoadedSkin); + mspreview.Renderer = renderer; + tspreview.Renderer = renderer; + pnltitle.Height = LoadedSkin.TitlebarHeight; + pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; + pnltitle.BackgroundImage = GetImage("titlebar"); + pnltitleleft.Visible = LoadedSkin.ShowTitleCorners; + pnltitleright.Visible = LoadedSkin.ShowTitleCorners; + pnltitleleft.BackColor = LoadedSkin.TitleLeftCornerBackground; + pnltitleright.BackColor = LoadedSkin.TitleRightCornerBackground; + pnltitleleft.Width = LoadedSkin.TitleLeftCornerWidth; + pnltitleright.Width = LoadedSkin.TitleRightCornerWidth; + pnltitleleft.BackgroundImage = GetImage("titleleft"); + pnltitleleft.BackgroundImageLayout = GetImageLayout("titleleft"); + pnltitleright.BackgroundImage = GetImage("titleright"); + pnltitleright.BackgroundImageLayout = GetImageLayout("titleright"); + pnltitle.BackgroundImageLayout = GetImageLayout("titlebar"); //RETARD ALERT. WHY WASN'T THIS THERE WHEN IMAGELAYOUTS WERE FIRST IMPLEMENTED? + + lbtitletext.BackColor = (pnltitle.BackgroundImage != null) ? Color.Transparent : LoadedSkin.TitleBackgroundColor; + lbtitletext.ForeColor = LoadedSkin.TitleTextColor; + lbtitletext.Font = LoadedSkin.TitleFont; + + pnlleft.BackColor = LoadedSkin.BorderLeftBackground; + pnlleft.BackgroundImage = GetImage("leftborder"); + pnlleft.BackgroundImageLayout = GetImageLayout("leftborder"); + pnlleft.Width = LoadedSkin.LeftBorderWidth; + pnlright.BackColor = LoadedSkin.BorderRightBackground; + pnlright.BackgroundImage = GetImage("rightborder"); + pnlright.BackgroundImageLayout = GetImageLayout("rightborder"); + pnlright.Width = LoadedSkin.RightBorderWidth; + + pnlbottom.BackColor = LoadedSkin.BorderBottomBackground; + pnlbottom.BackgroundImage = GetImage("bottomborder"); + pnlbottom.BackgroundImageLayout = GetImageLayout("bottomborder"); + pnlbottom.Height = LoadedSkin.BottomBorderWidth; + + pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; + pnlbottomr.BackgroundImage = GetImage("bottomrborder"); + pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); + pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; + pnlbottoml.BackgroundImage = GetImage("bottomlborder"); + pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); + + lbtitletext.ForeColor = LoadedSkin.TitleTextColor; + lbtitletext.Font = LoadedSkin.TitleFont; + pnlclose.BackColor = LoadedSkin.CloseButtonColor; + pnlclose.BackgroundImage = GetImage("closebutton"); + pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); + pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; + pnlminimize.BackgroundImage = GetImage("minimizebutton"); + pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); + pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; + pnlmaximize.BackgroundImage = GetImage("maximizebutton"); + pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); + + pnlclose.Size = LoadedSkin.CloseButtonSize; + pnlminimize.Size = LoadedSkin.MinimizeButtonSize; + pnlmaximize.Size = LoadedSkin.MaximizeButtonSize; + pnlclose.Location = FromRight(LoadedSkin.CloseButtonFromSide); + pnlminimize.Location = FromRight(LoadedSkin.MinimizeButtonFromSide); + pnlmaximize.Location = FromRight(LoadedSkin.MaximizeButtonFromSide); + pnlclose.Left -= pnlclose.Width; + pnlmaximize.Left -= pnlmaximize.Width; + pnlminimize.Left -= pnlminimize.Width; + + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } + + if (Shiftorium.UpgradeInstalled("app_icons")) + { + pnlicon.Show(); + pnlicon.Size = new Size(16, 16); + pnlicon.BackColor = Color.Transparent; + pnlicon.BackgroundImageLayout = ImageLayout.Stretch; + pnlicon.Location = LoadedSkin.TitlebarIconFromSide; + } + else + { + pnlicon.Hide(); + } + } + + /// + /// Froms the right. + /// + /// The right. + /// Input. + public Point FromRight(Point input) + { + return new Point(pnltitle.Width - input.X, input.Y); + } + + public int CodepointValue = 0; public List settings = new List(); public Skin LoadedSkin = null; @@ -123,6 +310,21 @@ namespace ShiftOS.WinForms.Applications btn.FlatStyle = FlatStyle.Flat; btn.Click += (o, a) => { + foreach(var mth in this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attrib in mth.GetCustomAttributes(false)) + { + if(attrib is ShifterMetaAttribute) + { + var meta = attrib as ShifterMetaAttribute; + if(meta.Meta == btn.Text) + { + mth?.Invoke(this, null); + } + } + } + } + PopulateSubcategories(c); }; @@ -164,6 +366,21 @@ namespace ShiftOS.WinForms.Applications } } + public void InvokeSetup(string cat) + { + foreach(var mth in this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)) + { + foreach(var attr in mth.GetCustomAttributes(false)) + { + if(attr is ShifterMetaAttribute) + { + if ((attr as ShifterMetaAttribute).Meta == cat) + mth.Invoke(this, null); + } + } + } + } + public void PopulateBody(string cat, string subcat) { flbody.Controls.Clear(); @@ -233,6 +450,7 @@ namespace ShiftOS.WinForms.Applications width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); } + InvokeSetup(cat); }; width.TextChanged += tc; @@ -247,7 +465,12 @@ namespace ShiftOS.WinForms.Applications 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; }; + str.TextChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + + InvokeSetup(cat); + }; flbody.Controls.Add(str); str.Show(); } @@ -271,6 +494,8 @@ namespace ShiftOS.WinForms.Applications color.BackgroundImageLayout = layout; LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; CodepointValue += 700; + InvokeSetup(cat); + }))); }; flbody.Controls.Add(color); @@ -316,6 +541,8 @@ namespace ShiftOS.WinForms.Applications width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); } + InvokeSetup(cat); + }; width.TextChanged += tc; @@ -331,6 +558,8 @@ namespace ShiftOS.WinForms.Applications { c.Field.SetValue(LoadedSkin, check.Checked); CodepointValue += 50; + InvokeSetup(cat); + }; flbody.SetFlowBreak(check, true); @@ -377,6 +606,8 @@ namespace ShiftOS.WinForms.Applications c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); CodepointValue += 100; + InvokeSetup(cat); + }; style.SelectedIndexChanged += (o, a) => @@ -387,6 +618,8 @@ namespace ShiftOS.WinForms.Applications c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); CodepointValue += 50; + InvokeSetup(cat); + }; size.TextChanged += (o, a) => @@ -404,6 +637,8 @@ namespace ShiftOS.WinForms.Applications size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); } CodepointValue += 50; + InvokeSetup(cat); + }; flbody.Controls.Add(name); @@ -434,6 +669,8 @@ namespace ShiftOS.WinForms.Applications { color.BackColor = col; CodepointValue += 300; + InvokeSetup(cat); + }))); }; flbody.SetFlowBreak(color, true); @@ -457,6 +694,8 @@ namespace ShiftOS.WinForms.Applications cBox.SelectedIndexChanged += (o, a) => { c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + InvokeSetup(cat); + }; labelHeight = cBox.Height; @@ -482,6 +721,8 @@ namespace ShiftOS.WinForms.Applications { c.Field.SetValue(LoadedSkin, name.SelectedIndex); CodepointValue += 75; + InvokeSetup(cat); + }; labelHeight = name.Height; flbody.Controls.Add(name); @@ -517,6 +758,8 @@ namespace ShiftOS.WinForms.Applications { width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); } + InvokeSetup(cat); + }; width.TextChanged += tc; diff --git a/ShiftOS.WinForms/Applications/Shifter.resx b/ShiftOS.WinForms/Applications/Shifter.resx index 1af7de1..f16904f 100644 --- a/ShiftOS.WinForms/Applications/Shifter.resx +++ b/ShiftOS.WinForms/Applications/Shifter.resx @@ -117,4 +117,56 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 127, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs index 28623ef..a31edd9 100644 --- a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs +++ b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs @@ -28,16 +28,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; -using static ShiftOS.Engine.SkinEngine; +using ShiftOS.Engine; using System.Windows.Forms; namespace ShiftOS.WinForms.Tools { public class ShiftOSMenuRenderer : ToolStripProfessionalRenderer { - public ShiftOSMenuRenderer() : base(new ShiftOSColorTable()) + public ShiftOSMenuRenderer() : base(new ShiftOSColorTable(ShiftOS.Engine.SkinEngine.LoadedSkin)) { - + } public ShiftOSMenuRenderer(ProfessionalColorTable table) : base(table) @@ -45,6 +45,26 @@ namespace ShiftOS.WinForms.Tools } + public ShiftOSMenuRenderer(Skin skn) : base(new ShiftOSColorTable(skn)) + { + + } + + public Skin LoadedSkin + { + get + { + if(ColorTable is ShiftOSColorTable) + { + return (ColorTable as ShiftOSColorTable).LoadedSkin; + } + else + { + return SkinEngine.LoadedSkin; + } + } + } + protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (e.Item.Tag?.ToString() == "applauncherbutton") @@ -99,6 +119,18 @@ namespace ShiftOS.WinForms.Tools public class ShiftOSColorTable : ProfessionalColorTable { + public ShiftOSColorTable(ShiftOS.Engine.Skin skn) + { + LoadedSkin = skn; + } + + public Skin LoadedSkin { get; private set; } + + public Image GetImage(string id) + { + return SkinEngine.GetImage(id); + } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } @@ -327,6 +359,19 @@ namespace ShiftOS.WinForms.Tools public class AppLauncherColorTable : ProfessionalColorTable { + public Image GetImage(string id) + { + return SkinEngine.GetImage(id); + } + + public Skin LoadedSkin + { + get + { + return SkinEngine.LoadedSkin; + } + } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 4fba470..4babbbd 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -129,7 +129,6 @@ namespace ShiftOS.WinForms this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; - this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); ParentWindow.OnSkinLoad(); @@ -139,9 +138,40 @@ namespace ShiftOS.WinForms Setup(); ParentWindow.OnUpgrade(); }; + Setup(); + this._parentWindow.TextChanged += (o, a) => + { + Setup(); + Desktop.ResetPanelButtons(); + + }; + + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - Desktop.ShowWindow(this); + if (!this.IsDialog) + { + Engine.AppearanceManager.OpenForms.Add(this); + } + SaveSystem.GameReady += () => + { + if (Shiftorium.UpgradeInstalled("wm_free_placement")) + { + AppearanceManager.Invoke(new Action(() => + { + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; + + })); + } + AppearanceManager.Invoke(new Action(() => + { + Setup(); + })); + }; + + ParentWindow.OnLoad(); } /// @@ -178,46 +208,7 @@ namespace ShiftOS.WinForms public void WindowBorder_Load(object sender, EventArgs e) { this.DoubleBuffered = true; - - this._parentWindow.TextChanged += (o, a) => - { - Setup(); - Desktop.ResetPanelButtons(); - - }; - - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - if (!this.IsDialog) - { - Engine.AppearanceManager.OpenForms.Add(this); - } - - SaveSystem.GameReady += () => - { - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - AppearanceManager.Invoke(new Action(() => - { - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - })); - } - AppearanceManager.Invoke(new Action(() => - { - Setup(); - })); - }; - - ControlManager.SetupControls(this); - - Setup(); - - var sWin = (IShiftOSWindow)ParentWindow; - - sWin.OnLoad(); + this._parentWindow.Show(); } /// diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index cfcb6d3..4fcd185 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -120,8 +120,7 @@ namespace ShiftOS.WinForms var wb = new WindowBorder(form as UserControl); wb.IsDialog = true; - - wb.Show(); + Desktop.ShowWindow(wb); } public override void SetupWindow(IShiftOSWindow form) @@ -213,6 +212,7 @@ namespace ShiftOS.WinForms wb.FormClosed -= onClose; }; wb.FormClosed += onClose; + Desktop.ShowWindow(wb); SetupWindows(); } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 800b107..48b7c0b 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -64,10 +64,14 @@ namespace ShiftOS.Engine { public static class SkinEngine { - public static ImageLayout GetImageLayout(string img) { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) { + public static ImageLayout GetImageLayout(string img) + { + if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) + { return LoadedSkin.SkinImageLayouts[img]; - } else { + } + else + { LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); return ImageLayout.Tile; } -- 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_TheReturn/Skinning.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 e05fc88500525e8c9b9e497e91aa7b9d04996019 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Apr 2017 09:25:17 -0400 Subject: Add sizing of applauncher elements --- .../DesktopWidgets/UpgradePercentage.Designer.cs | 75 +++++++++++++ .../DesktopWidgets/UpgradePercentage.cs | 41 +++++++ .../DesktopWidgets/UpgradePercentage.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS.WinForms/WinformsDesktop.cs | 8 ++ ShiftOS_TheReturn/Skinning.cs | 36 +++++++ 6 files changed, 289 insertions(+) create mode 100644 ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.resx (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs new file mode 100644 index 0000000..ca0d587 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs @@ -0,0 +1,75 @@ +namespace ShiftOS.WinForms.DesktopWidgets +{ + partial class UpgradePercentage + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pgupgrades = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.lbstatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // 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; + // + // lbstatus + // + this.lbstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbstatus.Location = new System.Drawing.Point(0, 0); + this.lbstatus.Name = "lbstatus"; + this.lbstatus.Size = new System.Drawing.Size(227, 99); + this.lbstatus.TabIndex = 1; + this.lbstatus.Text = "label1"; + this.lbstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // UpgradePercentage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbstatus); + this.Controls.Add(this.pgupgrades); + this.Name = "UpgradePercentage"; + this.Size = new System.Drawing.Size(227, 122); + this.ResumeLayout(false); + + } + + #endregion + + private Controls.ShiftedProgressBar pgupgrades; + private System.Windows.Forms.Label lbstatus; + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.cs b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.cs new file mode 100644 index 0000000..e7dec94 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.DesktopWidgets +{ + [DesktopWidget("Shiftorium Status", "Show how much upgrades you have and how much are available.")] + public partial class UpgradePercentage : UserControl, IDesktopWidget + { + public UpgradePercentage() + { + InitializeComponent(); + } + + public void OnSkinLoad() + { + ControlManager.SetupControl(lbstatus); + pgupgrades.Refresh(); + } + + public void OnUpgrade() + { + + pgupgrades.Maximum = Shiftorium.GetDefaults().Count; + pgupgrades.Value = SaveSystem.CurrentSave.CountUpgrades(); + lbstatus.Text = $"You have unlocked {pgupgrades.Value} upgrades out of the {pgupgrades.Maximum} available."; + } + + public void Setup() + { + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.resx b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9dc3593..915543f 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -264,6 +264,12 @@ Clock.cs + + UserControl + + + UpgradePercentage.cs + UserControl @@ -413,6 +419,9 @@ Clock.cs + + UpgradePercentage.cs + DownloadControl.cs diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index c458a4a..d15c04d 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -604,6 +604,14 @@ namespace ShiftOS.WinForms btnshutdown.Font = LoadedSkin.ShutdownFont; btnshutdown.ForeColor = LoadedSkin.ShutdownForeColor; + + pnladvancedal.Size = LoadedSkin.AALSize; + + pnlalsystemactions.Height = LoadedSkin.ALSystemActionHeight; + pnlstatus.Height = LoadedSkin.ALSystemStatusHeight; + + flcategories.Width = LoadedSkin.AALCategoryViewWidth; + this.flapps.Width = LoadedSkin.AALItemViewWidth; } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index cee18d8..4cc9bbd 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -1115,6 +1115,42 @@ namespace ShiftOS.Engine [ShifterDescription("What part of the panel should the status text stick to?")] public ContentAlignment ALStatusPanelAlignment = ContentAlignment.MiddleCenter; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("AL System Status Height")] + [ShifterDescription("Set the height of the top system status bar in the App Launcher.")] + public int ALSystemStatusHeight = 50; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("AL Size")] + [ShifterDescription("Set the size of the App Launcher's container")] + public Size AALSize = new Size(425, 500); + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("AL Category View Width")] + [ShifterDescription("Set the width of the left Category Listing on the app launcher.")] + public int AALCategoryViewWidth = 237; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("AL Item List Width")] + [ShifterDescription("Set the width of the item list in the app launcher.")] + public int AALItemViewWidth = 237; + + [ShifterMeta("Desktop")] + [ShifterCategory("App Launcher")] + [RequiresUpgrade("shift_advanced_app_launcher")] + [ShifterName("AL System Actions Height")] + [ShifterDescription("Set the height of the bottom system actions bar in the App Launcher.")] + public int ALSystemActionHeight = 30; + [ShifterMeta("Desktop")] [ShifterCategory("App Launcher")] [RequiresUpgrade("skinning;shift_advanced_app_launcher")] -- cgit v1.2.3 From d0d193bb1b869697d633d7ccac35179241f8e981 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 19:24:57 -0400 Subject: GUI-based login screen with skinning! --- ShiftOS.WinForms/GUILogin.Designer.cs | 135 ++++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.cs | 131 +++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.resx | 120 ++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS_TheReturn/LoginManager.cs | 65 ++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 120 +++++++++++++++----------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 ++++ 10 files changed, 555 insertions(+), 50 deletions(-) create mode 100644 ShiftOS.WinForms/GUILogin.Designer.cs create mode 100644 ShiftOS.WinForms/GUILogin.cs create mode 100644 ShiftOS.WinForms/GUILogin.resx create mode 100644 ShiftOS_TheReturn/LoginManager.cs (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..9125d98 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -0,0 +1,135 @@ +namespace ShiftOS.WinForms +{ + partial class GUILogin + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pnlloginform = new System.Windows.Forms.Panel(); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.lblogintitle = new System.Windows.Forms.Label(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlloginform.SuspendLayout(); + this.SuspendLayout(); + // + // pnlloginform + // + this.pnlloginform.Controls.Add(this.btnlogin); + this.pnlloginform.Controls.Add(this.txtpassword); + this.pnlloginform.Controls.Add(this.txtusername); + this.pnlloginform.Location = new System.Drawing.Point(13, 13); + this.pnlloginform.Name = "pnlloginform"; + this.pnlloginform.Size = new System.Drawing.Size(358, 236); + this.pnlloginform.TabIndex = 0; + this.pnlloginform.Tag = ""; + // + // btnlogin + // + this.btnlogin.AutoSize = true; + this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnlogin.Location = new System.Drawing.Point(129, 184); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(43, 23); + this.btnlogin.TabIndex = 2; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(24, 157); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(301, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(24, 131); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(301, 20); + this.txtusername.TabIndex = 0; + // + // lblogintitle + // + this.lblogintitle.AutoSize = true; + this.lblogintitle.Location = new System.Drawing.Point(99, 553); + this.lblogintitle.Name = "lblogintitle"; + this.lblogintitle.Size = new System.Drawing.Size(103, 13); + this.lblogintitle.TabIndex = 1; + this.lblogintitle.Tag = "header1 keepbg"; + this.lblogintitle.Text = "Welcome to ShiftOS"; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.Location = new System.Drawing.Point(924, 652); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(65, 23); + this.btnshutdown.TabIndex = 2; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); + // + // GUILogin + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(1001, 687); + this.Controls.Add(this.btnshutdown); + this.Controls.Add(this.lblogintitle); + this.Controls.Add(this.pnlloginform); + this.ForeColor = System.Drawing.Color.White; + this.Name = "GUILogin"; + this.Text = "GUILogin"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GUILogin_FormClosing); + this.Load += new System.EventHandler(this.GUILogin_Load); + this.pnlloginform.ResumeLayout(false); + this.pnlloginform.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel pnlloginform; + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label lblogintitle; + private System.Windows.Forms.Button btnshutdown; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs new file mode 100644 index 0000000..66ff06d --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms +{ + public partial class GUILogin : Form + { + public GUILogin() + { + InitializeComponent(); + uiTimer.Tick += (o, a) => + { + btnlogin.Left = txtusername.Left + ((txtusername.Width - btnlogin.Width) / 2); + btnlogin.Top = txtpassword.Top + txtpassword.Height + 5; + + lblogintitle.Left = pnlloginform.Left + ((pnlloginform.Width - lblogintitle.Width) / 2); + lblogintitle.Top = pnlloginform.Top - lblogintitle.Width - 5; + + }; + uiTimer.Interval = 100; + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Maximized; + this.TopMost = true; + } + + Timer uiTimer = new Timer(); + + public event Action LoginComplete; + + private void GUILogin_Load(object sender, EventArgs e) + { + uiTimer.Start(); + ControlManager.SetupControl(lblogintitle); + ControlManager.SetupControls(pnlloginform); + ControlManager.SetupControl(btnshutdown); + pnlloginform.CenterParent(); + this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; + this.BackgroundImage = SkinEngine.GetImage("login"); + this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); + } + + private ClientSave User = null; + + bool userRequestClose = true; + bool shuttingdown = false; + + private void GUILogin_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = userRequestClose; + if (!e.Cancel) + { + uiTimer.Stop(); + if (shuttingdown == false) + { + LoginComplete?.Invoke(User); + } + } + } + + private void btnlogin_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtusername.Text)) + { + Infobox.Show("Enter a username", "You must enter your username to login."); + return; + } + + //Don't check for blank passwords. + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == txtusername.Text); + if(user == null) + { + Infobox.Show("Invalid username", "That username was not found on your system."); + return; + } + + if (user.Password != txtpassword.Text) + { + Infobox.Show("Access denied.", "That password didn't work. Please try a different one."); + return; + } + + User = user; + userRequestClose = false; + shuttingdown = false; + this.Close(); + } + + private void btnshutdown_Click(object sender, EventArgs e) + { + userRequestClose = false; + shuttingdown = true; + this.Close(); + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + TerminalBackend.InvokeCommand("sos.shutdown"); + } + } + + public class GUILoginFrontend : ILoginFrontend + { + public bool UseGUILogin + { + get + { + return Shiftorium.UpgradeInstalled("gui_based_login_screen"); + } + } + + public event Action LoginComplete; + + public void Login() + { + var lform = new GUILogin(); + lform.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + lform.Show(); + } + } +} diff --git a/ShiftOS.WinForms/GUILogin.resx b/ShiftOS.WinForms/GUILogin.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b2f064d..ad8fc83 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index b528c72..c3d27ae 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,13 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "GUI Based Login Screen", + Cost: 500, + Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", + Dependencies: "skinning;desktop;wm_free_placement", + Category: "Kernel & System" + }, { Name: "Shift Screensavers", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1607ae9..411d701 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -323,6 +323,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -520,6 +526,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs new file mode 100644 index 0000000..d326f2c --- /dev/null +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public static class LoginManager + { + private static ILoginFrontend _login = null; + + public static void Init(ILoginFrontend login) + { + _login = login; + } + + public static void PromptForLogin() + { + _login.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + _login.Login(); + } + + public static bool ShouldUseGUILogin + { + get + { + if (_login == null) + return false; + return _login.UseGUILogin; + } + } + + public static event Action LoginComplete; + } + + /// + /// Interface for GUI-based logins. + /// + public interface ILoginFrontend + { + /// + /// When implemented, shows the login UI. + /// + void Login(); + + /// + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// + bool UseGUILogin { get; } + + + /// + /// Occurs when the login is complete. + /// + event Action LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f29e5b8..93a8add 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -263,70 +263,90 @@ namespace ShiftOS.Engine TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) { - if (progress == 0) + Action Completed = null; + Completed += (user) => { - if (!string.IsNullOrWhiteSpace(text)) + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else + { + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + if (!string.IsNullOrWhiteSpace(text)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; progress++; + } + else + { + Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; - return; + goback = true; + progress++; } - username = text; - progress++; } - else + else if (progress == 1) { - Console.WriteLine("Username not provided."); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } TerminalBackend.TextSent -= ev; - goback = true; - progress++; } - } - else if (progress == 1) + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while (progress == 0) { - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; + Thread.Sleep(10); } - }; - TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); - while(progress == 0) - { - Thread.Sleep(10); + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; } - if (goback) - goto Login; - Console.WriteLine("password:"); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index fb33dc5..3b5eadd 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -111,6 +111,7 @@ + diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4cc9bbd..b731c4f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -267,6 +267,22 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("gui_based_login_screen")] + [ShifterName("Login Screen Background Color")] + [ShifterDescription("Change the background color of the login screen.")] + public Color LoginScreenColor = Skin.DesktopBG; + + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("skinning;gui_based_login_screen")] + [ShifterName("Login Screen Background Image")] + [ShifterDescription("Set an image as your login screen!")] + [Image("login")] + public byte[] LoginScreenBG = null; + + [RequiresUpgrade("shift_screensaver")] [ShifterMeta("System")] [ShifterCategory("Screen saver")] -- cgit v1.2.3 From c18c0fbc325b1c6a0864f88c6e2f4d2889d62e18 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 20:32:28 -0400 Subject: dithering revamp --- ShiftOS.WinForms/Applications/Shifter.cs | 5 +- ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Tools/DitheringEngine.cs | 195 +++++++++++++----------------- ShiftOS.WinForms/WinformsDesktop.cs | 5 +- ShiftOS_TheReturn/Commands.cs | 17 +++ ShiftOS_TheReturn/Skinning.cs | 19 +++ 6 files changed, 123 insertions(+), 119 deletions(-) (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 05ba638..edc3703 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -139,10 +139,7 @@ namespace ShiftOS.WinForms.Applications 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.BackgroundImage = SkinEngine.GetImage("desktopbackground"); pnldesktoppreview.BackgroundImageLayout = GetImageLayout("desktopbackground"); desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 256894d..73215d4 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + SkinEngine.SetPostProcessor(new DitheringSkinPostProcessor()); SaveSystem.PreDigitalSocietyConnection += () => { Action completed = null; diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs index 8509a0b..f96a45a 100644 --- a/ShiftOS.WinForms/Tools/DitheringEngine.cs +++ b/ShiftOS.WinForms/Tools/DitheringEngine.cs @@ -33,6 +33,7 @@ using System.Drawing; using System.Threading; using ShiftOS.Engine; using System.Runtime.InteropServices; +using System.IO; namespace ShiftOS.WinForms.Tools { @@ -101,7 +102,7 @@ namespace ShiftOS.WinForms.Tools } } - public static void DitherColor(Color source, int width, int height, Action result) + public static Image DitherColor(Color source, int width, int height) { var bmp = new Bitmap(width + 1, height + 1); var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); @@ -115,7 +116,7 @@ namespace ShiftOS.WinForms.Tools } Marshal.Copy(rgb, 0, data.Scan0, rgb.Length); bmp.UnlockBits(data); - DitherImage(bmp, result); + return DitherImage(bmp); } @@ -226,15 +227,8 @@ namespace ShiftOS.WinForms.Tools #endif #if FLOYDSTEINBERG - public static void DitherImage(Image source, Action result) + public static Image DitherImage(Image source) { - if (source == null) - { - result?.Invoke(source); - return; - } - - var bmp = new Bitmap(source.Width, source.Height); var sourceBmp = (Bitmap)source; var sourceLck = sourceBmp.LockBits(new Rectangle(0, 0, sourceBmp.Width, sourceBmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); @@ -267,121 +261,80 @@ namespace ShiftOS.WinForms.Tools bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering"); bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering"); - for (int y = 0; y < (destLck.Height); y++) + if (!sixteenBits) { - for (int x = 0; x < (Math.Abs(destLck.Stride)); x += 3) + if (dithering == true) { - int i = getIndexFromXY(x, y, width); - byte red = sourceArr[i]; - byte green = sourceArr[i + 1]; - byte blue = sourceArr[i + 2]; - - Color oldc = Color.FromArgb(red, green, blue); - Color newc; - - if (sixteenBits) + if (false == true) { - newc = GetColor(oldc); + } else { - int gray = ((oldc.R + oldc.G + oldc.B) / 3); - - byte newgray = 0; - - if (dithering && !color_depth_floydsteinberg) - gray += error_r; - - - - if (eightBits) + int error = 0; + for (int i = 0; i < destArr.Length; i += 3) { - newgray = (byte)gray; - error_r = 0; - } - else if(sixBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0x3F) * 3); - error_r = newgray - gray; - } - else if (fourBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0xF) * 0xF); - error_r = newgray - gray; - } - else if (twoBits) - { - if (gray >= 191) - newgray = 0xFF; - else if (gray >= 127) - newgray = Color.LightGray.R; - else if (gray >= 64) - newgray = Color.DarkGray.R; - else - newgray = 0x00; - error_r = newgray - gray; - } - else - { - if (gray >= 127) - newgray = 0xFF; - else - newgray = 0x00; - error_r = newgray - gray; - } - newc = Color.FromArgb(newgray, newgray, newgray); - } + byte r = sourceArr[i]; + byte g = sourceArr[i + 1]; + byte b = sourceArr[i + 2]; - int nextIndex = getIndexFromXY(x + 3, y, width); - int nextRow = getIndexFromXY(x, y + 1, width); - int nextIndexOnNextRow = getIndexFromXY(x + 3, y + 1, width); - int prevIndexOnNextRow = getIndexFromXY(x - 3, y + 1, width); - - grays[i] = newc.R; - grays[i + 1] = newc.G; - grays[i + 2] = newc.B; - - if (dithering) - { - if (color_depth_floydsteinberg) - { - if (x + 3 < width) + int gray = (((r + g + b) / 3) + error); + int newgray = gray; + if (!eightBits) { - sourceArr[nextIndex] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 1] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 2] += (byte)((error_r * 7) / 16); - } - if (y + 1 < height) - { - sourceArr[nextRow] += (byte)((error_r) / 16); - sourceArr[nextRow + 1] += (byte)((error_r) / 16); - sourceArr[nextRow + 2] += (byte)((error_r) / 16); - } - if (x + 3 < width && y + 1 < height) - { - sourceArr[nextIndexOnNextRow] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 1] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 2] += (byte)((error_r * 3) / 16); - + if (sixBits) + { + newgray = gray >> 2; + } + else + { + if (fourBits) + { + newgray = (int)linear(gray, 0, 255, 0, 63) * 4; + } + else + { + if (twoBits) + { + if (gray > 127 + 63) + { + newgray = 255; + } + else if (gray > 127) + newgray = 127 + 63; + else if (gray > 63) + { + newgray = 127; + } + else if (gray > 0) + newgray = 63; + else + newgray = 0; + } + else + { + if (gray > 127) + newgray = 255; + else + newgray = 0; + } + } + } } - if (x - 3 > 0 && y + 1 < height) - { - sourceArr[prevIndexOnNextRow] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 1] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 2] += (byte)((error_r * 5) / 16); + if (newgray > 255) + newgray = 255; + if (newgray < 0) + newgray = 0; + error = gray - newgray; + destArr[i] = (byte)newgray; + destArr[i+1] = (byte)newgray; + destArr[i+2] = (byte)newgray; - } } } } } - for (int i = 0; i < destArr.Length - 3; i++) - { - destArr[i] = grays[i]; - - } - Marshal.Copy(destArr, 0, destPtr, destBytes); @@ -389,8 +342,7 @@ namespace ShiftOS.WinForms.Tools - Desktop.InvokeOnWorkerThread(new Action(() => { result?.Invoke(bmp); })); - + return bmp; } #endif @@ -399,4 +351,25 @@ namespace ShiftOS.WinForms.Tools return (width * y) + x; } } + + public class DitheringSkinPostProcessor : ISkinPostProcessor + { + public byte[] ProcessImage(byte[] original) + { + try + { + var img = SkinEngine.ImageFromBinary(original); + var dithered = DitheringEngine.DitherImage(img); + using (var mstr = new MemoryStream()) + { + dithered.Save(mstr, System.Drawing.Imaging.ImageFormat.Bmp); + return mstr.ToArray(); + } + } + catch + { + return original; + } + } + } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6825f34..4efef1b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -390,10 +390,7 @@ namespace ShiftOS.WinForms this.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) => - { - this.BackgroundImage = img; - })); + this.BackgroundImage = SkinEngine.GetImage("desktopbackground"); this.BackgroundImageLayout = GetImageLayout("desktopbackground"); desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index d622bb9..5b7674a 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -233,6 +233,23 @@ namespace ShiftOS.Engine [Namespace("dev")] public static class ShiftOSDevCommands { + [Command("buy")] + public static bool UnlockUpgrade(Dictionary args) + { + string upg = args["id"].ToString(); + try + { + SaveSystem.CurrentSave.Upgrades[upg] = true; + Shiftorium.InvokeUpgradeInstalled(); + SaveSystem.SaveGame(); + } + catch + { + Console.WriteLine("Upgrade not found."); + } + return true; + } + [Command("rock", description = "A little surprise for unstable builds...")] public static bool ThrowASandwichingRock() { diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index b731c4f..548e80f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -66,6 +66,13 @@ namespace ShiftOS.Engine public static class SkinEngine { + private static ISkinPostProcessor processor = null; + + public static void SetPostProcessor(ISkinPostProcessor _processor) + { + processor = _processor; + } + public static ImageLayout GetImageLayout(string img) { if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) @@ -93,6 +100,8 @@ namespace ShiftOS.Engine if (iattr.Name == img) { byte[] image = (byte[])field.GetValue(LoadedSkin); + if (processor != null) + image = processor.ProcessImage(image); return ImageFromBinary(image); } } @@ -1323,6 +1332,16 @@ namespace ShiftOS.Engine public string Category { get; set; } } + public interface ISkinPostProcessor + { + /// + /// Perform algorithmic operations at the bit level on a ShiftOS skin image. + /// + /// The image, as loaded by the engine, as a 32-bit ARGB byte array. + /// The processed image. + byte[] ProcessImage(byte[] original); + } + public class ShifterMetaAttribute : Attribute { -- cgit v1.2.3 From b1cace7807f28deff51f06665d544a4246879a82 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 15:51:19 -0400 Subject: Newer notification system (PANEL ICONS :D) --- ShiftOS.WinForms/Properties/Resources.Designer.cs | 10 ++ ShiftOS.WinForms/Properties/Resources.resx | 3 + .../Resources/notestate_connection_full.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/WinformsDesktop.Designer.cs | 130 ++++++++++++++++----- ShiftOS.WinForms/WinformsDesktop.cs | 78 ++++++++----- ShiftOS.WinForms/WinformsDesktop.resx | 3 + ShiftOS_TheReturn/AppearanceManager.cs | 5 +- ShiftOS_TheReturn/Desktop.cs | 17 ++- ShiftOS_TheReturn/ServerManager.cs | 1 + ShiftOS_TheReturn/Skinning.cs | 8 ++ 11 files changed, 200 insertions(+), 56 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/notestate_connection_full.bmp (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 0152be8..3e83c3f 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -1048,6 +1048,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap notestate_connection_full { + get { + object obj = ResourceManager.GetObject("notestate_connection_full", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index a90e69b..1db7a46 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34600,4 +34600,7 @@ ..\Resources\Ambient9.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/notestate_connection_full.bmp b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp new file mode 100644 index 0000000..a4e15b3 Binary files /dev/null and b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1079203..89da4e1 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -771,6 +771,7 @@ + diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 71ef161..968a31c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -53,15 +53,20 @@ namespace ShiftOS.WinForms private void InitializeComponent() { this.desktoppanel = new System.Windows.Forms.Panel(); - this.btnnotifications = new System.Windows.Forms.Button(); + this.pnlnotifications = new System.Windows.Forms.Panel(); + this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); 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.pnlscreensaver = new System.Windows.Forms.Panel(); - this.pnlwidgetlayer = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); + this.pnlwidgetlayer = new System.Windows.Forms.Panel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); + this.pnlnotificationbox = new System.Windows.Forms.Panel(); + this.lbnotemsg = new System.Windows.Forms.Label(); + this.lbnotetitle = new System.Windows.Forms.Label(); this.pnladvancedal = new System.Windows.Forms.Panel(); this.flapps = new System.Windows.Forms.FlowLayoutPanel(); this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); @@ -70,9 +75,13 @@ namespace ShiftOS.WinForms this.pnlstatus = new System.Windows.Forms.Panel(); this.lbalstatus = new System.Windows.Forms.Label(); this.desktoppanel.SuspendLayout(); + this.pnlnotifications.SuspendLayout(); + this.flnotifications.SuspendLayout(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); + this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); this.pnlstatus.SuspendLayout(); @@ -81,8 +90,7 @@ namespace ShiftOS.WinForms // desktoppanel // this.desktoppanel.BackColor = System.Drawing.Color.Green; - this.desktoppanel.Controls.Add(this.btnnotifications); - this.desktoppanel.Controls.Add(this.lbtime); + this.desktoppanel.Controls.Add(this.pnlnotifications); this.desktoppanel.Controls.Add(this.panelbuttonholder); this.desktoppanel.Controls.Add(this.sysmenuholder); this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; @@ -92,28 +100,34 @@ namespace ShiftOS.WinForms this.desktoppanel.TabIndex = 0; this.desktoppanel.Paint += new System.Windows.Forms.PaintEventHandler(this.desktoppanel_Paint); // - // btnnotifications - // - this.btnnotifications.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnnotifications.AutoSize = true; - this.btnnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnnotifications.BackColor = System.Drawing.Color.Transparent; - this.btnnotifications.FlatAppearance.BorderSize = 0; - this.btnnotifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnnotifications.Location = new System.Drawing.Point(1066, -2); - this.btnnotifications.Name = "btnnotifications"; - this.btnnotifications.Size = new System.Drawing.Size(136, 24); - this.btnnotifications.TabIndex = 3; - this.btnnotifications.Text = "Notifications (0)"; - this.btnnotifications.UseVisualStyleBackColor = false; - this.btnnotifications.Click += new System.EventHandler(this.btnnotifications_Click); + // pnlnotifications + // + this.pnlnotifications.Controls.Add(this.flnotifications); + this.pnlnotifications.Controls.Add(this.lbtime); + this.pnlnotifications.Cursor = System.Windows.Forms.Cursors.Default; + this.pnlnotifications.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlnotifications.Location = new System.Drawing.Point(1096, 0); + this.pnlnotifications.Name = "pnlnotifications"; + this.pnlnotifications.Size = new System.Drawing.Size(200, 24); + this.pnlnotifications.TabIndex = 3; + // + // flnotifications + // + this.flnotifications.AutoSize = true; + this.flnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flnotifications.Controls.Add(this.ntconnectionstatus); + this.flnotifications.Dock = System.Windows.Forms.DockStyle.Left; + this.flnotifications.Location = new System.Drawing.Point(0, 0); + this.flnotifications.Name = "flnotifications"; + this.flnotifications.Size = new System.Drawing.Size(22, 24); + this.flnotifications.TabIndex = 1; // // 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(3, 0); + this.lbtime.Location = new System.Drawing.Point(139, 7); this.lbtime.Name = "lbtime"; this.lbtime.Size = new System.Drawing.Size(49, 14); this.lbtime.TabIndex = 0; @@ -170,6 +184,13 @@ namespace ShiftOS.WinForms this.pnlscreensaver.TabIndex = 1; 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; + // // pnlwidgetlayer // this.pnlwidgetlayer.BackColor = System.Drawing.Color.Transparent; @@ -179,12 +200,53 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // 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; + // ntconnectionstatus + // + this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; + this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); + this.ntconnectionstatus.Name = "ntconnectionstatus"; + this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); + this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.ntconnectionstatus.TabIndex = 0; + this.ntconnectionstatus.TabStop = false; + this.ntconnectionstatus.Tag = "digitalsociety"; + // + // pnlnotificationbox + // + this.pnlnotificationbox.AutoSize = true; + this.pnlnotificationbox.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pnlnotificationbox.Controls.Add(this.lbnotemsg); + this.pnlnotificationbox.Controls.Add(this.lbnotetitle); + this.pnlnotificationbox.Location = new System.Drawing.Point(654, 111); + this.pnlnotificationbox.Name = "pnlnotificationbox"; + this.pnlnotificationbox.Size = new System.Drawing.Size(69, 68); + this.pnlnotificationbox.TabIndex = 0; + this.pnlnotificationbox.Visible = false; + // + // lbnotemsg + // + this.lbnotemsg.AutoSize = true; + this.lbnotemsg.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbnotemsg.Location = new System.Drawing.Point(0, 34); + this.lbnotemsg.MaximumSize = new System.Drawing.Size(350, 0); + this.lbnotemsg.Name = "lbnotemsg"; + this.lbnotemsg.Padding = new System.Windows.Forms.Padding(10); + this.lbnotemsg.Size = new System.Drawing.Size(69, 34); + this.lbnotemsg.TabIndex = 1; + this.lbnotemsg.Text = "label1"; + // + // lbnotetitle + // + this.lbnotetitle.AutoSize = true; + this.lbnotetitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbnotetitle.Location = new System.Drawing.Point(0, 0); + this.lbnotetitle.Margin = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Name = "lbnotetitle"; + this.lbnotetitle.Padding = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Size = new System.Drawing.Size(69, 34); + this.lbnotetitle.TabIndex = 0; + this.lbnotetitle.Tag = "header2"; + this.lbnotetitle.Text = "label1"; // // pnladvancedal // @@ -262,6 +324,7 @@ namespace ShiftOS.WinForms this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(1296, 738); + this.Controls.Add(this.pnlnotificationbox); this.Controls.Add(this.pnlwidgetlayer); this.Controls.Add(this.pnladvancedal); this.Controls.Add(this.pnlscreensaver); @@ -274,16 +337,24 @@ namespace ShiftOS.WinForms this.Load += new System.EventHandler(this.Desktop_Load); this.desktoppanel.ResumeLayout(false); this.desktoppanel.PerformLayout(); + this.pnlnotifications.ResumeLayout(false); + this.pnlnotifications.PerformLayout(); + this.flnotifications.ResumeLayout(false); + this.flnotifications.PerformLayout(); this.sysmenuholder.ResumeLayout(false); this.sysmenuholder.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlscreensaver.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); + this.pnlnotificationbox.ResumeLayout(false); + this.pnlnotificationbox.PerformLayout(); this.pnladvancedal.ResumeLayout(false); this.pnlalsystemactions.ResumeLayout(false); this.pnlalsystemactions.PerformLayout(); this.pnlstatus.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -295,7 +366,6 @@ namespace ShiftOS.WinForms private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem apps; private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; - private System.Windows.Forms.Button btnnotifications; private System.Windows.Forms.Panel pnlscreensaver; private System.Windows.Forms.Panel pnlssicon; private System.Windows.Forms.Panel pnladvancedal; @@ -306,6 +376,12 @@ namespace ShiftOS.WinForms private System.Windows.Forms.FlowLayoutPanel flapps; private System.Windows.Forms.FlowLayoutPanel flcategories; private System.Windows.Forms.Panel pnlwidgetlayer; + private System.Windows.Forms.Panel pnlnotifications; + private System.Windows.Forms.FlowLayoutPanel flnotifications; + private System.Windows.Forms.Panel pnlnotificationbox; + private System.Windows.Forms.Label lbnotemsg; + private System.Windows.Forms.Label lbnotetitle; + private System.Windows.Forms.PictureBox ntconnectionstatus; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 4efef1b..15ecb7a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -54,6 +54,38 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void PushNotification(string app, string title, string msg) + { + lbnotemsg.Text = msg; + lbnotetitle.Text = title; + + var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); + if (ctl == null) + pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; + else + { + int left = ctl.PointToScreen(ctl.Location).X; + int realleft = left - pnlnotificationbox.Width; + realleft += ctl.Width; + pnlnotificationbox.Left = realleft; + } + + + if (LoadedSkin.DesktopPanelPosition == 0) + pnlnotificationbox.Top = desktoppanel.Height; + else + pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + var notekiller = new System.Windows.Forms.Timer(); + notekiller.Interval = 10000; + notekiller.Tick += (o, a) => + { + pnlnotificationbox.Hide(); + }; + Engine.AudioManager.PlayStream(Properties.Resources.infobox); + pnlnotificationbox.Show(); + notekiller.Start(); + } + /// /// Initializes a new instance of the class. /// @@ -105,24 +137,6 @@ namespace ShiftOS.WinForms }; this.TopMost = false; - NotificationDaemon.NotificationMade += (note) => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - - NotificationDaemon.NotificationRead += () => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - this.LocationChanged += (o, a) => { if (this.Left != 0) @@ -143,10 +157,6 @@ namespace ShiftOS.WinForms { if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); }; Shiftorium.Installed += () => { @@ -187,8 +197,10 @@ namespace ShiftOS.WinForms if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) { lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; + lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; + + pnlnotifications.Width = flnotifications.Width + lbtime.Width + LoadedSkin.DesktopPanelClockFromRight.X; } } @@ -215,8 +227,6 @@ namespace ShiftOS.WinForms catch { } - btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; - btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; }; time.Start(); @@ -372,10 +382,13 @@ namespace ShiftOS.WinForms desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); - btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); + ControlManager.SetupControls(pnlnotificationbox); //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + lbtime.BackColor = Color.Transparent; + pnlnotifications.BackgroundImage = GetImage("panelclockbg"); + pnlnotifications.BackgroundImageLayout = GetImageLayout("panelclockbg"); + pnlnotifications.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; panelbuttonholder.Top = 0; panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; @@ -1060,4 +1073,15 @@ namespace ShiftOS.WinForms } } } + + public static class ControlCollectionExtensions + { + public static IList ToList(this Control.ControlCollection ctrls) + { + var lst = new List(); + foreach (var ctl in ctrls) + lst.Add(ctl as Control); + return lst; + } + } } \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index d5494e3..b77504b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index d8004bc..a10f419 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -226,7 +226,10 @@ namespace ShiftOS.Engine OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); - Environment.Exit(0); + Desktop.InvokeOnWorkerThread(() => + { + Environment.Exit(0); + }); } /// diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index bc17a8e..a5e7f43 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -102,7 +102,14 @@ namespace ShiftOS.Engine /// Gets the name of the desktop. /// string DesktopName { get; } - + + /// + /// Show a notification on the desktop. + /// + /// An application ID (for determining what system icon to show the notification alongside) + /// The title of the notification. + /// Isn't this.... self explanatory? + void PushNotification(string app, string title, string message); /// /// Performs most of the skinning and layout handling for the desktop. @@ -266,6 +273,14 @@ namespace ShiftOS.Engine { _desktop.HideAppLauncher(); } + + public static void PushNotification(string app, string title, string msg) + { + InvokeOnWorkerThread(() => + { + _desktop.PushNotification(app, title, msg); + }); + } } // sorry i almost killed everything :P } diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 825064b..371d8e7 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -131,6 +131,7 @@ namespace ShiftOS.Engine { if (!UserDisconnect) { + Desktop.PushNotification("digital_society_connection", "Disconnected from Digital Society.", "The ShiftOS kernel has been disconnected from the Digital Society. We are attempting to re-connect you."); TerminalBackend.PrefixEnabled = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; ConsoleEx.Bold = true; diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 548e80f..4340f1a 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -276,6 +276,14 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [Image("panelclockbg")] + [ShifterMeta("Desktop")] + [ShifterCategory("Panel Clock")] + [ShifterName("Panel Clock Background Image")] + [ShifterDescription("Set the background image of the panel clock.")] + [RequiresUpgrade("skinning;shift_panel_clock")] + public byte[] PanelClockBG = null; + [ShifterMeta("System")] [ShifterCategory("Login Screen")] [RequiresUpgrade("gui_based_login_screen")] -- 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_TheReturn/Skinning.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 c0614c4f218d9ad071e8af3a2cad46d254a33b53 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 09:00:52 -0400 Subject: document skinengine --- ShiftOS_TheReturn/Skinning.cs | 90 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) (limited to 'ShiftOS_TheReturn/Skinning.cs') diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index c2f47fa..f5dd211 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -37,42 +37,71 @@ using System.Reflection; using ShiftOS.Engine.Scripting; namespace ShiftOS.Engine { - + /// + /// Skinning API for Lua. + /// [Exposed("skinning")] public class SkinFunctions { + /// + /// Reload the current skin. + /// public void loadSkin() { SkinEngine.LoadSkin(); } + /// + /// Get the current skin info. + /// + /// A proxy object containing all skin variables. public dynamic getSkin() { return SkinEngine.LoadedSkin; } + /// + /// Set the current skin to the specified class. + /// + /// The class to load. public void setSkin(Skin skn) { Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(skn)); SkinEngine.LoadSkin(); } + /// + /// Retrieves an image from the skin file. + /// + /// The skin image ID + /// The loaded image, null (nil in Lua) if none is found. public dynamic getImage(string id) { return SkinEngine.GetImage(id); } } - + /// + /// Skin engine management class. + /// public static class SkinEngine { private static ISkinPostProcessor processor = null; + /// + /// Load a new skin postprocessor into the engine. + /// + /// The postprocessor to load. public static void SetPostProcessor(ISkinPostProcessor _processor) { processor = _processor; } + /// + /// Retrieve the user-specified image layout of a skin image. + /// + /// The skin image ID. + /// The for the image. public static ImageLayout GetImageLayout(string img) { if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) @@ -86,6 +115,11 @@ namespace ShiftOS.Engine } } + /// + /// Retrieves an image from the skin after postprocessing it. + /// + /// The image ID to search. + /// The post-processed image, or null if none was found. public static System.Drawing.Image GetImage(string img) { var type = typeof(Skin); @@ -111,11 +145,20 @@ namespace ShiftOS.Engine return null; } + /// + /// Set the engine's current icon prober. + /// + /// The icon prober to use. public static void SetIconProber(IIconProber prober) { _iconProber = prober; } + /// + /// Load a from a array. + /// + /// The array to convert + /// The resulting image. public static Image ImageFromBinary(byte[] image) { if (image == null) @@ -126,6 +169,9 @@ namespace ShiftOS.Engine private static Skin loadedSkin = new Skin(); + /// + /// Gets the currently loaded skin. + /// public static Skin LoadedSkin { get @@ -138,6 +184,9 @@ namespace ShiftOS.Engine } } + /// + /// Initiates the skin engine. + /// public static void Init() { Application.ApplicationExit += (o, a) => @@ -160,8 +209,14 @@ namespace ShiftOS.Engine } } + /// + /// Occurs when the skin is loaded. + /// public static event EmptyEventHandler SkinLoaded; + /// + /// Reload the current skin. + /// public static void LoadSkin() { LoadedSkin = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("skin.json"))); @@ -170,6 +225,9 @@ namespace ShiftOS.Engine Desktop.PopulateAppLauncher(); } + /// + /// Save the skin loaded in memory to the filesystem. + /// public static void SaveSkin() { Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin, Formatting.Indented)); @@ -177,6 +235,11 @@ namespace ShiftOS.Engine private static IIconProber _iconProber = null; + /// + /// Retrieves the default icon for a given icon ID. + /// + /// The icon ID to search. + /// The resulting icon image. public static Image GetDefaultIcon(string id) { if (_iconProber == null) @@ -213,6 +276,11 @@ namespace ShiftOS.Engine } } + /// + /// Retrieves the user-defined icon for a specified icon ID. + /// + /// The icon ID to search. + /// The resulting icon image. public static Image GetIcon(string id) { if (!LoadedSkin.AppIcons.ContainsKey(id)) @@ -231,11 +299,23 @@ namespace ShiftOS.Engine } } + /// + /// Interface for probing app icons. + /// public interface IIconProber { + /// + /// Retrieve the icon image from a . + /// + /// The attribute data + /// The resulting image. Image GetIcon(DefaultIconAttribute attr); } + /// + /// Sets the default icon ID for a . + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple =false)] public class DefaultIconAttribute : Attribute { public DefaultIconAttribute(string id) @@ -246,6 +326,9 @@ namespace ShiftOS.Engine public string ID { get; private set; } } + /// + /// The data stored in any .skn file. + /// public class Skin { //borrowing from the discourse theme for the default skin @@ -1372,6 +1455,9 @@ namespace ShiftOS.Engine public Font AdvALItemFont = SysFont2; } + /// + /// Marks a skin spec field as hidden from the Shifter. + /// public class ShifterHiddenAttribute : Attribute { -- cgit v1.2.3