From 4e9b4ead03fad469b1870452472280ce8f532112 Mon Sep 17 00:00:00 2001 From: Barrett Lewis Date: Mon, 14 Sep 2015 18:29:52 -0500 Subject: [PATCH 1/2] Add 'Pinnable' property to MetroForm --- MetroFramework/Forms/MetroForm.cs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/MetroFramework/Forms/MetroForm.cs b/MetroFramework/Forms/MetroForm.cs index 49706f57..3f686b5f 100644 --- a/MetroFramework/Forms/MetroForm.cs +++ b/MetroFramework/Forms/MetroForm.cs @@ -114,6 +114,9 @@ public MetroStyleManager StyleManager set { metroStyleManager = value; } } + [Category(MetroDefaults.PropertyCategory.Appearance)] + public bool Pinnable { get; set; } + #endregion #region Fields @@ -499,6 +502,9 @@ protected override void OnLoad(EventArgs e) if (MinimizeBox) AddWindowButton(WindowButtons.Minimize); + if (Pinnable) + AddWindowButton(WindowButtons.Pin); + UpdateWindowButtonPosition(); } @@ -685,7 +691,8 @@ private enum WindowButtons { Minimize, Maximize, - Close + Close, + Pin } private Dictionary windowButtonList; @@ -715,6 +722,10 @@ private void AddWindowButton(WindowButtons button) else newButton.Text = "2"; } + else if (button == WindowButtons.Pin) + { + newButton.Text = TopMost ? "=" : "ë"; + } newButton.Style = Style; newButton.Theme = Theme; @@ -755,6 +766,11 @@ private void WindowButton_Click(object sender, EventArgs e) btn.Text = "1"; } } + else if (btnFlag == WindowButtons.Pin) + { + TopMost = !TopMost; + btn.Text = TopMost ? "=" : "ë"; + } } } @@ -762,7 +778,13 @@ private void UpdateWindowButtonPosition() { if (!ControlBox) return; - Dictionary priorityOrder = new Dictionary(3) { { 0, WindowButtons.Close }, { 1, WindowButtons.Maximize }, { 2, WindowButtons.Minimize } }; + Dictionary priorityOrder = new Dictionary(4) + { + { 0, WindowButtons.Close }, + { 1, WindowButtons.Maximize }, + { 2, WindowButtons.Minimize }, + { 3, WindowButtons.Pin} + }; Point firstButtonLocation = new Point(ClientRectangle.Width - borderWidth - 25, borderWidth); int lastDrawedButtonPosition = firstButtonLocation.X - 25; @@ -793,6 +815,9 @@ private void UpdateWindowButtonPosition() windowButtonList[button.Value].Location = new Point(lastDrawedButtonPosition, borderWidth); lastDrawedButtonPosition = lastDrawedButtonPosition - 25; + + // leave an extra space between icons from index 0-2 and 3+ + if (button.Key == 2) lastDrawedButtonPosition = lastDrawedButtonPosition - 10; } } From 1cb7708f8849d0b1e1d0a4599bc52abaee63500b Mon Sep 17 00:00:00 2001 From: Barrett Lewis Date: Thu, 2 Nov 2017 12:54:01 -0500 Subject: [PATCH 2/2] Add italic option to label fonts --- MetroFramework/MetroFonts.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MetroFramework/MetroFonts.cs b/MetroFramework/MetroFonts.cs index ab1fa3a0..815a4874 100644 --- a/MetroFramework/MetroFonts.cs +++ b/MetroFramework/MetroFonts.cs @@ -42,7 +42,8 @@ public enum MetroLabelWeight { Light, Regular, - Bold + Bold, + Italic } public enum MetroWaterMarkWeight @@ -401,6 +402,8 @@ public static Font Label(MetroLabelSize labelSize, MetroLabelWeight labelWeight) return Default(12f); if (labelWeight == MetroLabelWeight.Bold) return DefaultBold(12f); + if (labelWeight == MetroLabelWeight.Italic) + return DefaultItalic(12f); } else if (labelSize == MetroLabelSize.Medium) { @@ -410,6 +413,8 @@ public static Font Label(MetroLabelSize labelSize, MetroLabelWeight labelWeight) return Default(14f); if (labelWeight == MetroLabelWeight.Bold) return DefaultBold(14f); + if (labelWeight == MetroLabelWeight.Italic) + return DefaultItalic(14f); } else if (labelSize == MetroLabelSize.Tall) { @@ -419,6 +424,8 @@ public static Font Label(MetroLabelSize labelSize, MetroLabelWeight labelWeight) return Default(18f); if (labelWeight == MetroLabelWeight.Bold) return DefaultBold(18f); + if (labelWeight == MetroLabelWeight.Italic) + return DefaultItalic(18f); } return DefaultLight(14f);