From a3f3e03569e0268ddc70c699d49bc70331f60ab2 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Apr 2017 14:37:59 -0400 Subject: Call OnUpgrade() when upgrade installed. --- ShiftOS.WinForms/WindowBorder.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 0308f8a..4fba470 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -124,7 +124,6 @@ namespace ShiftOS.WinForms } }; - this.Width = LoadedSkin.LeftBorderWidth + _parentWindow.Width + LoadedSkin.RightBorderWidth; this.Height = LoadedSkin.TitlebarHeight + _parentWindow.Height + LoadedSkin.BottomBorderWidth; @@ -133,6 +132,13 @@ namespace ShiftOS.WinForms this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); + ParentWindow.OnSkinLoad(); + ParentWindow.OnUpgrade(); + Shiftorium.Installed += () => + { + Setup(); + ParentWindow.OnUpgrade(); + }; Desktop.ShowWindow(this); -- 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.WinForms/WindowBorder.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 fb481614fc2cd64357d60c4459adb5b65072bbce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 10:50:05 -0400 Subject: Dramatic speed-up of window loading. --- ShiftOS.WinForms/Applications/Artpad.cs | 371 +++---------------------------- ShiftOS.WinForms/Controls/TerminalBox.cs | 5 + ShiftOS.WinForms/Tools/ControlManager.cs | 106 ++++++--- ShiftOS.WinForms/WindowBorder.cs | 6 +- 4 files changed, 114 insertions(+), 374 deletions(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Applications/Artpad.cs b/ShiftOS.WinForms/Applications/Artpad.cs index 71f7afb..7ef66aa 100644 --- a/ShiftOS.WinForms/Applications/Artpad.cs +++ b/ShiftOS.WinForms/Applications/Artpad.cs @@ -38,6 +38,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.WinForms.Tools; using ShiftOS.Engine; +using System.Diagnostics; namespace ShiftOS.WinForms.Applications { @@ -55,8 +56,11 @@ namespace ShiftOS.WinForms.Applications { try { + Stopwatch sw = new Stopwatch(); + sw.Start(); InitializeComponent(); - + sw.Stop(); + Console.WriteLine("ArtPad construction timespan:" + sw.Elapsed.ToString()); } catch (Exception ex) { @@ -141,17 +145,7 @@ namespace ShiftOS.WinForms.Applications private void Template_Load(object sender, EventArgs e) { - justopened = true; - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - setuppreview(); - settoolcolours(); - loadcolors(); - AddFonts(); - setuptoolbox(); - determinevisiblepalettes(); - tmrsetupui.Start(); + //Moved to the engine "OnLoad" method. } @@ -171,55 +165,24 @@ namespace ShiftOS.WinForms.Applications needtosave = false; } + //PHILCODE: I just reduced this function's amount of Windows Forms calls by 66%. public void setuptoolbox() { - btnpixelplacer.Hide(); - btnpencil.Hide(); - btnfloodfill.Hide(); - btnoval.Hide(); - btnsquare.Hide(); - btnlinetool.Hide(); - btnpaintbrush.Hide(); - btntexttool.Hide(); - btneracer.Hide(); - btnnew.Hide(); - btnopen.Hide(); - btnsave.Hide(); - btnundo.Hide(); - btnredo.Hide(); - btnpixelplacermovementmode.Hide(); - - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true) - btnpixelplacer.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true) - btnpencil.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true) - btnfloodfill.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true) - btnoval.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true) - btnsquare.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true) - btnlinetool.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true) - btnpaintbrush.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true) - btntexttool.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true) - btneracer.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true) - btnnew.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true) - btnopen.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true) - btnsave.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true) - btnundo.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true) - btnredo.Show(); - if (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true) - btnpixelplacermovementmode.Show(); - + btnpixelplacer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true); + btnpencil.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true); + btnfloodfill.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true); + btnoval.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true); + btnsquare.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true); + btnlinetool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true); + btnpaintbrush.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true); + btntexttool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true); + btneracer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true); + btnnew.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true); + btnopen.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true); + btnsave.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true); + btnundo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true); + btnredo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true); + btnpixelplacermovementmode.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true); } private void AddFonts() @@ -688,290 +651,6 @@ namespace ShiftOS.WinForms.Applications } } - // - public void loadcolors() - { - /*bool allwhite = true; - for (int i = 0; i <= 127; i++) - { - if (ShiftOSDesktop.artpad_colour_palettes(i) == null) - { - } - else { - allwhite = false; - } - } - if (allwhite == true) - { - for (i = 0; i <= 127; i++) - { - ShiftOSDesktop.artpad_colour_palettes(i) = Color.Black; - } - } - colourpalette1.BackColor = ShiftOSDesktop.artpad_colour_palettes(0); - colourpalette2.BackColor = ShiftOSDesktop.artpad_colour_palettes(1); - colourpalette3.BackColor = ShiftOSDesktop.artpad_colour_palettes(2); - colourpalette4.BackColor = ShiftOSDesktop.artpad_colour_palettes(3); - colourpalette5.BackColor = ShiftOSDesktop.artpad_colour_palettes(4); - colourpalette6.BackColor = ShiftOSDesktop.artpad_colour_palettes(5); - colourpalette7.BackColor = ShiftOSDesktop.artpad_colour_palettes(6); - colourpalette8.BackColor = ShiftOSDesktop.artpad_colour_palettes(7); - colourpalette9.BackColor = ShiftOSDesktop.artpad_colour_palettes(8); - colourpalette10.BackColor = ShiftOSDesktop.artpad_colour_palettes(9); - colourpalette11.BackColor = ShiftOSDesktop.artpad_colour_palettes(10); - colourpalette12.BackColor = ShiftOSDesktop.artpad_colour_palettes(11); - colourpalette13.BackColor = ShiftOSDesktop.artpad_colour_palettes(12); - colourpalette14.BackColor = ShiftOSDesktop.artpad_colour_palettes(13); - colourpalette15.BackColor = ShiftOSDesktop.artpad_colour_palettes(14); - colourpalette16.BackColor = ShiftOSDesktop.artpad_colour_palettes(15); - colourpalette17.BackColor = ShiftOSDesktop.artpad_colour_palettes(16); - colourpalette18.BackColor = ShiftOSDesktop.artpad_colour_palettes(17); - colourpalette19.BackColor = ShiftOSDesktop.artpad_colour_palettes(18); - colourpalette20.BackColor = ShiftOSDesktop.artpad_colour_palettes(19); - colourpalette21.BackColor = ShiftOSDesktop.artpad_colour_palettes(20); - colourpalette22.BackColor = ShiftOSDesktop.artpad_colour_palettes(21); - colourpalette23.BackColor = ShiftOSDesktop.artpad_colour_palettes(22); - colourpalette24.BackColor = ShiftOSDesktop.artpad_colour_palettes(23); - colourpalette25.BackColor = ShiftOSDesktop.artpad_colour_palettes(24); - colourpalette26.BackColor = ShiftOSDesktop.artpad_colour_palettes(25); - colourpalette27.BackColor = ShiftOSDesktop.artpad_colour_palettes(26); - colourpalette28.BackColor = ShiftOSDesktop.artpad_colour_palettes(27); - colourpalette29.BackColor = ShiftOSDesktop.artpad_colour_palettes(28); - colourpalette30.BackColor = ShiftOSDesktop.artpad_colour_palettes(29); - colourpalette31.BackColor = ShiftOSDesktop.artpad_colour_palettes(30); - colourpalette32.BackColor = ShiftOSDesktop.artpad_colour_palettes(31); - colourpalette33.BackColor = ShiftOSDesktop.artpad_colour_palettes(32); - colourpalette34.BackColor = ShiftOSDesktop.artpad_colour_palettes(33); - colourpalette35.BackColor = ShiftOSDesktop.artpad_colour_palettes(34); - colourpalette36.BackColor = ShiftOSDesktop.artpad_colour_palettes(35); - colourpalette37.BackColor = ShiftOSDesktop.artpad_colour_palettes(36); - colourpalette38.BackColor = ShiftOSDesktop.artpad_colour_palettes(37); - colourpalette39.BackColor = ShiftOSDesktop.artpad_colour_palettes(38); - colourpalette40.BackColor = ShiftOSDesktop.artpad_colour_palettes(39); - colourpalette41.BackColor = ShiftOSDesktop.artpad_colour_palettes(40); - colourpalette42.BackColor = ShiftOSDesktop.artpad_colour_palettes(41); - colourpalette43.BackColor = ShiftOSDesktop.artpad_colour_palettes(42); - colourpalette44.BackColor = ShiftOSDesktop.artpad_colour_palettes(43); - colourpalette45.BackColor = ShiftOSDesktop.artpad_colour_palettes(44); - colourpalette46.BackColor = ShiftOSDesktop.artpad_colour_palettes(45); - colourpalette47.BackColor = ShiftOSDesktop.artpad_colour_palettes(46); - colourpalette48.BackColor = ShiftOSDesktop.artpad_colour_palettes(47); - colourpalette49.BackColor = ShiftOSDesktop.artpad_colour_palettes(48); - colourpalette50.BackColor = ShiftOSDesktop.artpad_colour_palettes(49); - colourpalette51.BackColor = ShiftOSDesktop.artpad_colour_palettes(50); - colourpalette52.BackColor = ShiftOSDesktop.artpad_colour_palettes(51); - colourpalette53.BackColor = ShiftOSDesktop.artpad_colour_palettes(52); - colourpalette54.BackColor = ShiftOSDesktop.artpad_colour_palettes(53); - colourpalette55.BackColor = ShiftOSDesktop.artpad_colour_palettes(54); - colourpalette56.BackColor = ShiftOSDesktop.artpad_colour_palettes(55); - colourpalette57.BackColor = ShiftOSDesktop.artpad_colour_palettes(56); - colourpalette58.BackColor = ShiftOSDesktop.artpad_colour_palettes(57); - colourpalette59.BackColor = ShiftOSDesktop.artpad_colour_palettes(58); - colourpalette60.BackColor = ShiftOSDesktop.artpad_colour_palettes(59); - colourpalette61.BackColor = ShiftOSDesktop.artpad_colour_palettes(60); - colourpalette62.BackColor = ShiftOSDesktop.artpad_colour_palettes(61); - colourpalette63.BackColor = ShiftOSDesktop.artpad_colour_palettes(62); - colourpalette64.BackColor = ShiftOSDesktop.artpad_colour_palettes(63); - colourpalette65.BackColor = ShiftOSDesktop.artpad_colour_palettes(64); - colourpalette66.BackColor = ShiftOSDesktop.artpad_colour_palettes(65); - colourpalette67.BackColor = ShiftOSDesktop.artpad_colour_palettes(66); - colourpalette68.BackColor = ShiftOSDesktop.artpad_colour_palettes(67); - colourpalette69.BackColor = ShiftOSDesktop.artpad_colour_palettes(68); - colourpalette70.BackColor = ShiftOSDesktop.artpad_colour_palettes(69); - colourpalette71.BackColor = ShiftOSDesktop.artpad_colour_palettes(70); - colourpalette72.BackColor = ShiftOSDesktop.artpad_colour_palettes(71); - colourpalette73.BackColor = ShiftOSDesktop.artpad_colour_palettes(72); - colourpalette74.BackColor = ShiftOSDesktop.artpad_colour_palettes(73); - colourpalette75.BackColor = ShiftOSDesktop.artpad_colour_palettes(74); - colourpalette76.BackColor = ShiftOSDesktop.artpad_colour_palettes(75); - colourpalette77.BackColor = ShiftOSDesktop.artpad_colour_palettes(76); - colourpalette78.BackColor = ShiftOSDesktop.artpad_colour_palettes(77); - colourpalette79.BackColor = ShiftOSDesktop.artpad_colour_palettes(78); - colourpalette80.BackColor = ShiftOSDesktop.artpad_colour_palettes(79); - colourpalette81.BackColor = ShiftOSDesktop.artpad_colour_palettes(80); - colourpalette82.BackColor = ShiftOSDesktop.artpad_colour_palettes(81); - colourpalette83.BackColor = ShiftOSDesktop.artpad_colour_palettes(82); - colourpalette84.BackColor = ShiftOSDesktop.artpad_colour_palettes(83); - colourpalette85.BackColor = ShiftOSDesktop.artpad_colour_palettes(84); - colourpalette86.BackColor = ShiftOSDesktop.artpad_colour_palettes(85); - colourpalette87.BackColor = ShiftOSDesktop.artpad_colour_palettes(86); - colourpalette88.BackColor = ShiftOSDesktop.artpad_colour_palettes(87); - colourpalette89.BackColor = ShiftOSDesktop.artpad_colour_palettes(88); - colourpalette90.BackColor = ShiftOSDesktop.artpad_colour_palettes(89); - colourpalette91.BackColor = ShiftOSDesktop.artpad_colour_palettes(90); - colourpalette92.BackColor = ShiftOSDesktop.artpad_colour_palettes(91); - colourpalette93.BackColor = ShiftOSDesktop.artpad_colour_palettes(92); - colourpalette94.BackColor = ShiftOSDesktop.artpad_colour_palettes(93); - colourpalette95.BackColor = ShiftOSDesktop.artpad_colour_palettes(94); - colourpalette96.BackColor = ShiftOSDesktop.artpad_colour_palettes(95); - colourpalette97.BackColor = ShiftOSDesktop.artpad_colour_palettes(96); - colourpalette98.BackColor = ShiftOSDesktop.artpad_colour_palettes(97); - colourpalette99.BackColor = ShiftOSDesktop.artpad_colour_palettes(98); - colourpalette100.BackColor = ShiftOSDesktop.artpad_colour_palettes(99); - colourpalette101.BackColor = ShiftOSDesktop.artpad_colour_palettes(100); - colourpalette102.BackColor = ShiftOSDesktop.artpad_colour_palettes(101); - colourpalette103.BackColor = ShiftOSDesktop.artpad_colour_palettes(102); - colourpalette104.BackColor = ShiftOSDesktop.artpad_colour_palettes(103); - colourpalette105.BackColor = ShiftOSDesktop.artpad_colour_palettes(104); - colourpalette106.BackColor = ShiftOSDesktop.artpad_colour_palettes(105); - colourpalette107.BackColor = ShiftOSDesktop.artpad_colour_palettes(106); - colourpalette108.BackColor = ShiftOSDesktop.artpad_colour_palettes(107); - colourpalette109.BackColor = ShiftOSDesktop.artpad_colour_palettes(108); - colourpalette110.BackColor = ShiftOSDesktop.artpad_colour_palettes(109); - colourpalette111.BackColor = ShiftOSDesktop.artpad_colour_palettes(110); - colourpalette112.BackColor = ShiftOSDesktop.artpad_colour_palettes(111); - colourpalette113.BackColor = ShiftOSDesktop.artpad_colour_palettes(112); - colourpalette114.BackColor = ShiftOSDesktop.artpad_colour_palettes(113); - colourpalette115.BackColor = ShiftOSDesktop.artpad_colour_palettes(114); - colourpalette116.BackColor = ShiftOSDesktop.artpad_colour_palettes(115); - colourpalette117.BackColor = ShiftOSDesktop.artpad_colour_palettes(116); - colourpalette118.BackColor = ShiftOSDesktop.artpad_colour_palettes(117); - colourpalette119.BackColor = ShiftOSDesktop.artpad_colour_palettes(118); - colourpalette120.BackColor = ShiftOSDesktop.artpad_colour_palettes(119); - colourpalette121.BackColor = ShiftOSDesktop.artpad_colour_palettes(120); - colourpalette122.BackColor = ShiftOSDesktop.artpad_colour_palettes(121); - colourpalette123.BackColor = ShiftOSDesktop.artpad_colour_palettes(122); - colourpalette124.BackColor = ShiftOSDesktop.artpad_colour_palettes(123); - colourpalette125.BackColor = ShiftOSDesktop.artpad_colour_palettes(124); - colourpalette126.BackColor = ShiftOSDesktop.artpad_colour_palettes(125); - colourpalette127.BackColor = ShiftOSDesktop.artpad_colour_palettes(126); - colourpalette128.BackColor = ShiftOSDesktop.artpad_colour_palettes(127); - */ - } - - public void savecolors() - {/* - ShiftOSDesktop.artpad_colour_palettes(0) = colourpalette1.BackColor; - ShiftOSDesktop.artpad_colour_palettes(1) = colourpalette2.BackColor; - ShiftOSDesktop.artpad_colour_palettes(2) = colourpalette3.BackColor; - ShiftOSDesktop.artpad_colour_palettes(3) = colourpalette4.BackColor; - ShiftOSDesktop.artpad_colour_palettes(4) = colourpalette5.BackColor; - ShiftOSDesktop.artpad_colour_palettes(5) = colourpalette6.BackColor; - ShiftOSDesktop.artpad_colour_palettes(6) = colourpalette7.BackColor; - ShiftOSDesktop.artpad_colour_palettes(7) = colourpalette8.BackColor; - ShiftOSDesktop.artpad_colour_palettes(8) = colourpalette9.BackColor; - ShiftOSDesktop.artpad_colour_palettes(9) = colourpalette10.BackColor; - ShiftOSDesktop.artpad_colour_palettes(10) = colourpalette11.BackColor; - ShiftOSDesktop.artpad_colour_palettes(11) = colourpalette12.BackColor; - ShiftOSDesktop.artpad_colour_palettes(12) = colourpalette13.BackColor; - ShiftOSDesktop.artpad_colour_palettes(13) = colourpalette14.BackColor; - ShiftOSDesktop.artpad_colour_palettes(14) = colourpalette15.BackColor; - ShiftOSDesktop.artpad_colour_palettes(15) = colourpalette16.BackColor; - ShiftOSDesktop.artpad_colour_palettes(16) = colourpalette17.BackColor; - ShiftOSDesktop.artpad_colour_palettes(17) = colourpalette18.BackColor; - ShiftOSDesktop.artpad_colour_palettes(18) = colourpalette19.BackColor; - ShiftOSDesktop.artpad_colour_palettes(19) = colourpalette20.BackColor; - ShiftOSDesktop.artpad_colour_palettes(20) = colourpalette21.BackColor; - ShiftOSDesktop.artpad_colour_palettes(21) = colourpalette22.BackColor; - ShiftOSDesktop.artpad_colour_palettes(22) = colourpalette23.BackColor; - ShiftOSDesktop.artpad_colour_palettes(23) = colourpalette24.BackColor; - ShiftOSDesktop.artpad_colour_palettes(24) = colourpalette25.BackColor; - ShiftOSDesktop.artpad_colour_palettes(25) = colourpalette26.BackColor; - ShiftOSDesktop.artpad_colour_palettes(26) = colourpalette27.BackColor; - ShiftOSDesktop.artpad_colour_palettes(27) = colourpalette28.BackColor; - ShiftOSDesktop.artpad_colour_palettes(28) = colourpalette29.BackColor; - ShiftOSDesktop.artpad_colour_palettes(29) = colourpalette30.BackColor; - ShiftOSDesktop.artpad_colour_palettes(30) = colourpalette31.BackColor; - ShiftOSDesktop.artpad_colour_palettes(31) = colourpalette32.BackColor; - ShiftOSDesktop.artpad_colour_palettes(32) = colourpalette33.BackColor; - ShiftOSDesktop.artpad_colour_palettes(33) = colourpalette34.BackColor; - ShiftOSDesktop.artpad_colour_palettes(34) = colourpalette35.BackColor; - ShiftOSDesktop.artpad_colour_palettes(35) = colourpalette36.BackColor; - ShiftOSDesktop.artpad_colour_palettes(36) = colourpalette37.BackColor; - ShiftOSDesktop.artpad_colour_palettes(37) = colourpalette38.BackColor; - ShiftOSDesktop.artpad_colour_palettes(38) = colourpalette39.BackColor; - ShiftOSDesktop.artpad_colour_palettes(39) = colourpalette40.BackColor; - ShiftOSDesktop.artpad_colour_palettes(40) = colourpalette41.BackColor; - ShiftOSDesktop.artpad_colour_palettes(41) = colourpalette42.BackColor; - ShiftOSDesktop.artpad_colour_palettes(42) = colourpalette43.BackColor; - ShiftOSDesktop.artpad_colour_palettes(43) = colourpalette44.BackColor; - ShiftOSDesktop.artpad_colour_palettes(44) = colourpalette45.BackColor; - ShiftOSDesktop.artpad_colour_palettes(45) = colourpalette46.BackColor; - ShiftOSDesktop.artpad_colour_palettes(46) = colourpalette47.BackColor; - ShiftOSDesktop.artpad_colour_palettes(47) = colourpalette48.BackColor; - ShiftOSDesktop.artpad_colour_palettes(48) = colourpalette49.BackColor; - ShiftOSDesktop.artpad_colour_palettes(49) = colourpalette50.BackColor; - ShiftOSDesktop.artpad_colour_palettes(50) = colourpalette51.BackColor; - ShiftOSDesktop.artpad_colour_palettes(51) = colourpalette52.BackColor; - ShiftOSDesktop.artpad_colour_palettes(52) = colourpalette53.BackColor; - ShiftOSDesktop.artpad_colour_palettes(53) = colourpalette54.BackColor; - ShiftOSDesktop.artpad_colour_palettes(54) = colourpalette55.BackColor; - ShiftOSDesktop.artpad_colour_palettes(55) = colourpalette56.BackColor; - ShiftOSDesktop.artpad_colour_palettes(56) = colourpalette57.BackColor; - ShiftOSDesktop.artpad_colour_palettes(57) = colourpalette58.BackColor; - ShiftOSDesktop.artpad_colour_palettes(58) = colourpalette59.BackColor; - ShiftOSDesktop.artpad_colour_palettes(59) = colourpalette60.BackColor; - ShiftOSDesktop.artpad_colour_palettes(60) = colourpalette61.BackColor; - ShiftOSDesktop.artpad_colour_palettes(61) = colourpalette62.BackColor; - ShiftOSDesktop.artpad_colour_palettes(62) = colourpalette63.BackColor; - ShiftOSDesktop.artpad_colour_palettes(63) = colourpalette64.BackColor; - ShiftOSDesktop.artpad_colour_palettes(64) = colourpalette65.BackColor; - ShiftOSDesktop.artpad_colour_palettes(65) = colourpalette66.BackColor; - ShiftOSDesktop.artpad_colour_palettes(66) = colourpalette67.BackColor; - ShiftOSDesktop.artpad_colour_palettes(67) = colourpalette68.BackColor; - ShiftOSDesktop.artpad_colour_palettes(68) = colourpalette69.BackColor; - ShiftOSDesktop.artpad_colour_palettes(69) = colourpalette70.BackColor; - ShiftOSDesktop.artpad_colour_palettes(70) = colourpalette71.BackColor; - ShiftOSDesktop.artpad_colour_palettes(71) = colourpalette72.BackColor; - ShiftOSDesktop.artpad_colour_palettes(72) = colourpalette73.BackColor; - ShiftOSDesktop.artpad_colour_palettes(73) = colourpalette74.BackColor; - ShiftOSDesktop.artpad_colour_palettes(74) = colourpalette75.BackColor; - ShiftOSDesktop.artpad_colour_palettes(75) = colourpalette76.BackColor; - ShiftOSDesktop.artpad_colour_palettes(76) = colourpalette77.BackColor; - ShiftOSDesktop.artpad_colour_palettes(77) = colourpalette78.BackColor; - ShiftOSDesktop.artpad_colour_palettes(78) = colourpalette79.BackColor; - ShiftOSDesktop.artpad_colour_palettes(79) = colourpalette80.BackColor; - ShiftOSDesktop.artpad_colour_palettes(80) = colourpalette81.BackColor; - ShiftOSDesktop.artpad_colour_palettes(81) = colourpalette82.BackColor; - ShiftOSDesktop.artpad_colour_palettes(82) = colourpalette83.BackColor; - ShiftOSDesktop.artpad_colour_palettes(83) = colourpalette84.BackColor; - ShiftOSDesktop.artpad_colour_palettes(84) = colourpalette85.BackColor; - ShiftOSDesktop.artpad_colour_palettes(85) = colourpalette86.BackColor; - ShiftOSDesktop.artpad_colour_palettes(86) = colourpalette87.BackColor; - ShiftOSDesktop.artpad_colour_palettes(87) = colourpalette88.BackColor; - ShiftOSDesktop.artpad_colour_palettes(88) = colourpalette89.BackColor; - ShiftOSDesktop.artpad_colour_palettes(89) = colourpalette90.BackColor; - ShiftOSDesktop.artpad_colour_palettes(90) = colourpalette91.BackColor; - ShiftOSDesktop.artpad_colour_palettes(91) = colourpalette92.BackColor; - ShiftOSDesktop.artpad_colour_palettes(92) = colourpalette93.BackColor; - ShiftOSDesktop.artpad_colour_palettes(93) = colourpalette94.BackColor; - ShiftOSDesktop.artpad_colour_palettes(94) = colourpalette95.BackColor; - ShiftOSDesktop.artpad_colour_palettes(95) = colourpalette96.BackColor; - ShiftOSDesktop.artpad_colour_palettes(96) = colourpalette97.BackColor; - ShiftOSDesktop.artpad_colour_palettes(97) = colourpalette98.BackColor; - ShiftOSDesktop.artpad_colour_palettes(98) = colourpalette99.BackColor; - ShiftOSDesktop.artpad_colour_palettes(99) = colourpalette100.BackColor; - ShiftOSDesktop.artpad_colour_palettes(100) = colourpalette101.BackColor; - ShiftOSDesktop.artpad_colour_palettes(101) = colourpalette102.BackColor; - ShiftOSDesktop.artpad_colour_palettes(102) = colourpalette103.BackColor; - ShiftOSDesktop.artpad_colour_palettes(103) = colourpalette104.BackColor; - ShiftOSDesktop.artpad_colour_palettes(104) = colourpalette105.BackColor; - ShiftOSDesktop.artpad_colour_palettes(105) = colourpalette106.BackColor; - ShiftOSDesktop.artpad_colour_palettes(106) = colourpalette107.BackColor; - ShiftOSDesktop.artpad_colour_palettes(107) = colourpalette108.BackColor; - ShiftOSDesktop.artpad_colour_palettes(108) = colourpalette109.BackColor; - ShiftOSDesktop.artpad_colour_palettes(109) = colourpalette110.BackColor; - ShiftOSDesktop.artpad_colour_palettes(110) = colourpalette111.BackColor; - ShiftOSDesktop.artpad_colour_palettes(111) = colourpalette112.BackColor; - ShiftOSDesktop.artpad_colour_palettes(112) = colourpalette113.BackColor; - ShiftOSDesktop.artpad_colour_palettes(113) = colourpalette114.BackColor; - ShiftOSDesktop.artpad_colour_palettes(114) = colourpalette115.BackColor; - ShiftOSDesktop.artpad_colour_palettes(115) = colourpalette116.BackColor; - ShiftOSDesktop.artpad_colour_palettes(116) = colourpalette117.BackColor; - ShiftOSDesktop.artpad_colour_palettes(117) = colourpalette118.BackColor; - ShiftOSDesktop.artpad_colour_palettes(118) = colourpalette119.BackColor; - ShiftOSDesktop.artpad_colour_palettes(119) = colourpalette120.BackColor; - ShiftOSDesktop.artpad_colour_palettes(120) = colourpalette121.BackColor; - ShiftOSDesktop.artpad_colour_palettes(121) = colourpalette122.BackColor; - ShiftOSDesktop.artpad_colour_palettes(122) = colourpalette123.BackColor; - ShiftOSDesktop.artpad_colour_palettes(123) = colourpalette124.BackColor; - ShiftOSDesktop.artpad_colour_palettes(124) = colourpalette125.BackColor; - ShiftOSDesktop.artpad_colour_palettes(125) = colourpalette126.BackColor; - ShiftOSDesktop.artpad_colour_palettes(126) = colourpalette127.BackColor; - ShiftOSDesktop.artpad_colour_palettes(127) = colourpalette128.BackColor; - */ - } - // public void settoolcolours() { @@ -1859,6 +1538,12 @@ namespace ShiftOS.WinForms.Applications ctrl.Tag = "keepbg"; ctrl.BackColor = Color.Black; } + setuppreview(); + settoolcolours(); + AddFonts(); + setuptoolbox(); + determinevisiblepalettes(); + } public void OnSkinLoad() diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index df820f7..cdb0965 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -118,5 +118,10 @@ namespace ShiftOS.WinForms.Controls } base.OnMouseUp(mevent); } + + public TerminalBox() : base() + { + this.Tag = "keepbg keepfg keepfont"; + } } } diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index a2a76b7..781e045 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -28,6 +28,7 @@ using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; @@ -143,9 +144,11 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - SuspendDrawing(ctrl); - ctrl.SuspendLayout(); - SetCursor(ctrl); + Desktop.InvokeOnWorkerThread(new Action(() => + { + SuspendDrawing(ctrl); + ctrl.SuspendLayout(); + })); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { string tag = ""; @@ -160,32 +163,52 @@ namespace ShiftOS.WinForms.Tools { if (ctrl.BackColor != Control.DefaultBackColor) { - ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; + Desktop.InvokeOnWorkerThread(() => + { + ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; + }); } } - ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; - - ctrl.Font = SkinEngine.LoadedSkin.MainFont; - - if (tag.Contains("header1")) + if (!tag.Contains("keepfont")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; + ctrl.Font = SkinEngine.LoadedSkin.MainFont; + }); + if (tag.Contains("header1")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - } + if (tag.Contains("header2")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.Header2Font; + }); + } - if (tag.Contains("header3")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - } + if (tag.Contains("header3")) + { + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.Header3Font; + }); + } + } try { - ctrl.Text = Localization.Parse(ctrl.Text); + string ctrlText = Localization.Parse(ctrl.Text); + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Text = ctrlText; + }); } catch { @@ -206,19 +229,31 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - (ctrl as Button).FlatStyle = FlatStyle.Flat; + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as Button).FlatStyle = FlatStyle.Flat; + }); } else if (ctrl is WindowBorder) { - (ctrl as WindowBorder).Setup(); + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as WindowBorder).Setup(); + }); } } + Desktop.InvokeOnWorkerThread(() => + { - MakeDoubleBuffered(ctrl); - ctrl.ResumeLayout(); - ResumeDrawing(ctrl); + MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); + ResumeDrawing(ctrl); + }); + ControlSetup?.Invoke(ctrl); } + public static event Action ControlSetup; + public static void MakeDoubleBuffered(Control c) { if (System.Windows.Forms.SystemInformation.TerminalServerSession) @@ -234,13 +269,28 @@ namespace ShiftOS.WinForms.Tools } - public static void SetupControls(Control frm) + public static void SetupControls(Control frm, bool runInThread = true) { SetupControl(frm); - for (int i = 0; i < frm.Controls.Count; i++) + ThreadStart ts = () => + { + for (int i = 0; i < frm.Controls.Count; i++) + { + SetupControls(frm.Controls[i], false); + } + + }; + + if (runInThread == true) + { + var t = new Thread(ts); + t.IsBackground = true; + t.Start(); + } + else { - SetupControls(frm.Controls[i]); + ts?.Invoke(); } } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 4babbbd..e716803 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -146,8 +146,6 @@ namespace ShiftOS.WinForms }; - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; if (!this.IsDialog) { @@ -171,7 +169,6 @@ namespace ShiftOS.WinForms })); }; - ParentWindow.OnLoad(); } /// @@ -208,6 +205,9 @@ namespace ShiftOS.WinForms public void WindowBorder_Load(object sender, EventArgs e) { this.DoubleBuffered = true; + this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; + this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; + ParentWindow.OnLoad(); this._parentWindow.Show(); } -- cgit v1.2.3 From 6ec8e375c4b756bcd323df6babd4a4a74cd75904 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Apr 2017 13:06:13 -0400 Subject: Desktop preview --- ShiftOS.WinForms/Applications/Shifter.Designer.cs | 275 ++++++++++++++++++++++ ShiftOS.WinForms/Applications/Shifter.cs | 158 +++++++++++++ ShiftOS.WinForms/Applications/Shifter.resx | 39 +-- ShiftOS.WinForms/Tools/ControlManager.cs | 2 +- ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs | 14 +- ShiftOS.WinForms/WindowBorder.cs | 2 +- ShiftOS_TheReturn/ServerManager.cs | 12 +- 7 files changed, 478 insertions(+), 24 deletions(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Applications/Shifter.Designer.cs b/ShiftOS.WinForms/Applications/Shifter.Designer.cs index f919834..593f43d 100644 --- a/ShiftOS.WinForms/Applications/Shifter.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shifter.Designer.cs @@ -95,6 +95,29 @@ namespace ShiftOS.WinForms.Applications this.pnlintro = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); + this.pnldesktoppreview = new System.Windows.Forms.Panel(); + this.pnlscreensaver = new System.Windows.Forms.Panel(); + this.pnlssicon = new System.Windows.Forms.Panel(); + this.desktoppanel = new System.Windows.Forms.Panel(); + this.lbtime = new System.Windows.Forms.Label(); + this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); + this.sysmenuholder = new System.Windows.Forms.Panel(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.apps = new System.Windows.Forms.ToolStripMenuItem(); + this.pnladvancedal = new System.Windows.Forms.Panel(); + this.flapps = new System.Windows.Forms.FlowLayoutPanel(); + this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); + this.pnlalsystemactions = new System.Windows.Forms.Panel(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlstatus = new System.Windows.Forms.Panel(); + this.lbalstatus = new System.Windows.Forms.Label(); + this.item1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.item5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.shutdownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.separatorToolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.panel1.SuspendLayout(); this.pnlpreview.SuspendLayout(); this.pnlwindow.SuspendLayout(); @@ -106,6 +129,14 @@ namespace ShiftOS.WinForms.Applications this.mspreview.SuspendLayout(); this.tspreview.SuspendLayout(); this.pnlintro.SuspendLayout(); + this.pnldesktoppreview.SuspendLayout(); + this.pnlscreensaver.SuspendLayout(); + this.desktoppanel.SuspendLayout(); + this.sysmenuholder.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.pnladvancedal.SuspendLayout(); + this.pnlalsystemactions.SuspendLayout(); + this.pnlstatus.SuspendLayout(); this.SuspendLayout(); // // panel1 @@ -121,6 +152,7 @@ namespace ShiftOS.WinForms.Applications // // pnlpreview // + this.pnlpreview.Controls.Add(this.pnldesktoppreview); this.pnlpreview.Controls.Add(this.pnlintro); this.pnlpreview.Controls.Add(this.pnlwindow); this.pnlpreview.Dock = System.Windows.Forms.DockStyle.Fill; @@ -500,6 +532,214 @@ namespace ShiftOS.WinForms.Applications this.label2.Text = resources.GetString("label2.Text"); this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // pnldesktoppreview + // + this.pnldesktoppreview.Controls.Add(this.pnlscreensaver); + this.pnldesktoppreview.Controls.Add(this.desktoppanel); + this.pnldesktoppreview.Controls.Add(this.pnladvancedal); + this.pnldesktoppreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnldesktoppreview.Location = new System.Drawing.Point(0, 0); + this.pnldesktoppreview.Name = "pnldesktoppreview"; + this.pnldesktoppreview.Size = new System.Drawing.Size(757, 286); + this.pnldesktoppreview.TabIndex = 2; + // + // pnlscreensaver + // + this.pnlscreensaver.Controls.Add(this.pnlssicon); + this.pnlscreensaver.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlscreensaver.Location = new System.Drawing.Point(0, 24); + this.pnlscreensaver.Name = "pnlscreensaver"; + this.pnlscreensaver.Size = new System.Drawing.Size(757, 262); + this.pnlscreensaver.TabIndex = 3; + this.pnlscreensaver.Visible = false; + // + // pnlssicon + // + this.pnlssicon.Location = new System.Drawing.Point(303, 495); + this.pnlssicon.Name = "pnlssicon"; + this.pnlssicon.Size = new System.Drawing.Size(200, 100); + this.pnlssicon.TabIndex = 0; + // + // desktoppanel + // + this.desktoppanel.BackColor = System.Drawing.Color.Green; + this.desktoppanel.Controls.Add(this.lbtime); + this.desktoppanel.Controls.Add(this.panelbuttonholder); + this.desktoppanel.Controls.Add(this.sysmenuholder); + this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; + this.desktoppanel.Location = new System.Drawing.Point(0, 0); + this.desktoppanel.Name = "desktoppanel"; + this.desktoppanel.Size = new System.Drawing.Size(757, 24); + this.desktoppanel.TabIndex = 2; + // + // lbtime + // + this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbtime.AutoSize = true; + this.lbtime.Location = new System.Drawing.Point(-536, 0); + this.lbtime.Name = "lbtime"; + this.lbtime.Size = new System.Drawing.Size(35, 13); + this.lbtime.TabIndex = 0; + this.lbtime.Text = "label1"; + this.lbtime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // panelbuttonholder + // + this.panelbuttonholder.AutoSize = true; + this.panelbuttonholder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.panelbuttonholder.Location = new System.Drawing.Point(107, -77); + this.panelbuttonholder.Name = "panelbuttonholder"; + this.panelbuttonholder.Size = new System.Drawing.Size(0, 0); + this.panelbuttonholder.TabIndex = 2; + // + // sysmenuholder + // + this.sysmenuholder.Controls.Add(this.menuStrip1); + this.sysmenuholder.Location = new System.Drawing.Point(12, 5); + this.sysmenuholder.Name = "sysmenuholder"; + this.sysmenuholder.Size = new System.Drawing.Size(68, 24); + this.sysmenuholder.TabIndex = 1; + // + // menuStrip1 + // + this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Fill; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.apps}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(0); + this.menuStrip1.Size = new System.Drawing.Size(68, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // apps + // + this.apps.AutoSize = false; + this.apps.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.item1ToolStripMenuItem, + this.item2ToolStripMenuItem, + this.item3ToolStripMenuItem, + this.item4ToolStripMenuItem, + this.item5ToolStripMenuItem, + this.separatorToolStripMenuItem1, + this.shutdownToolStripMenuItem}); + this.apps.Name = "apps"; + this.apps.Padding = new System.Windows.Forms.Padding(0); + this.apps.Size = new System.Drawing.Size(58, 20); + this.apps.Tag = "applauncherbutton"; + this.apps.Text = "ShiftOS"; + // + // pnladvancedal + // + this.pnladvancedal.Controls.Add(this.flapps); + this.pnladvancedal.Controls.Add(this.flcategories); + this.pnladvancedal.Controls.Add(this.pnlalsystemactions); + this.pnladvancedal.Controls.Add(this.pnlstatus); + this.pnladvancedal.Location = new System.Drawing.Point(0, -53); + this.pnladvancedal.Name = "pnladvancedal"; + this.pnladvancedal.Size = new System.Drawing.Size(433, 417); + this.pnladvancedal.TabIndex = 4; + this.pnladvancedal.Visible = false; + // + // flapps + // + this.flapps.Dock = System.Windows.Forms.DockStyle.Fill; + this.flapps.Location = new System.Drawing.Point(221, 58); + this.flapps.Name = "flapps"; + this.flapps.Size = new System.Drawing.Size(212, 328); + this.flapps.TabIndex = 3; + // + // flcategories + // + this.flcategories.Dock = System.Windows.Forms.DockStyle.Left; + this.flcategories.Location = new System.Drawing.Point(0, 58); + this.flcategories.Name = "flcategories"; + this.flcategories.Size = new System.Drawing.Size(221, 328); + this.flcategories.TabIndex = 2; + // + // pnlalsystemactions + // + this.pnlalsystemactions.Controls.Add(this.btnshutdown); + this.pnlalsystemactions.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlalsystemactions.Location = new System.Drawing.Point(0, 386); + this.pnlalsystemactions.Name = "pnlalsystemactions"; + this.pnlalsystemactions.Size = new System.Drawing.Size(433, 31); + this.pnlalsystemactions.TabIndex = 1; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnshutdown.Location = new System.Drawing.Point(363, 3); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(67, 25); + this.btnshutdown.TabIndex = 0; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + // + // pnlstatus + // + this.pnlstatus.Controls.Add(this.lbalstatus); + this.pnlstatus.Dock = System.Windows.Forms.DockStyle.Top; + this.pnlstatus.Location = new System.Drawing.Point(0, 0); + this.pnlstatus.Name = "pnlstatus"; + this.pnlstatus.Size = new System.Drawing.Size(433, 58); + this.pnlstatus.TabIndex = 0; + // + // lbalstatus + // + this.lbalstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbalstatus.Location = new System.Drawing.Point(0, 0); + this.lbalstatus.Name = "lbalstatus"; + this.lbalstatus.Size = new System.Drawing.Size(433, 58); + this.lbalstatus.TabIndex = 0; + this.lbalstatus.Text = "michael@system\r\n0 Codepoints\r\n0 installed, 0 available"; + this.lbalstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // item1ToolStripMenuItem + // + this.item1ToolStripMenuItem.Name = "item1ToolStripMenuItem"; + this.item1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item1ToolStripMenuItem.Text = "Item 1"; + // + // item2ToolStripMenuItem + // + this.item2ToolStripMenuItem.Name = "item2ToolStripMenuItem"; + this.item2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item2ToolStripMenuItem.Text = "Item 2"; + // + // item3ToolStripMenuItem + // + this.item3ToolStripMenuItem.Name = "item3ToolStripMenuItem"; + this.item3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item3ToolStripMenuItem.Text = "Item 3"; + // + // item4ToolStripMenuItem + // + this.item4ToolStripMenuItem.Name = "item4ToolStripMenuItem"; + this.item4ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item4ToolStripMenuItem.Text = "Item 4"; + // + // item5ToolStripMenuItem + // + this.item5ToolStripMenuItem.Name = "item5ToolStripMenuItem"; + this.item5ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.item5ToolStripMenuItem.Text = "Item 5"; + // + // shutdownToolStripMenuItem + // + this.shutdownToolStripMenuItem.Name = "shutdownToolStripMenuItem"; + this.shutdownToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.shutdownToolStripMenuItem.Text = "Shutdown"; + // + // separatorToolStripMenuItem1 + // + this.separatorToolStripMenuItem1.Name = "separatorToolStripMenuItem1"; + this.separatorToolStripMenuItem1.Size = new System.Drawing.Size(149, 6); + // // Shifter // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -523,6 +763,18 @@ namespace ShiftOS.WinForms.Applications this.tspreview.ResumeLayout(false); this.tspreview.PerformLayout(); this.pnlintro.ResumeLayout(false); + this.pnldesktoppreview.ResumeLayout(false); + this.pnlscreensaver.ResumeLayout(false); + this.desktoppanel.ResumeLayout(false); + this.desktoppanel.PerformLayout(); + this.sysmenuholder.ResumeLayout(false); + this.sysmenuholder.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.pnladvancedal.ResumeLayout(false); + this.pnlalsystemactions.ResumeLayout(false); + this.pnlalsystemactions.PerformLayout(); + this.pnlstatus.ResumeLayout(false); this.ResumeLayout(false); } @@ -571,5 +823,28 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.Panel pnlintro; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel pnldesktoppreview; + private System.Windows.Forms.Panel pnlscreensaver; + private System.Windows.Forms.Panel pnlssicon; + private System.Windows.Forms.Panel desktoppanel; + private System.Windows.Forms.Label lbtime; + private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; + private System.Windows.Forms.Panel sysmenuholder; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem apps; + private System.Windows.Forms.Panel pnladvancedal; + private System.Windows.Forms.FlowLayoutPanel flapps; + private System.Windows.Forms.FlowLayoutPanel flcategories; + private System.Windows.Forms.Panel pnlalsystemactions; + private System.Windows.Forms.Button btnshutdown; + private System.Windows.Forms.Panel pnlstatus; + private System.Windows.Forms.Label lbalstatus; + private System.Windows.Forms.ToolStripMenuItem item1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item3ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item4ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem item5ToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem shutdownToolStripMenuItem; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index e22956f..600a9b2 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -47,6 +47,164 @@ namespace ShiftOS.WinForms.Applications PopulateShifter(); } + [ShifterMeta("Desktop")] + public void ResetDesktop() + { + pnldesktoppreview.BringToFront(); + pnldesktoppreview.Tag = "keepbg"; + SetupDesktop(); + } + + /// + /// Populates the panel buttons. + /// + /// The panel buttons. + public void PopulatePanelButtons() + { + if (DesktopFunctions.ShowDefaultElements == true) + { + panelbuttonholder.Controls.Clear(); + if (Shiftorium.IsInitiated == true) + { + if (Shiftorium.UpgradeInstalled("wm_panel_buttons")) + { + + var pnlbtn = new Panel(); + pnlbtn.Margin = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0); + pnlbtn.BackColor = LoadedSkin.PanelButtonColor; + pnlbtn.BackgroundImage = GetImage("panelbutton"); + pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton"); + + var pnlbtntext = new Label(); + pnlbtntext.Text = "Panel Button Text"; + pnlbtntext.AutoSize = true; + pnlbtntext.Location = LoadedSkin.PanelButtonFromLeft; + pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor; + pnlbtntext.BackColor = Color.Transparent; + + pnlbtn.BackColor = LoadedSkin.PanelButtonColor; + if (pnlbtn.BackgroundImage != null) + { + pnlbtntext.BackColor = Color.Transparent; + } + pnlbtn.Size = LoadedSkin.PanelButtonSize; + pnlbtn.Tag = "keepbg"; + pnlbtntext.Tag = "keepbg"; + pnlbtn.Controls.Add(pnlbtntext); + this.panelbuttonholder.Controls.Add(pnlbtn); + pnlbtn.Show(); + pnlbtntext.Show(); + + pnlbtntext.Font = LoadedSkin.PanelButtonFont; + + + + + } + } + } + + } + + /// + /// Setups the desktop. + /// + /// The desktop. + public void SetupDesktop() + { + if (DesktopFunctions.ShowDefaultElements == true) + { + desktoppanel.BackColor = Color.Green; + + //upgrades + + if (Shiftorium.IsInitiated == true) + { + desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); + lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); + + //skinning + lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + + panelbuttonholder.Top = 0; + panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; + panelbuttonholder.Height = desktoppanel.Height; + panelbuttonholder.BackColor = Color.Transparent; + panelbuttonholder.Margin = new Padding(0, 0, 0, 0); + + sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher"); + + //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. + //To compensate, we must recreate the desktop color and make the alpha channel '255'. + pnldesktoppreview.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); + //Not doing this will cause an ArgumentException. + + DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => + { + pnldesktoppreview.BackgroundImage = img; + })); + pnldesktoppreview.BackgroundImageLayout = GetImageLayout("desktopbackground"); + desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; + + var pnlimg = GetImage("desktoppanel"); + if (pnlimg != null) + { + var bmp = new Bitmap(pnlimg); + bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); + pnlimg = bmp; + } + + desktoppanel.BackgroundImage = pnlimg; + if (desktoppanel.BackgroundImage != null) + { + desktoppanel.BackColor = Color.Transparent; + } + var appimg = GetImage("applauncher"); + if (appimg != null) + { + var bmp = new Bitmap(appimg); + bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); + appimg = bmp; + } + menuStrip1.BackgroundImage = appimg; + lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + lbtime.Font = LoadedSkin.DesktopPanelClockFont; + if (desktoppanel.BackgroundImage == null) + { + lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; + } + else + { + lbtime.BackColor = Color.Transparent; + } + apps.Text = LoadedSkin.AppLauncherText; + sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; + sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; + apps.Size = sysmenuholder.Size; + menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable(LoadedSkin)); + desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); + desktoppanel.Height = LoadedSkin.DesktopPanelHeight; + if (LoadedSkin.DesktopPanelPosition == 1) + { + desktoppanel.Dock = DockStyle.Bottom; + } + else + { + desktoppanel.Dock = DockStyle.Top; + } + } + } + else + { + desktoppanel.Hide(); + } + + PopulatePanelButtons(); + } + + + + [ShifterMeta("Windows")] public void SetupWindowPreview() { diff --git a/ShiftOS.WinForms/Applications/Shifter.resx b/ShiftOS.WinForms/Applications/Shifter.resx index 9533980..c18f92a 100644 --- a/ShiftOS.WinForms/Applications/Shifter.resx +++ b/ShiftOS.WinForms/Applications/Shifter.resx @@ -117,20 +117,23 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - The Shifter is a brilliant application for ShiftOS that allows you to customize almost every aspect of the user interface. - -To use the Shifter, simply select a category from the left, then a list of sub-categories will show up. Choose a sub-category, then a list of settings will appear. You can modify any one of these settings. A live preview of what you are editing will show, and you can use it to see what your new user experience will look like. - -When you are done, hit Apply Changes to apply your changes! - -You can also earn Codepoints through the Shifter. The more you tweak and customize, the more Codepoints you'll earn! Go nuts! Shift it your way! - + + 230, 17 + + + 127, 17 + + + 17, 17 + + + 17, 17 + 127, 17 - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -145,7 +148,7 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -160,7 +163,7 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG @@ -175,7 +178,13 @@ You can also earn Codepoints through the Shifter. The more you tweak and customi TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - 17, 17 - + + The Shifter is a brilliant application for ShiftOS that allows you to customize almost every aspect of the user interface. + +To use the Shifter, simply select a category from the left, then a list of sub-categories will show up. Choose a sub-category, then a list of settings will appear. You can modify any one of these settings. A live preview of what you are editing will show, and you can use it to see what your new user experience will look like. + +When you are done, hit Apply Changes to apply your changes! + +You can also earn Codepoints through the Shifter. The more you tweak and customize, the more Codepoints you'll earn! Go nuts! Shift it your way! + \ No newline at end of file diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 781e045..1c6f40c 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -277,7 +277,7 @@ namespace ShiftOS.WinForms.Tools { for (int i = 0; i < frm.Controls.Count; i++) { - SetupControls(frm.Controls[i], false); + SetupControls(frm.Controls[i], false); } }; diff --git a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs index a31edd9..81e8c89 100644 --- a/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs +++ b/ShiftOS.WinForms/Tools/ShiftOSMenuRenderer.cs @@ -364,14 +364,18 @@ namespace ShiftOS.WinForms.Tools return SkinEngine.GetImage(id); } - public Skin LoadedSkin + public AppLauncherColorTable() { - get - { - return SkinEngine.LoadedSkin; - } + LoadedSkin = SkinEngine.LoadedSkin; + } + + public AppLauncherColorTable(Skin skn) + { + LoadedSkin = skn; } + public Skin LoadedSkin { get; private set; } + public override Color ButtonSelectedHighlight { get { return LoadedSkin.Menu_ButtonSelectedHighlight; } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index e716803..e809f90 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -129,6 +129,7 @@ namespace ShiftOS.WinForms this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; + this._parentWindow.Show(); ControlManager.SetupControls(this._parentWindow); ParentWindow.OnSkinLoad(); @@ -208,7 +209,6 @@ namespace ShiftOS.WinForms this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; ParentWindow.OnLoad(); - this._parentWindow.Show(); } /// diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 4fce247..d356600 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -34,6 +34,7 @@ using System.Threading; using ShiftOS; using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; +using System.Net.Sockets; namespace ShiftOS.Engine { @@ -191,8 +192,15 @@ namespace ShiftOS.Engine } }; - client.Connect(mud_address, port); - + try + { + client.Connect(mud_address, port); + } + catch(SocketException ex) + { + System.Diagnostics.Debug.Print(ex.ToString()); + Initiate(mud_address, port); + } } public static void SendMessage(string name, string contents) -- cgit v1.2.3 From 56e216a430694d86c242df763484deba682f3302 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 15 Apr 2017 20:21:11 -0400 Subject: Hide AL when clicking on window ctrls --- .../Applications/MUDControlCentre.Designer.cs | 184 ++++++++--------- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 + ShiftOS.WinForms/Tools/ControlManager.cs | 5 +- ShiftOS.WinForms/WindowBorder.cs | 12 ++ ShiftOS.WinForms/WinformsDesktop.cs | 112 +++++++---- ShiftOS_TheReturn/Desktop.cs | 8 + ShiftOS_TheReturn/Skinning.cs | 224 ++++++++++++++++----- 7 files changed, 358 insertions(+), 194 deletions(-) (limited to 'ShiftOS.WinForms/WindowBorder.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 e833a9bf2751f16d8614af9aa20f5b9bec3d81a8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Apr 2017 14:53:10 -0400 Subject: FUCKTONS OF SHIFTORIUM WORK --- ShiftOS.WinForms/Applications/FormatEditor.cs | 3 +- ShiftOS.WinForms/Applications/Shiftnet.Designer.cs | 30 +- ShiftOS.WinForms/Applications/Shiftnet.cs | 301 +++++++-------------- .../Applications/ShiftoriumFrontend.cs | 2 +- ShiftOS.WinForms/Program.cs | 33 ++- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 18 ++ .../ShiftnetSites/AppscapeMain.Designer.cs | 113 ++++++++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 208 ++++++++++++++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx | 120 ++++++++ .../ShiftnetSites/MainHomepage.Designer.cs | 153 +++++++++++ ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs | 89 ++++++ ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx | 128 +++++++++ ShiftOS.WinForms/WindowBorder.cs | 15 +- ShiftOS_TheReturn/Command.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 2 +- ShiftOS_TheReturn/SaveSystem.cs | 2 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/ShiftnetSite.cs | 46 ++++ ShiftOS_TheReturn/Shiftorium.cs | 6 +- 20 files changed, 1040 insertions(+), 239 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx create mode 100644 ShiftOS_TheReturn/ShiftnetSite.cs (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index 7491e36..db52d85 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -36,11 +36,10 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] [Launcher("Format Editor", true, "al_format_editor", "Customization")] - [RequiresUpgrade("format_editor")] + [AppscapeEntry("Format Editor", "Edit the syntax of your Terminal to be however you like.", 750, "file_skimmer", "Customization")] [WinOpen("formateditor")] [DefaultTitle("Format Editor")] [DefaultIcon("iconFormatEditor")] - public partial class FormatEditor : UserControl, IShiftOSWindow { IList parts = new List(); diff --git a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs index eca44ae..a7fe700 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs @@ -57,13 +57,12 @@ namespace ShiftOS.WinForms.Applications this.btnforward = new System.Windows.Forms.Button(); this.txturl = new System.Windows.Forms.TextBox(); this.btngo = new System.Windows.Forms.Button(); - this.wbcanvas = new System.Windows.Forms.WebBrowser(); + this.pnlcanvas = new System.Windows.Forms.Panel(); this.flcontrols.SuspendLayout(); this.SuspendLayout(); // // flcontrols // - this.flcontrols.AutoSize = true; this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.flcontrols.Controls.Add(this.btnback); this.flcontrols.Controls.Add(this.btnforward); @@ -123,42 +122,35 @@ namespace ShiftOS.WinForms.Applications this.btngo.UseVisualStyleBackColor = true; this.btngo.Click += new System.EventHandler(this.btngo_Click); // - // wbcanvas + // pnlcanvas // - this.wbcanvas.Dock = System.Windows.Forms.DockStyle.Fill; - this.wbcanvas.IsWebBrowserContextMenuEnabled = false; - this.wbcanvas.Location = new System.Drawing.Point(0, 29); - this.wbcanvas.MinimumSize = new System.Drawing.Size(20, 20); - this.wbcanvas.Name = "wbcanvas"; - this.wbcanvas.ScriptErrorsSuppressed = true; - this.wbcanvas.Size = new System.Drawing.Size(805, 510); - this.wbcanvas.TabIndex = 1; - this.wbcanvas.WebBrowserShortcutsEnabled = false; - this.wbcanvas.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbcanvas_Navigated); - this.wbcanvas.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.wbcanvas_Navigating); + this.pnlcanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcanvas.Location = new System.Drawing.Point(0, 29); + this.pnlcanvas.Name = "pnlcanvas"; + this.pnlcanvas.Size = new System.Drawing.Size(805, 510); + this.pnlcanvas.TabIndex = 1; // // Shiftnet // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.wbcanvas); + this.Controls.Add(this.pnlcanvas); this.Controls.Add(this.flcontrols); this.Name = "Shiftnet"; this.Size = new System.Drawing.Size(805, 539); this.flcontrols.ResumeLayout(false); this.flcontrols.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - - private System.Windows.Forms.FlowLayoutPanel flcontrols; private System.Windows.Forms.Button btnback; private System.Windows.Forms.Button btnforward; private System.Windows.Forms.TextBox txturl; private System.Windows.Forms.Button btngo; - private System.Windows.Forms.WebBrowser wbcanvas; + private System.Windows.Forms.Panel pnlcanvas; + private System.Windows.Forms.FlowLayoutPanel flcontrols; } } diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 54a8aa6..7f5d3c1 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -35,6 +35,8 @@ using ShiftOS.Engine; using Newtonsoft.Json; using static ShiftOS.Engine.SkinEngine; using ShiftOS.WinForms.Tools; +using System.IO; +using System.Reflection; namespace ShiftOS.WinForms.Applications { @@ -50,216 +52,34 @@ namespace ShiftOS.WinForms.Applications [WinOpen("shiftnet")] [RequiresUpgrade("victortran_shiftnet")] [DefaultIcon("iconShiftnet")] - public partial class Shiftnet : UserControl, IShiftOSWindow + public partial class Shiftnet : UserControl, IShiftOSWindow, IShiftnetClient { public Shiftnet() { InitializeComponent(); - ServerManager.MessageReceived += (msg) => - { - try - { - if (msg.Name == "shiftnet_file") - { - if (Objects.ShiftFS.Utils.FileExists("0:/md.txt")) - { - this.Invoke(new Action(() => - { - wbcanvas.DocumentText = ConstructHtml(Objects.ShiftFS.Utils.ReadAllText("0:/md.txt")); - })); - } - else - { - this.Invoke(new Action(() => - { - wbcanvas.DocumentText = ConstructHtml(msg.Contents); - })); - } - } - } - catch - { - - } - }; - } - - public string ConstructHtml(string markdown) - { - var TerminalForeColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalForeColorCC); - var TerminalBackColor = ControlManager.ConvertColor(SkinEngine.LoadedSkin.TerminalBackColorCC); - string html = $@" - - - - - - -"; - - string body = CommonMark.CommonMarkConverter.Convert(markdown); - for (int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed()) - { - //halt the page load until 'download' finishes. - } - html = html.Replace("", body); - return html; } public string CurrentUrl { get; set; } - private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e) - { - string Url = e.Url.ToString().Replace("http://", ""); - if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:")) - { - e.Cancel = true; - Future.Clear(); - if (Url.StartsWith("runsyscmd/")) - { - ProcessShiftnetCmd(Url.Replace("runsyscmd/", "")); - } - - ShiftnetNavigate(Url.ToString()); - } - } - - public void ProcessShiftnetCmd(string cmd) - { - var args = cmd.Split('/'); - switch (args[0]) - { - case "setsnsub": - for (int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++) - { - if (DownloadManager.GetAllSubscriptions()[i].Name == args[1]) - { - var sub = DownloadManager.GetAllSubscriptions()[i]; - Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action((answer) => - { - if (answer == true) - { - if (SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth) - { - //Initial fee gets deducted. - SaveSystem.CurrentSave.Codepoints -= sub.CostPerMonth; - //Then we set the subscription. - SaveSystem.CurrentSave.ShiftnetSubscription = i; - //Then we say that we have paid this month. - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - //Then we send our save to the MUD. - SaveSystem.SaveGame(); - - } - else - { - //User can't afford this subscription. - Infobox.Show("Shiftnet - Not enough Codepoints", $"You cannot afford to pay for this subscription at this time. You need {sub.CostPerMonth - SaveSystem.CurrentSave.Codepoints} more Codepoints."); - } - } - })); - } - } - return; - } - } - public Stack History = new Stack(); public Stack Future = new Stack(); - public void ShiftnetNavigate(string Url, bool pushHistory = true) - { - if (Url.EndsWith(".rnp") || !Url.Contains(".")) - { - if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory) - History.Push(CurrentUrl); - CurrentUrl = Url; - ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new - { - url = Url - })); - txturl.Text = Url; - - } - else - { - ServerMessageReceived smr = null; - smr = (msg) => - { - if (msg.Name == "download_meta") - { - var bytes = JsonConvert.DeserializeObject(msg.Contents); - string destPath = null; - string ext = Url.Split('.')[Url.Split('.').Length - 1]; - this.Invoke(new Action(() => - { - FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action((file) => - { - destPath = file; - })); - })); - while (string.IsNullOrEmpty(destPath)) - { - - } - var d = new Download - { - ShiftnetUrl = Url, - Destination = destPath, - Bytes = bytes, - Progress = 0, - }; - DownloadManager.StartDownload(d); - this.Invoke(new Action(() => - { - AppearanceManager.SetupWindow(new Downloader()); - })); - ServerManager.MessageReceived -= smr; - } - }; - ServerManager.MessageReceived += smr; - ServerManager.SendMessage("download_start", Url); - } - } + public IShiftnetSite CurrentPage = null; public void OnLoad() { - ShiftnetNavigate("shiftnet/main"); + NavigateToUrl("shiftnet/main"); } public void OnSkinLoad() { - ShiftnetNavigate(CurrentUrl); + CurrentPage?.OnSkinLoad(); + btnback.Location = new Point(2, 2); + btnforward.Location = new Point(btnback.Left + btnback.Width + 2, 2); + txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2); + txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width*2) - 2; + btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2); } public bool OnUnload() @@ -269,6 +89,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + CurrentPage?.OnUpgrade(); } private void btnback_Click(object sender, EventArgs e) @@ -279,7 +100,7 @@ namespace ShiftOS.WinForms.Applications if (!string.IsNullOrEmpty(hist)) { Future.Push(hist); - ShiftnetNavigate(hist, false); + NavigateToUrl(hist); } } catch @@ -295,7 +116,8 @@ namespace ShiftOS.WinForms.Applications string fut = Future.Pop(); if (!string.IsNullOrEmpty(fut)) { - ShiftnetNavigate(fut); + History.Push(CurrentUrl); + NavigateToUrl(fut); } } catch @@ -309,8 +131,8 @@ namespace ShiftOS.WinForms.Applications if (!string.IsNullOrWhiteSpace(txturl.Text)) { Future.Clear(); - - ShiftnetNavigate(txturl.Text); + History.Push(CurrentUrl); + NavigateToUrl(txturl.Text); } } @@ -323,8 +145,95 @@ namespace ShiftOS.WinForms.Applications } } - private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e) + public void NavigateToUrl(string url) + { + txturl.Text = url; + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach (var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) + { + if (type.BaseType == typeof(UserControl)) + { + var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + if (attribute != null) + { + if (attribute.Url == url) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + var obj = (IShiftnetSite)Activator.CreateInstance(type, null); + obj.GoToUrl += (u) => + { + History.Push(u); + NavigateToUrl(u); + }; + obj.GoBack += () => + { + string u = History.Pop(); + Future.Push(u); + NavigateToUrl(u); + }; + CurrentPage = obj; + this.pnlcanvas.Controls.Clear(); + this.pnlcanvas.Controls.Add((UserControl)obj); + ((UserControl)obj).Show(); + ((UserControl)obj).Dock = DockStyle.Fill; + obj.OnUpgrade(); + obj.OnSkinLoad(); + obj.Setup(); + return; + } + } + } + } + } + } + } + catch (Exception ex) + { + pnlcanvas.Controls.Clear(); + var tlbl = new Label(); + tlbl.Text = "Server error in \"" + url + "\" application."; + tlbl.Tag = "header1"; + tlbl.AutoSize = true; + tlbl.Location = new Point(10, 10); + tlbl.Dock = DockStyle.Top; + pnlcanvas.Controls.Add(tlbl); + tlbl.Show(); + + var crash = new Label(); + crash.Dock = DockStyle.Fill; + crash.AutoSize = false; + crash.Text = ex.ToString(); + pnlcanvas.Controls.Add(crash); + crash.Show(); + crash.BringToFront(); + ControlManager.SetupControls(pnlcanvas); + return; + } + } + } + pnlcanvas.Controls.Clear(); + var lbl = new Label(); + lbl.Text = "Page not found!"; + lbl.Tag = "header1"; + lbl.AutoSize = true; + lbl.Location = new Point(10, 10); + pnlcanvas.Controls.Add(lbl); + lbl.Show(); + + } + + public void RefreshSite() { + NavigateToUrl(CurrentUrl); } } } diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 0762897..66b0448 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -185,7 +185,7 @@ namespace ShiftOS.WinForms.Applications { long cpCost = 0; backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); + Dictionary UpgradesToBuy = new Dictionary(); foreach (var itm in lbupgrades.SelectedItems) { cpCost += upgrades[itm.ToString()].Cost; diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 36c9338..3343cb0 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -34,6 +34,7 @@ using static ShiftOS.Objects.ShiftFS.Utils; using ShiftOS.WinForms.Applications; using ShiftOS.WinForms.Tools; using System.Reflection; +using System.IO; namespace ShiftOS.WinForms { @@ -98,7 +99,37 @@ namespace ShiftOS.WinForms { public List GetDefaults() { - return JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); + var defaultList = JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); + + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach(var type in asm.GetTypes()) + { + var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute; + if(attrib != null) + { + var upgrade = new ShiftoriumUpgrade + { + Id = attrib.Name.ToLower().Replace(" ", "_"), + Name = attrib.Name, + Description = attrib.Description, + Cost = attrib.Cost, + Category = attrib.Category, + Dependencies = (string.IsNullOrWhiteSpace(attrib.DependencyString)) ? "appscape_handled_nodisplay" : "appscape_handled_nodisplay;" + attrib.DependencyString + }; + defaultList.Add(upgrade); + } + } + } + catch { } + } + } + return defaultList; } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index ca555d4..e68277c 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -368,13 +368,6 @@ Category: "GUI", Dependencies:"desktop;wm_unlimited_windows" }, - { - Name: "Format Editor", - Cost: 6000, - Description: "Allows you to change the format of commands.", - Category: "Applications", - Dependencies: "shifter;name_changer" - }, { Name: "Format Editor Optional Text", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index bd8fd65..3edfd38 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -317,6 +317,18 @@ Resources.resx + + UserControl + + + AppscapeMain.cs + + + UserControl + + + MainHomepage.cs + @@ -463,6 +475,12 @@ Designer Resources.Designer.cs + + AppscapeMain.cs + + + MainHomepage.cs + WindowBorder.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs new file mode 100644 index 0000000..6698e5a --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.Designer.cs @@ -0,0 +1,113 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class AppscapeMain + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); + this.pnlappslist = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.lbtitle = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(17, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Appscape"; + // + // flcategories + // + this.flcategories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.flcategories.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flcategories.Location = new System.Drawing.Point(20, 120); + this.flcategories.Margin = new System.Windows.Forms.Padding(0); + this.flcategories.Name = "flcategories"; + this.flcategories.Size = new System.Drawing.Size(187, 310); + this.flcategories.TabIndex = 1; + // + // pnlappslist + // + this.pnlappslist.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.pnlappslist.Location = new System.Drawing.Point(221, 120); + this.pnlappslist.Name = "pnlappslist"; + this.pnlappslist.Size = new System.Drawing.Size(459, 310); + this.pnlappslist.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(57, 13); + this.label2.TabIndex = 3; + this.label2.Tag = "header2"; + this.label2.Text = "Categories"; + // + // lbtitle + // + this.lbtitle.AutoSize = true; + this.lbtitle.Location = new System.Drawing.Point(218, 76); + this.lbtitle.Name = "lbtitle"; + this.lbtitle.Size = new System.Drawing.Size(57, 13); + this.lbtitle.TabIndex = 4; + this.lbtitle.Tag = "header2"; + this.lbtitle.Text = "Categories"; + // + // AppscapeMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbtitle); + this.Controls.Add(this.label2); + this.Controls.Add(this.pnlappslist); + this.Controls.Add(this.flcategories); + this.Controls.Add(this.label1); + this.Name = "AppscapeMain"; + this.Size = new System.Drawing.Size(709, 457); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.FlowLayoutPanel flcategories; + private System.Windows.Forms.Panel pnlappslist; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lbtitle; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs new file mode 100644 index 0000000..88db07b --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -0,0 +1,208 @@ +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.ShiftnetSites +{ + [ShiftnetSite("shiftnet/appscape", "Appscape", "Bringing ShiftOS to life")] + [ShiftnetFundamental] + public partial class AppscapeMain : UserControl, IShiftnetSite + { + public AppscapeMain() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public string Category = "All"; + + public string[] GetCategories() + { + var upgrades = Shiftorium.GetDefaults().Where(x => x.Dependencies.Contains("appscape_")); + List cats = new List(); + cats.Add("All"); + try + { + if (upgrades.Count() > 0) + foreach (var upg in upgrades) + { + if (!cats.Contains(upg.Category)) + cats.Add(upg.Category); + } + } + catch { } + return cats.ToArray(); + } + + public ShiftoriumUpgrade CurrentUpgrade = null; + + public void SetupCategory(string cat) + { + pnlappslist.Controls.Clear(); + pnlappslist.Show(); + pnlappslist.BringToFront(); + Category = cat; + var upgrades = GetAllInCategory(); + lbtitle.Text = cat; + if(upgrades.Length == 0) + { + var err = new Label(); + err.AutoSize = true; + err.Text = "There are no apps in this list! Come back later for more."; + pnlappslist.Controls.Add(err); + err.Show(); + } + else + { + var fl = new FlowLayoutPanel(); + fl.Dock = DockStyle.Fill; + pnlappslist.Controls.Add(fl); + fl.Show(); + foreach(var upg in upgrades) + { + var pnl = new Panel(); + pnl.Height = 250; + pnl.Width = 200; + fl.Controls.Add(pnl); + pnl.Show(); + var upgTitle = new Label(); + upgTitle.Text = upg.Name; + upgTitle.Dock = DockStyle.Top; + upgTitle.AutoSize = true; + upgTitle.MaximumSize = new Size(pnl.Width, 0); + upgTitle.Tag = "header3"; + pnl.Controls.Add(upgTitle); + upgTitle.Show(); + + var cp_display = new Panel(); + cp_display.Height = 30; + cp_display.Dock = DockStyle.Bottom; + pnl.Controls.Add(cp_display); + cp_display.Show(); + + var cp_value = new Label(); + if (Shiftorium.UpgradeInstalled(upg.ID)) + { + cp_value.Text = "Out of stock."; + } + else + { + cp_value.Text = $"{upg.Cost} CP"; + } + cp_value.AutoSize = true; + cp_value.Top = (cp_display.Height - cp_value.Height) / 2; + cp_value.Left = 5; + cp_display.Controls.Add(cp_value); + cp_value.Show(); + + + if(cp_value.Text != "Out of stock.") + { + var more_info = new Button(); + more_info.Text = "More info"; + more_info.Click += (o, a) => + { + ViewMoreInfo(upg); + }; + more_info.AutoSize = false; + more_info.AutoSizeMode = AutoSizeMode.GrowAndShrink; + more_info.Top = (cp_display.Height - more_info.Height) / 2; + more_info.Left = cp_display.Width - more_info.Width - 5; + cp_display.Controls.Add(more_info); + more_info.Show(); + } + + var desc = new Label(); + desc.Text = upg.Description; + desc.AutoSize = false; + desc.Dock = DockStyle.Fill; + pnl.Controls.Add(desc); + desc.Show(); + desc.BringToFront(); + + + ControlManager.SetupControls(pnl); + } + } + } + + public void ViewMoreInfo(ShiftoriumUpgrade upg) + { + + } + + public ShiftoriumUpgrade[] GetAllInCategory() + { + var upgrades = Shiftorium.GetDefaults().Where(x => (x.Dependencies == null) ? false : x.Dependencies.Contains("appscape_")); + if (upgrades.Count() == 0) + return new ShiftoriumUpgrade[0]; + + if (Category == "All") + return upgrades.ToArray(); + else + return upgrades.Where(x => x.Category == Category).ToArray(); + } + + public void Setup() + { + flcategories.Controls.Clear(); + foreach(var cat in this.GetCategories()) + { + var btn = new Button(); + btn.Text = cat; + btn.Click += (o, a) => + { + SetupCategory(cat); + }; + ControlManager.SetupControl(btn); + btn.Width = flcategories.Width - 2; + flcategories.Controls.Add(btn); + btn.Show(); + } + SetupCategory("All"); + } + } +} + +namespace ShiftOS.WinForms +{ + /// + /// Special version of for specifying Appscape applications as Shiftorium upgrades. + /// + public class AppscapeEntryAttribute : RequiresUpgradeAttribute + { + public AppscapeEntryAttribute(string name, string description, long cost, string dependencies = "", string category = "Misc") : base((string.IsNullOrWhiteSpace(dependencies)) ? name.ToLower().Replace(" ","_") : name.ToLower().Replace(" ", "_") + dependencies) + { + Name = name; + Description = description; + Category = category; + Cost = cost; + DependencyString = dependencies; + } + + public string Name { get; private set; } + public string Description { get; private set; } + public string Category { get; private set; } + public long Cost { get; private set; } + public string DependencyString { get; private set; } + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.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/ShiftnetSites/MainHomepage.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs new file mode 100644 index 0000000..bebc8bd --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.Designer.cs @@ -0,0 +1,153 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class MainHomepage + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainHomepage)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.lbspecheader = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.label4 = new System.Windows.Forms.Label(); + this.flfundamentals = new System.Windows.Forms.FlowLayoutPanel(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(710, 65); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Welcome to the Shiftnet!"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 65); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(710, 22); + this.label2.TabIndex = 1; + this.label2.Text = "The Shiftnet is a vast network of services, websites, software and so much more f" + + "or ShiftOS. Have a look around!"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // panel1 + // + this.panel1.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.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.lbspecheader); + this.panel1.Location = new System.Drawing.Point(27, 140); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(389, 281); + this.panel1.TabIndex = 2; + // + // lbspecheader + // + this.lbspecheader.Dock = System.Windows.Forms.DockStyle.Top; + this.lbspecheader.Location = new System.Drawing.Point(0, 0); + this.lbspecheader.Name = "lbspecheader"; + this.lbspecheader.Size = new System.Drawing.Size(389, 42); + this.lbspecheader.TabIndex = 0; + this.lbspecheader.Tag = "header3"; + this.lbspecheader.Text = "How to use the Shiftnet"; + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Fill; + this.label3.Location = new System.Drawing.Point(0, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(389, 239); + this.label3.TabIndex = 1; + this.label3.Text = resources.GetString("label3.Text"); + // + // panel2 + // + this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel2.Controls.Add(this.flfundamentals); + this.panel2.Controls.Add(this.label4); + this.panel2.Location = new System.Drawing.Point(439, 140); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(247, 281); + this.panel2.TabIndex = 3; + // + // label4 + // + this.label4.Dock = System.Windows.Forms.DockStyle.Top; + this.label4.Location = new System.Drawing.Point(0, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(247, 42); + this.label4.TabIndex = 1; + this.label4.Tag = "header3"; + this.label4.Text = "The Fundamentals"; + // + // flfundamentals + // + this.flfundamentals.Dock = System.Windows.Forms.DockStyle.Fill; + this.flfundamentals.Location = new System.Drawing.Point(0, 42); + this.flfundamentals.Name = "flfundamentals"; + this.flfundamentals.Size = new System.Drawing.Size(247, 239); + this.flfundamentals.TabIndex = 2; + // + // MainHomepage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "MainHomepage"; + this.Size = new System.Drawing.Size(710, 437); + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label lbspecheader; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.FlowLayoutPanel flfundamentals; + private System.Windows.Forms.Label label4; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs new file mode 100644 index 0000000..cb39cd6 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; +using System.Reflection; +using System.IO; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/main", "Main Site", "The main Shiftnet hub.")] + public partial class MainHomepage : UserControl, IShiftnetSite + { + public MainHomepage() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + + } + + public void Setup() + { + //Get the Fundamentals List + flfundamentals.Controls.Clear(); + foreach (var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if (exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach (var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) + { + if (type.BaseType == typeof(UserControl)) + { + var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + if (attribute != null) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + if (type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetFundamentalAttribute) != null) + { + var dash = new Label(); + dash.Text = " - "; + dash.AutoSize = true; + flfundamentals.Controls.Add(dash); + dash.Show(); + var link = new LinkLabel(); + link.Text = attribute.Name; + link.Click += (o, a) => + { + GoToUrl?.Invoke(attribute.Url); + }; + flfundamentals.Controls.Add(link); + flfundamentals.SetFlowBreak(link, true); + link.Show(); + } + } + } + } + } + } + } + catch { } + } + } + + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx new file mode 100644 index 0000000..e9a0c8f --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + The Shiftnet works a lot like a regular web browser. To browse to a website, you can either click links or you can type a Shiftnet URL into your Address Bar at the top and click "Go". + +An example of a Shiftnet URL would be "shiftnet/main", which you are at right now. This is the main Shiftnet hub. You can also browse to files and folder listings, if you have access to them. + + +There are lots of Shiftnet websites for you to visit - so go ahead and explore, but first, check out some of the fundamental sites and services to the right! + + \ No newline at end of file diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 64f2da4..2829a3e 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -134,18 +134,16 @@ 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(); + SetupControls(this); + this.Width = LoadedSkin.LeftBorderWidth + this.Width + LoadedSkin.RightBorderWidth; + this.Height = LoadedSkin.TitlebarHeight + this.Height + LoadedSkin.BottomBorderWidth; ControlManager.SetupControls(this._parentWindow); - ParentWindow.OnSkinLoad(); - ParentWindow.OnUpgrade(); Shiftorium.Installed += () => { Setup(); @@ -221,6 +219,9 @@ namespace ShiftOS.WinForms this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; ParentWindow.OnLoad(); + ParentWindow.OnSkinLoad(); + ParentWindow.OnUpgrade(); + } /// diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index c6d58e1..09cf206 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -104,7 +104,7 @@ namespace ShiftOS.Engine /// /// Gets whether the dependent upgrade(s) are installed. /// - public bool Installed + public virtual bool Installed { get { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 0257f11..ce94030 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -612,7 +612,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); cat = args["cat"].ToString(); } - Dictionary upgrades = new Dictionary(); + Dictionary upgrades = new Dictionary(); int maxLength = 5; IEnumerable upglist = Shiftorium.GetAvailable(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 998c60d..3e68a70 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -223,7 +223,7 @@ namespace ShiftOS.Engine public static event EmptyEventHandler GameReady; - public static void TransferCodepointsToVoid(int amount) + public static void TransferCodepointsToVoid(long amount) { CurrentSave.Codepoints -= amount; NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index b6ff903..f7b730f 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -124,6 +124,7 @@ + diff --git a/ShiftOS_TheReturn/ShiftnetSite.cs b/ShiftOS_TheReturn/ShiftnetSite.cs new file mode 100644 index 0000000..5460171 --- /dev/null +++ b/ShiftOS_TheReturn/ShiftnetSite.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public interface IShiftnetSite + { + void Setup(); + void OnSkinLoad(); + void OnUpgrade(); + + event Action GoToUrl; + event Action GoBack; + } + + /// + /// Marks a shiftnet site as a fundamental, and will make it display on the homepage. + /// + public class ShiftnetFundamentalAttribute : Attribute + { + + } + + public interface IShiftnetClient + { + void NavigateToUrl(string url); + void RefreshSite(); + } + + public class ShiftnetSiteAttribute : Attribute + { + public ShiftnetSiteAttribute(string url, string name, string description) + { + Url = url; + Name = name; + Description = description; + } + + public string Url { get; private set; } + public string Name { get; private set; } + public string Description { get; private set; } + } +} diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 43ea13a..c46aed0 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -85,7 +85,7 @@ namespace ShiftOS.Engine return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; } - public static bool Buy(string id, int cost) + public static bool Buy(string id, long cost) { if(SaveSystem.CurrentSave.Codepoints >= cost) { @@ -188,7 +188,7 @@ namespace ShiftOS.Engine } - public static int GetCPValue(string id) + public static long GetCPValue(string id) { foreach(var upg in GetDefaults()) { @@ -316,7 +316,7 @@ namespace ShiftOS.Engine { public string Name { get; set; } public string Description { get; set; } - public int Cost { get; set; } + public long Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } public string Id { get; set; } public string Category { get; set; } -- cgit v1.2.3 From 7c070a8213fc59f289385d82b60c3a49c02e03a9 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Apr 2017 17:23:29 -0400 Subject: block ctrl and alt in terminal --- ShiftOS.WinForms/Applications/Terminal.cs | 6 ++++++ ShiftOS.WinForms/WindowBorder.cs | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index cae0bda..a4889e9 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -250,6 +250,12 @@ namespace ShiftOS.WinForms.Applications }; txt.KeyDown += (o, a) => { + if (a.Control == true || a.Alt == true) + { + a.SuppressKeyPress = true; + return; + } + if (a.KeyCode == Keys.Enter) { try diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 2829a3e..0d351d2 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -134,14 +134,14 @@ namespace ShiftOS.WinForms } }; - - + + this.Width = (LoadedSkin.LeftBorderWidth*2) + _parentWindow.Width + LoadedSkin.RightBorderWidth; + this.Height = (LoadedSkin.TitlebarHeight*2) + _parentWindow.Height + LoadedSkin.BottomBorderWidth; + this.pnlcontents.Controls.Add(this._parentWindow); this._parentWindow.Dock = DockStyle.Fill; this._parentWindow.Show(); SetupControls(this); - this.Width = LoadedSkin.LeftBorderWidth + this.Width + LoadedSkin.RightBorderWidth; - this.Height = LoadedSkin.TitlebarHeight + this.Height + LoadedSkin.BottomBorderWidth; ControlManager.SetupControls(this._parentWindow); Shiftorium.Installed += () => -- cgit v1.2.3 From 7293e2f07f99603c1f63826d705ce4179d70c663 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Apr 2017 13:28:37 -0400 Subject: Window Resizing. --- ShiftOS.WinForms/Resources/Shiftorium.txt | 8 +++- ShiftOS.WinForms/TestCommandsForUpgrades.cs | 3 +- ShiftOS.WinForms/WindowBorder.Designer.cs | 15 ++++++++ ShiftOS.WinForms/WindowBorder.cs | 60 +++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 8431260..b528c72 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -14,7 +14,13 @@ Dependencies: "screensavers;shifter", Category: "Customization" }, - + { + Name: "Resizable Windows", + Cost: 250, + Dependencies: "draggable_windows", + Description: "We can drag windows around, which is nice, but what if you want to give a window more working space? This upgrade allows you to resize windows.", + Category: "Enhancements" + }, // CALCULATOR UPGRADES { diff --git a/ShiftOS.WinForms/TestCommandsForUpgrades.cs b/ShiftOS.WinForms/TestCommandsForUpgrades.cs index 491cc6a..739a2a2 100644 --- a/ShiftOS.WinForms/TestCommandsForUpgrades.cs +++ b/ShiftOS.WinForms/TestCommandsForUpgrades.cs @@ -10,11 +10,12 @@ namespace ShiftOS.WinForms [Namespace("test")] public static class TestCommandsForUpgrades { - [ShiftoriumUpgrade("Test Command", 50, "This is a simple test command", null, "Test")] [Command("simpletest")] public static bool Simple() { return true; } } + + } diff --git a/ShiftOS.WinForms/WindowBorder.Designer.cs b/ShiftOS.WinForms/WindowBorder.Designer.cs index ecd2586..e862c35 100644 --- a/ShiftOS.WinForms/WindowBorder.Designer.cs +++ b/ShiftOS.WinForms/WindowBorder.Designer.cs @@ -173,6 +173,9 @@ namespace ShiftOS.WinForms this.pnlbottom.Name = "pnlbottom"; this.pnlbottom.Size = new System.Drawing.Size(730, 2); this.pnlbottom.TabIndex = 1; + this.pnlbottom.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseDown); + this.pnlbottom.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlbottom_MouseMove); + this.pnlbottom.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseUp); // // pnlbottomr // @@ -181,6 +184,9 @@ namespace ShiftOS.WinForms this.pnlbottomr.Name = "pnlbottomr"; this.pnlbottomr.Size = new System.Drawing.Size(2, 2); this.pnlbottomr.TabIndex = 3; + this.pnlbottomr.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseDown); + this.pnlbottomr.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlbottomr_MouseMove); + this.pnlbottomr.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseUp); // // pnlbottoml // @@ -189,6 +195,9 @@ namespace ShiftOS.WinForms this.pnlbottoml.Name = "pnlbottoml"; this.pnlbottoml.Size = new System.Drawing.Size(2, 2); this.pnlbottoml.TabIndex = 2; + this.pnlbottoml.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseDown); + this.pnlbottoml.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlbottoml_MouseMove); + this.pnlbottoml.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseUp); // // pnlleft // @@ -198,6 +207,9 @@ namespace ShiftOS.WinForms this.pnlleft.Name = "pnlleft"; this.pnlleft.Size = new System.Drawing.Size(2, 461); this.pnlleft.TabIndex = 2; + this.pnlleft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseDown); + this.pnlleft.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlleft_MouseMove); + this.pnlleft.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseUp); // // pnlright // @@ -207,6 +219,9 @@ namespace ShiftOS.WinForms this.pnlright.Name = "pnlright"; this.pnlright.Size = new System.Drawing.Size(2, 461); this.pnlright.TabIndex = 3; + this.pnlright.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseDown); + this.pnlright.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseMove); + this.pnlright.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pnlright_MouseUp); // // pnlcontents // diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 0d351d2..49298dd 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -293,9 +293,11 @@ namespace ShiftOS.WinForms pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; pnlbottomr.BackgroundImage = GetImage("bottomrborder"); pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); + pnlbottomr.Width = pnlright.Width; pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; pnlbottoml.BackgroundImage = GetImage("bottomlborder"); pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); + pnlbottoml.Width = pnlleft.Width; lbtitletext.ForeColor = LoadedSkin.TitleTextColor; lbtitletext.Font = LoadedSkin.TitleFont; @@ -496,5 +498,63 @@ namespace ShiftOS.WinForms private void lbtitletext_MouseMove(object sender, MouseEventArgs e) { pnltitle_MouseMove(sender, e); } + + bool resizing = false; + + private void pnlright_MouseDown(object sender, MouseEventArgs e) + { + if (Shiftorium.UpgradeInstalled("resizable_windows")) + resizing = true; + } + + private void pnlright_MouseMove(object sender, MouseEventArgs e) + { + if(resizing == true) + { + this.Width += e.X; + } + } + + private void pnlright_MouseUp(object sender, MouseEventArgs e) + { + resizing = false; + } + + private void pnlleft_MouseMove(object sender, MouseEventArgs e) + { + if(resizing == true) + { + this.Left += e.X; + this.Width -= e.X; + } + } + + private void pnlbottom_MouseMove(object sender, MouseEventArgs e) + { + if(resizing == true) + { + this.Height += e.Y; + } + } + + private void pnlbottomr_MouseMove(object sender, MouseEventArgs e) + { + if(resizing == true) + { + this.Width += e.X; + this.Height += e.Y; + } + } + + private void pnlbottoml_MouseMove(object sender, MouseEventArgs e) + { + if (resizing == true) + { + this.Width -= e.X; + this.Height += e.Y; + this.Left += e.X; + } + + } } } -- cgit v1.2.3 From 12490dec7deaa972cb29166095a7ef0c1f005541 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Apr 2017 18:59:20 -0400 Subject: Various intro fixes. --- ShiftOS.WinForms/Oobe.cs | 5 ++++- ShiftOS.WinForms/OobeStory.cs | 6 ++++++ ShiftOS.WinForms/WindowBorder.cs | 4 ++++ ShiftOS_TheReturn/AudioManager.cs | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/WindowBorder.cs') diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 6017d35..309495d 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -261,7 +261,10 @@ You must join the digital society, rise up the ranks, and save us. { Utils.Delete(Paths.GetPath("user.dat")); } - Application.Restart(); + string json = Utils.ExportMount(0); + System.IO.File.WriteAllText(Paths.SaveFile, json); + System.Diagnostics.Process.Start(Application.ExecutablePath); + Environment.Exit(0); } }); diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index d4d066b..ab730e7 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -205,7 +205,11 @@ namespace ShiftOS.WinForms while (position == 0) Thread.Sleep(10); Console.WriteLine("Connecting to the multi-user domain as " + SaveSystem.CurrentSave.SystemName + "..."); + bool connected = false; + Engine.AudioManager.PlayCompleted += () => { connected = true; }; Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); + while (connected == false) + Thread.Sleep(10); Console.WriteLine("Connection successful, system spinning up..."); Thread.Sleep(200); UsernameWait: @@ -299,6 +303,8 @@ namespace ShiftOS.WinForms TerminalBackend.PrintPrompt(); Console.Write("sos.help"); TerminalBackend.InvokeCommand("sos.help"); + Thread.Sleep(1000); + TerminalBackend.PrintPrompt(); }; } }); diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 49298dd..25c7639 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -257,6 +257,7 @@ namespace ShiftOS.WinForms { this.DoubleBuffered = true; this.TransparencyKey = LoadedSkin.SystemKey; + pnlcontents.BackColor = this.TransparencyKey; pnltitle.Height = LoadedSkin.TitlebarHeight; pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; pnltitle.BackgroundImage = GetImage("titlebar"); @@ -504,7 +505,9 @@ namespace ShiftOS.WinForms private void pnlright_MouseDown(object sender, MouseEventArgs e) { if (Shiftorium.UpgradeInstalled("resizable_windows")) + { resizing = true; + } } private void pnlright_MouseMove(object sender, MouseEventArgs e) @@ -518,6 +521,7 @@ namespace ShiftOS.WinForms private void pnlright_MouseUp(object sender, MouseEventArgs e) { resizing = false; + pnlcontents.Show(); } private void pnlleft_MouseMove(object sender, MouseEventArgs e) diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index d689cad..a636497 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -87,6 +87,7 @@ namespace ShiftOS.Engine _out.Init(_reader); _out.Volume = _provider.Volume; _out.Play(); + _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; } catch { } } @@ -107,6 +108,8 @@ namespace ShiftOS.Engine ShiftOS.Engine.AudioManager.Play("snd.wav"); } + + public static event Action PlayCompleted; } public interface IAudioProvider -- cgit v1.2.3 From 31cc9148dd23737df16d8456a42d003cd31dd488 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 21 May 2017 12:21:41 +0000 Subject: holy ashit --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++ ShiftOS.Objects/ShiftFS.cs | 37 +- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 + ShiftOS.Server/SaveManager.cs | 17 +- .../Applications/FileSkimmer.Designer.cs | 11 +- ShiftOS.WinForms/Applications/FileSkimmer.cs | 69 +- ShiftOS.WinForms/Applications/Pong.Designer.cs | 769 --------------- ShiftOS.WinForms/Applications/Pong.cs | 977 ------------------- .../Applications/ShiftoriumFrontend.Designer.cs | 317 ------ .../Applications/ShiftoriumFrontend.cs | 274 ------ ShiftOS.WinForms/Applications/Skin Loader.cs | 342 ------- ShiftOS.WinForms/Applications/TriWrite.Designer.cs | 192 ---- ShiftOS.WinForms/Applications/TriWrite.cs | 76 -- ShiftOS.WinForms/Applications/TriWrite.resx | 108 +- ShiftOS.WinForms/Controls/TerminalBox.cs | 130 +++ .../DesktopWidgets/HeartbeatWidget.Designer.cs | 62 ++ ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs | 51 + .../DesktopWidgets/HeartbeatWidget.resx | 120 +++ ShiftOS.WinForms/GUILogin.Designer.cs | 135 +++ ShiftOS.WinForms/GUILogin.cs | 136 +++ ShiftOS.WinForms/GUILogin.resx | 120 +++ ShiftOS.WinForms/Oobe.cs | 4 + ShiftOS.WinForms/OobeStory.cs | 6 +- ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 + ShiftOS.WinForms/ShiftOS.WinForms.csproj | 34 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS.WinForms/WindowBorder.cs | 55 ++ ShiftOS_TheReturn/Commands.cs | 17 +- ShiftOS_TheReturn/LoginManager.cs | 65 ++ ShiftOS_TheReturn/SaveSystem.cs | 209 ++-- ShiftOS_TheReturn/ServerManager.cs | 16 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 + ShiftOS_TheReturn/UniteClient.cs | 12 +- ShiftOS_TheReturn/UserManagementCommands.cs | 113 +++ 38 files changed, 2506 insertions(+), 3067 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs delete mode 100644 ShiftOS.WinForms/Applications/Skin Loader.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx 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.WinForms/WindowBorder.cs') diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..b42cd34 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1030 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index c2121f0..45cdb14 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -32,23 +32,16 @@ using System.Threading; namespace ShiftOS.Objects.ShiftFS { - public enum Permissions - { - User, - Administrator, - Superuser, - All - } public class File { public string Name; public byte[] Data; public byte[] HeaderData; public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public System.IO.Stream GetStream() { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return new System.IO.MemoryStream(Data); } @@ -59,7 +52,7 @@ namespace ShiftOS.Objects.ShiftFS return null; } - public File(string name, byte[] data, bool ReadAccess_to_low_users, Permissions perm) + public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm) { Name = name; Data = data; @@ -73,31 +66,31 @@ namespace ShiftOS.Objects.ShiftFS public List Files = new List(); public List Subdirectories = new List(); public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public void AddFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Add(file); } } public void RemoveFile(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(Files.Find(x => x.Name == name)); } } public void RemoveFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(file); } } public File FindFileByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Files.Find(x => x.Name == name); } @@ -105,28 +98,28 @@ namespace ShiftOS.Objects.ShiftFS } public void AddDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Add(dir); } } public void RemoveDirectory(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); } } public void RemoveDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(dir); } } public Directory FindDirectoryByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Subdirectories.Find(x => x.Name == name); } @@ -136,7 +129,7 @@ namespace ShiftOS.Objects.ShiftFS public static class Utils { - public static Permissions CurrentUser { get; set; } + public static UserPermissions CurrentUser { get; set; } public static List Mounts { get; set; } @@ -232,7 +225,7 @@ namespace ShiftOS.Objects.ShiftFS { try { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser)); } catch { } } @@ -281,7 +274,7 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser)); } else { diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 7a19aeb..c2ef5ed 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -58,6 +58,7 @@ + diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs new file mode 100644 index 0000000..61d11b8 --- /dev/null +++ b/ShiftOS.Objects/UserConfig.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace ShiftOS.Objects +{ + public class UserConfig + { + public string UniteUrl { get; set; } + public string DigitalSocietyAddress { get; set; } + public int DigitalSocietyPort { get; set; } + + public static UserConfig Get() + { + var conf = new UserConfig + { + UniteUrl = "http://getshiftos.ml", + DigitalSocietyAddress = "michaeltheshifter.me", + DigitalSocietyPort = 13370 + }; + + if (!File.Exists("servers.json")) + { + File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); + } + else + { + conf = JsonConvert.DeserializeObject(File.ReadAllText("servers.json")); + } + return conf; + } + } +} diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..acf28a5 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -189,7 +189,7 @@ namespace ShiftOS.Server //Update the shiftos website with the user's codepoints. if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken)) { - var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString()); + var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString()); wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); wreq.GetResponse(); } @@ -216,6 +216,21 @@ namespace ShiftOS.Server WriteEncFile(savefile, JsonConvert.SerializeObject(save)); } + try + { + var wr = System.Net.HttpWebRequest.Create("http://getshiftos.ml/API/GetCodepoints"); + wr.Headers.Add("Authentication: Token " + save.UniteAuthToken); + var response = wr.GetResponse(); + using (var rstr = response.GetResponseStream()) + { + using (var sreader = new StreamReader(rstr)) + { + long cp = Convert.ToInt64(sreader.ReadToEnd()); + save.Codepoints = cp; + } + } + } + catch { } Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index a7b7aa5..965e4eb 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -69,10 +69,10 @@ namespace ShiftOS.WinForms.Applications // // lvitems // - this.lvitems.Dock = System.Windows.Forms.DockStyle.Right; - this.lvitems.Location = new System.Drawing.Point(120, 0); + this.lvitems.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvitems.Location = new System.Drawing.Point(149, 0); this.lvitems.Name = "lvitems"; - this.lvitems.Size = new System.Drawing.Size(514, 332); + this.lvitems.Size = new System.Drawing.Size(485, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); @@ -81,8 +81,8 @@ namespace ShiftOS.WinForms.Applications // // panel1 // - this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lvitems); + this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lbcurrentfolder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 24); @@ -95,8 +95,9 @@ namespace ShiftOS.WinForms.Applications this.pinnedItems.Dock = System.Windows.Forms.DockStyle.Left; this.pinnedItems.Location = new System.Drawing.Point(0, 0); this.pinnedItems.Name = "pinnedItems"; - this.pinnedItems.Size = new System.Drawing.Size(114, 332); + this.pinnedItems.Size = new System.Drawing.Size(149, 332); this.pinnedItems.TabIndex = 3; + this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click); // // lbcurrentfolder // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 6309775..218e9e2 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -34,8 +34,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using static ShiftOS.Objects.ShiftFS.Utils; -using Newtonsoft.Json; using ShiftOS.Engine; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -129,8 +129,14 @@ namespace ShiftOS.WinForms.Applications { int amountsCalled = -1; amountsCalled = amountsCalled + 1; - pinnedItems.Nodes.Add(path); - pinnedItems.Nodes[amountsCalled].Nodes.Add("test"); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + Pinned.Add(path); + WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned)); + ResetList(); } public void ChangeDirectory(string path) @@ -153,8 +159,40 @@ namespace ShiftOS.WinForms.Applications } } + public void PopulatePinned(TreeNode node, string[] items) + { + foreach(var dir in items) + { + var treenode = new TreeNode(); + if (DirectoryExists(dir)) + { + var dinf = GetDirectoryInfo(dir); + treenode.Text = dinf.Name; + } + else if (FileExists(dir)) + { + var finf = GetFileInfo(dir); + treenode.Text = finf.Name; + } + treenode.Tag = dir; + node.Nodes.Add(treenode); + } + } + public void ResetList() { + pinnedItems.Nodes.Clear(); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + var node = new TreeNode(); + node.Text = "Pinned"; + PopulatePinned(node, Pinned.ToArray()); + pinnedItems.Nodes.Add(node); + node.ExpandAll(); + if(lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); @@ -423,14 +461,14 @@ namespace ShiftOS.WinForms.Applications { if (result == true) { - if (currentdir != "__system") + if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one") { pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text); ResetList(); } else { - Infobox.Show("Cannot Pin", "You cannot pin a system drive."); + Infobox.Show("Cannot Pin", "You can only pin files or folders."); } } @@ -438,5 +476,26 @@ namespace ShiftOS.WinForms.Applications } catch { } } + + private void pinnedItems_Click(object sender, EventArgs e) + { + try + { + if (pinnedItems.SelectedNode != null) + { + string path = pinnedItems.SelectedNode.Tag.ToString(); + if (DirectoryExists(path)) + { + currentdir = path; + ResetList(); + } + else if (FileExists(path)) + { + FileSkimmerBackend.OpenFile(path); + } + } + } + catch { } + } } } diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs deleted file mode 100644 index b1186c6..0000000 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ /dev/null @@ -1,769 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class Pong - { - /// - /// 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); - } - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.gameTimer = new System.Windows.Forms.Timer(this.components); - this.counter = new System.Windows.Forms.Timer(this.components); - this.tmrcountdown = new System.Windows.Forms.Timer(this.components); - this.tmrstoryline = new System.Windows.Forms.Timer(this.components); - this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListView(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); - this.label10 = new System.Windows.Forms.Label(); - this.pnlgamestats = new System.Windows.Forms.Panel(); - this.button1 = new System.Windows.Forms.Button(); - this.label12 = new System.Windows.Forms.Label(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlfinalstats = new System.Windows.Forms.Panel(); - this.btnplayagain = new System.Windows.Forms.Button(); - this.lblfinalcodepoints = new System.Windows.Forms.Label(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.pnlintro = new System.Windows.Forms.Panel(); - this.Label6 = new System.Windows.Forms.Label(); - this.btnstartgame = new System.Windows.Forms.Button(); - this.Label8 = new System.Windows.Forms.Label(); - this.lblbeatai = new System.Windows.Forms.Label(); - this.lblcountdown = new System.Windows.Forms.Label(); - this.ball = new ShiftOS.WinForms.Controls.Canvas(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.btnmatchmake = new System.Windows.Forms.Button(); - this.pgcontents.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - this.pnlintro.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.SuspendLayout(); - // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_Tick); - // - // counter - // - this.counter.Interval = 1000; - this.counter.Tick += new System.EventHandler(this.counter_Tick); - // - // tmrcountdown - // - this.tmrcountdown.Interval = 1000; - this.tmrcountdown.Tick += new System.EventHandler(this.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // pgcontents - // - this.pgcontents.BackColor = System.Drawing.Color.White; - this.pgcontents.Controls.Add(this.pnlintro); - this.pgcontents.Controls.Add(this.pnlhighscore); - this.pgcontents.Controls.Add(this.pnlgamestats); - this.pgcontents.Controls.Add(this.pnlfinalstats); - this.pgcontents.Controls.Add(this.pnllose); - this.pgcontents.Controls.Add(this.lblbeatai); - this.pgcontents.Controls.Add(this.lblcountdown); - this.pgcontents.Controls.Add(this.ball); - this.pgcontents.Controls.Add(this.paddleHuman); - this.pgcontents.Controls.Add(this.paddleComputer); - this.pgcontents.Controls.Add(this.lbllevelandtime); - this.pgcontents.Controls.Add(this.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgcontents.Location = new System.Drawing.Point(0, 0); - this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(912, 504); - this.pgcontents.TabIndex = 20; - this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); - this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(688, 302); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - this.lbhighscore.UseCompatibleStateImageBehavior = false; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlgamestats - // - this.pnlgamestats.Controls.Add(this.button1); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - this.pnlgamestats.Controls.Add(this.btncashout); - this.pnlgamestats.Controls.Add(this.Label2); - this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(104, 375); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); - // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - this.lblfinalcodepoints.Name = "lblfinalcodepoints"; - this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); - this.lblfinalcodepoints.TabIndex = 15; - this.lblfinalcodepoints.Tag = "header1"; - this.lblfinalcodepoints.Text = "134 CP"; - this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - this.Label11.Name = "Label11"; - this.Label11.Size = new System.Drawing.Size(33, 33); - this.Label11.TabIndex = 14; - this.Label11.Tag = "header2"; - this.Label11.Text = "+"; - this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; - this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); - this.lblfinalcomputerreward.TabIndex = 12; - this.lblfinalcomputerreward.Tag = "header2"; - this.lblfinalcomputerreward.Text = "34"; - this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - this.lblfinallevelreward.Name = "lblfinallevelreward"; - this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); - this.lblfinallevelreward.TabIndex = 10; - this.lblfinallevelreward.Tag = "header2"; - this.lblfinallevelreward.Text = "100"; - this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; - this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); - this.lblfinalcodepointswithtext.TabIndex = 1; - this.lblfinalcodepointswithtext.Tag = "header2"; - this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; - this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlintro - // - this.pnlintro.Controls.Add(this.btnmatchmake); - this.pnlintro.Controls.Add(this.Label6); - this.pnlintro.Controls.Add(this.btnstartgame); - this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(0, 0); - this.pnlintro.Name = "pnlintro"; - this.pnlintro.Size = new System.Drawing.Size(595, 303); - this.pnlintro.TabIndex = 13; - this.pnlintro.Tag = "header2"; - // - // Label6 - // - this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label6.Location = new System.Drawing.Point(3, 39); - this.Label6.Name = "Label6"; - this.Label6.Size = new System.Drawing.Size(589, 159); - this.Label6.TabIndex = 15; - this.Label6.Text = "{PONG_DESC}"; - this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.Label6.Click += new System.EventHandler(this.Label6_Click); - // - // btnstartgame - // - this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnstartgame.Location = new System.Drawing.Point(188, 215); - this.btnstartgame.Name = "btnstartgame"; - this.btnstartgame.Size = new System.Drawing.Size(242, 28); - this.btnstartgame.TabIndex = 15; - this.btnstartgame.Text = "{PLAY}"; - this.btnstartgame.UseVisualStyleBackColor = true; - this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click); - // - // Label8 - // - this.Label8.AutoSize = true; - this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label8.ForeColor = System.Drawing.Color.Black; - this.Label8.Location = new System.Drawing.Point(250, 5); - this.Label8.Name = "Label8"; - this.Label8.Size = new System.Drawing.Size(280, 31); - this.Label8.TabIndex = 14; - this.Label8.Text = "{PONG_WELCOME}"; - this.Label8.Click += new System.EventHandler(this.Label8_Click); - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - this.lblbeatai.Name = "lblbeatai"; - this.lblbeatai.Size = new System.Drawing.Size(600, 30); - this.lblbeatai.TabIndex = 8; - this.lblbeatai.Tag = "header2"; - this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; - this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblbeatai.Visible = false; - // - // lblcountdown - // - this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblcountdown.Location = new System.Drawing.Point(182, 152); - this.lblcountdown.Name = "lblcountdown"; - this.lblcountdown.Size = new System.Drawing.Size(315, 49); - this.lblcountdown.TabIndex = 7; - this.lblcountdown.Text = "3"; - this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcountdown.Visible = false; - // - // ball - // - this.ball.BackColor = System.Drawing.Color.Black; - this.ball.Location = new System.Drawing.Point(300, 152); - this.ball.Name = "ball"; - this.ball.Size = new System.Drawing.Size(20, 20); - this.ball.TabIndex = 2; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleHuman.Name = "paddleHuman"; - this.paddleHuman.Size = new System.Drawing.Size(20, 100); - this.paddleHuman.TabIndex = 3; - this.paddleHuman.TabStop = false; - // - // paddleComputer - // - this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(878, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleComputer.Name = "paddleComputer"; - this.paddleComputer.Size = new System.Drawing.Size(20, 100); - this.paddleComputer.TabIndex = 1; - // - // lbllevelandtime - // - this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; - this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); - this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(912, 22); - this.lbllevelandtime.TabIndex = 4; - this.lbllevelandtime.Tag = "header1"; - this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; - this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatscodepoints - // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatscodepoints.AutoSize = true; - this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); - this.lblstatscodepoints.TabIndex = 12; - this.lblstatscodepoints.Tag = "header2"; - this.lblstatscodepoints.Text = "Codepoints: "; - this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsY - // - this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatsY.AutoSize = true; - this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(440, 460); - this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(76, 23); - this.lblstatsY.TabIndex = 11; - this.lblstatsY.Tag = "header2"; - this.lblstatsY.Text = "Yspeed:"; - this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsX - // - this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lblstatsX.AutoSize = true; - this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 460); - this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(83, 23); - this.lblstatsX.TabIndex = 5; - this.lblstatsX.Tag = "header2"; - this.lblstatsX.Text = "Xspeed: "; - this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnmatchmake - // - this.btnmatchmake.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnmatchmake.Location = new System.Drawing.Point(188, 253); - this.btnmatchmake.Name = "btnmatchmake"; - this.btnmatchmake.Size = new System.Drawing.Size(242, 28); - this.btnmatchmake.TabIndex = 16; - this.btnmatchmake.Text = "Or, play against another Shifter!"; - this.btnmatchmake.UseVisualStyleBackColor = true; - this.btnmatchmake.Click += new System.EventHandler(this.btnmatchmake_Click); - // - // Pong - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; - this.Name = "Pong"; - this.Size = new System.Drawing.Size(912, 504); - this.Load += new System.EventHandler(this.Pong_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - this.pgcontents.ResumeLayout(false); - this.pgcontents.PerformLayout(); - this.pnlhighscore.ResumeLayout(false); - this.pnlhighscore.PerformLayout(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); - this.pnlfinalstats.ResumeLayout(false); - this.pnlfinalstats.PerformLayout(); - this.pnllose.ResumeLayout(false); - this.pnlintro.ResumeLayout(false); - this.pnlintro.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.ResumeLayout(false); - - } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListView lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - internal System.Windows.Forms.Label label12; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button button2; - internal System.Windows.Forms.Button btnmatchmake; - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs deleted file mode 100644 index 585639a..0000000 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ /dev/null @@ -1,977 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [MultiplayerOnly] - [Launcher("Pong", true, "al_pong", "Games")] - [WinOpen("pong")] - [DefaultIcon("iconPong")] - public partial class Pong : UserControl, IShiftOSWindow - { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - int xVel = 7; - int yVel = 8; - int computerspeed = 8; - int level = 1; - int secondsleft = 60; - int casualposition; - double xveldec = 3.0; - double yveldec = 3.0; - double incrementx = 0.4; - double incrementy = 0.2; - int levelxspeed = 3; - int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; - int countdown = 3; - - bool aiShouldIsbeEnabled = true; - - public Pong() - { - InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - setuplevelrewards(); - } - - - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - if (IsMultiplayerSession) - { - if (IsLeader) - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleHuman.Top.ToString()); - } - else - { - paddleComputer.Location = new Point(paddleComputer.Location.X, (loc.Y) - (paddleComputer.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleComputer.Top.ToString()); - } - } - else - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - } - } - - private void CenterPanels() - { - pnlfinalstats.CenterParent(); - pnlgamestats.CenterParent(); - pnlhighscore.CenterParent(); - pnlintro.CenterParent(); - pnllose.CenterParent(); - lblcountdown.CenterParent(); - lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; - SetupStats(); - } - - public void SetupStats() - { - lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); - lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); - lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; - lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; - } - - int OpponentY = 0; - - bool IsLeader = false; - - int LeaderX = 0; - int LeaderY = 0; - - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - - //Check if paddle upgrade has been bought and change paddles accordingly - //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - //{ - // paddleHuman.Height = 150; - // paddleComputer.Height = 150; - //} - //I don't know the point of this but I'm fucking 86ing it. - Michael - - //Set the computer player to move according to the ball's position. - if (IsMultiplayerSession == true) - { - //If we're multiplayer, then we want to set the computer Y to the opponent's Y. - //If we're the leader, we set the AI paddle, else we set the player paddle. - if (IsLeader) - paddleComputer.Top = OpponentY; - else - paddleHuman.Top = OpponentY; - } - else - { - if (aiShouldIsbeEnabled) - if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) - { - if (ball.Location.Y > paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - if (ball.Location.Y < paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - casualposition = rand.Next(-150, 201); - } - else - { - //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael - if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - //Rylan is hot. Used to be //used to be me.location.y - if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - } - } - //Set Xvel and Yvel speeds from decimal - if (xVel > 0) - xVel = (int)Math.Round(xveldec); - if (xVel < 0) - xVel = (int)-Math.Round(xveldec); - if (yVel > 0) - yVel = (int)Math.Round(yveldec); - if (yVel < 0) - yVel = (int)-Math.Round(yveldec); - - bool BallPhysics = true; - - if (IsMultiplayerSession) - { - //Logic for moving the ball in Multiplayer. - if (IsLeader) - { - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - else - { - //Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - BallPhysics = false; - } - } - else - {// Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - if (BallPhysics) - { - // Check for top wall. - if (ball.Location.Y < 0) - { - ball.Location = new Point(ball.Location.X, 0); - yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - // Check for bottom wall. - if (ball.Location.Y > pgcontents.Height - ball.Height) - { - ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); - yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - - // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) - { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y); - //randomly increase x or y speed of ball - switch (rand.Next(1, 3)) - { - case 1: - xveldec = xveldec + incrementx; - break; - case 2: - if (yveldec > 0) - yveldec = yveldec + incrementy; - if (yveldec < 0) - yveldec = yveldec - incrementy; - break; - } - xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - - } - - // Check for computer paddle. - if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) - { - ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y); - xveldec = xveldec + incrementx; - xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - } - } - - - - // Check for left wall. - if (ball.Location.X < -100) - { - //If we are in multiplayer, and not the leader, we won. - if (IsMultiplayerSession) - { - if (IsLeader) - { - //We lost. - NotifyLoseToTarget(); - } - else - { - //We won. - NotifyWinToTarget(); - Win(); - } - } - else - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - pnllose.Show(); - gameTimer.Stop(); - counter.Stop(); - lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) - { - totalreward = levelrewards[level - 1] + beatairewardtotal; - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); - } - else - { - lblbutyougained.Hide(); - } - } - } - - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - if (IsMultiplayerSession) - { - //If we are the leader we won. - if (IsLeader) - { - NotifyWinToTarget(); - Win(); - } - else - { - NotifyLoseToTarget(); - } - } - else - { - Win(); - } - } - - if (IsMultiplayerSession) - { - if (IsLeader) - { - ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location)); - } - } - - if (IsLeader) - { - //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy - lblstatsX.Text = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - - if (xVel > 20 || xVel < -20) - { - paddleHuman.Width = Math.Abs(xVel); - paddleComputer.Width = Math.Abs(xVel); - } - else - { - paddleHuman.Width = 20; - paddleComputer.Width = 20; - } - } - if (!IsMultiplayerSession) - { - computerspeed = Math.Abs(yVel); - } - } - } - - public void ServerMessageReceivedHandler(ServerMessage msg) - { - if(msg.Name == "pong_mp_setballpos") - { - var pt = JsonConvert.DeserializeObject(msg.Contents); - LeaderX = pt.X; - LeaderY = pt.Y; - } - else if(msg.Name == "pong_mp_youlose") - { - LoseMP(); - } - else if(msg.Name == "pong_mp_setopponenty") - { - int y = Convert.ToInt32(msg.Contents); - OpponentY = y; - } - else if(msg.Name == "pong_handshake_matchmake") - { - PossibleMatchmakes.Add(msg.Contents); - } - else if(msg.Name == "pong_handshake_complete") - { - LeaveMatchmake(); - StartLevel(); - } - else if(msg.Name == "pong_handshake_giveleaderid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - YouGUID = ServerManager.thisGuid.ToString(); - SendFollowerGUID(); - } - else if(msg.Name == "pong_handshake_left") - { - if (this.PossibleMatchmakes.Contains(msg.Contents)) - this.PossibleMatchmakes.Remove(msg.Contents); - } - else if(msg.Name == "pong_handshake_setfollowerguid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - } - else if(msg.Name == "pong_mp_youwin") - { - Win(); - } - } - - public void NotifyLoseToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null); - } - - public void NotifyWinToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null); - } - - public void LeaveMatchmake() - { - ServerManager.Forward("all", "pong_handshake_left", YouGUID); - } - - List PossibleMatchmakes = new List(); - - public void SendLeaderGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_giveleaderid", YouGUID); - } - - - public void StartMultiplayer() - { - IsMultiplayerSession = true; - YouGUID = ServerManager.thisGuid.ToString(); - ServerManager.SendMessage("pong_handshake_matchmake", YouGUID); - } - - - public void SendFollowerGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_setfollowerguid", YouGUID); - } - - public void LoseMP() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if(IsLeader) - if (xVel > 0) - xVel = -xVel; - lblbeatai.Show(); - lblbeatai.Text = "The opponent has beaten you!"; - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - public void Win() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - beatairewardtotal = beatairewardtotal + beataireward; - lblbeatai.Show(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}"); - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - // ERROR: Handles clauses are not supported in C# - private void counter_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - secondsleft = secondsleft - 1; - if (secondsleft == 1) - { - secondsleft = 60; - level = level + 1; - if (SaveSystem.CurrentSave.UniteAuthToken != null) - { - try - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongLevel() < level) - unite.SetPongLevel(level); - } - catch { } - } - generatenextlevel(); - pnlgamestats.Show(); - pnlgamestats.BringToFront(); - pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2)); - - counter.Stop(); - gameTimer.Stop(); - SendHighscores(); - } - - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - } - SetupStats(); - } - - [Obsolete("This method does nothing. Use UniteClient for highscore queries.")] - public void SendHighscores() - { - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) - { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } - - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } - - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } - - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - if (level < 15) - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = level * 10; - } else - { - beataireward = level * 5; - } - } - else - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; - } - } - - totalreward = levelrewards[level - 1] + beatairewardtotal; - - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); - } - - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - switch (countdown) - { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - case 1: - lblcountdown.Text = "1"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 2: - lblcountdown.Text = "2"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 3: - lblcountdown.Text = "3"; - countdown = countdown - 1; - lblcountdown.Show(); - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - } - - } - } - - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); - lblfinalcomputerreward.Text = beatairewardtotal.ToString(); - lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); - SaveSystem.TransferCodepointsFrom("pong", totalreward); - if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken)) - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongCP() < totalreward) - { - unite.SetPongCP(totalreward); - } - } - } - - private void newgame() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); - - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - public void btnhighscore_Click(object s, EventArgs a) - { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - - bool IsMultiplayerSession = false; - - string YouGUID = ""; - string OpponentGUID = ""; - - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - lbhighscore.View = View.Details; - lbhighscore.FullRowSelect = true; - lbhighscore.Columns.Clear(); - var n = new ColumnHeader(); - n.Text = "Player"; - n.Width = lbhighscore.Width / 3; - var l = new ColumnHeader(); - l.Text = "Level"; - l.Width = n.Width; - var c = new ColumnHeader(); - c.Text = "Codepoints"; - c.Width = n.Width; - lbhighscore.Columns.Add(n); - lbhighscore.Columns.Add(l); - lbhighscore.Columns.Add(c); - - var t = new Thread(() => - { - try - { - - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - var hs = unite.GetPongHighscores(); - foreach (var score in hs.Highscores) - { - string username = unite.GetDisplayNameId(score.UserId); - this.Invoke(new Action(() => - { - var name_item = new ListViewItem(); - name_item.Text = username; - lbhighscore.Items.Add(name_item); - name_item.SubItems.Add(score.Level.ToString()); - name_item.SubItems.Add(score.CodepointsCashout.ToString()); - })); - } - } - catch - { - Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); - this.Invoke(new Action(pnlgamestats.BringToFront)); - return; - } - }); - t.Start(); - pnlhighscore.Show(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } - - public void StartLevel() - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } - - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); - - if (i >= 25 && i <= 50) - { - tmrstoryline.Stop(); - } - - } - - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) - { - tmrstoryline.Stop(); - } - - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) - { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { - aiShouldIsbeEnabled = false; - } - - private void ball_MouseLeave(object sender, EventArgs e) { - aiShouldIsbeEnabled = true; - } - - public void OnLoad() - { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - CenterPanels(); - lblbeatai.Hide(); - } - - public void OnSkinLoad() - { - CenterPanels(); - this.SizeChanged += (o, a) => - { - CenterPanels(); - }; - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - CenterPanels(); - } - - private void button2_Click(object sender, EventArgs e) - { - pnlhighscore.Hide(); - } - - private void btnmatchmake_Click(object sender, EventArgs e) - { - this.StartMultiplayer(); - pnlintro.Hide(); - lblbeatai.Text = "Beat the other player to earn Codepoints."; - lblcountdown.Text = "Waiting for another player..."; - lblcountdown.Left = (this.Width - lblcountdown.Width) / 2; - } - } -} diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs deleted file mode 100644 index 32d508b..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ /dev/null @@ -1,317 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class ShiftoriumFrontend - { - /// - /// 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.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.lbupgradedesc = new System.Windows.Forms.Label(); - this.pnlupgradeactions = new System.Windows.Forms.Panel(); - this.btnbuy = new System.Windows.Forms.Button(); - this.lbupgradetitle = new System.Windows.Forms.Label(); - this.pnllist = new System.Windows.Forms.Panel(); - this.lbcodepoints = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.lbupgrades = new System.Windows.Forms.ListBox(); - this.label3 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.btncat_back = new System.Windows.Forms.Button(); - this.btncat_forward = new System.Windows.Forms.Button(); - this.lblcategorytext = new System.Windows.Forms.Label(); - this.lbnoupgrades = new System.Windows.Forms.Label(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.pnlupgradeactions.SuspendLayout(); - this.pnllist.SuspendLayout(); - this.panel3.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.Controls.Add(this.panel2); - this.panel1.Controls.Add(this.pnllist); - 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(782, 427); - this.panel1.TabIndex = 0; - // - // panel2 - // - this.panel2.Controls.Add(this.lbupgradedesc); - this.panel2.Controls.Add(this.pnlupgradeactions); - this.panel2.Controls.Add(this.lbupgradetitle); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(406, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(376, 427); - this.panel2.TabIndex = 1; - // - // lbupgradedesc - // - this.lbupgradedesc.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbupgradedesc.Location = new System.Drawing.Point(0, 42); - this.lbupgradedesc.Name = "lbupgradedesc"; - this.lbupgradedesc.Size = new System.Drawing.Size(376, 348); - this.lbupgradedesc.TabIndex = 2; - this.lbupgradedesc.Text = "{SHIFTORIUM_EXP}"; - this.lbupgradedesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradedesc.UseCompatibleTextRendering = true; - // - // pnlupgradeactions - // - this.pnlupgradeactions.Controls.Add(this.btnbuy); - this.pnlupgradeactions.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlupgradeactions.Location = new System.Drawing.Point(0, 390); - this.pnlupgradeactions.Name = "pnlupgradeactions"; - this.pnlupgradeactions.Size = new System.Drawing.Size(376, 37); - this.pnlupgradeactions.TabIndex = 1; - // - // btnbuy - // - this.btnbuy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnbuy.AutoSize = true; - this.btnbuy.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnbuy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnbuy.Location = new System.Drawing.Point(327, 9); - this.btnbuy.Name = "btnbuy"; - this.btnbuy.Size = new System.Drawing.Size(37, 25); - this.btnbuy.TabIndex = 0; - this.btnbuy.Text = "Buy"; - this.btnbuy.UseVisualStyleBackColor = true; - this.btnbuy.Visible = false; - this.btnbuy.Click += new System.EventHandler(this.btnbuy_Click); - // - // lbupgradetitle - // - this.lbupgradetitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbupgradetitle.Location = new System.Drawing.Point(0, 0); - this.lbupgradetitle.Name = "lbupgradetitle"; - this.lbupgradetitle.Size = new System.Drawing.Size(376, 42); - this.lbupgradetitle.TabIndex = 0; - this.lbupgradetitle.Text = "{WELCOME_TO_SHIFTORIUM}"; - this.lbupgradetitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradetitle.UseCompatibleTextRendering = true; - // - // pnllist - // - this.pnllist.Controls.Add(this.lbnoupgrades); - this.pnllist.Controls.Add(this.panel3); - this.pnllist.Controls.Add(this.lbcodepoints); - this.pnllist.Controls.Add(this.label1); - this.pnllist.Controls.Add(this.pgupgradeprogress); - this.pnllist.Controls.Add(this.lbupgrades); - this.pnllist.Dock = System.Windows.Forms.DockStyle.Left; - this.pnllist.Location = new System.Drawing.Point(0, 0); - this.pnllist.Name = "pnllist"; - this.pnllist.Size = new System.Drawing.Size(406, 427); - this.pnllist.TabIndex = 0; - // - // lbcodepoints - // - this.lbcodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lbcodepoints.AutoSize = true; - this.lbcodepoints.Location = new System.Drawing.Point(128, 357); - this.lbcodepoints.Name = "lbcodepoints"; - this.lbcodepoints.Size = new System.Drawing.Size(135, 13); - this.lbcodepoints.TabIndex = 3; - this.lbcodepoints.Text = "You have: %cp Codepoints"; - this.lbcodepoints.Click += new System.EventHandler(this.lbcodepoints_Click); - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 399); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(137, 13); - this.label1.TabIndex = 2; - this.label1.Text = "{UPGRADE_PROGRESS}:"; - // - // pgupgradeprogress - // - 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; - // - // lbupgrades - // - this.lbupgrades.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.lbupgrades.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.lbupgrades.FormattingEnabled = true; - this.lbupgrades.Location = new System.Drawing.Point(3, 105); - this.lbupgrades.Name = "lbupgrades"; - this.lbupgrades.Size = new System.Drawing.Size(397, 238); - this.lbupgrades.TabIndex = 0; - this.lbupgrades.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbupgrades_DrawItem); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 399); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(137, 13); - this.label3.TabIndex = 2; - // - // panel3 - // - this.panel3.Controls.Add(this.lblcategorytext); - this.panel3.Controls.Add(this.btncat_forward); - this.panel3.Controls.Add(this.btncat_back); - this.panel3.Location = new System.Drawing.Point(6, 76); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(394, 23); - this.panel3.TabIndex = 5; - // - // btncat_back - // - this.btncat_back.AutoSize = true; - this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left; - this.btncat_back.Location = new System.Drawing.Point(0, 0); - this.btncat_back.Name = "btncat_back"; - this.btncat_back.Size = new System.Drawing.Size(29, 23); - this.btncat_back.TabIndex = 0; - this.btncat_back.Text = "<--"; - this.btncat_back.UseVisualStyleBackColor = true; - this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click); - // - // btncat_forward - // - this.btncat_forward.AutoSize = true; - this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right; - this.btncat_forward.Location = new System.Drawing.Point(365, 0); - this.btncat_forward.Name = "btncat_forward"; - this.btncat_forward.Size = new System.Drawing.Size(29, 23); - this.btncat_forward.TabIndex = 1; - this.btncat_forward.Text = "-->"; - this.btncat_forward.UseVisualStyleBackColor = true; - this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click); - // - // lblcategorytext - // - this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblcategorytext.Location = new System.Drawing.Point(29, 0); - this.lblcategorytext.Name = "lblcategorytext"; - this.lblcategorytext.Size = new System.Drawing.Size(336, 23); - this.lblcategorytext.TabIndex = 2; - this.lblcategorytext.Text = "label2"; - this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbnoupgrades - // - this.lbnoupgrades.AutoSize = true; - this.lbnoupgrades.Location = new System.Drawing.Point(69, 183); - this.lbnoupgrades.Name = "lbnoupgrades"; - this.lbnoupgrades.Size = new System.Drawing.Size(71, 13); - this.lbnoupgrades.TabIndex = 6; - this.lbnoupgrades.Tag = "header2"; - this.lbnoupgrades.Text = "No upgrades!"; - this.lbnoupgrades.Visible = false; - // - // ShiftoriumFrontend - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.panel1); - this.ForeColor = System.Drawing.Color.LightGreen; - this.Name = "ShiftoriumFrontend"; - this.Size = new System.Drawing.Size(782, 427); - this.Load += new System.EventHandler(this.Shiftorium_Load); - this.panel1.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.pnlupgradeactions.ResumeLayout(false); - this.pnlupgradeactions.PerformLayout(); - this.pnllist.ResumeLayout(false); - this.pnllist.PerformLayout(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Panel pnllist; - private System.Windows.Forms.ListBox lbupgrades; - private System.Windows.Forms.Label lbupgradedesc; - private System.Windows.Forms.Panel pnlupgradeactions; - private System.Windows.Forms.Label lbupgradetitle; - private System.Windows.Forms.Button btnbuy; - private ShiftedProgressBar pgupgradeprogress; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label lbcodepoints; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label lblcategorytext; - private System.Windows.Forms.Button btncat_forward; - private System.Windows.Forms.Button btncat_back; - private System.Windows.Forms.Label lbnoupgrades; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs deleted file mode 100644 index 66b0448..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ /dev/null @@ -1,274 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using backend = ShiftOS.Engine.Shiftorium; -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] - [RequiresUpgrade("shiftorium_gui")] - [MultiplayerOnly] - [WinOpen("shiftorium")] - [DefaultTitle("Shiftorium")] - [DefaultIcon("iconShiftorium")] - public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow - { - public int CategoryId = 0; - public static System.Timers.Timer timer100; - - - public ShiftoriumFrontend() - { - cp_update = new System.Windows.Forms.Timer(); - cp_update.Tick += (o, a) => - { - lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints."; - }; - cp_update.Interval = 100; - InitializeComponent(); - PopulateShiftorium(); - lbupgrades.SelectedIndexChanged += (o, a) => - { - try - { - lbupgrades.Refresh(); - SelectUpgrade(lbupgrades.SelectedItem.ToString()); - } - catch { } - }; - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - backend.Installed += () => - { - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - }; - - } - - public void SelectUpgrade(string name) - { - btnbuy.Show(); - var upg = upgrades[name]; - lbupgradetitle.Text = Localization.Parse(upg.Name); - lbupgradedesc.Text = Localization.Parse(upg.Description); - } - - Dictionary upgrades = new Dictionary(); - - public void PopulateShiftorium() - { - try - { - lbnoupgrades.Hide(); - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - - foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) - { - String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - lbupgrades.Items.Add(name); - } - - if (lbupgrades.Items.Count == 0) - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - else - { - lbnoupgrades.Hide(); - } - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); - } - catch - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - } - - public static bool UpgradeInstalled(string upg) - { - return backend.UpgradeInstalled(upg); - } - - public static bool UpgradeAttributesUnlocked(FieldInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(MethodInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(Type finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - private void lbupgrades_DrawItem(object sender, DrawItemEventArgs e) - { - var foreground = new SolidBrush(LoadedSkin.ControlTextColor); - var background = new SolidBrush(LoadedSkin.ControlColor); - - e.Graphics.FillRectangle(background, e.Bounds); - try - { - if (lbupgrades.GetSelected(e.Index) == true) - { - e.Graphics.FillRectangle(foreground, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, background, e.Bounds.Location); - } - else - { - e.Graphics.FillRectangle(background, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, foreground, e.Bounds.Location); - } - } - catch - { - } - } - - private void btnbuy_Click(object sender, EventArgs e) - { - long cpCost = 0; - backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); - foreach (var itm in lbupgrades.SelectedItems) - { - cpCost += upgrades[itm.ToString()].Cost; - UpgradesToBuy.Add(upgrades[itm.ToString()].ID, upgrades[itm.ToString()].Cost); - } - if (SaveSystem.CurrentSave.Codepoints < cpCost) - { - Infobox.Show("Insufficient Codepoints", $"You do not have enough Codepoints to perform this action. You need {cpCost - SaveSystem.CurrentSave.Codepoints} more."); - - } - else - { - foreach(var upg in UpgradesToBuy) - { - backend.Buy(upg.Key, upg.Value); - } - } - - backend.Silent = false; - PopulateShiftorium(); - btnbuy.Hide(); - } - - private void Shiftorium_Load(object sender, EventArgs e) { - - } - - public void OnLoad() - { - cp_update.Start(); - lbnoupgrades.Hide(); - } - - public void OnSkinLoad() - { - - } - - Timer cp_update = new System.Windows.Forms.Timer(); - - public bool OnUnload() - { - cp_update.Stop(); - cp_update = null; - return true; - } - - public void OnUpgrade() - { - lbupgrades.SelectionMode = (UpgradeInstalled("shiftorium_gui_bulk_buy") == true) ? SelectionMode.MultiExtended : SelectionMode.One; - lbcodepoints.Visible = Shiftorium.UpgradeInstalled("shiftorium_gui_codepoints_display"); - } - - private void lbcodepoints_Click(object sender, EventArgs e) - { - - } - - void Timer() - { - timer100 = new System.Timers.Timer(); - timer100.Interval = 2000; - //timer100.Elapsed += ???; - timer100.AutoReset = true; - timer100.Enabled = true; - } - - private void btncat_back_Click(object sender, EventArgs e) - { - if(CategoryId > 0) - { - CategoryId--; - PopulateShiftorium(); - } - } - - private void btncat_forward_Click(object sender, EventArgs e) - { - if(CategoryId < backend.GetCategories().Length - 1) - { - CategoryId++; - PopulateShiftorium(); - } - } - } -} diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs deleted file mode 100644 index 1f09e4a..0000000 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ /dev/null @@ -1,342 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Skin Loader", true, "al_skin_loader", "Customization")] - [RequiresUpgrade("skinning")] - [WinOpen("skin_loader")] - [DefaultTitle("Skin Loader")] - [DefaultIcon("iconSkinLoader")] - public partial class Skin_Loader : UserControl, IShiftOSWindow - { - public Skin_Loader() - { - InitializeComponent(); - SetupControls(pnlborder); - SetupControls(pnldesktop); - LoadedSkin = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(SkinEngine.LoadedSkin)); - this.Load += (o, a) => { SetupUI(); }; - - } - - public void SetupControls(Control ctrl) - { - ctrl.Tag = "keepbg keepfg keepfont"; - foreach (Control c in ctrl.Controls) - SetupControls(c); - } - - public Skin LoadedSkin { get; set; } - - public void SetupUI() - { - SetupDesktop(); - Setup(); - } - - public void SetupDesktop() - { - menuStrip1.Renderer = new ShiftOSMenuRenderer(); - - this.DoubleBuffered = true; - desktoppanel.BackColor = Color.Green; - - //upgrades - - if (SaveSystem.CurrentSave != null) - { - desktoppanel.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop"); - lbtime.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop_clock_widget"); - - //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - - sysmenuholder.Visible = ShiftoriumFrontend.UpgradeInstalled("app_launcher"); - - //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. - //To compensate, we must recreate the desktop color and make the alpha channel '255'. - pnldesktop.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); - //Not doing this will cause an ArgumentException. - - pnldesktop.BackgroundImage = GetImage("desktopbackground"); - pnldesktop.BackgroundImageLayout = GetImageLayout("desktopbackground"); - desktoppanel.BackgroundImage = GetImage("desktoppanel"); - menuStrip1.BackgroundImage = GetImage("applauncher"); - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - lbtime.Font = LoadedSkin.DesktopPanelClockFont; - lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; - lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; - - if (desktoppanel.BackgroundImage == null) - { - lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; - } - else - { - lbtime.BackColor = Color.Transparent; - } - apps.Text = LoadedSkin.AppLauncherText; - sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; - sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; - apps.Size = sysmenuholder.Size; - menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable()); - desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; - desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); - desktoppanel.Height = LoadedSkin.DesktopPanelHeight; - if (LoadedSkin.DesktopPanelPosition == 1) - { - desktoppanel.Dock = DockStyle.Bottom; - } - else - { - desktoppanel.Dock = DockStyle.Top; - } - } - - } - - public ImageLayout GetImageLayout(string img) - { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) - { - return LoadedSkin.SkinImageLayouts[img]; - } - else - { - LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); - return ImageLayout.Tile; - } - } - - public 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) - { - var iattr = attr as ImageAttribute; - if (iattr.Name == img) - { - byte[] image = (byte[])field.GetValue(LoadedSkin); - return SkinEngine.ImageFromBinary(image); - } - } - } - } - - return null; - } - - bool IsDialog = false; - - public void Setup() - { - pnlcontents.BackColor = LoadedSkin.ControlColor; - - this.lbtitletext.Text = Localization.Parse("{TEMPLATE}"); - this.Dock = DockStyle.Fill; - - if (SaveSystem.CurrentSave != null) - { - this.pnltitle.Visible = ShiftoriumFrontend.UpgradeInstalled("wm_titlebar"); - this.pnlclose.Visible = ShiftoriumFrontend.UpgradeInstalled("close_button"); - this.pnlminimize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("minimize_button"); - this.pnlmaximize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("maximize_button"); - SetupSkin(); - } - else - { - this.pnltitle.Visible = false; - this.pnlclose.Visible = false; - this.pnlminimize.Visible = false; - this.pnlmaximize.Visible = false; - - } - } - - public void SetupSkin() - { - pnltitlemaster.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"); - - - lbtitletext.BackColor = 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 = LoadedSkin.TitleTextLeft; - break; - default: - lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; - lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; - break; - } - } - - public Point FromRight(Point input) - { - return new Point(pnltitle.Width - input.X, input.Y); - } - - private void btnapply_Click(object sender, EventArgs e) - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin)); - SkinEngine.LoadSkin(); - } - - private void btnclose_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnloaddefault_Click(object sender, EventArgs e) - { - this.LoadedSkin = new ShiftOS.Engine.Skin(); - SetupUI(); - } - - private void btnexport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Save, new Action((filename) => - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(filename, JsonConvert.SerializeObject(LoadedSkin)); - string fname = filename.Split('/')[filename.Split('/').Length - 1]; - if(!System.IO.Directory.Exists(Paths.SharedFolder + "\\skins")) - { - System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); - } - - string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; - System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); - - }))); - } - - private void btnimport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action((filename) => - { - LoadedSkin = JsonConvert.DeserializeObject(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename)); - SetupUI(); - }))); - } - - public void OnLoad() - { - - SetupUI(); - } - - public void OnSkinLoad() - { - SetupUI(); - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - SetupUI(); - } - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs b/ShiftOS.WinForms/Applications/TriWrite.Designer.cs deleted file mode 100644 index e420fd5..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs +++ /dev/null @@ -1,192 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class TriWrite - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TriWrite)); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tvcontacts = new System.Windows.Forms.TreeView(); - this.panel1 = new System.Windows.Forms.Panel(); - this.txtbody = new System.Windows.Forms.Label(); - this.lbtitle = new System.Windows.Forms.Label(); - this.txtcontents = new System.Windows.Forms.TextBox(); - this.menuStrip2 = new System.Windows.Forms.MenuStrip(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip3 = new System.Windows.Forms.MenuStrip(); - this.menuStrip1.SuspendLayout(); - this.panel1.SuspendLayout(); - this.menuStrip2.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addContactToolStripMenuItem, - this.removeToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(872, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // addContactToolStripMenuItem - // - this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem"; - this.addContactToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // removeToolStripMenuItem - // - this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // tvcontacts - // - this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left; - this.tvcontacts.Location = new System.Drawing.Point(0, 24); - this.tvcontacts.Name = "tvcontacts"; - this.tvcontacts.Size = new System.Drawing.Size(224, 551); - this.tvcontacts.TabIndex = 1; - // - // panel1 - // - this.panel1.Controls.Add(this.txtbody); - this.panel1.Controls.Add(this.lbtitle); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(224, 24); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(648, 551); - this.panel1.TabIndex = 2; - // - // txtbody - // - this.txtbody.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.txtbody.Location = new System.Drawing.Point(7, 54); - this.txtbody.Name = "txtbody"; - this.txtbody.Size = new System.Drawing.Size(626, 481); - this.txtbody.TabIndex = 1; - this.txtbody.Text = resources.GetString("txtbody.Text"); - // - // lbtitle - // - this.lbtitle.AutoSize = true; - this.lbtitle.Location = new System.Drawing.Point(7, 4); - this.lbtitle.Name = "lbtitle"; - this.lbtitle.Size = new System.Drawing.Size(44, 13); - this.lbtitle.TabIndex = 0; - this.lbtitle.Tag = "header1"; - this.lbtitle.Text = "TriWrite"; - // - // txtcontents - // - this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtcontents.Location = new System.Drawing.Point(0, 53); - this.txtcontents.Multiline = true; - this.txtcontents.Name = "txtcontents"; - this.txtcontents.Size = new System.Drawing.Size(527, 460); - this.txtcontents.TabIndex = 1; - this.txtcontents.TabStop = false; - // - // menuStrip2 - // - this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.openToolStripMenuItem, - this.saveToolStripMenuItem}); - this.menuStrip2.Location = new System.Drawing.Point(0, 0); - this.menuStrip2.Name = "menuStrip2"; - this.menuStrip2.Size = new System.Drawing.Size(527, 24); - this.menuStrip2.TabIndex = 2; - this.menuStrip2.Text = "menuStrip2"; - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.newToolStripMenuItem.Text = "New"; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - this.openToolStripMenuItem.Text = "Open"; - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.saveToolStripMenuItem.Text = "Save"; - // - // menuStrip3 - // - this.menuStrip3.Location = new System.Drawing.Point(0, 30); - this.menuStrip3.Name = "menuStrip3"; - this.menuStrip3.Size = new System.Drawing.Size(527, 24); - this.menuStrip3.TabIndex = 3; - this.menuStrip3.Text = "menuStrip3"; - // - // TriWrite - // - this.Controls.Add(this.txtcontents); - this.Controls.Add(this.menuStrip3); - this.Controls.Add(this.menuStrip2); - this.Name = "TriWrite"; - this.Size = new System.Drawing.Size(527, 513); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.menuStrip2.ResumeLayout(false); - this.menuStrip2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.TreeView tvcontacts; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Label txtbody; - private System.Windows.Forms.Label lbtitle; - private System.Windows.Forms.TextBox txtcontents; - private System.Windows.Forms.MenuStrip menuStrip2; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.MenuStrip menuStrip3; - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs deleted file mode 100644 index 6fb814f..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ /dev/null @@ -1,76 +0,0 @@ -using ShiftOS.Objects.ShiftFS; -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; - -namespace ShiftOS.WinForms.Applications -{ - [WinOpen("triwrite")] - [AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, null, "Office")] - [DefaultTitle("TriWrite")] - [Launcher("TriWrite", false, null, "Office")] - public partial class TriWrite : UserControl, IShiftOSWindow - { - - public TriWrite() - { - InitializeComponent(); - } - - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - txtcontents.Text = ""; - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Open, new Action((file) => this.LoadFile(file)))); - } - - public void LoadFile(string file) - { - txtcontents.Text = Utils.ReadAllText(file); - } - - public void SaveFile(string file) - { - Utils.WriteAllText(file, txtcontents.Text); - } - - private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Save, new Action((file) => this.SaveFile(file)))); - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/TriWrite.resx b/ShiftOS.WinForms/Applications/TriWrite.resx index 525a23c..a06716c 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.resx +++ b/ShiftOS.WinForms/Applications/TriWrite.resx @@ -130,7 +130,113 @@ To add a contact, simply click "Add Contact", and to remove one, click "Remove". 132, 17 - + 247, 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== + + + + + 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== + + + + + 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== + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index cdb0965..ea7808c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -86,6 +86,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); this.SelectionFont = ConstructFont(); @@ -119,6 +120,135 @@ namespace ShiftOS.WinForms.Controls base.OnMouseUp(mevent); } + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + if (!TerminalBackend.InStory) + { + switch (e.KeyCode) { + case Keys.Add: + case Keys.Alt: + case Keys.Apps: + case Keys.Attn: + case Keys.BrowserBack: + case Keys.BrowserFavorites: + case Keys.BrowserForward: + case Keys.BrowserHome: + case Keys.BrowserRefresh: + case Keys.BrowserSearch: + case Keys.BrowserStop: + case Keys.Cancel: + case Keys.Capital: + case Keys.Clear: + case Keys.Control: + case Keys.ControlKey: + case Keys.Crsel: + case Keys.Decimal: + case Keys.Divide: + case Keys.Down: + case Keys.End: + case Keys.Enter: + case Keys.EraseEof: + case Keys.Escape: + case Keys.Execute: + case Keys.Exsel: + case Keys.F1: + case Keys.F10: + case Keys.F11: + case Keys.F12: + case Keys.F13: + case Keys.F14: + case Keys.F15: + case Keys.F16: + case Keys.F17: + case Keys.F18: + case Keys.F19: + case Keys.F2: + case Keys.F20: + case Keys.F21: + case Keys.F22: + case Keys.F23: + case Keys.F24: + case Keys.F3: + case Keys.F4: + case Keys.F5: + case Keys.F6: + case Keys.F7: + case Keys.F8: + case Keys.F9: + case Keys.FinalMode: + case Keys.HanguelMode: + case Keys.HanjaMode: + case Keys.Help: + case Keys.Home: + case Keys.IMEAccept: + case Keys.IMEConvert: + case Keys.IMEModeChange: + case Keys.IMENonconvert: + case Keys.Insert: + case Keys.JunjaMode: + case Keys.KeyCode: + case Keys.LaunchApplication1: + case Keys.LaunchApplication2: + case Keys.LaunchMail: + case Keys.LButton: + case Keys.LControlKey: + case Keys.Left: + case Keys.LineFeed: + case Keys.LMenu: + case Keys.LShiftKey: + case Keys.LWin: + case Keys.MButton: + case Keys.MediaNextTrack: + case Keys.MediaPlayPause: + case Keys.MediaPreviousTrack: + case Keys.MediaStop: + case Keys.Menu: + case Keys.Modifiers: + case Keys.Multiply: + case Keys.Next: + case Keys.NoName: + case Keys.None: + case Keys.NumLock: + case Keys.Pa1: + case Keys.Packet: + case Keys.PageUp: + case Keys.Pause: + case Keys.Play: + case Keys.Print: + case Keys.PrintScreen: + case Keys.ProcessKey: + case Keys.RButton: + case Keys.RControlKey: + case Keys.Right: + case Keys.RMenu: + case Keys.RShiftKey: + case Keys.RWin: + case Keys.Scroll: + case Keys.Select: + case Keys.SelectMedia: + case Keys.Separator: + case Keys.Shift: + case Keys.ShiftKey: + case Keys.Sleep: + case Keys.Subtract: + case Keys.Tab: + case Keys.Up: + case Keys.VolumeDown: + case Keys.VolumeMute: + case Keys.VolumeUp: + case Keys.XButton1: + case Keys.XButton2: + case Keys.Zoom: + + break; + default: + //Engine.AudioManager.PlayStream(Properties.Resources.typesound); // infernal beeping noise only enable for the trailers + break; + } + } + } + public TerminalBox() : base() { this.Tag = "keepbg keepfg keepfont"; diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs new file mode 100644 index 0000000..c6a7d83 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs @@ -0,0 +1,62 @@ +namespace ShiftOS.WinForms.DesktopWidgets +{ + partial class HeartbeatWidget + { + /// + /// 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.lbheartbeat = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbheartbeat + // + this.lbheartbeat.AutoSize = true; + this.lbheartbeat.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbheartbeat.Location = new System.Drawing.Point(0, 0); + this.lbheartbeat.Name = "lbheartbeat"; + this.lbheartbeat.Size = new System.Drawing.Size(35, 13); + this.lbheartbeat.TabIndex = 0; + this.lbheartbeat.Text = "label1"; + // + // HeartbeatWidget + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.lbheartbeat); + this.Name = "HeartbeatWidget"; + this.Size = new System.Drawing.Size(35, 13); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbheartbeat; + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs new file mode 100644 index 0000000..b0dc552 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs @@ -0,0 +1,51 @@ +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.WinForms.Tools; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.DesktopWidgets +{ + [DesktopWidget("Server ping", "See the time spent between client requests and server replies in the digital society.")] + public partial class HeartbeatWidget : UserControl, IDesktopWidget + { + public HeartbeatWidget() + { + InitializeComponent(); + tmr.Interval = 1; + tmr.Tick += (o, a) => + { + if(ts != ServerManager.DigitalSocietyPing) + { + ts = ServerManager.DigitalSocietyPing; + lbheartbeat.Text = "Server ping: " + ts.ToString() + " MS"; + } + }; + } + + //Fun fact. I misspelled this as "TimeSpam." + long ts = 0; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + Timer tmr = new Timer(); + + public void Setup() + { + tmr.Start(); + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.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/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..e10071f --- /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(159, 163); + 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(69, 115); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(300, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(3, 14); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(300, 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..078061c --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,136 @@ +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(); + txtusername.CenterParent(); + txtusername.Location = new System.Drawing.Point(txtusername.Location.X, 77); + txtpassword.CenterParent(); + btnlogin.CenterParent(); + btnlogin.Location = new System.Drawing.Point(btnlogin.Location.X, 143); + 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/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index a4d63e0..d5f28f8 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -312,11 +312,15 @@ You must join the digital society, rise up the ranks, and save us. sve.Codepoints = 0; sve.Upgrades = new Dictionary(); sve.ID = Guid.NewGuid(); + sve.StoriesExperienced = new List(); + sve.StoriesExperienced.Add("mud_fundamentals"); Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => { sve.StoryPosition = 8675309; SaveSystem.CurrentSave = sve; + Shiftorium.Silent = true; SaveSystem.SaveGame(); + Shiftorium.Silent = false; }); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..a35e1d8 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -120,7 +120,7 @@ namespace ShiftOS.WinForms Console.Write(" "); ConsoleEx.BackgroundColor = ConsoleColor.Black; } - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } @@ -135,15 +135,15 @@ namespace ShiftOS.WinForms { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); - Engine.AudioManager.PlayStream(Properties.Resources.writesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - } + private static bool isValid(string text, string chars) { foreach(var c in text) 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 9fc237f..97cc3c9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -70,9 +70,7 @@ About.cs - - UserControl - + TriWrite.cs @@ -178,9 +176,7 @@ Notifications.cs - - UserControl - + Pong.cs @@ -202,9 +198,7 @@ Shiftnet.cs - - UserControl - + ShiftoriumFrontend.cs @@ -226,9 +220,7 @@ ShopItemCreator.cs - - UserControl - + Skin Loader.cs @@ -298,6 +290,12 @@ CodepointsWidget.cs + + UserControl + + + HeartbeatWidget.cs + UserControl @@ -317,6 +315,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -502,6 +506,9 @@ CodepointsWidget.cs + + HeartbeatWidget.cs + TerminalWidget.cs @@ -511,6 +518,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs index 4c85005..c78e987 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -59,7 +60,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index a46a9b0..7d0fd33 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -99,7 +100,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 25c7639..40dc629 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -515,6 +515,17 @@ namespace ShiftOS.WinForms if(resizing == true) { this.Width += e.X; + 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; + } } } @@ -522,6 +533,17 @@ namespace ShiftOS.WinForms { resizing = false; pnlcontents.Show(); + 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; + } } private void pnlleft_MouseMove(object sender, MouseEventArgs e) @@ -530,6 +552,17 @@ namespace ShiftOS.WinForms { this.Left += e.X; this.Width -= e.X; + 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; + } } } @@ -547,6 +580,17 @@ namespace ShiftOS.WinForms { this.Width += e.X; this.Height += e.Y; + 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; + } } } @@ -557,6 +601,17 @@ namespace ShiftOS.WinForms this.Width -= e.X; this.Height += e.Y; this.Left += e.X; + 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; + } } } diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 57d1d34..dc0b3a2 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -276,6 +276,17 @@ namespace ShiftOS.Engine return true; } + [Command("restart")] + public static bool Restart() + { + SaveSystem.CurrentSave.Upgrades = new Dictionary(); + SaveSystem.CurrentSave.Codepoints = 0; + SaveSystem.CurrentSave.StoriesExperienced.Clear(); + SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); + SaveSystem.SaveGame(); + Shiftorium.InvokeUpgradeInstalled(); + return true; + } [Command("freecp")] public static bool FreeCodepoints(Dictionary args) @@ -283,8 +294,8 @@ namespace ShiftOS.Engine if (args.ContainsKey("amount")) try { - Int64 codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); - SaveSystem.TransferCodepointsFrom("dev", codepointsToAdd); + long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); + SaveSystem.CurrentSave.Codepoints += codepointsToAdd; return true; } catch (Exception ex) @@ -293,7 +304,7 @@ namespace ShiftOS.Engine return true; } - SaveSystem.TransferCodepointsFrom("dev", 1000); + SaveSystem.CurrentSave.Codepoints += 1000; return true; } 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 945869b..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,7 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = Permissions.All; + root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } @@ -98,13 +98,25 @@ namespace ShiftOS.Engine } Thread.Sleep(350); - Console.WriteLine("Initiating kernel..."); + Console.WriteLine("ShiftKernel v0.4.2"); + Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); + Console.WriteLine(""); + Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); + Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); + Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); + Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); + Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); + Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); + Console.WriteLine("SOFTWARE."); + Console.WriteLine(""); Thread.Sleep(250); - Console.WriteLine("Reading filesystem..."); + Console.WriteLine("[init] Kernel boot complete."); + Console.WriteLine("[sfs] Loading SFS driver v3"); Thread.Sleep(100); - Console.WriteLine("Reading configuration..."); + Console.WriteLine("[sfs] 4096 blocks read."); + Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - Console.WriteLine("{CONNECTING_TO_MUD}"); + Console.WriteLine("[inetd] Connecting to network..."); if (defaultConf.ConnectToMud == true) { @@ -113,32 +125,32 @@ namespace ShiftOS.Engine { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("Connection successful."); + Console.WriteLine("[inetd] Connection successful."); }; try { - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } catch (Exception ex) { //No errors, this never gets called. - Console.WriteLine("{ERROR}: " + ex.Message); + Console.WriteLine("[inetd] SEVERE: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } } @@ -196,14 +208,60 @@ namespace ShiftOS.Engine Thread.Sleep(75); Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + Console.WriteLine("[usr-man] Accepting logins on local tty 1."); + Sysname: + bool waitingForNewSysName = false; + bool gobacktosysname = false; + + if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) + { + Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => + { + if (string.IsNullOrWhiteSpace(name)) + Infobox.Show("Invalid name", "Please enter a valid name.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else if (name.Length < 5) + Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else + { + CurrentSave.SystemName = name; + if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) + { + var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); + unite.SetSysName(name); + } + SaveSystem.SaveGame(); + gobacktosysname = false; + waitingForNewSysName = false; + } + }); + + + } + + while (waitingForNewSysName) + { + Thread.Sleep(10); + } + + if (gobacktosysname) + { + goto Sysname; + } if (CurrentSave.Users == null) CurrentSave.Users = new List(); - if(CurrentSave.Users.Count == 0) + if (CurrentSave.Users.Count == 0) { CurrentSave.Users.Add(new ClientSave { @@ -211,76 +269,101 @@ namespace ShiftOS.Engine Password = "", Permissions = UserPermissions.Root }); - Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); } TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) + { + Action Completed = null; + Completed += (user) => + { + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else { - if (progress == 0) + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => { - if (!string.IsNullOrWhiteSpace(text)) + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + string loginstr = CurrentSave.SystemName + " login: "; + string getuser = text.Remove(0, loginstr.Length); + if (!string.IsNullOrWhiteSpace(getuser)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = getuser; 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."); + string passwordstr = "password: "; + string getpass = text.Remove(0, passwordstr.Length); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == getpass) + { + 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.Write(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.Write("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/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 0bdfcd9..825064b 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -35,6 +35,7 @@ using ShiftOS; using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; using System.Net.Sockets; +using System.Diagnostics; namespace ShiftOS.Engine { @@ -54,6 +55,12 @@ namespace ShiftOS.Engine private static NetObjectClient client { get; set; } private static bool UserDisconnect = false; + public static long DigitalSocietyPing + { + get; + private set; + } + public static void Disconnect() { UserDisconnect = true; @@ -139,6 +146,11 @@ namespace ShiftOS.Engine }; client.OnReceived += (o, a) => { + if (PingTimer.IsRunning) + { + DigitalSocietyPing = PingTimer.ElapsedMilliseconds; + PingTimer.Reset(); + } var msg = a.Data.Object as ServerMessage; if (msg.Name == "Welcome") { @@ -207,6 +219,8 @@ namespace ShiftOS.Engine } } + private static Stopwatch PingTimer = new Stopwatch(); + public static void SendMessage(string name, string contents) { var sMsg = new ServerMessage @@ -215,7 +229,7 @@ namespace ShiftOS.Engine Contents = contents, GUID = thisGuid.ToString(), }; - + PingTimer.Start(); client.Send(new NetObject("msg", sMsg)); } 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")] diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 1136b5c..8d6a58d 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -5,13 +5,20 @@ using System.Net; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using ShiftOS.Objects; namespace ShiftOS.Unite { public class UniteClient { public string Token { get; private set; } - public string BaseURL { get; private set; } + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } public string GetDisplayNameId(string id) { @@ -25,7 +32,8 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { - BaseURL = baseurl; + //Handled by the servers.json file + //BaseURL = baseurl; Token = usertoken; } diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index 62735a3..5702e08 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -47,6 +47,11 @@ namespace ShiftOS.Engine } var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); + if(user.Username != SaveSystem.CurrentUser.Username) + { + Console.WriteLine("Error: Cannot remove yourself."); + return true; + } SaveSystem.CurrentSave.Users.Remove(user); Console.WriteLine($"Removing user \"{name}\" from system..."); SaveSystem.SaveGame(); @@ -55,13 +60,121 @@ namespace ShiftOS.Engine + + [Command("set_acl")] + [RequiresArgument("user")] + [RequiresArgument("val")] + public static bool SetUserPermission(Dictionary args) + { + int permission = 0; + string username = args["user"].ToString(); + try + { + permission = Convert.ToInt32(args["val"].ToString()); + } + catch + { + Console.WriteLine("Error: Permission value must be an integer."); + return true; + } + + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) + { + Console.WriteLine("Error: User not found."); + return true; + } + + UserPermissions uperm = UserPermissions.Guest; + + switch (permission) + { + case 0: + uperm = UserPermissions.Guest; + break; + case 1: + uperm = UserPermissions.User; + break; + case 2: + uperm = UserPermissions.Admin; + break; + case 3: + uperm = UserPermissions.Root; + break; + default: + Console.WriteLine("Permission value must be between 0 and 4."); + return true; + } + + //Permissions are backwards... oops... + if(uperm < SaveSystem.CurrentUser.Permissions) + { + Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + return true; + } + + var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; + if (SaveSystem.CurrentUser.Permissions > oldperm) + { + Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + return true; + } + + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; + Console.WriteLine("User permissions updated."); + return true; + } + + + [Command("users", description = "Get a list of all users on the system.")] + public static bool GetUsers() + { + foreach (var u in SaveSystem.CurrentSave.Users) + { + if (u.Username == SaveSystem.CurrentUser.Username) + { + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + } + else + { + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + } + Console.WriteLine(u.Username); + } + return true; + } } [Namespace("user")] [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] [RequiresArgument("old")] -- cgit v1.2.3