зеркало из https://github.com/dotnet/winforms.git
Dispose GetWindowsFont return value (#3482)
This commit is contained in:
Родитель
b22a5ace3f
Коммит
c231d486a0
|
@ -538,18 +538,16 @@ namespace System.Windows.Forms
|
|||
flags |= User32.DT.RIGHT;
|
||||
}
|
||||
|
||||
using (WindowsFont wfont = WindowsGraphicsCacheManager.GetWindowsFont(Font))
|
||||
{
|
||||
textSize = wg.MeasureText(Text, wfont, new Size(textRectangle.Width, int.MaxValue), flags);
|
||||
using WindowsFont wfont = WindowsGraphicsCacheManager.GetWindowsFont(Font);
|
||||
textSize = wg.MeasureText(Text, wfont, new Size(textRectangle.Width, int.MaxValue), flags);
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
wg.DrawText(Text, wfont, textRectangle, ForeColor, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlPaint.DrawStringDisabled(wg, Text, Font, backColor, textRectangle, ((TextFormatFlags)flags));
|
||||
}
|
||||
if (Enabled)
|
||||
{
|
||||
wg.DrawText(Text, wfont, textRectangle, ForeColor, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlPaint.DrawStringDisabled(wg, Text, Font, backColor, textRectangle, (TextFormatFlags)flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1275,13 +1275,11 @@ namespace System.Windows.Forms
|
|||
wg.TextPadding = TextPaddingOptions.LeftAndRightPadding;
|
||||
}
|
||||
|
||||
using (WindowsFont wf = WindowsGraphicsCacheManager.GetWindowsFont(Font))
|
||||
{
|
||||
User32.DRAWTEXTPARAMS dtParams = wg.GetTextMargins(wf);
|
||||
using WindowsFont wf = WindowsGraphicsCacheManager.GetWindowsFont(Font);
|
||||
User32.DRAWTEXTPARAMS dtParams = wg.GetTextMargins(wf);
|
||||
|
||||
// This is actually leading margin.
|
||||
return dtParams.iLeftMargin;
|
||||
}
|
||||
// This is actually leading margin.
|
||||
return dtParams.iLeftMargin;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -703,12 +703,10 @@ namespace System.Windows.Forms
|
|||
wg.TextPadding = TextPaddingOptions.LeftAndRightPadding;
|
||||
}
|
||||
|
||||
using (WindowsFont wf = WindowsGraphicsCacheManager.GetWindowsFont(Font))
|
||||
{
|
||||
User32.DRAWTEXTPARAMS dtParams = wg.GetTextMargins(wf);
|
||||
iLeftMargin = dtParams.iLeftMargin;
|
||||
iRightMargin = dtParams.iRightMargin;
|
||||
}
|
||||
using WindowsFont wf = WindowsGraphicsCacheManager.GetWindowsFont(Font);
|
||||
User32.DRAWTEXTPARAMS dtParams = wg.GetTextMargins(wf);
|
||||
iLeftMargin = dtParams.iLeftMargin;
|
||||
iRightMargin = dtParams.iRightMargin;
|
||||
}
|
||||
|
||||
Rectangle visualRectangle = new Rectangle(clientRectWithPadding.X + iLeftMargin,
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace System.Windows.Forms
|
|||
return Size.Empty;
|
||||
}
|
||||
|
||||
WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
using WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
return WindowsGraphicsCacheManager.MeasurementGraphics.MeasureText(text, wf);
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,8 @@ namespace System.Windows.Forms
|
|||
return Size.Empty;
|
||||
}
|
||||
|
||||
WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
return WindowsGraphicsCacheManager.MeasurementGraphics.MeasureText(text, WindowsGraphicsCacheManager.GetWindowsFont(font), proposedSize);
|
||||
using WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
return WindowsGraphicsCacheManager.MeasurementGraphics.MeasureText(text, wf, proposedSize);
|
||||
}
|
||||
|
||||
public static Size MeasureText(string? text, Font? font, Size proposedSize, TextFormatFlags flags)
|
||||
|
@ -202,7 +202,8 @@ namespace System.Windows.Forms
|
|||
{
|
||||
return Size.Empty;
|
||||
}
|
||||
WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
|
||||
using WindowsFont? wf = WindowsGraphicsCacheManager.GetWindowsFont(font);
|
||||
return WindowsGraphicsCacheManager.MeasurementGraphics.MeasureText(text, wf, proposedSize, GetTextFormatFlags(flags));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче