* UILedLabel: 重构显示位置,并增加Padding属性关联显示
This commit is contained in:
parent
b9c87e15e8
commit
7fd73a8808
@ -18,6 +18,7 @@
|
|||||||
*
|
*
|
||||||
* 2021-04-11: V3.0.2 增加文件说明
|
* 2021-04-11: V3.0.2 增加文件说明
|
||||||
* 2022-03-19: V3.1.1 重构主题配色
|
* 2022-03-19: V3.1.1 重构主题配色
|
||||||
|
* 2025-03-31: V3.8.2 重构显示位置,并增加Padding属性关联显示
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -48,8 +49,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
|
|
||||||
int width = CharCount * IntervalOn * 5 +
|
int width = (IntervalOn + IntervalIn) * 6 * CharCount;
|
||||||
CharCount * IntervalIn * 4 + (CharCount + 1) * IntervalOn + CharCount * IntervalIn;
|
|
||||||
int height = IntervalOn * 7 + IntervalIn * 6;
|
int height = IntervalOn * 7 + IntervalIn * 6;
|
||||||
|
|
||||||
float left = 0;
|
float left = 0;
|
||||||
@ -57,22 +57,22 @@ namespace Sunny.UI
|
|||||||
switch (TextAlign)
|
switch (TextAlign)
|
||||||
{
|
{
|
||||||
case ContentAlignment.TopLeft:
|
case ContentAlignment.TopLeft:
|
||||||
left = 0;
|
left = IntervalOn + IntervalIn + Padding.Left;
|
||||||
top = 0;
|
top = IntervalOn + IntervalIn + Padding.Top;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.TopCenter:
|
case ContentAlignment.TopCenter:
|
||||||
left = (Width - width) / 2.0f;
|
left = (Width - width) / 2.0f;
|
||||||
top = 0;
|
top = IntervalOn + IntervalIn + Padding.Top;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.TopRight:
|
case ContentAlignment.TopRight:
|
||||||
left = Width - width;
|
left = Width - width - Padding.Right;
|
||||||
top = 0;
|
top = IntervalOn + IntervalIn + Padding.Top;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.MiddleLeft:
|
case ContentAlignment.MiddleLeft:
|
||||||
left = 0;
|
left = IntervalOn + IntervalIn + Padding.Left;
|
||||||
top = (Height - height) / 2.0f;
|
top = (Height - height) / 2.0f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -82,23 +82,23 @@ namespace Sunny.UI
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.MiddleRight:
|
case ContentAlignment.MiddleRight:
|
||||||
left = Width - width;
|
left = Width - width - Padding.Right;
|
||||||
top = (Height - height) / 2.0f;
|
top = (Height - height) / 2.0f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.BottomLeft:
|
case ContentAlignment.BottomLeft:
|
||||||
left = 0;
|
left = IntervalOn + IntervalIn + Padding.Left;
|
||||||
top = Height - height;
|
top = Height - height - (IntervalOn + IntervalIn) - Padding.Bottom;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.BottomCenter:
|
case ContentAlignment.BottomCenter:
|
||||||
left = (Width - width) / 2.0f;
|
left = (Width - width) / 2.0f;
|
||||||
top = Height - height;
|
top = Height - height - (IntervalOn + IntervalIn) - Padding.Bottom;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentAlignment.BottomRight:
|
case ContentAlignment.BottomRight:
|
||||||
left = Width - width;
|
left = Width - width - Padding.Right;
|
||||||
top = Height - height;
|
top = Height - height - (IntervalOn + IntervalIn) - Padding.Bottom;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,8 @@ namespace Sunny.UI
|
|||||||
foreach (char c in Text)
|
foreach (char c in Text)
|
||||||
{
|
{
|
||||||
float charStart = left + (IntervalOn + IntervalIn) * 6 * idx;
|
float charStart = left + (IntervalOn + IntervalIn) * 6 * idx;
|
||||||
byte[] bts = UILedChars.Chars.ContainsKey(c) ? UILedChars.Chars[c] : UILedChars.Chars[' '];
|
byte[] bts = UILedChars.Chars[' '];
|
||||||
|
if (UILedChars.Chars.TryGetValue(c, out var bytes)) bts = bytes;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
byte bt = bts[i];
|
byte bt = bts[i];
|
||||||
@ -117,12 +118,7 @@ namespace Sunny.UI
|
|||||||
bool bon = array[7 - j];
|
bool bon = array[7 - j];
|
||||||
if (bon)
|
if (bon)
|
||||||
{
|
{
|
||||||
e.Graphics.FillRectangle(
|
e.Graphics.FillRectangle(ForeColor, btStart, top + (IntervalOn + IntervalIn) * j, IntervalOn, IntervalOn);
|
||||||
ForeColor,
|
|
||||||
btStart,
|
|
||||||
top + (IntervalOn + IntervalIn) * j,
|
|
||||||
IntervalOn,
|
|
||||||
IntervalOn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user