diff options
| author | John T <[email protected]> | 2017-11-05 18:47:46 -0500 |
|---|---|---|
| committer | John T <[email protected]> | 2017-11-05 18:47:46 -0500 |
| commit | a10440a45c40652b13e883aec832a0c8ded685e8 (patch) | |
| tree | ab64311e47f8e59c7c46cd50c94bec424165ecc2 /ShiftOS.Engine/WindowManager/ShiftWM.cs | |
| parent | 019da5b9ebf67b758a31dd05c4b17de66fa682f2 (diff) | |
| download | shiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.tar.gz shiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.tar.bz2 shiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.zip | |
Added a half-complete ShiftFS and did some code cleanup
Diffstat (limited to 'ShiftOS.Engine/WindowManager/ShiftWM.cs')
| -rw-r--r-- | ShiftOS.Engine/WindowManager/ShiftWM.cs | 215 |
1 files changed, 109 insertions, 106 deletions
diff --git a/ShiftOS.Engine/WindowManager/ShiftWM.cs b/ShiftOS.Engine/WindowManager/ShiftWM.cs index 64b84f9..b6079bd 100644 --- a/ShiftOS.Engine/WindowManager/ShiftWM.cs +++ b/ShiftOS.Engine/WindowManager/ShiftWM.cs @@ -1,126 +1,129 @@ -using System; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; 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 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 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 + 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.programIcon.Image = 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.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.ToIcon(), true, false); + return info; + } + } +}
\ No newline at end of file |
