diff --git a/SunnyUI/Controls/UINavBar.cs b/SunnyUI/Controls/UINavBar.cs index 6aa265da..254772a9 100644 --- a/SunnyUI/Controls/UINavBar.cs +++ b/SunnyUI/Controls/UINavBar.cs @@ -642,7 +642,7 @@ namespace Sunny.UI NavBarMenu.Style = UIStyles.Style; NavBarMenu.Items.Clear(); NavBarMenu.ImageList = ImageList; - NavBarMenu.Font = DropMenuFont.SetDPIScaleFont(DropMenuFont.Size); + NavBarMenu.Font = DropMenuFont; foreach (TreeNode node in Nodes[SelectedIndex].Nodes) { ToolStripMenuItem item = new ToolStripMenuItem(node.Text) { Tag = node }; diff --git a/SunnyUI/Forms/UINotifier.cs b/SunnyUI/Forms/UINotifier.cs index 1a74e3a6..74b4d3e0 100644 --- a/SunnyUI/Forms/UINotifier.cs +++ b/SunnyUI/Forms/UINotifier.cs @@ -35,8 +35,6 @@ using System.Linq; using System.Threading; using System.Windows.Forms; -#pragma warning disable 1591 - namespace Sunny.UI { public sealed partial class UINotifier : Form @@ -108,7 +106,7 @@ namespace Sunny.UI InApplication = insideMe; InitializeComponent(); - if (Notes.Count == 0) + if (Notes.IsEmpty) ID = 1; else ID = (short)(Notes.Keys.Max() + 1); // Set the Note ID diff --git a/SunnyUI/Style/UIDPIScale.cs b/SunnyUI/Style/UIDPIScale.cs index 40d7060f..387c5998 100644 --- a/SunnyUI/Style/UIDPIScale.cs +++ b/SunnyUI/Style/UIDPIScale.cs @@ -29,22 +29,24 @@ namespace Sunny.UI { private static float dpiScale = -1; - public static float DPIScale() + public static float DPIScale() => UIStyles.GlobalFont ? SystemDPIScale * 100.0f / UIStyles.GlobalFontScale : SystemDPIScale; + + private static float SystemDPIScale { - if (dpiScale < 0) + get { - using Bitmap bmp = new Bitmap(1, 1); - using Graphics g = bmp.Graphics(); - dpiScale = g.DpiX / 96.0f; + if (dpiScale < 0) + { + using Bitmap bmp = new Bitmap(1, 1); + using Graphics g = bmp.Graphics(); + dpiScale = g.DpiX / 96.0f; + } + + return dpiScale; } - - return UIStyles.GlobalFont ? dpiScale * 100.0f / UIStyles.GlobalFontScale : dpiScale; } - public static bool NeedSetDPIFont() - { - return UIStyles.DPIScale && (DPIScale() > 1 || UIStyles.GlobalFont); - } + public static bool NeedSetDPIFont() => UIStyles.DPIScale && (SystemDPIScale > 1 || UIStyles.GlobalFont); internal static Font DPIScaleFont(this Font font, float fontSize) { @@ -78,21 +80,22 @@ namespace Sunny.UI internal static List GetAllDPIScaleControls(this Control control) { var list = new List(); - foreach (Control con in control.Controls) + foreach (Control ctrl in control.Controls) { - if (con is IStyleInterface ctrl) list.Add(ctrl); + if (ctrl is IStyleInterface istyleCtrl) list.Add(istyleCtrl); - if (con is UITextBox) continue; - if (con is UIDropControl) continue; - if (con is UIListBox) continue; - if (con is UIImageListBox) continue; - if (con is UIPagination) continue; - if (con is UIRichTextBox) continue; - if (con is UITreeView) continue; + if (ctrl is UITextBox) continue; + if (ctrl is UIDropControl) continue; + if (ctrl is UIListBox) continue; + if (ctrl is UIImageListBox) continue; + if (ctrl is UIPagination) continue; + if (ctrl is UIRichTextBox) continue; + if (ctrl is UITreeView) continue; + if (ctrl is UITransfer) continue; - if (con.Controls.Count > 0) + if (ctrl.Controls.Count > 0) { - list.AddRange(GetAllDPIScaleControls(con)); + list.AddRange(GetAllDPIScaleControls(ctrl)); } }