aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/WindowManager/ShiftWM.cs
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-11-17 20:29:46 -0700
committerAShifter <[email protected]>2017-11-17 20:29:46 -0700
commitebdc09fe679b4b06fd149c8fc6539244100ce896 (patch)
tree65dfe45bbfd194ddb534cc80107ab8e6d80cf5bc /ShiftOS.Engine/WindowManager/ShiftWM.cs
parent1d0b393e6969d9671daead8049973a374421046f (diff)
parent97722fbe9d474adffbba0b92e9727c48a8205234 (diff)
downloadshiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.tar.gz
shiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.tar.bz2
shiftos-rewind-ebdc09fe679b4b06fd149c8fc6539244100ce896.zip
Merge remote-tracking branch 'refs/remotes/ShiftOS-Rewind/master'
Diffstat (limited to 'ShiftOS.Engine/WindowManager/ShiftWM.cs')
-rw-r--r--ShiftOS.Engine/WindowManager/ShiftWM.cs219
1 files changed, 110 insertions, 109 deletions
diff --git a/ShiftOS.Engine/WindowManager/ShiftWM.cs b/ShiftOS.Engine/WindowManager/ShiftWM.cs
index 64b84f9..fa16cf9 100644
--- a/ShiftOS.Engine/WindowManager/ShiftWM.cs
+++ b/ShiftOS.Engine/WindowManager/ShiftWM.cs
@@ -1,126 +1,127 @@
-using System;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
+using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
+using ShiftOS.Engine.Misc;
+using ShiftOS.Engine.Properties;
using static ShiftOS.Engine.WindowManager.InfoboxTemplate;
namespace ShiftOS.Engine.WindowManager
{
- public static class ShiftWM
- {
- 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);
- }
-
- /// <summary>
- /// Shows a new ShiftWindow based on a UserControl.
- /// </summary>
- /// <param name="content">The UserControl to use</param>
- /// <param name="title">The program's title</param>
- /// <param name="icon">The icon to show</param>
- /// <param name="showAsInfobox">Checks if this is an infobox</param>
- /// <param name="resize">Enables or disables resizing</param>
- /// <returns></returns>
- public static ShiftWindow Init(UserControl content, string title, Icon icon, bool showAsInfobox = false, bool resize = true)
- {
- // Setup Window
- ShiftWindow app = new ShiftWindow
- {
- Text = title,
- Title = {Text = title}
- };
-
- app.Width = content.Width + app.leftSide.Width + app.rightSide.Width;
- app.Height = content.Height + app.bottomSide.Height + app.titleBar.Height;
-
- if (ShiftSkinData.titleBarColor == Color.Empty)
- {
- Color borderColor = Color.FromArgb(64, 64, 64);
- ShiftSkinData.btnCloseColor = Color.Black;
- ShiftSkinData.btnMaxColor = Color.Black;
- ShiftSkinData.btnMinColor = Color.Black;
- ShiftSkinData.leftTopCornerColor = borderColor;
- ShiftSkinData.titleBarColor = borderColor;
- ShiftSkinData.rightTopCornerColor = borderColor;
- ShiftSkinData.leftSideColor = borderColor;
- ShiftSkinData.rightSideColor = borderColor;
- ShiftSkinData.leftBottomCornerColor = borderColor;
- ShiftSkinData.bottomSideColor = borderColor;
- ShiftSkinData.rightBottomCornerColor = borderColor;
- }
-
- app.btnClose.BackColor = ShiftSkinData.btnCloseColor;
- app.btnMax.BackColor = ShiftSkinData.btnMaxColor;
- app.btnMin.BackColor = ShiftSkinData.btnMinColor;
- app.leftTopCorner.BackColor = ShiftSkinData.leftTopCornerColor;
- app.titleBar.BackColor = ShiftSkinData.titleBarColor;
- app.rightTopCorner.BackColor = ShiftSkinData.rightTopCornerColor;
- app.leftSide.BackColor = ShiftSkinData.leftSideColor;
- app.rightSide.BackColor = ShiftSkinData.rightSideColor;
- app.leftBottomCorner.BackColor = ShiftSkinData.leftBottomCornerColor;
- app.bottomSide.BackColor = ShiftSkinData.bottomSideColor;
- app.rightBottomCorner.BackColor = ShiftSkinData.rightBottomCornerColor;
-
-
- // 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.ToBitmap();
- app.Icon = icon;
- }
+ public static class ShiftWM
+ {
+ public static EventList<ShiftWindow> Windows = new EventList<ShiftWindow>();
+
+ public static ShiftWindow GetShiftWindow(this UserControl control)
+ {
+ return Windows.First(p => (uint) control.Tag == p.Id);
+ }
+
+ /// <summary>
+ /// Shows a new ShiftWindow based on a UserControl.
+ /// </summary>
+ /// <param name="content">The UserControl to use</param>
+ /// <param name="title">The program's title</param>
+ /// <param name="icon">The icon to show</param>
+ /// <param name="showAsInfobox">Checks if this is an infobox</param>
+ /// <param name="resize">Enables or disables resizing</param>
+ /// <returns></returns>
+ public static ShiftWindow Init(
+ UserControl content,
+ string title,
+ Bitmap icon,
+ bool showAsInfobox = false,
+ bool resize = true)
+ {
+ // Setup Window
+ var app = new ShiftWindow
+ {
+ Text = title,
+ Title = { Text = title }
+ };
+
+ app.Width = content.Width + app.leftSide.Width + app.rightSide.Width;
+ app.Height = content.Height + app.bottomSide.Height + app.titleBar.Height;
+
+ if (ShiftSkinData.TitleBarColor == Color.Empty)
+ {
+ var borderColor = Color.FromArgb(64, 64, 64);
+ ShiftSkinData.BtnCloseColor = Color.Black;
+ ShiftSkinData.BtnMaxColor = Color.Black;
+ ShiftSkinData.BtnMinColor = Color.Black;
+ ShiftSkinData.LeftTopCornerColor = borderColor;
+ ShiftSkinData.TitleBarColor = borderColor;
+ ShiftSkinData.RightTopCornerColor = borderColor;
+ ShiftSkinData.LeftSideColor = borderColor;
+ ShiftSkinData.RightSideColor = borderColor;
+ ShiftSkinData.LeftBottomCornerColor = borderColor;
+ ShiftSkinData.BottomSideColor = borderColor;
+ ShiftSkinData.RightBottomCornerColor = borderColor;
+ }
+
+ app.btnClose.BackColor = ShiftSkinData.BtnCloseColor;
+ app.btnMax.BackColor = ShiftSkinData.BtnMaxColor;
+ app.btnMin.BackColor = ShiftSkinData.BtnMinColor;
+ app.leftTopCorner.BackColor = ShiftSkinData.LeftTopCornerColor;
+ app.titleBar.BackColor = ShiftSkinData.TitleBarColor;
+ app.rightTopCorner.BackColor = ShiftSkinData.RightTopCornerColor;
+ app.leftSide.BackColor = ShiftSkinData.LeftSideColor;
+ app.rightSide.BackColor = ShiftSkinData.RightSideColor;
+ app.leftBottomCorner.BackColor = ShiftSkinData.LeftBottomCornerColor;
+ app.bottomSide.BackColor = ShiftSkinData.BottomSideColor;
+ app.rightBottomCorner.BackColor = ShiftSkinData.RightBottomCornerColor;
+
+
+ // Icon Setup
+ if (icon == null)
+ {
+ app.programIcon.Hide();
+ app.Title.Location = new Point(2, 7);
+ }
+
+ else
+ {
+ app.programIcon.Image = icon;
+ app.Icon = icon.ToIcon();
+ }
// Setup UC
content.Parent = app.programContent;
- content.BringToFront();
- content.Dock = DockStyle.Fill;
- app.Show();
+ content.BringToFront();
+ content.Dock = DockStyle.Fill;
+ app.Show();
- content.Tag = app.SetId();
+ content.Tag = app.SetId();
Debug.WriteLine($"usercontrol: {content.Tag} window: {app.Id}");
- app.Closed += (sender, args) =>
- {
- Windows.Remove((ShiftWindow) sender);
- };
+ app.Closed += (sender, args) => { Windows.Remove((ShiftWindow) sender); };
Windows.Add(app);
- if (content is IShiftWindowExtensions extensions)
- {
- extensions.OnLoaded(app);
- }
-
- return app;
- }
-
- /// <summary>
- /// Shows a new infobox.
- /// </summary>
- /// <param name="title">The title of the infobox.</param>
- /// <param name="body">The infobox's content.</param>
- /// <param name="type">The ButtonType used for the infobox.</param>
- /// <returns></returns>
- public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type)
- {
- InfoboxTemplate info = new InfoboxTemplate(type)
- {
- label1 = { Text = body }
- };
- Init(info, title, Properties.Resources.iconInfoBox_fw.ToIcon(), true, false);
- return info;
- }
- }
-}
+ if (content is IShiftWindowExtensions extensions)
+ {
+ extensions.OnLoaded(app);
+ }
+
+ return app;
+ }
+
+ /// <summary>
+ /// Shows a new infobox.
+ /// </summary>
+ /// <param name="title">The title of the infobox.</param>
+ /// <param name="body">The infobox's content.</param>
+ /// <param name="type">The ButtonType used for the infobox.</param>
+ /// <returns></returns>
+ public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type)
+ {
+ var info = new InfoboxTemplate(type)
+ {
+ label1 = { Text = body }
+ };
+ Init(info, title, Resources.iconInfoBox_fw, true, false);
+ return info;
+ }
+ }
+} \ No newline at end of file