* 修复了一个DPI可能的出错

This commit is contained in:
Sunny 2022-01-07 11:35:25 +08:00
parent 599acadacd
commit 278fbca08d
3 changed files with 12 additions and 2 deletions

Binary file not shown.

View File

@ -146,7 +146,7 @@ namespace Sunny.UI
/// 提供一个Graphics常用于需要计算文字大小时
/// </summary>
/// <returns>大小</returns>
private static Graphics Graphics()
public static Graphics Graphics()
{
if (TempGraphics == null)
{

View File

@ -29,7 +29,17 @@ namespace Sunny.UI
{
public static float DPIScale(this Control control)
{
return control.CreateGraphics().DpiX / 96.0f;
try
{
if (control != null)
return control.CreateGraphics().DpiX / 96.0f;
else
return GDI.Graphics().DpiX / 96.0f;
}
catch
{
return 1;
}
}
public static float DPIScaleFontSize(this Control control, Font font)