diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 8b03be1..8137816 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -43,12 +43,16 @@ namespace ShiftOS.WinForms.Applications InitializeComponent(); } + public string Title { get; private set; } + public void OnLoad() { + AppearanceManager.SetWindowTitle(this, this.Title); } public void OnSkinLoad() { + AppearanceManager.SetWindowTitle(this, this.Title); } public bool OnUnload() @@ -63,7 +67,7 @@ namespace ShiftOS.WinForms.Applications internal void OpenInternal(string title, string msg) { AppearanceManager.SetupWindow(this); - this.Parent.Text = title; + Title = title; lbmessage.Text = msg; txtinput.Hide(); flyesno.Hide(); @@ -83,7 +87,7 @@ namespace ShiftOS.WinForms.Applications public void PromptTextInternal(string title, string message, Action callback) { AppearanceManager.SetupWindow(this); - this.Parent.Text = title; + Title = title; lbmessage.Text = message; txtinput.Show(); flyesno.Hide(); @@ -119,7 +123,7 @@ namespace ShiftOS.WinForms.Applications public void PromptYesNoInternal(string title, string message, Action callback) { AppearanceManager.SetupWindow(this); - this.Parent.Text = title; + Title = title; lbmessage.Text = message; txtinput.Hide(); flyesno.Show(); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 1aff2db..cf637f4 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -201,6 +201,12 @@ Description: "Use a fully customizable desktop in place of the terminal to control ShiftOS.", Dependencies: "window_manager" }, + { + Name: "App Icons", + Cost: 100, + Description: "So you have a titlebar, well, let's add an icon to it to hopefully make it easier to tell which app is which.", + Dependencies: "wm_titlebar;skinning" + }, { Name: "Close command", Cost: 150, diff --git a/ShiftOS.WinForms/WindowBorder.Designer.cs b/ShiftOS.WinForms/WindowBorder.Designer.cs index 1696fe5..f12f803 100644 --- a/ShiftOS.WinForms/WindowBorder.Designer.cs +++ b/ShiftOS.WinForms/WindowBorder.Designer.cs @@ -56,11 +56,11 @@ namespace ShiftOS.WinForms private void InitializeComponent() { this.pnltitle = new System.Windows.Forms.Panel(); - this.pnltitleleft = new System.Windows.Forms.Panel(); - this.pnltitleright = 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(); @@ -68,6 +68,7 @@ namespace ShiftOS.WinForms this.pnlleft = new System.Windows.Forms.Panel(); this.pnlright = new System.Windows.Forms.Panel(); this.pnlcontents = new System.Windows.Forms.Panel(); + this.pnlicon = new System.Windows.Forms.Panel(); this.pnltitle.SuspendLayout(); this.pnlbottom.SuspendLayout(); this.SuspendLayout(); @@ -75,6 +76,7 @@ namespace ShiftOS.WinForms // 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); @@ -89,22 +91,6 @@ namespace ShiftOS.WinForms this.pnltitle.Paint += new System.Windows.Forms.PaintEventHandler(this.pnltitle_Paint); this.pnltitle.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnltitle_MouseMove); // - // 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(728, 0); - this.pnltitleright.Name = "pnltitleright"; - this.pnltitleright.Size = new System.Drawing.Size(2, 30); - this.pnltitleright.TabIndex = 5; - // // pnlminimize // this.pnlminimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -135,6 +121,22 @@ namespace ShiftOS.WinForms this.pnlclose.TabIndex = 1; this.pnlclose.Click += new System.EventHandler(this.pnlclose_Click); // + // 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(728, 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) @@ -144,7 +146,7 @@ namespace ShiftOS.WinForms 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(4, 0); + 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; @@ -209,6 +211,13 @@ namespace ShiftOS.WinForms this.pnlcontents.Size = new System.Drawing.Size(730, 463); this.pnlcontents.TabIndex = 4; // + // 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; + // // WindowBorder // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -243,5 +252,6 @@ namespace ShiftOS.WinForms private System.Windows.Forms.Panel pnlcontents; private System.Windows.Forms.Panel pnltitleright; private System.Windows.Forms.Panel pnltitleleft; + private System.Windows.Forms.Panel pnlicon; } } diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 46dd76a..6e5d271 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -87,6 +87,11 @@ namespace ShiftOS.WinForms } } + internal void SetTitle(string title) + { + lbtitletext.Text = title; + } + /// /// Initializes a new instance of the class. /// @@ -305,13 +310,27 @@ namespace ShiftOS.WinForms switch (LoadedSkin.TitleTextCentered) { case false: - lbtitletext.Location = LoadedSkin.TitleTextLeft; + 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.BackgroundImage = GetIcon(this.ParentWindow.GetType().Name); + pnlicon.BackgroundImageLayout = ImageLayout.Stretch; + pnlicon.Location = LoadedSkin.TitlebarIconFromSide; + } + else + { + pnlicon.Hide(); + } } /// diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index a8fb7c5..b8f0cae 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -77,6 +77,12 @@ namespace ShiftOS.WinForms catch { } } + public override void SetTitle(IShiftOSWindow win, string title) + { + var wb = (win as UserControl).ParentForm as WindowBorder; + wb.SetTitle(title); + } + public override void SetupDialog(IShiftOSWindow form) { if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 112bca5..dc88092 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -76,6 +76,11 @@ namespace ShiftOS.Engine } } + public static void SetWindowTitle(IShiftOSWindow window, string title) + { + winmgr.SetTitle(window, title); + } + public static IEnumerable GetAllWindowTypes() { List types = new List(); @@ -231,6 +236,8 @@ namespace ShiftOS.Engine public abstract void SetupDialog(IShiftOSWindow win); public abstract void InvokeAction(Action act); + + public abstract void SetTitle(IShiftOSWindow win, string title); } public interface IWindowBorder diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 3b618c1..d155688 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -112,6 +112,23 @@ namespace ShiftOS.Engine { public static void SaveSkin() { Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin, Formatting.Indented)); } + + public static Image GetIcon(string id) + { + if (!LoadedSkin.AppIcons.ContainsKey(id)) + LoadedSkin.AppIcons.Add(id, null); + + if (LoadedSkin.AppIcons[id] == null) + return new Bitmap(16, 16); + else + { + using (var sr = new MemoryStream(LoadedSkin.AppIcons[id])) + { + return Image.FromStream(sr); + } + } + + } } public class Skin { @@ -138,7 +155,11 @@ namespace ShiftOS.Engine { } [ShifterHidden] - public Dictionary AppNames = new Dictionary(); + public Dictionary AppNames = new Dictionary(); + + [ShifterHidden] + public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("Windows")] [ShifterCategory("Titlebar")] @@ -914,6 +935,13 @@ namespace ShiftOS.Engine { //we DO NOT want this showing in the shifter. [ShifterHidden] public Dictionary SkinImageLayouts = new Dictionary(); + + [ShifterMeta("Windows")] + [ShifterCategory("Titlebar")] + [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 class ShifterHiddenAttribute : Attribute {