@@ -16,6 +16,7 @@ public class SettingsForm : Form
1616 private Settings _draftCfg ; // Draft Settings
1717 private UIController _ui ;
1818 private MainForm _mainForm ;
19+ private int _lastDpi = 96 ;
1920
2021 private FlowLayoutPanel _pnlNavContainer ;
2122 private BufferedPanel _pnlContent ; // 使用现有的 BufferedPanel
@@ -57,13 +58,17 @@ public SettingsForm(Settings cfg, UIController ui, MainForm mainForm)
5758 _draftCfg = _cfg . DeepClone ( ) ;
5859
5960 InitializeComponent ( ) ;
61+ _lastDpi = this . DeviceDpi ;
6062
6163 // ★★★ 关键点 1:构造时就初始化所有页面 ★★★
6264 InitPages ( ) ;
6365 }
6466
6567 private void InitializeComponent ( )
6668 {
69+ // SettingsForm uses manual UIUtils scaling during construction.
70+ // Disable WinForms auto-rescaling on cross-monitor DPI changes to avoid double scaling.
71+ this . AutoScaleMode = AutoScaleMode . None ;
6772 UIUtils . ScaleFactor = this . DeviceDpi / 96f ;
6873
6974 this . Size = new Size ( UIUtils . S ( 820 ) , UIUtils . S ( 680 ) ) ;
@@ -248,5 +253,41 @@ private void ApplySettings()
248253 // 将 Live 环境中由插件生成的最新监控项同步回 Draft,并保留动态显示属性
249254 SettingsChanger . RebaseDraftMonitorItems ( _cfg , _draftCfg ) ;
250255 }
256+
257+ protected override void OnDpiChanged ( DpiChangedEventArgs e )
258+ {
259+ base . OnDpiChanged ( e ) ;
260+
261+ // Settings UI uses manual sizing based on the initial DPI.
262+ // Keep fonts visually stable across monitors to avoid extra whitespace
263+ // when the form moves between 150% and 100% displays.
264+ if ( _lastDpi > 0 && e . DeviceDpiNew > 0 && _lastDpi != e . DeviceDpiNew )
265+ {
266+ float ratio = ( float ) _lastDpi / e . DeviceDpiNew ;
267+ RescaleFonts ( this , ratio ) ;
268+ foreach ( var page in _pages . Values )
269+ {
270+ if ( ! page . IsDisposed && page . Parent == null )
271+ {
272+ RescaleFonts ( page , ratio ) ;
273+ }
274+ }
275+ _lastDpi = e . DeviceDpiNew ;
276+ }
277+ }
278+
279+ private static void RescaleFonts ( Control root , float ratio )
280+ {
281+ if ( root . Font != null )
282+ {
283+ float newSize = Math . Max ( 1f , root . Font . Size * ratio ) ;
284+ root . Font = new Font ( root . Font . FontFamily , newSize , root . Font . Style ) ;
285+ }
286+
287+ foreach ( Control child in root . Controls )
288+ {
289+ RescaleFonts ( child , ratio ) ;
290+ }
291+ }
251292 }
252- }
293+ }
0 commit comments