重构GDI一些方法

This commit is contained in:
Sunny 2023-10-30 13:52:56 +08:00
parent 54940a41db
commit 922c52914c
2 changed files with 4 additions and 4 deletions

View File

@ -243,7 +243,7 @@ namespace Sunny.UI
Gr.DrawLine(pen, ptStart, ptEnd);
//Draw Strings
Font font = new Font(this.AnalogMeter.Font.FontFamily, (float)(6F * drawRatio));
using Font font = new Font(this.AnalogMeter.Font.FontFamily, (float)(6F * drawRatio));
float tx = (float)(cx + (radius - (20 * drawRatio)) * Math.Cos(currentAngle));
float ty = (float)(cy + (radius - (20 * drawRatio)) * Math.Sin(currentAngle));

View File

@ -560,6 +560,7 @@ namespace Sunny.UI
brushKnobPointer.Dispose();
gOffScreen?.Dispose();
OffScreenImage?.Dispose();
_scaleFont?.Dispose();
}
public UIKnob()
@ -1057,8 +1058,6 @@ namespace Sunny.UI
/// </summary>
private void SetDimensions()
{
Font font;
// Rectangle
float x, y, w, h;
x = 0;
@ -1082,7 +1081,7 @@ namespace Sunny.UI
String str = String.Format("{0,0:D}", (int)val);
float fSize = _scaleFont.Size;
Font font;
if (_scaleFontAutoSize)
{
fSize = (float)(6F * drawRatio);
@ -1097,6 +1096,7 @@ namespace Sunny.UI
}
SizeF strsize = TextRenderer.MeasureText(str, font);
font.Dispose();
// Graduations outside
gradLength = 4 * drawRatio;