зеркало из https://github.com/DeGsoft/maui-linux.git
Implement CharacterSpacing property in WinUI LabelHandler
This commit is contained in:
Родитель
fc90bf6c40
Коммит
8d93d937de
|
@ -94,7 +94,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
[PortHandler]
|
||||
internal static int ToEm(this double pt)
|
||||
{
|
||||
return Convert.ToInt32( pt * 0.0624f * 1000); //Coefficient for converting Pt to Em. The value is uniform spacing between characters, in units of 1/1000 of an em.
|
||||
|
|
|
@ -282,6 +282,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
|
|||
textBlock.UpdateLineBreakMode(Element.LineBreakMode);
|
||||
}
|
||||
|
||||
[PortHandler]
|
||||
void UpdateCharacterSpacing(TextBlock textBlock)
|
||||
{
|
||||
textBlock.CharacterSpacing = Element.CharacterSpacing.ToEm();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
|
@ -21,8 +19,8 @@ namespace Microsoft.Maui.Handlers
|
|||
public static void MapTextColor(LabelHandler handler, ILabel label) =>
|
||||
handler.TextBlock?.UpdateTextColor(label);
|
||||
|
||||
[MissingMapper]
|
||||
public static void MapCharacterSpacing(LabelHandler handler, ILabel label) { }
|
||||
public static void MapCharacterSpacing(LabelHandler handler, ILabel label) =>
|
||||
handler.TextBlock?.UpdateCharacterSpacing(label);
|
||||
|
||||
public static void MapFont(LabelHandler handler, ILabel label)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace Microsoft.Maui
|
||||
{
|
||||
public static class CharacterSpacingExtensions
|
||||
{
|
||||
public static int ToEm(this double pt)
|
||||
{
|
||||
return Convert.ToInt32(pt * 0.0624f * 1000); //Coefficient for converting Pt to Em. The value is uniform spacing between characters, in units of 1/1000 of an em.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,5 +23,10 @@ namespace Microsoft.Maui
|
|||
|
||||
public static void UpdatePadding(this TextBlock nativeControl, ILabel label) =>
|
||||
nativeControl.UpdateProperty(TextBlock.PaddingProperty, label.Padding.ToNative());
|
||||
|
||||
public static void UpdateCharacterSpacing(this TextBlock nativeControl, ILabel label)
|
||||
{
|
||||
nativeControl.CharacterSpacing = label.CharacterSpacing.ToEm();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче