aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/WindowManager
diff options
context:
space:
mode:
authorJohn T <[email protected]>2017-09-27 18:32:16 -0400
committerJohn T <[email protected]>2017-09-27 18:32:16 -0400
commita25baf08203237fc2eeeb4b7ca720f7d47f8a666 (patch)
tree2664b08ca0f9b57ed0a9240ab54441ece6ac2d71 /ShiftOS.Engine/WindowManager
parentdc7533184a88271bfd2a3aae299532ec7632144d (diff)
downloadshiftos-rewind-a25baf08203237fc2eeeb4b7ca720f7d47f8a666.tar.gz
shiftos-rewind-a25baf08203237fc2eeeb4b7ca720f7d47f8a666.tar.bz2
shiftos-rewind-a25baf08203237fc2eeeb4b7ca720f7d47f8a666.zip
added desktop and some small additions and changes to shiftwm
Diffstat (limited to 'ShiftOS.Engine/WindowManager')
-rw-r--r--ShiftOS.Engine/WindowManager/InfoboxTemplate.cs58
-rw-r--r--ShiftOS.Engine/WindowManager/ShiftWM.cs82
-rw-r--r--ShiftOS.Engine/WindowManager/ShiftWindow.Designer.cs446
-rw-r--r--ShiftOS.Engine/WindowManager/ShiftWindow.cs126
4 files changed, 377 insertions, 335 deletions
diff --git a/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs b/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs
index c1921a6..a5be129 100644
--- a/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs
+++ b/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs
@@ -1,11 +1,5 @@
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 System.Media;
using System.IO;
@@ -14,38 +8,39 @@ namespace ShiftOS.Engine.WindowManager
{
public partial class InfoboxTemplate : UserControl
{
- Stream str;
- public int buttonChoice;
- public int buttonSelected;
- public InfoboxTemplate(buttonType type)
+ Stream _str;
+ private int _buttonChoice;
+ private int _buttonSelected;
+ public InfoboxTemplate(ButtonType type)
{
InitializeComponent();
switch (type)
{
- case buttonType.OK:
+ case ButtonType.Ok:
btnOpt1.Text = "OK";
btnOpt2.Hide();
btnOpt1.Location = new Point(109, 134);
- buttonChoice = 1;
+ _buttonChoice = 1;
break;
- case buttonType.OKCancel:
+ case ButtonType.OkCancel:
btnOpt1.Text = "OK";
btnOpt2.Text = "Cancel";
- buttonChoice = 2;
+ _buttonChoice = 2;
break;
- case buttonType.YesNo:
+ case ButtonType.YesNo:
btnOpt1.Text = "Yes";
btnOpt2.Text = "No";
- buttonChoice = 3;
+ _buttonChoice = 3;
break;
}
}
- public enum buttonType
+
+ public enum ButtonType
{
YesNo,
- OKCancel,
- OK
+ OkCancel,
+ Ok
}
private void btnOpt1_Click(object sender, EventArgs e)
@@ -53,12 +48,12 @@ namespace ShiftOS.Engine.WindowManager
switch (btnOpt1.Text)
{
case "OK":
- buttonSelected = 1;
- ParentForm.Close();
+ _buttonSelected = 1;
+ ParentForm?.Close();
break;
case "Yes":
- buttonSelected = 2;
- ParentForm.Close();
+ _buttonSelected = 2;
+ ParentForm?.Close();
break;
}
}
@@ -68,27 +63,26 @@ namespace ShiftOS.Engine.WindowManager
switch (btnOpt2.Text)
{
case "No":
- buttonSelected = 3;
+ _buttonSelected = 3;
break;
case "Cancel":
- buttonSelected = 4;
+ _buttonSelected = 4;
break;
}
}
+
public void Play()
{
- str = Properties.Resources.infobox;
- SoundPlayer sp = new SoundPlayer(str);
+ _str = Properties.Resources.infobox;
+ SoundPlayer sp = new SoundPlayer(_str);
sp.Play();
sp.Stream.Position = 0;
}
- private void InfoboxTemplate_Load(object sender, EventArgs e)
- {
- Play();
- }
+ private void InfoboxTemplate_Load(object sender, EventArgs e)
+ => Play();
- private void changeSize_Tick(object sender, EventArgs e)
+ private void changeSize_Tick(object sender, EventArgs e)
{
this.Height += label1.Height;
this.Width += label1.Width;
diff --git a/ShiftOS.Engine/WindowManager/ShiftWM.cs b/ShiftOS.Engine/WindowManager/ShiftWM.cs
index 38537c7..539d469 100644
--- a/ShiftOS.Engine/WindowManager/ShiftWM.cs
+++ b/ShiftOS.Engine/WindowManager/ShiftWM.cs
@@ -1,41 +1,81 @@
-using System.Drawing;
+using System;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
using static ShiftOS.Engine.WindowManager.InfoboxTemplate;
namespace ShiftOS.Engine.WindowManager
{
- public class ShiftWM
+ public static class ShiftWM
{
- public ShiftWindow Init(UserControl content, string title, Image icon, bool ShowAsInfobox = false, bool resize = true)
+ public static ObservableCollection<ShiftWindow> Windows { get; } = new ObservableCollection<ShiftWindow>();
+
+ public static ShiftWindow GetShiftWindow(this UserControl control)
+ {
+ return Windows.First(p => (uint) control.Tag == p.Id);
+ }
+
+ public static ShiftWindow Init(UserControl content, string title, Icon icon, bool showAsInfobox = false, bool resize = true)
{
// Setup Window
- ShiftWindow app = new ShiftWindow();
- app.Text = title;
- app.Title.Text = title;
- app.Width = content.Width + app.left.Width + app.right.Width;
+ ShiftWindow app = new ShiftWindow
+ {
+ Text = title,
+ Title = {Text = title}
+ };
+
+ app.Width = content.Width + app.left.Width + app.right.Width;
app.Height = content.Height + app.bottom.Height + app.top.Height;
// Icon Setup
- if (icon == null)
- {
- app.programIcon.Hide();
- app.programIcon.Image = Properties.Resources.nullIcon;
- app.Title.Location = new Point(2, 7);
- }
- else app.programIcon.Image = icon;
-
- // Setup UC
- content.Parent = app.programContent;
+ if (icon == null)
+ {
+ app.programIcon.Hide();
+ app.programIcon.Image = Properties.Resources.nullIcon;
+ app.Title.Location = new Point(2, 7);
+ }
+
+ else
+ {
+ app.programIcon.Image = icon.ToBitmap();
+ app.Icon = icon;
+ }
+
+ // Setup UC
+ content.Parent = app.programContent;
content.BringToFront();
content.Dock = DockStyle.Fill;
app.Show();
+
+ content.Tag = app.SetId();
+
+ Debug.WriteLine($"usercontrol: {content.Tag} window: {app.Id}");
+
+ app.Closed += (sender, args) =>
+ {
+ Windows.Remove((ShiftWindow) sender);
+ };
+
+ Windows.Add(app);
+
+ if (content is IShiftWindowExtensions extensions)
+ {
+ extensions.OnLoaded(app);
+ }
+
return app;
}
- public InfoboxTemplate StartInfoboxSession(string title, string body, buttonType type)
+
+ public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type)
{
- InfoboxTemplate info = new InfoboxTemplate(type);
- info.label1.Text = body;
- Init(info, title, Properties.Resources.iconInfoBox_fw, true, false);
+ InfoboxTemplate info = new InfoboxTemplate(type)
+ {
+ label1 = { Text = body }
+ };
+
+ Init(info, title, Properties.Resources.iconInfoBox_fw.ToIcon(), true, false);
return info;
}
}
diff --git a/ShiftOS.Engine/WindowManager/ShiftWindow.Designer.cs b/ShiftOS.Engine/WindowManager/ShiftWindow.Designer.cs
index f7443d6..1e0f105 100644
--- a/ShiftOS.Engine/WindowManager/ShiftWindow.Designer.cs
+++ b/ShiftOS.Engine/WindowManager/ShiftWindow.Designer.cs
@@ -28,220 +28,238 @@
/// </summary>
private void InitializeComponent()
{
- this.program = new System.Windows.Forms.Panel();
- this.programContent = new System.Windows.Forms.Panel();
- this.bottomleftcorner = new System.Windows.Forms.Panel();
- this.toprightcorner = new System.Windows.Forms.Panel();
- this.bottomrightcorner = new System.Windows.Forms.Panel();
- this.topleftcorner = new System.Windows.Forms.Panel();
- this.bottom = new System.Windows.Forms.Panel();
- this.top = new System.Windows.Forms.Panel();
- this.programIcon = new System.Windows.Forms.PictureBox();
- this.maximizebutton = new System.Windows.Forms.PictureBox();
- this.minimizebutton = new System.Windows.Forms.PictureBox();
- this.Title = new System.Windows.Forms.Label();
- this.closebutton = new System.Windows.Forms.PictureBox();
- this.right = new System.Windows.Forms.Panel();
- this.left = new System.Windows.Forms.Panel();
- this.program.SuspendLayout();
- this.top.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.closebutton)).BeginInit();
- this.SuspendLayout();
- //
- // program
- //
- this.program.BackColor = System.Drawing.Color.White;
- this.program.Controls.Add(this.programContent);
- this.program.Controls.Add(this.bottomleftcorner);
- this.program.Controls.Add(this.toprightcorner);
- this.program.Controls.Add(this.bottomrightcorner);
- this.program.Controls.Add(this.topleftcorner);
- this.program.Controls.Add(this.bottom);
- this.program.Controls.Add(this.top);
- this.program.Controls.Add(this.right);
- this.program.Controls.Add(this.left);
- this.program.Dock = System.Windows.Forms.DockStyle.Fill;
- this.program.Location = new System.Drawing.Point(0, 0);
- this.program.Name = "program";
- this.program.Size = new System.Drawing.Size(284, 261);
- this.program.TabIndex = 11;
- //
- // programContent
- //
- this.programContent.Dock = System.Windows.Forms.DockStyle.Fill;
- this.programContent.Location = new System.Drawing.Point(4, 30);
- this.programContent.Name = "programContent";
- this.programContent.Size = new System.Drawing.Size(276, 227);
- this.programContent.TabIndex = 11;
- //
- // bottomleftcorner
- //
- this.bottomleftcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.bottomleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.bottomleftcorner.Location = new System.Drawing.Point(0, 257);
- this.bottomleftcorner.Name = "bottomleftcorner";
- this.bottomleftcorner.Size = new System.Drawing.Size(5, 4);
- this.bottomleftcorner.TabIndex = 10;
- //
- // toprightcorner
- //
- this.toprightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.toprightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.toprightcorner.Location = new System.Drawing.Point(278, 0);
- this.toprightcorner.Name = "toprightcorner";
- this.toprightcorner.Size = new System.Drawing.Size(6, 30);
- this.toprightcorner.TabIndex = 9;
- //
- // bottomrightcorner
- //
- this.bottomrightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.bottomrightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.bottomrightcorner.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
- this.bottomrightcorner.Location = new System.Drawing.Point(280, 257);
- this.bottomrightcorner.Name = "bottomrightcorner";
- this.bottomrightcorner.Size = new System.Drawing.Size(4, 4);
- this.bottomrightcorner.TabIndex = 4;
- //
- // topleftcorner
- //
- this.topleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.topleftcorner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
- this.topleftcorner.Location = new System.Drawing.Point(0, 0);
- this.topleftcorner.Name = "topleftcorner";
- this.topleftcorner.Size = new System.Drawing.Size(7, 30);
- this.topleftcorner.TabIndex = 8;
- //
- // bottom
- //
- this.bottom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.bottom.Cursor = System.Windows.Forms.Cursors.SizeNS;
- this.bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.bottom.Location = new System.Drawing.Point(4, 257);
- this.bottom.Name = "bottom";
- this.bottom.Size = new System.Drawing.Size(276, 4);
- this.bottom.TabIndex = 3;
- //
- // top
- //
- this.top.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.top.Controls.Add(this.programIcon);
- this.top.Controls.Add(this.maximizebutton);
- this.top.Controls.Add(this.minimizebutton);
- this.top.Controls.Add(this.Title);
- this.top.Controls.Add(this.closebutton);
- this.top.Dock = System.Windows.Forms.DockStyle.Top;
- this.top.ForeColor = System.Drawing.SystemColors.ControlText;
- this.top.Location = new System.Drawing.Point(4, 0);
- this.top.Name = "top";
- this.top.Size = new System.Drawing.Size(276, 30);
- this.top.TabIndex = 0;
- this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
- //
- // programIcon
- //
- this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.programIcon.ErrorImage = null;
- this.programIcon.InitialImage = null;
- this.programIcon.Location = new System.Drawing.Point(6, 7);
- this.programIcon.Name = "programIcon";
- this.programIcon.Size = new System.Drawing.Size(16, 16);
- this.programIcon.TabIndex = 7;
- this.programIcon.TabStop = false;
- //
- // maximizebutton
- //
- this.maximizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.maximizebutton.BackColor = System.Drawing.Color.Black;
- this.maximizebutton.Location = new System.Drawing.Point(230, 4);
- this.maximizebutton.Name = "maximizebutton";
- this.maximizebutton.Size = new System.Drawing.Size(21, 21);
- this.maximizebutton.TabIndex = 6;
- this.maximizebutton.TabStop = false;
- this.maximizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseDown);
- this.maximizebutton.MouseEnter += new System.EventHandler(this.maximizebutton_MouseEnter);
- this.maximizebutton.MouseLeave += new System.EventHandler(this.maximizebutton_MouseLeave);
- this.maximizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseUp);
- //
- // minimizebutton
- //
- this.minimizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.minimizebutton.BackColor = System.Drawing.Color.Black;
- this.minimizebutton.Location = new System.Drawing.Point(207, 4);
- this.minimizebutton.Name = "minimizebutton";
- this.minimizebutton.Size = new System.Drawing.Size(21, 21);
- this.minimizebutton.TabIndex = 5;
- this.minimizebutton.TabStop = false;
- this.minimizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseDown);
- this.minimizebutton.MouseEnter += new System.EventHandler(this.minimizebutton_MouseEnter);
- this.minimizebutton.MouseLeave += new System.EventHandler(this.minimizebutton_MouseLeave);
- this.minimizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseUp);
- //
- // Title
- //
- this.Title.AutoSize = true;
- this.Title.BackColor = System.Drawing.Color.Transparent;
- this.Title.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.Title.ForeColor = System.Drawing.Color.White;
- this.Title.Location = new System.Drawing.Point(25, 8);
- this.Title.Name = "Title";
- this.Title.Size = new System.Drawing.Size(98, 13);
- this.Title.TabIndex = 3;
- this.Title.Text = "Application Title";
- this.Title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
- //
- // closebutton
- //
- this.closebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.closebutton.BackColor = System.Drawing.Color.Black;
- this.closebutton.Location = new System.Drawing.Point(253, 4);
- this.closebutton.Name = "closebutton";
- this.closebutton.Size = new System.Drawing.Size(21, 21);
- this.closebutton.TabIndex = 4;
- this.closebutton.TabStop = false;
- this.closebutton.Click += new System.EventHandler(this.closebutton_Click);
- this.closebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseDown);
- this.closebutton.MouseEnter += new System.EventHandler(this.closebutton_MouseEnter);
- this.closebutton.MouseLeave += new System.EventHandler(this.closebutton_MouseLeave);
- this.closebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseUp);
- //
- // right
- //
- this.right.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.right.Cursor = System.Windows.Forms.Cursors.SizeWE;
- this.right.Dock = System.Windows.Forms.DockStyle.Right;
- this.right.Location = new System.Drawing.Point(280, 0);
- this.right.Name = "right";
- this.right.Size = new System.Drawing.Size(4, 261);
- this.right.TabIndex = 2;
- //
- // left
- //
- this.left.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
- this.left.Dock = System.Windows.Forms.DockStyle.Left;
- this.left.Location = new System.Drawing.Point(0, 0);
- this.left.Name = "left";
- this.left.Size = new System.Drawing.Size(4, 261);
- this.left.TabIndex = 1;
- //
- // ShiftWindow
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(284, 261);
- this.Controls.Add(this.program);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Name = "ShiftWindow";
- this.program.ResumeLayout(false);
- this.top.ResumeLayout(false);
- this.top.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.closebutton)).EndInit();
- this.ResumeLayout(false);
+ this.program = new System.Windows.Forms.Panel();
+ this.programContent = new System.Windows.Forms.Panel();
+ this.bottomleftcorner = new System.Windows.Forms.Panel();
+ this.toprightcorner = new System.Windows.Forms.Panel();
+ this.bottomrightcorner = new System.Windows.Forms.Panel();
+ this.topleftcorner = new System.Windows.Forms.Panel();
+ this.bottom = new System.Windows.Forms.Panel();
+ this.top = new System.Windows.Forms.Panel();
+ this.programIcon = new System.Windows.Forms.PictureBox();
+ this.maximizebutton = new System.Windows.Forms.PictureBox();
+ this.minimizebutton = new System.Windows.Forms.PictureBox();
+ this.Title = new System.Windows.Forms.Label();
+ this.closebutton = new System.Windows.Forms.PictureBox();
+ this.right = new System.Windows.Forms.Panel();
+ this.left = new System.Windows.Forms.Panel();
+ this.program.SuspendLayout();
+ this.top.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.closebutton)).BeginInit();
+ this.SuspendLayout();
+ //
+ // program
+ //
+ this.program.BackColor = System.Drawing.Color.White;
+ this.program.Controls.Add(this.programContent);
+ this.program.Controls.Add(this.bottomleftcorner);
+ this.program.Controls.Add(this.toprightcorner);
+ this.program.Controls.Add(this.bottomrightcorner);
+ this.program.Controls.Add(this.topleftcorner);
+ this.program.Controls.Add(this.bottom);
+ this.program.Controls.Add(this.top);
+ this.program.Controls.Add(this.right);
+ this.program.Controls.Add(this.left);
+ this.program.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.program.Location = new System.Drawing.Point(0, 0);
+ this.program.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.program.Name = "program";
+ this.program.Size = new System.Drawing.Size(426, 402);
+ this.program.TabIndex = 11;
+ //
+ // programContent
+ //
+ this.programContent.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.programContent.Location = new System.Drawing.Point(6, 46);
+ this.programContent.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.programContent.Name = "programContent";
+ this.programContent.Size = new System.Drawing.Size(414, 350);
+ this.programContent.TabIndex = 11;
+ //
+ // bottomleftcorner
+ //
+ this.bottomleftcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.bottomleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.bottomleftcorner.Location = new System.Drawing.Point(0, 395);
+ this.bottomleftcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.bottomleftcorner.Name = "bottomleftcorner";
+ this.bottomleftcorner.Size = new System.Drawing.Size(8, 6);
+ this.bottomleftcorner.TabIndex = 10;
+ //
+ // toprightcorner
+ //
+ this.toprightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.toprightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.toprightcorner.Location = new System.Drawing.Point(417, 0);
+ this.toprightcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.toprightcorner.Name = "toprightcorner";
+ this.toprightcorner.Size = new System.Drawing.Size(9, 46);
+ this.toprightcorner.TabIndex = 9;
+ //
+ // bottomrightcorner
+ //
+ this.bottomrightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.bottomrightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.bottomrightcorner.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
+ this.bottomrightcorner.Location = new System.Drawing.Point(420, 395);
+ this.bottomrightcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.bottomrightcorner.Name = "bottomrightcorner";
+ this.bottomrightcorner.Size = new System.Drawing.Size(6, 6);
+ this.bottomrightcorner.TabIndex = 4;
+ //
+ // topleftcorner
+ //
+ this.topleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.topleftcorner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
+ this.topleftcorner.Location = new System.Drawing.Point(0, 0);
+ this.topleftcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.topleftcorner.Name = "topleftcorner";
+ this.topleftcorner.Size = new System.Drawing.Size(10, 46);
+ this.topleftcorner.TabIndex = 8;
+ //
+ // bottom
+ //
+ this.bottom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.bottom.Cursor = System.Windows.Forms.Cursors.SizeNS;
+ this.bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.bottom.Location = new System.Drawing.Point(6, 396);
+ this.bottom.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.bottom.Name = "bottom";
+ this.bottom.Size = new System.Drawing.Size(414, 6);
+ this.bottom.TabIndex = 3;
+ //
+ // top
+ //
+ this.top.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.top.Controls.Add(this.programIcon);
+ this.top.Controls.Add(this.maximizebutton);
+ this.top.Controls.Add(this.minimizebutton);
+ this.top.Controls.Add(this.Title);
+ this.top.Controls.Add(this.closebutton);
+ this.top.Dock = System.Windows.Forms.DockStyle.Top;
+ this.top.ForeColor = System.Drawing.SystemColors.ControlText;
+ this.top.Location = new System.Drawing.Point(6, 0);
+ this.top.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.top.Name = "top";
+ this.top.Size = new System.Drawing.Size(414, 46);
+ this.top.TabIndex = 0;
+ this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
+ //
+ // programIcon
+ //
+ this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.programIcon.ErrorImage = null;
+ this.programIcon.InitialImage = null;
+ this.programIcon.Location = new System.Drawing.Point(9, 11);
+ this.programIcon.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.programIcon.Name = "programIcon";
+ this.programIcon.Size = new System.Drawing.Size(24, 25);
+ this.programIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+ this.programIcon.TabIndex = 7;
+ this.programIcon.TabStop = false;
+ //
+ // maximizebutton
+ //
+ this.maximizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.maximizebutton.BackColor = System.Drawing.Color.Black;
+ this.maximizebutton.Location = new System.Drawing.Point(345, 6);
+ this.maximizebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.maximizebutton.Name = "maximizebutton";
+ this.maximizebutton.Size = new System.Drawing.Size(32, 32);
+ this.maximizebutton.TabIndex = 6;
+ this.maximizebutton.TabStop = false;
+ this.maximizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseDown);
+ this.maximizebutton.MouseEnter += new System.EventHandler(this.maximizebutton_MouseEnter);
+ this.maximizebutton.MouseLeave += new System.EventHandler(this.maximizebutton_MouseLeave);
+ this.maximizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseUp);
+ //
+ // minimizebutton
+ //
+ this.minimizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.minimizebutton.BackColor = System.Drawing.Color.Black;
+ this.minimizebutton.Location = new System.Drawing.Point(310, 6);
+ this.minimizebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.minimizebutton.Name = "minimizebutton";
+ this.minimizebutton.Size = new System.Drawing.Size(32, 32);
+ this.minimizebutton.TabIndex = 5;
+ this.minimizebutton.TabStop = false;
+ this.minimizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseDown);
+ this.minimizebutton.MouseEnter += new System.EventHandler(this.minimizebutton_MouseEnter);
+ this.minimizebutton.MouseLeave += new System.EventHandler(this.minimizebutton_MouseLeave);
+ this.minimizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseUp);
+ //
+ // Title
+ //
+ this.Title.AutoSize = true;
+ this.Title.BackColor = System.Drawing.Color.Transparent;
+ this.Title.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.Title.ForeColor = System.Drawing.Color.White;
+ this.Title.Location = new System.Drawing.Point(38, 12);
+ this.Title.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.Title.Name = "Title";
+ this.Title.Size = new System.Drawing.Size(149, 21);
+ this.Title.TabIndex = 3;
+ this.Title.Text = "Application Title";
+ this.Title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
+ //
+ // closebutton
+ //
+ this.closebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
+ this.closebutton.BackColor = System.Drawing.Color.Black;
+ this.closebutton.Location = new System.Drawing.Point(380, 6);
+ this.closebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.closebutton.Name = "closebutton";
+ this.closebutton.Size = new System.Drawing.Size(32, 32);
+ this.closebutton.TabIndex = 4;
+ this.closebutton.TabStop = false;
+ this.closebutton.Click += new System.EventHandler(this.closebutton_Click);
+ this.closebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseDown);
+ this.closebutton.MouseEnter += new System.EventHandler(this.closebutton_MouseEnter);
+ this.closebutton.MouseLeave += new System.EventHandler(this.closebutton_MouseLeave);
+ this.closebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseUp);
+ //
+ // right
+ //
+ this.right.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.right.Cursor = System.Windows.Forms.Cursors.SizeWE;
+ this.right.Dock = System.Windows.Forms.DockStyle.Right;
+ this.right.Location = new System.Drawing.Point(420, 0);
+ this.right.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.right.Name = "right";
+ this.right.Size = new System.Drawing.Size(6, 402);
+ this.right.TabIndex = 2;
+ //
+ // left
+ //
+ this.left.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
+ this.left.Dock = System.Windows.Forms.DockStyle.Left;
+ this.left.Location = new System.Drawing.Point(0, 0);
+ this.left.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.left.Name = "left";
+ this.left.Size = new System.Drawing.Size(6, 402);
+ this.left.TabIndex = 1;
+ //
+ // ShiftWindow
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(426, 402);
+ this.Controls.Add(this.program);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+ this.Name = "ShiftWindow";
+ this.Text = "c";
+ this.program.ResumeLayout(false);
+ this.top.ResumeLayout(false);
+ this.top.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.closebutton)).EndInit();
+ this.ResumeLayout(false);
}
diff --git a/ShiftOS.Engine/WindowManager/ShiftWindow.cs b/ShiftOS.Engine/WindowManager/ShiftWindow.cs
index 45aec7c..a41786a 100644
--- a/ShiftOS.Engine/WindowManager/ShiftWindow.cs
+++ b/ShiftOS.Engine/WindowManager/ShiftWindow.cs
@@ -1,11 +1,6 @@
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 System.Runtime.InteropServices;
@@ -13,91 +8,86 @@ namespace ShiftOS.Engine.WindowManager
{
public partial class ShiftWindow : Form
{
- public ShiftWindow()
+ public uint Id { get; private set; }
+
+ public UserControl ChildControl { get; set; }
+
+ public ShiftWindow()
{
InitializeComponent();
}
- public const int WM_NCLBUTTONDOWN = 0xA1;
- public const int HT_CAPTION = 0x2;
+
+ public uint SetId()
+ {
+ do
+ {
+ Id = (uint)Tools.Rnd.Next(100000, 999999);
+ }
+ while (ShiftWM.Windows.FirstOrDefault(w => w.Id == Id) != null);
+
+ return Id;
+ }
+
+ private const int WM_NCLBUTTONDOWN = 0xA1;
+ private const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd,
+ private static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
+
[DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
+ private static extern bool ReleaseCapture();
private void Programtopbar_drag(object sender, MouseEventArgs e)
{
- if (e.Button == MouseButtons.Left)
- {
- ReleaseCapture();
- SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
- }
- }
+ if (e.Button != MouseButtons.Left) return;
- private void closebutton_Click(object sender, EventArgs e)
- {
- this.Close();
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
- private void closebutton_MouseEnter(object sender, EventArgs e)
- {
- closebutton.BackColor = Color.Gray;
- }
+ private void closebutton_Click(object sender, EventArgs e)
+ => this.Close();
- private void closebutton_MouseLeave(object sender, EventArgs e)
- {
- closebutton.BackColor = Color.Black;
- }
+ private void closebutton_MouseEnter(object sender, EventArgs e)
+ => closebutton.BackColor = Color.Gray;
- private void maximizebutton_MouseEnter(object sender, EventArgs e)
- {
- maximizebutton.BackColor = Color.Gray;
- }
+ private void closebutton_MouseLeave(object sender, EventArgs e)
+ => closebutton.BackColor = Color.Black;
- private void maximizebutton_MouseLeave(object sender, EventArgs e)
- {
- maximizebutton.BackColor = Color.Black;
- }
+ private void maximizebutton_MouseEnter(object sender, EventArgs e)
+ => maximizebutton.BackColor = Color.Gray;
- private void minimizebutton_MouseEnter(object sender, EventArgs e)
- {
- minimizebutton.BackColor = Color.Gray;
- }
+ private void maximizebutton_MouseLeave(object sender, EventArgs e)
+ => maximizebutton.BackColor = Color.Black;
- private void minimizebutton_MouseLeave(object sender, EventArgs e)
- {
- minimizebutton.BackColor = Color.Black;
- }
+ private void minimizebutton_MouseEnter(object sender, EventArgs e)
+ => minimizebutton.BackColor = Color.Gray;
- private void closebutton_MouseDown(object sender, MouseEventArgs e)
- {
- closebutton.BackColor = Color.Black;
- }
+ private void minimizebutton_MouseLeave(object sender, EventArgs e)
+ => minimizebutton.BackColor = Color.Black;
- private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
- {
- maximizebutton.BackColor = Color.Black;
- }
+ private void closebutton_MouseDown(object sender, MouseEventArgs e)
+ => closebutton.BackColor = Color.Black;
- private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
- {
- minimizebutton.BackColor = Color.Black;
- }
+ private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
+ => maximizebutton.BackColor = Color.Black;
- private void minimizebutton_MouseUp(object sender, MouseEventArgs e)
- {
- minimizebutton.BackColor = Color.Gray;
- }
+ private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
+ => minimizebutton.BackColor = Color.Black;
- private void maximizebutton_MouseUp(object sender, MouseEventArgs e)
- {
- maximizebutton.BackColor = Color.Gray;
- }
+ private void minimizebutton_MouseUp(object sender, MouseEventArgs e)
+ => minimizebutton.BackColor = Color.Gray;
- private void closebutton_MouseUp(object sender, MouseEventArgs e)
- {
- closebutton.BackColor = Color.Gray;
- }
- }
+ private void maximizebutton_MouseUp(object sender, MouseEventArgs e)
+ => maximizebutton.BackColor = Color.Gray;
+
+ private void closebutton_MouseUp(object sender, MouseEventArgs e)
+ => closebutton.BackColor = Color.Gray;
+ }
+
+ public interface IShiftWindowExtensions
+ {
+ void OnLoaded(ShiftWindow window);
+ }
}