diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index d27a3c40..d0101205 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 3da1ccdf..4a64a965 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/SunnyUI/Common/UControl.cs b/SunnyUI/Common/UControl.cs index df0d747f..539be8f9 100644 --- a/SunnyUI/Common/UControl.cs +++ b/SunnyUI/Common/UControl.cs @@ -329,6 +329,12 @@ namespace Sunny.UI control.Font.Style, control.Font.Unit, control.Font.GdiCharSet); } + public static Font DPIScaleFont(this Control control, Font font) + { + return new Font(font.FontFamily, font.Size / control.DPIScale(), + font.Style, font.Unit, font.GdiCharSet); + } + public static void SetDPIScaleFont(this Control control) { if (!control.DPIScale().Equals(1)) @@ -490,7 +496,6 @@ namespace Sunny.UI private static bool GetChildNodeCheckedState(TreeNode node) { - if (node.Nodes.Count > 0) { var count = node.Nodes.Cast().Where(n => n.Checked).ToList().Count; @@ -505,8 +510,6 @@ namespace Sunny.UI return GetChildNodeCheckedState(nd); } } - - } return false; } diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index 2df6ee30..02eb5366 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -79,6 +79,12 @@ namespace Sunny.UI if (!IsScaled && UIStyles.DPIScale) { this.SetDPIScaleFont(); + + if (!this.DPIScale().Equals(1)) + { + this.TitleFont = this.DPIScaleFont(this.TitleFont); + } + foreach (Control control in this.GetAllDPIScaleControls()) { control.SetDPIScaleFont(); @@ -444,7 +450,6 @@ namespace Sunny.UI } } - private Rectangle ControlBoxRect; private Rectangle MaximizeBoxRect; @@ -1509,12 +1514,14 @@ namespace Sunny.UI case Win32.User.WM_ERASEBKGND: m.Result = IntPtr.Zero; break; + case Win32.User.WM_HOTKEY: int hotKeyId = (int)(m.WParam); if (hotKeys.ContainsKey(hotKeyId)) - HotKeyEventHandler?.Invoke(this, new HotKeyEventArgs(hotKeys[hotKeyId], DateTime.Now)); - + HotKeyEventHandler?.Invoke(this, new HotKeyEventArgs(hotKeys[hotKeyId], DateTime.Now)); + break; + default: base.WndProc(ref m); break; @@ -1522,7 +1529,7 @@ namespace Sunny.UI if (m.Msg == Win32.User.WM_NCHITTEST && ShowDragStretch && WindowState == FormWindowState.Normal) { - //Point vPoint = new Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF); + //Point vPoint = new Point((int)m.LParam & 0xFFFF, (int)m.LParam >> 16 & 0xFFFF); Point vPoint = new Point(MousePosition.X, MousePosition.Y);//修正有分屏后,调整窗体大小时鼠标显示左右箭头问题 vPoint = PointToClient(vPoint); int dragSize = 5; @@ -1842,7 +1849,7 @@ namespace Sunny.UI UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout); } - #endregion + #endregion 一些辅助窗口 #region IFrame实现 @@ -1889,7 +1896,6 @@ namespace Sunny.UI public virtual void Feedback(object sender, int pageIndex, params object[] objects) { - } #endregion IFrame实现 diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index 4e535062..7e009d8e 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -30,6 +30,7 @@ using System.Diagnostics; using System.Drawing; using System.Drawing.Design; using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace Sunny.UI { @@ -76,6 +77,11 @@ namespace Sunny.UI if (!IsScaled) { this.SetDPIScaleFont(); + if (!this.DPIScale().Equals(1)) + { + this.TitleFont = this.DPIScaleFont(this.TitleFont); + } + foreach (Control control in this.GetAllDPIScaleControls()) { control.SetDPIScaleFont(); @@ -145,7 +151,6 @@ namespace Sunny.UI protected virtual void SymbolChange() { - } [Browsable(false)] @@ -239,6 +244,7 @@ namespace Sunny.UI } public event EventHandler Initialize; + public event EventHandler Finalize; protected override void OnControlAdded(ControlEventArgs e) @@ -533,7 +539,6 @@ namespace Sunny.UI InControlBox = inControlBox; Invalidate(); } - } } @@ -574,7 +579,6 @@ namespace Sunny.UI } } - protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); @@ -584,12 +588,10 @@ namespace Sunny.UI private void CalcSystemBoxPos() { ControlBoxRect = new Rectangle(Width - 6 - 28, titleHeight / 2 - 14, 28, 28); - } private Rectangle ControlBoxRect; - /// /// 是否显示窗体的控制按钮 /// @@ -894,6 +896,6 @@ namespace Sunny.UI UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout); } - #endregion + #endregion 一些辅助窗口 } } \ No newline at end of file