* 修复了一个DPI可能的出错
This commit is contained in:
parent
599acadacd
commit
278fbca08d
Binary file not shown.
@ -146,7 +146,7 @@ namespace Sunny.UI
|
||||
/// 提供一个Graphics,常用于需要计算文字大小时
|
||||
/// </summary>
|
||||
/// <returns>大小</returns>
|
||||
private static Graphics Graphics()
|
||||
public static Graphics Graphics()
|
||||
{
|
||||
if (TempGraphics == null)
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user