Windows are now forms. Minimizing works. Useful panel buttons work. Desktop is less fucking flickery.

This commit is contained in:
Alkaline Thunder 2018-12-30 21:10:54 -05:00
parent 0f7902b802
commit c8c32ad8d2
8 changed files with 128 additions and 123 deletions

View file

@ -30,18 +30,17 @@
{
this.components = new System.ComponentModel.Container();
this.DesktopPanel = new System.Windows.Forms.Panel();
this.CurrentTime = new System.Windows.Forms.Label();
this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
this.Workspace = new System.Windows.Forms.Panel();
this.PanelButtonList = new System.Windows.Forms.FlowLayoutPanel();
this.AppLauncherHolder = new System.Windows.Forms.Panel();
this.AppLauncherStrip = new System.Windows.Forms.MenuStrip();
this.AppLauncherMenu = new System.Windows.Forms.ToolStripMenuItem();
this.PanelButtonList = new System.Windows.Forms.FlowLayoutPanel();
this.TimePanel = new System.Windows.Forms.Panel();
this.AppLauncherHolder = new System.Windows.Forms.Panel();
this.CurrentTime = new System.Windows.Forms.Label();
this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
this.DesktopPanel.SuspendLayout();
this.AppLauncherHolder.SuspendLayout();
this.AppLauncherStrip.SuspendLayout();
this.TimePanel.SuspendLayout();
this.AppLauncherHolder.SuspendLayout();
this.SuspendLayout();
//
// DesktopPanel
@ -57,6 +56,55 @@
this.DesktopPanel.Size = new System.Drawing.Size(800, 24);
this.DesktopPanel.TabIndex = 0;
//
// PanelButtonList
//
this.PanelButtonList.Dock = System.Windows.Forms.DockStyle.Fill;
this.PanelButtonList.Location = new System.Drawing.Point(88, 0);
this.PanelButtonList.Margin = new System.Windows.Forms.Padding(0);
this.PanelButtonList.Name = "PanelButtonList";
this.PanelButtonList.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
this.PanelButtonList.Size = new System.Drawing.Size(605, 24);
this.PanelButtonList.TabIndex = 2;
//
// AppLauncherHolder
//
this.AppLauncherHolder.BackColor = System.Drawing.Color.Gray;
this.AppLauncherHolder.Controls.Add(this.AppLauncherStrip);
this.AppLauncherHolder.Dock = System.Windows.Forms.DockStyle.Left;
this.AppLauncherHolder.Location = new System.Drawing.Point(0, 0);
this.AppLauncherHolder.Name = "AppLauncherHolder";
this.AppLauncherHolder.Size = new System.Drawing.Size(88, 24);
this.AppLauncherHolder.TabIndex = 0;
//
// AppLauncherStrip
//
this.AppLauncherStrip.GripMargin = new System.Windows.Forms.Padding(0);
this.AppLauncherStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AppLauncherMenu});
this.AppLauncherStrip.Location = new System.Drawing.Point(0, 0);
this.AppLauncherStrip.Name = "AppLauncherStrip";
this.AppLauncherStrip.Padding = new System.Windows.Forms.Padding(0);
this.AppLauncherStrip.Size = new System.Drawing.Size(88, 24);
this.AppLauncherStrip.TabIndex = 1;
this.AppLauncherStrip.Text = "menuStrip1";
//
// AppLauncherMenu
//
this.AppLauncherMenu.AutoSize = false;
this.AppLauncherMenu.Name = "AppLauncherMenu";
this.AppLauncherMenu.Padding = new System.Windows.Forms.Padding(0);
this.AppLauncherMenu.Size = new System.Drawing.Size(77, 24);
this.AppLauncherMenu.Text = "Applications";
//
// TimePanel
//
this.TimePanel.Controls.Add(this.CurrentTime);
this.TimePanel.Dock = System.Windows.Forms.DockStyle.Right;
this.TimePanel.Location = new System.Drawing.Point(693, 0);
this.TimePanel.Name = "TimePanel";
this.TimePanel.Size = new System.Drawing.Size(107, 24);
this.TimePanel.TabIndex = 3;
//
// CurrentTime
//
this.CurrentTime.AutoSize = true;
@ -73,71 +121,12 @@
this.UpdateTimer.Interval = 10;
this.UpdateTimer.Tick += new System.EventHandler(this.UpdateTimer_Tick);
//
// Workspace
//
this.Workspace.BackColor = System.Drawing.Color.Transparent;
this.Workspace.Dock = System.Windows.Forms.DockStyle.Fill;
this.Workspace.Location = new System.Drawing.Point(0, 24);
this.Workspace.Name = "Workspace";
this.Workspace.Size = new System.Drawing.Size(800, 426);
this.Workspace.TabIndex = 1;
//
// AppLauncherStrip
//
this.AppLauncherStrip.GripMargin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.AppLauncherStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AppLauncherMenu});
this.AppLauncherStrip.Location = new System.Drawing.Point(0, 0);
this.AppLauncherStrip.Name = "AppLauncherStrip";
this.AppLauncherStrip.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.AppLauncherStrip.Size = new System.Drawing.Size(88, 24);
this.AppLauncherStrip.TabIndex = 1;
this.AppLauncherStrip.Text = "menuStrip1";
//
// AppLauncherMenu
//
this.AppLauncherMenu.AutoSize = false;
this.AppLauncherMenu.Name = "AppLauncherMenu";
this.AppLauncherMenu.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.AppLauncherMenu.Size = new System.Drawing.Size(77, 24);
this.AppLauncherMenu.Text = "Applications";
//
// PanelButtonList
//
this.PanelButtonList.Dock = System.Windows.Forms.DockStyle.Fill;
this.PanelButtonList.Location = new System.Drawing.Point(88, 0);
this.PanelButtonList.Margin = new System.Windows.Forms.Padding(0);
this.PanelButtonList.Name = "PanelButtonList";
this.PanelButtonList.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
this.PanelButtonList.Size = new System.Drawing.Size(605, 24);
this.PanelButtonList.TabIndex = 2;
//
// TimePanel
//
this.TimePanel.Controls.Add(this.CurrentTime);
this.TimePanel.Dock = System.Windows.Forms.DockStyle.Right;
this.TimePanel.Location = new System.Drawing.Point(693, 0);
this.TimePanel.Name = "TimePanel";
this.TimePanel.Size = new System.Drawing.Size(107, 24);
this.TimePanel.TabIndex = 3;
//
// AppLauncherHolder
//
this.AppLauncherHolder.BackColor = System.Drawing.Color.Gray;
this.AppLauncherHolder.Controls.Add(this.AppLauncherStrip);
this.AppLauncherHolder.Dock = System.Windows.Forms.DockStyle.Left;
this.AppLauncherHolder.Location = new System.Drawing.Point(0, 0);
this.AppLauncherHolder.Name = "AppLauncherHolder";
this.AppLauncherHolder.Size = new System.Drawing.Size(88, 24);
this.AppLauncherHolder.TabIndex = 0;
//
// Desktop
//
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(800, 450);
this.Controls.Add(this.Workspace);
this.Controls.Add(this.DesktopPanel);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
@ -149,12 +138,12 @@
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Desktop_KeyDown);
this.DesktopPanel.ResumeLayout(false);
this.AppLauncherHolder.ResumeLayout(false);
this.AppLauncherHolder.PerformLayout();
this.AppLauncherStrip.ResumeLayout(false);
this.AppLauncherStrip.PerformLayout();
this.TimePanel.ResumeLayout(false);
this.TimePanel.PerformLayout();
this.AppLauncherHolder.ResumeLayout(false);
this.AppLauncherHolder.PerformLayout();
this.ResumeLayout(false);
}
@ -164,7 +153,6 @@
private System.Windows.Forms.Panel DesktopPanel;
private System.Windows.Forms.Label CurrentTime;
private System.Windows.Forms.Timer UpdateTimer;
private System.Windows.Forms.Panel Workspace;
private System.Windows.Forms.MenuStrip AppLauncherStrip;
private System.Windows.Forms.ToolStripMenuItem AppLauncherMenu;
private System.Windows.Forms.FlowLayoutPanel PanelButtonList;

View file

@ -27,6 +27,7 @@ namespace ShiftOS
this.CurrentSystem = InSystem;
InitializeComponent();
ResetAppLauncher();
this.DoubleBuffered = true;
}
private void ResetPanelButtons()
@ -34,20 +35,15 @@ namespace ShiftOS
// Clear the panel button list.
this.PanelButtonList.Controls.Clear();
// Go through every control in the workspace.
foreach(Control ctrl in Workspace.Controls)
{
// Check if it's a Window.
if(ctrl is Window)
foreach (var window in CurrentSystem.GetWindows())
{
// Create a panel button for the window.
var panelButton = new PanelButton(this, ctrl as Window);
var panelButton = new PanelButton(this, window);
// Add it to our UI.
this.PanelButtonList.Controls.Add(panelButton);
}
}
}
private void UpdateTimer_Tick(object sender, EventArgs e)
{
@ -63,6 +59,8 @@ namespace ShiftOS
// then we become transparent.
this.BackgroundImage = null;
this.BackColor = this.TransparencyKey;
}
else
{
@ -225,10 +223,10 @@ namespace ShiftOS
}
// Has the amount of children (windows) in the workspace changed?
if(_lastWorkspaceChildCount != this.Workspace.Controls.Count)
if(_lastWorkspaceChildCount != CurrentSystem.GetWindows().Count)
{
// Update it.
_lastWorkspaceChildCount = this.Workspace.Controls.Count;
_lastWorkspaceChildCount = CurrentSystem.GetWindows().Count;
// Reset panel buttons.
this.ResetPanelButtons();
@ -238,11 +236,6 @@ namespace ShiftOS
this.CurrentSystem.UpdateDesktop();
}
public Panel GetWorkspace()
{
return this.Workspace;
}
public void ResetAppLauncher()
{
// Clear out the existing app launcher items, if any.

View file

@ -120,6 +120,9 @@
<metadata name="AppLauncherStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>139, 17</value>
</metadata>
<metadata name="AppLauncherStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>139, 17</value>
</metadata>
<metadata name="UpdateTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View file

@ -42,6 +42,7 @@
this.IconBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.IconBox.TabIndex = 0;
this.IconBox.TabStop = false;
this.IconBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelButton_MouseClick);
//
// TitleText
//
@ -52,6 +53,7 @@
this.TitleText.Size = new System.Drawing.Size(89, 15);
this.TitleText.TabIndex = 1;
this.TitleText.Text = "Window Title";
this.TitleText.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelButton_MouseClick);
//
// PanelButton
//
@ -62,9 +64,10 @@
this.Controls.Add(this.IconBox);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);
this.ForeColor = System.Drawing.Color.White;
this.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "PanelButton";
this.Size = new System.Drawing.Size(204, 20);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelButton_MouseClick);
((System.ComponentModel.ISupportInitialize)(this.IconBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -82,5 +82,19 @@ namespace ShiftOS
}
private void PanelButton_MouseClick(object sender, MouseEventArgs e)
{
if(_window.Enabled == false)
{
_window.Enabled = true;
_window.Opacity = 1;
}
else
{
_window.Opacity = 0;
_window.Enabled = false;
}
}
}
}

View file

@ -16,7 +16,7 @@ namespace ShiftOS
private SkinContext _skinContext = null;
private FilesystemContext _filesystem = null;
private int _codepoints = 0;
private List<Window> _windows = new List<Window>();
private Dictionary<string, Type> _programTypeMap = new Dictionary<string, Type>();
private List<ProgramAttribute> _programMetadata = new List<ProgramAttribute>();
@ -50,18 +50,15 @@ namespace ShiftOS
// Set the system context of the window.
window.SetSystemContext(this);
// Add the window to the desktop's workspace.
var work = _desktop.GetWorkspace();
work.Controls.Add(window);
// Center the window on the workspace.
window.Left = (work.Width - window.Width) / 2;
window.Top = (work.Height - window.Height) / 2;
// Ensure the window is visible.
_windows.Add(window);
window.Show();
window.FormClosed += (o, a) =>
{
_windows.Remove(window);
Console.WriteLine(" --> Closed {0}", window.WindowTitle);
};
// Program was successfully launched.
return true;
}
@ -75,6 +72,11 @@ namespace ShiftOS
}
}
public List<Window> GetWindows()
{
return _windows;
}
public string GetProgramName(string InExecutableName)
{
// TODO: Check if the program is installed or unlocked.

View file

@ -59,7 +59,7 @@
this.TitleBarHolder.Dock = System.Windows.Forms.DockStyle.Top;
this.TitleBarHolder.Location = new System.Drawing.Point(0, 0);
this.TitleBarHolder.Name = "TitleBarHolder";
this.TitleBarHolder.Size = new System.Drawing.Size(601, 30);
this.TitleBarHolder.Size = new System.Drawing.Size(585, 30);
this.TitleBarHolder.TabIndex = 0;
this.TitleBarHolder.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown);
//
@ -72,6 +72,7 @@
this.IconBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.IconBox.TabIndex = 8;
this.IconBox.TabStop = false;
this.IconBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown);
//
// TitleText
//
@ -84,21 +85,23 @@
this.TitleText.Size = new System.Drawing.Size(100, 17);
this.TitleText.TabIndex = 5;
this.TitleText.Text = "Window Title";
this.TitleText.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown);
//
// MinimizeButton
//
this.MinimizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.MinimizeButton.BackColor = System.Drawing.Color.Black;
this.MinimizeButton.Location = new System.Drawing.Point(520, 3);
this.MinimizeButton.Location = new System.Drawing.Point(504, 3);
this.MinimizeButton.Name = "MinimizeButton";
this.MinimizeButton.Size = new System.Drawing.Size(24, 24);
this.MinimizeButton.TabIndex = 7;
this.MinimizeButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MinimizeButton_MouseClick);
//
// RollButton
//
this.RollButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.RollButton.BackColor = System.Drawing.Color.Black;
this.RollButton.Location = new System.Drawing.Point(547, 3);
this.RollButton.Location = new System.Drawing.Point(531, 3);
this.RollButton.Name = "RollButton";
this.RollButton.Size = new System.Drawing.Size(24, 24);
this.RollButton.TabIndex = 6;
@ -108,7 +111,7 @@
//
this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.CloseButton.BackColor = System.Drawing.Color.Black;
this.CloseButton.Location = new System.Drawing.Point(574, 3);
this.CloseButton.Location = new System.Drawing.Point(558, 3);
this.CloseButton.Name = "CloseButton";
this.CloseButton.Size = new System.Drawing.Size(24, 24);
this.CloseButton.TabIndex = 5;
@ -118,10 +121,11 @@
//
this.TitleBarRight.BackColor = System.Drawing.Color.Gray;
this.TitleBarRight.Dock = System.Windows.Forms.DockStyle.Right;
this.TitleBarRight.Location = new System.Drawing.Point(599, 0);
this.TitleBarRight.Location = new System.Drawing.Point(583, 0);
this.TitleBarRight.Name = "TitleBarRight";
this.TitleBarRight.Size = new System.Drawing.Size(2, 30);
this.TitleBarRight.TabIndex = 2;
this.TitleBarRight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown);
//
// TitleBarLeft
//
@ -131,6 +135,7 @@
this.TitleBarLeft.Name = "TitleBarLeft";
this.TitleBarLeft.Size = new System.Drawing.Size(2, 30);
this.TitleBarLeft.TabIndex = 1;
this.TitleBarLeft.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown);
//
// BottomBarHolder
//
@ -138,16 +143,16 @@
this.BottomBarHolder.Controls.Add(this.BottomRight);
this.BottomBarHolder.Controls.Add(this.BottomLeft);
this.BottomBarHolder.Dock = System.Windows.Forms.DockStyle.Bottom;
this.BottomBarHolder.Location = new System.Drawing.Point(0, 344);
this.BottomBarHolder.Location = new System.Drawing.Point(0, 305);
this.BottomBarHolder.Name = "BottomBarHolder";
this.BottomBarHolder.Size = new System.Drawing.Size(601, 2);
this.BottomBarHolder.Size = new System.Drawing.Size(585, 2);
this.BottomBarHolder.TabIndex = 1;
//
// BottomRight
//
this.BottomRight.BackColor = System.Drawing.Color.Gray;
this.BottomRight.Dock = System.Windows.Forms.DockStyle.Right;
this.BottomRight.Location = new System.Drawing.Point(599, 0);
this.BottomRight.Location = new System.Drawing.Point(583, 0);
this.BottomRight.Name = "BottomRight";
this.BottomRight.Size = new System.Drawing.Size(2, 2);
this.BottomRight.TabIndex = 2;
@ -165,9 +170,9 @@
//
this.RightBar.BackColor = System.Drawing.Color.Gray;
this.RightBar.Dock = System.Windows.Forms.DockStyle.Right;
this.RightBar.Location = new System.Drawing.Point(599, 30);
this.RightBar.Location = new System.Drawing.Point(583, 30);
this.RightBar.Name = "RightBar";
this.RightBar.Size = new System.Drawing.Size(2, 314);
this.RightBar.Size = new System.Drawing.Size(2, 275);
this.RightBar.TabIndex = 3;
//
// LeftBar
@ -176,7 +181,7 @@
this.LeftBar.Dock = System.Windows.Forms.DockStyle.Left;
this.LeftBar.Location = new System.Drawing.Point(0, 30);
this.LeftBar.Name = "LeftBar";
this.LeftBar.Size = new System.Drawing.Size(2, 314);
this.LeftBar.Size = new System.Drawing.Size(2, 275);
this.LeftBar.TabIndex = 4;
//
// Window
@ -185,13 +190,17 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(585, 307);
this.Controls.Add(this.LeftBar);
this.Controls.Add(this.RightBar);
this.Controls.Add(this.BottomBarHolder);
this.Controls.Add(this.TitleBarHolder);
this.ForeColor = System.Drawing.Color.Black;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Window";
this.Size = new System.Drawing.Size(601, 346);
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.TopMost = true;
this.TitleBarHolder.ResumeLayout(false);
this.TitleBarHolder.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.IconBox)).EndInit();

View file

@ -12,7 +12,7 @@ using System.Windows.Forms;
namespace ShiftOS.Windowing
{
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
public partial class Window : UserControl
public partial class Window : Form
{
private SystemContext _currentSystem = null;
private int PreRollHeight = 0;
@ -38,8 +38,6 @@ namespace ShiftOS.Windowing
private void OnDesktopUpdated(object sender, EventArgs e)
{
this.BackColor = Color.Transparent;
// Get the skin data.
var skin = this.CurrentSystem.GetSkinContext();
var skindata = skin.GetSkinData();
@ -336,17 +334,6 @@ namespace ShiftOS.Windowing
}
}
public event EventHandler WindowClosed;
protected virtual void OnClose() { }
public void Close()
{
WindowClosed?.Invoke(this, EventArgs.Empty);
OnClose();
this.Parent?.Controls.Remove(this);
}
private void CloseButton_MouseClick(object sender, MouseEventArgs e)
{
this.Close();
@ -365,5 +352,11 @@ namespace ShiftOS.Windowing
}
IsRolled = !IsRolled;
}
private void MinimizeButton_MouseClick(object sender, MouseEventArgs e)
{
this.Opacity = 0;
this.Enabled = false;
}
}
}