1
0
Форкнуть 0
This commit is contained in:
Javier Suárez Ruiz 2021-10-12 12:42:59 +02:00
Родитель f56cf11038
Коммит 020beacdae
7 изменённых файлов: 21 добавлений и 13 удалений

Просмотреть файл

@ -84,7 +84,7 @@
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) == true ">
<PackageReference Include="Microsoft.Graphics.Win2D" />
<PackageReference Include="Microsoft.Maui.Graphics.Win2D.WinUI.Desktop" Version="6.0.100-rc.1.382" />
<PackageReference Include="Microsoft.Maui.Graphics.Win2D.WinUI.Desktop" Version="6.0.101-preview.9.512" />
</ItemGroup>
</Project>

Просмотреть файл

@ -15,7 +15,7 @@
<PackageId>Microsoft.Maui.Graphics.Controls</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Graphics" Version="6.0.100-rc.1.382" />
<PackageReference Include="Microsoft.Maui.Graphics" Version="6.0.101-preview.9.512" />
</ItemGroup>
<Import Project="..\..\Microsoft.Maui.Graphics.Controls.MultiTargeting.targets" />
</Project>

Просмотреть файл

@ -11,10 +11,10 @@ namespace Microsoft.Maui.Graphics.Controls
public static PropertyMapper<IButton> PropertyMapper = new PropertyMapper<IButton>(ViewHandler.Mapper)
{
[nameof(IButton.Background)] = ViewHandler.MapInvalidate,
[nameof(IButton.Text)] = ViewHandler.MapInvalidate,
[nameof(IButton.TextColor)] = ViewHandler.MapInvalidate,
[nameof(IButton.Font)] = ViewHandler.MapInvalidate,
[nameof(IButton.CharacterSpacing)] = ViewHandler.MapInvalidate,
[nameof(IText.Text)] = ViewHandler.MapInvalidate,
[nameof(ITextStyle.TextColor)] = ViewHandler.MapInvalidate,
[nameof(ITextStyle.Font)] = ViewHandler.MapInvalidate,
[nameof(ITextStyle.CharacterSpacing)] = ViewHandler.MapInvalidate,
[nameof(IButton.Padding)] = ViewHandler.MapInvalidate
};

Просмотреть файл

@ -31,13 +31,15 @@
{
canvas.SaveState();
canvas.FontColor = button.TextColor.WithDefault(Cupertino.Color.Label.Light.White);
var textColor = (button as ITextStyle)?.TextColor;
canvas.FontColor = textColor?.WithDefault(Cupertino.Color.Label.Light.White);
canvas.FontSize = 17f;
var height = dirtyRect.Height;
var width = dirtyRect.Width;
canvas.DrawString(button.Text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
var text = (button as IText)?.Text;
canvas.DrawString(text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}

Просмотреть файл

@ -67,7 +67,10 @@
canvas.SaveState();
if (button.IsEnabled)
canvas.FontColor = button.TextColor.WithDefault(Fluent.Color.Foreground.White);
{
var textColor = (button as ITextStyle)?.TextColor;
canvas.FontColor = textColor?.WithDefault(Fluent.Color.Foreground.White);
}
else
canvas.FontColor = Fluent.Color.Foreground.NeutralPrimary.ToColor();
@ -76,7 +79,8 @@
var height = dirtyRect.Height;
var width = dirtyRect.Width;
canvas.DrawString(button.Text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
var text = (button as IText)?.Text;
canvas.DrawString(text, 0, 0, width, height, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}

Просмотреть файл

@ -42,7 +42,8 @@ namespace Microsoft.Maui.Graphics.Controls
canvas.FontName = "Roboto";
canvas.FontColor = button.TextColor.WithDefault(button.IsEnabled ? Material.Color.White : Material.Color.Gray1);
var textColor = (button as ITextStyle)?.TextColor;
canvas.FontColor = textColor?.WithDefault(button.IsEnabled ? Material.Color.White : Material.Color.Gray1);
canvas.FontSize = Material.Font.Button;
@ -51,7 +52,8 @@ namespace Microsoft.Maui.Graphics.Controls
var width = dirtyRect.Width;
canvas.DrawString(button.Text.ToUpper(), x, y, width, MaterialBackgroundHeight, HorizontalAlignment.Center, VerticalAlignment.Center);
var text = (button as IText)?.Text;
canvas.DrawString(text?.ToUpper(), x, y, width, MaterialBackgroundHeight, HorizontalAlignment.Center, VerticalAlignment.Center);
canvas.RestoreState();
}

Просмотреть файл

@ -7,7 +7,7 @@ namespace Microsoft.Maui.Graphics.Controls
{
public static Color WithDefault(this Color color, string defaultColor)
{
if (!color.IsDefault())
if (color != null && !color.IsDefault())
return color;
else
return Color.FromArgb(defaultColor);