UISymbolLabel:修复Dock和AutoSize同时设置的Bug

This commit is contained in:
Sunny 2021-12-24 11:11:37 +08:00
parent 47a4686b8e
commit 4e8772c0f6
2 changed files with 6 additions and 3 deletions

Binary file not shown.

View File

@ -17,6 +17,7 @@
* : 2020-01-01
*
* 2020-04-23: V2.2.4 UISymbolLabel
* 2021-12-24: V3.0.9 Dock和AutoSize同时设置的Bug
******************************************************************************/
using System;
@ -219,10 +220,12 @@ namespace Sunny.UI
SizeF ImageSize = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
SizeF TextSize = e.Graphics.MeasureString(Text, Font);
if (autoSize)
if (Dock == DockStyle.None && autoSize)
{
Width = (int)(SymbolSize + ImageInterval * 3 + TextSize.Width);
Height = (int)Math.Max(SymbolSize, TextSize.Height);
int width = (int)(SymbolSize + ImageInterval * 3 + TextSize.Width);
int height = (int)Math.Max(SymbolSize, TextSize.Height);
if (Width != width) Width = width;
if (Height != height) Height = height;
}
if (TextAlign == ContentAlignment.TopCenter || TextAlign == ContentAlignment.TopLeft || TextAlign == ContentAlignment.TopRight)