* UFontImage: 修复了一个窗体属性编辑器图标显示不全的问题
This commit is contained in:
parent
2057e10406
commit
869d80e936
@ -181,23 +181,6 @@ namespace Sunny.UI
|
||||
return region;
|
||||
}
|
||||
|
||||
private static Graphics TempGraphics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供一个Graphics,常用于需要计算文字大小时
|
||||
/// </summary>
|
||||
/// <returns>大小</returns>
|
||||
internal static Graphics Graphics()
|
||||
{
|
||||
if (TempGraphics == null)
|
||||
{
|
||||
Bitmap bmp = new Bitmap(1, 1);
|
||||
TempGraphics = bmp.Graphics();
|
||||
}
|
||||
|
||||
return TempGraphics;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取起始颜色到终止颜色之间的渐变颜色
|
||||
/// </summary>
|
||||
|
@ -22,6 +22,7 @@
|
||||
* 2021-06-15: V3.0.4 增加FontAwesomeV5的字体图标,重构代码
|
||||
* 2021-06-15: V3.3.5 增加FontAwesomeV6的字体图标,重构代码
|
||||
* 2022-05-16: V3.3.6 重构DrawFontImage函数
|
||||
* 2022-05-17: V3.3.7 修复了一个窗体属性编辑器图标显示不全的问题
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -162,7 +163,10 @@ namespace Sunny.UI
|
||||
{
|
||||
//字体
|
||||
Font font = GetFont(symbol, symbolSize);
|
||||
if (font == null) return;
|
||||
if (font == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var symbolValue = GetSymbolValue(symbol);
|
||||
string text = char.ConvertFromUtf32(symbolValue);
|
||||
@ -317,7 +321,9 @@ namespace Sunny.UI
|
||||
/// <returns>字体大小</returns>
|
||||
public int GetFontSize(int symbol, int imageSize)
|
||||
{
|
||||
return BinarySearch(GDI.Graphics(), MinFontSize, MaxFontSize, symbol, imageSize);
|
||||
using Bitmap bitmap = new Bitmap(48, 48);
|
||||
using Graphics graphics = Graphics.FromImage(bitmap);
|
||||
return BinarySearch(graphics, MinFontSize, MaxFontSize, symbol, imageSize);
|
||||
}
|
||||
|
||||
public int BinarySearch(Graphics graphics, int low, int high, int symbol, int imageSize)
|
||||
|
@ -27,9 +27,19 @@ namespace Sunny.UI
|
||||
{
|
||||
public static class UIDPIScale
|
||||
{
|
||||
private static float dpiScale = -1;
|
||||
|
||||
public static float DPIScale()
|
||||
{
|
||||
return GDI.Graphics().DpiX / 96.0f / (UIStyles.FontSize / 12.0f);
|
||||
if (dpiScale > 0)
|
||||
{
|
||||
return dpiScale;
|
||||
}
|
||||
|
||||
using Bitmap bmp = new Bitmap(1, 1);
|
||||
using Graphics g = bmp.Graphics();
|
||||
dpiScale = g.DpiX / 96.0f / (UIStyles.FontSize / 12.0f);
|
||||
return dpiScale;
|
||||
}
|
||||
|
||||
public static bool DPIScaleIsOne()
|
||||
|
Loading…
x
Reference in New Issue
Block a user