Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3057376
Added FontIcon markup extension
Sergio0694 Jan 25, 2020
728f1ce
Removed unnecessary using directives
Sergio0694 Jan 25, 2020
800efba
Renamed the FontIcon markup extension
Sergio0694 Jan 25, 2020
c2f00be
Added FontIcon tests
Sergio0694 Jan 25, 2020
4493ffc
Fixed a typo in the test XAML
Sergio0694 Jan 26, 2020
6418ba5
Merge branch 'master' into feature/font-icon-extension
michael-hawker Feb 11, 2020
e8d4309
Update UnitTests/Extensions/Test_FontIconExtensionMarkupExtension.cs
Sergio0694 Feb 12, 2020
6638416
Update UnitTests/Extensions/Test_FontIconExtensionMarkupExtension.cs
Sergio0694 Feb 12, 2020
452a276
Update UnitTests/Extensions/Test_FontIconExtensionMarkupExtension.cs
Sergio0694 Feb 12, 2020
5577118
Added new FontIcon properties
Sergio0694 Feb 12, 2020
9018d88
Merge branch 'feature/font-icon-extension' of https://github.com/Serg…
Sergio0694 Feb 12, 2020
870306c
Added more tests for the new properties
Sergio0694 Feb 12, 2020
c6d6023
Added FontIconSourceExtension
Sergio0694 Feb 12, 2020
e90b0eb
Added BitmapIconExtension
Sergio0694 Feb 12, 2020
8dda65e
Merge branch 'master' into feature/bitmap-icon-extension
Sergio0694 Feb 12, 2020
cea30df
Merge branch 'master' into feature/font-icon-source-extension
Sergio0694 Feb 12, 2020
1b34996
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Mar 15, 2020
23dcec0
Merge branch 'master' into feature/bitmap-icon-extension
Sergio0694 Mar 15, 2020
63c2b6e
Merge branch 'master' into feature/font-icon-source-extension
Sergio0694 Mar 15, 2020
96b22d4
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Mar 24, 2020
7d6f9ec
Merge branch 'master' into feature/bitmap-icon-extension
Sergio0694 Mar 24, 2020
91947c1
Merge branch 'master' into feature/font-icon-source-extension
Sergio0694 Mar 24, 2020
0d8f538
Added tests for the FontIconSource extension
Sergio0694 Mar 24, 2020
1af9349
Fixed namespace for BitmapIconExtension type
Sergio0694 Mar 24, 2020
bdcfd9a
Added tests for BitmapIconExtension type
Sergio0694 Mar 24, 2020
88844c1
Merge branch 'master' into feature/bitmap-icon-extension
Sergio0694 Mar 24, 2020
d0421d8
Merge branch 'master' into feature/font-icon-source-extension
Sergio0694 Mar 24, 2020
1d9ad41
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Mar 24, 2020
ae5f94b
Merge pull request #14 from Sergio0694/feature/font-icon-source-exten…
Sergio0694 Mar 24, 2020
76cfed2
Merge branch 'feature/font-icon-extension' into feature/bitmap-icon-e…
Sergio0694 Mar 24, 2020
3618cc2
Merge pull request #15 from Sergio0694/feature/bitmap-icon-extension
Sergio0694 Mar 24, 2020
993cdef
Removed [Bindable] attribute from markup extensions
Sergio0694 Mar 25, 2020
329a5bd
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Mar 31, 2020
0d57964
Added a sample page for the FontIconExtension type
Sergio0694 Mar 31, 2020
ede72e4
Added sample for the BitmapIcon extension
Sergio0694 Mar 31, 2020
b783070
Added FontIconSource sample page (not loading)
Sergio0694 Mar 31, 2020
bf098a6
Minor code style tweaks, also tests work now ¯\_(ツ)_/¯
Sergio0694 Mar 31, 2020
843a442
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Apr 1, 2020
117c8f9
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Apr 2, 2020
246a41d
Merge branch 'master' into feature/font-icon-extension
azchohfi Apr 2, 2020
bf6a306
Added shallow copy for icon markup extensions
Sergio0694 Apr 2, 2020
83e538a
Fixed a missing resource in the icon markup sample page
Sergio0694 Apr 2, 2020
1a524b6
Code refactoring
Sergio0694 Apr 4, 2020
d706a40
Updated samples page
Sergio0694 Apr 4, 2020
0925cf1
Code refactoring, minor optimizations
Sergio0694 Apr 4, 2020
69e5687
Added SymbolIconSourceExtension type
Sergio0694 Apr 4, 2020
fecdc53
Added SymbolIconSourceExtension sample
Sergio0694 Apr 4, 2020
3f4a5c8
Added foreground property to icon extensions
Sergio0694 Apr 4, 2020
26c4ec3
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Apr 19, 2020
a44d3b4
Merge branch 'master' into feature/font-icon-extension
Sergio0694 Apr 22, 2020
e6ca30d
Fixed a typo in a unit test
Sergio0694 Apr 22, 2020
dae5a49
Fixed remaining unit tests
Sergio0694 Apr 22, 2020
22392d2
Merge branch 'master' into feature/font-icon-extension
Sergio0694 May 5, 2020
24d8a10
Merge branch 'master' into feature/font-icon-extension
michael-hawker May 5, 2020
875dfd3
Merge branch 'master' into feature/font-icon-extension
michael-hawker May 12, 2020
78f4d76
Removed unnecessary using directives
Sergio0694 May 12, 2020
db20516
Fixed BitmapIcon and FontIcon extension tests
Sergio0694 May 12, 2020
364ea74
Fixed FontIconSource extension tests
Sergio0694 May 12, 2020
c27aa22
Merge branch 'master' into feature/font-icon-extension
Sergio0694 May 12, 2020
5110f5b
Merge branch 'master' into feature/font-icon-extension
Sergio0694 May 13, 2020
48481f1
Merge branch 'master' into feature/font-icon-extension
Sergio0694 May 15, 2020
d9f0395
Merge remote-tracking branch 'upstream/master' into feature/font-icon…
Sergio0694 May 15, 2020
3e80c64
Fixed build errors after merge
Sergio0694 May 15, 2020
6dd7056
Merge branch 'master' into feature/font-icon-extension
Sergio0694 May 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Microsoft.Toolkit.Uwp.UI/Extensions/Markup/FontIconExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml.Media;

namespace Microsoft.Toolkit.Uwp.UI.Extensions
{
/// <summary>
/// Custom <see cref="MarkupExtension"/> which can provide <see cref="FontIcon"/> values.
/// </summary>
[Bindable]
[MarkupExtensionReturnType(ReturnType = typeof(FontIcon))]
public class FontIconExtension : MarkupExtension
{
/// <summary>
/// Gets or sets the <see cref="string"/> representing the icon to display.
/// </summary>
public string Glyph { get; set; }

/// <summary>
/// Gets or sets the font family to use to display the icon. If <see langword="null"/>, "Segoe MDL2 Assets" will be used.
/// </summary>
public FontFamily FontFamily { get; set; }

/// <inheritdoc/>
protected override object ProvideValue()
{
return new FontIcon
{
Glyph = Glyph,
FontFamily = FontFamily ?? new FontFamily("Segoe MDL2 Assets")
};
}
}
}
5 changes: 0 additions & 5 deletions Microsoft.Toolkit.Uwp.UI/Extensions/Markup/NullableBool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;

Expand Down
1 change: 0 additions & 1 deletion Microsoft.Toolkit.Uwp.UI/Extensions/Markup/OnDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Windows.ApplicationModel;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;
Expand Down
63 changes: 63 additions & 0 deletions UnitTests/Extensions/Test_FontIconExtensionMarkupExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Toolkit.Uwp.UI.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;

namespace UnitTests.Extensions
{
[TestClass]
public class Test_FontIconExtensionMarkupExtension
{
[TestCategory("FontIconExtensionMarkupExtension")]
[UITestMethod]
public void Test_FontIconExtension_MarkupExtension_ProvideSegoeMdl2Asset()
{
var treeroot = XamlReader.Load(@"<Page
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:ex=""using:Microsoft.Toolkit.Uwp.UI.Extensions"">
<AppBarButton x:Name=""Check"" Icon=""{ex:FontIcon Glyph=&#xE14D;}""/>
</Page>") as FrameworkElement;

var button = treeroot.FindChildByName("Check") as AppBarButton;

Assert.IsNotNull(button, $"Could not find the {nameof(AppBarButton)} control in tree.");

var icon = button.Icon as FontIcon;

Assert.IsNotNull(icon, $"Could not find the {nameof(FontIcon)} element in button.");

Assert.AreEqual(icon.Glyph, "\uE105", "Expected icon glyph to be E105.");
Assert.AreEqual(icon.FontFamily.Source, "Segoe MDL2 Assets", "Expected font family to be Segoe MDL2 Assets");
}

[TestCategory("FontIconExtensionMarkupExtension")]
[UITestMethod]
public void Test_FontIconExtension_MarkupExtension_ProvideSegoeUI()
{
var treeroot = XamlReader.Load(@"<Page
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:ex=""using:Microsoft.Toolkit.Uwp.UI.Extensions"">
<AppBarButton x:Name=""Check"" Icon=""{ex:FontIcon Glyph=&#xE14D;, FontFamily='Segoe UI'}""/>
</Page>") as FrameworkElement;

var button = treeroot.FindChildByName("Check") as AppBarButton;

Assert.IsNotNull(button, $"Could not find the {nameof(AppBarButton)} control in tree.");

var icon = button.Icon as FontIcon;

Assert.IsNotNull(icon, $"Could not find the {nameof(FontIcon)} element in button.");

Assert.AreEqual(icon.Glyph, "\uE105", "Expected icon glyph to be E105.");
Assert.AreEqual(icon.FontFamily.Source, "Segoe MDL2 Assets", "Expected font family to be Segoe UI");
}
}
}
1 change: 1 addition & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<Compile Include="Converters\Test_StringFormatConverter.cs" />
<Compile Include="Extensions\Helpers\ObjectWithNullableBoolProperty.cs" />
<Compile Include="Extensions\Test_ArrayExtensions.cs" />
<Compile Include="Extensions\Test_FontIconExtensionMarkupExtension.cs" />
<Compile Include="Extensions\Test_NullableBoolMarkupExtension.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Helpers\Test_AdvancedCollectionView.cs" />
Expand Down