Comments (2)
Implemented in 52a57f6.
烦请测试,若实现有缺漏欢迎 re-open.
from fluenticons.
写了一个简单的例子可供参考【
/// <summary>
/// An abstract <see cref="MarkupExtension"/> which to produce text-based icons.
/// </summary>
public abstract class SymbolIconBaseExtension : MarkupExtension
{
/// <summary>
/// Gets or sets if the icon is filled.
/// </summary>
public bool IsFilled { get; set; }
/// <summary>
/// Gets or sets if the icon use Segoe metrics.
/// </summary>
public bool UseSegoeMetrics { get; set; }
/// <summary>
/// Gets or sets the size of the icon to display.
/// </summary>
public double FontSize { get; set; }
/// <summary>
/// Gets or sets the symbol of the icon to display.
/// </summary>
public Symbol Symbol { get; set; }
/// <summary>
/// Gets or sets the size of the icon to display. Priority is higher than <see cref="FontSize"/>.
/// </summary>
public FontSizeType Size { get; set; }
/// <summary>
/// Gets or sets the thickness of the icon glyph.
/// </summary>
public FontWeight FontWeight { get; set; } = FontWeights.Normal;
/// <summary>
/// Gets or sets the font style for the icon glyph.
/// </summary>
public FontStyle FontStyle { get; set; } = FontStyle.Normal;
/// <summary>
/// Gets or sets the foreground <see cref="Brush"/> for the icon.
/// </summary>
public Brush? Foreground { get; set; }
/// <summary>
/// Gets or sets a value indicating whether automatic text enlargement, to reflect the system text size setting, is enabled.
/// </summary>
public bool IsTextScaleFactorEnabled { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the icon is mirrored when the flow direction is right to left.
/// </summary>
public bool MirroredWhenRightToLeft { get; set; }
}
/// <summary>
/// Symbol icon source markup extension
/// </summary>
[MarkupExtensionReturnType(ReturnType = typeof(SymbolIconSource))]
public class SymbolIconSourceExtension : SymbolIconBaseExtension
{
/// <inheritdoc />
protected override object ProvideValue()
{
var icon = new SymbolIconSource
{
IsFilled = IsFilled,
UseSegoeMetrics = UseSegoeMetrics,
Symbol = Symbol,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
MirroredWhenRightToLeft = MirroredWhenRightToLeft
};
if (Size is not FontSizeType.None)
icon.FontSize = (int)Size;
else if (FontSize > 0)
icon.FontSize = FontSize;
if (Foreground is not null)
icon.Foreground = Foreground;
return icon;
}
}
/// <summary>
/// Symbol icon markup extension
/// </summary>
[MarkupExtensionReturnType(ReturnType = typeof(SymbolIcon))]
public class SymbolIconExtension : SymbolIconBaseExtension
{
/// <inheritdoc cref="FrameworkElement.FlowDirection"/>
public FlowDirection FlowDirection { get; set; }
/// <inheritdoc />
protected override object ProvideValue()
{
var icon = new SymbolIcon
{
IsFilled = IsFilled,
UseSegoeMetrics = UseSegoeMetrics,
Symbol = Symbol,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
MirroredWhenRightToLeft = MirroredWhenRightToLeft,
FlowDirection = FlowDirection
};
if (Size is not FontSizeType.None)
icon.FontSize = (int)Size;
else if (FontSize > 0)
icon.FontSize = FontSize;
if (Foreground is not null)
icon.Foreground = Foreground;
return icon;
}
}
/// <summary>
/// Font size
/// </summary>
/// <remarks>
/// <see href="https://learn.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font"/>
/// </remarks>
public enum FontSizeType
{
/// <summary>
/// Use FontSize property
/// </summary>
None = 0,
/// <summary>
/// 16
/// </summary>
Small = 16,
/// <summary>
/// 20
/// </summary>
Normal = 20,
/// <summary>
/// 24
/// </summary>
Large = 24,
/// <summary>
/// 32
/// </summary>
ExLarge = 32,
/// <summary>
/// 48
/// </summary>
ExExLarge = 48,
/// <summary>
/// 64
/// </summary>
ExExExLarge = 64
}
from fluenticons.
Related Issues (9)
- Can I use these icons with FluentAvalonia HOT 7
- Can it be used in Winform? HOT 1
- Issue with RTL language support HOT 2
- Why disable inherit FontSize? HOT 2
- Recent base class change from Avalonia IconElement to Control HOT 7
- Avalonia Foreground Color Broken on macOS HOT 7
- Crash when NativeAOT enabled HOT 5
- Can't set properties using style selector HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluenticons.