支持DPI和默认字体更改 [英] Supporting DPI and Default Font Changes
问题描述
所以我想弄清楚如何窗体的AutoScaleMode财产都不可能帮助,支持与字体或 DPI 系统一>这是我的工作,开发机器不同。
从SDK:
AutoScaleMode枚举
公开枚举AutoScaleMode
无 自动缩放被禁用。 字形 控制比例相对的尺寸 类是使用,它通常是字体 系统字体。 DPI 控制比例相对于显示器的分辨率。 常见的分辨率为96和120 DPI。
在默认情况下.NET 2.0形式使用AutoScaleMode.Font。
所以,我在我的Windows XP,宋体8点,96 DPI开发机设计一个样表。然后,我尝试过了一个
- 在14点的Segoe UI 96 DPI机
- 在14点的Segoe UI 150 DPI机
结果并不令人感到鼓舞,因为你可以在这个截图所示:
在AutoScaleMode属性未旨在实现NET的形式支持不同的字体或DPI设置。那么,什么是的正确方法,以支持不同的字体和DPI设置?
正确的方法是缩放控制,表单本身中的文本。这听起来很复杂,但布局控件(TableLayoutPanel中和FlowLayoutPanel的),结合AutoSize属性,使这个相当少的困难。
So I'm trying to figure out how the Form's AutoScaleMode property can possibly help to support a system with a font or DPI that is different from my work development machine.
From the SDK:
AutoScaleMode Enumeration
public enum AutoScaleMode
None Automatic scaling is disabled. Font Controls scale relative to the dimensions of the font the classes are using, which is typically the system font. Dpi Controls scale relative to the display resolution. Common resolutions are 96 and 120 DPI.
By default .NET 2.0 Forms use AutoScaleMode.Font.
So I designed a sample form on my Windows XP, Tahoma 8 pt, 96 DPI development machine. Then I tried it out on a
- 14 pt Segoe UI 96 DPI machine
- 14 pt Segoe UI 150 DPI machine
The results were not encouraging, as you can see in this screenshot:
The AutoScaleMode property was not designed to enable a .NET Form for support of different font or DPI settings. So what is the proper way to support different font and DPI settings?
The correct way is to scale the controls, the form itself and the text within. This sounds very complicated, but the layout controls (TableLayoutPanel and FlowLayoutPanel), combined with the AutoSize property, make this considerably less difficult.
这篇关于支持DPI和默认字体更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!