Browse Source

Complete docs for new icon types

feature/icons
Max Katz 5 years ago
parent
commit
d51810b336
  1. 48
      src/Avalonia.Controls/FontIcon.cs
  2. 3
      src/Avalonia.Controls/IconElement.cs
  3. 24
      src/Avalonia.Controls/IconSourceElement.cs
  4. 22
      src/Avalonia.Controls/ImageIcon.cs
  5. 4
      src/Avalonia.Controls/PathIcon.cs

48
src/Avalonia.Controls/FontIcon.cs

@ -3,11 +3,20 @@ using Avalonia.Media;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary>
/// Represents an icon that uses a glyph from the specified font.
/// </summary>
public class FontIcon : IconElement public class FontIcon : IconElement
{ {
/// <summary>
/// Gets the identifier for the <see cref="Glyph"/> dependency property.
/// </summary>
public static readonly StyledProperty<string> GlyphProperty = public static readonly StyledProperty<string> GlyphProperty =
AvaloniaProperty.Register<FontIcon, string>(nameof(Glyph)); AvaloniaProperty.Register<FontIcon, string>(nameof(Glyph));
/// <summary>
/// Gets or sets the character code that identifies the icon glyph.
/// </summary>
public string Glyph public string Glyph
{ {
get => GetValue(GlyphProperty); get => GetValue(GlyphProperty);
@ -15,71 +24,60 @@ namespace Avalonia.Controls
} }
} }
/// <summary>
/// Represents an icon source that uses a glyph from the specified font.
/// </summary>
public class FontIconSource : IconSource public class FontIconSource : IconSource
{ {
/// <inheritdoc cref="FontIcon.GlyphProperty" />
public static readonly StyledProperty<string> GlyphProperty = public static readonly StyledProperty<string> GlyphProperty =
FontIcon.GlyphProperty.AddOwner<FontIconSource>(); FontIcon.GlyphProperty.AddOwner<FontIconSource>();
/// <summary> /// <inheritdoc cref="TextBlock.FontFamilyProperty" />
/// Defines the <see cref="FontFamily"/> property.
/// </summary>
public static readonly StyledProperty<FontFamily> FontFamilyProperty = public static readonly StyledProperty<FontFamily> FontFamilyProperty =
TextBlock.FontFamilyProperty.AddOwner<FontIconSource>(); TextBlock.FontFamilyProperty.AddOwner<FontIconSource>();
/// <summary> /// <inheritdoc cref="TextBlock.FontSizeProperty" />
/// Defines the <see cref="FontSize"/> property.
/// </summary>
public static readonly StyledProperty<double> FontSizeProperty = public static readonly StyledProperty<double> FontSizeProperty =
TextBlock.FontSizeProperty.AddOwner<FontIconSource>(); TextBlock.FontSizeProperty.AddOwner<FontIconSource>();
/// <summary> /// <inheritdoc cref="TextBlock.FontStyleProperty" />
/// Defines the <see cref="FontStyle"/> property.
/// </summary>
public static readonly StyledProperty<FontStyle> FontStyleProperty = public static readonly StyledProperty<FontStyle> FontStyleProperty =
TextBlock.FontStyleProperty.AddOwner<FontIconSource>(); TextBlock.FontStyleProperty.AddOwner<FontIconSource>();
/// <summary> /// <inheritdoc cref="TextBlock.FontWeightProperty" />
/// Defines the <see cref="FontWeight"/> property.
/// </summary>
public static readonly StyledProperty<FontWeight> FontWeightProperty = public static readonly StyledProperty<FontWeight> FontWeightProperty =
TextBlock.FontWeightProperty.AddOwner<FontIconSource>(); TextBlock.FontWeightProperty.AddOwner<FontIconSource>();
/// <inheritdoc cref="FontIcon.Glyph" />
public string Glyph public string Glyph
{ {
get => GetValue(GlyphProperty); get => GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value); set => SetValue(GlyphProperty, value);
} }
/// <summary> /// <inheritdoc cref="TextBlock.FontFamily" />
/// Gets or sets the font family used to draw the control's text.
/// </summary>
public FontFamily FontFamily public FontFamily FontFamily
{ {
get => GetValue(FontFamilyProperty); get => GetValue(FontFamilyProperty);
set => SetValue(FontFamilyProperty, value); set => SetValue(FontFamilyProperty, value);
} }
/// <summary> /// <inheritdoc cref="TextBlock.FontSize" />
/// Gets or sets the size of the control's text in points.
/// </summary>
public double FontSize public double FontSize
{ {
get => GetValue(FontSizeProperty); get => GetValue(FontSizeProperty);
set => SetValue(FontSizeProperty, value); set => SetValue(FontSizeProperty, value);
} }
/// <summary> /// <inheritdoc cref="TextBlock.FontStyle" />
/// Gets or sets the font style used to draw the control's text.
/// </summary>
public FontStyle FontStyle public FontStyle FontStyle
{ {
get => GetValue(FontStyleProperty); get => GetValue(FontStyleProperty);
set => SetValue(FontStyleProperty, value); set => SetValue(FontStyleProperty, value);
} }
/// <summary> /// <inheritdoc cref="TextBlock.FontWeight" />
/// Gets or sets the font weight used to draw the control's text.
/// </summary>
public FontWeight FontWeight public FontWeight FontWeight
{ {
get => GetValue(FontWeightProperty); get => GetValue(FontWeightProperty);

3
src/Avalonia.Controls/IconElement.cs

@ -2,6 +2,9 @@
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary>
/// Represents the base class for an icon UI element.
/// </summary>
public abstract class IconElement : TemplatedControl public abstract class IconElement : TemplatedControl
{ {

24
src/Avalonia.Controls/IconSourceElement.cs

@ -6,11 +6,24 @@ using Avalonia.Metadata;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary>
/// Represents an icon that uses an IconSource as its content.
/// </summary>
/// <remarks>
/// <see cref="Avalonia.Controls.IconSource"/> is similar to IconElement. However, because it is not a <see cref="Control"/>, it can be shared.
/// <see cref="IconSourceElement"/> provides a wrapper that lets you use an IconSource in places that require an IconElement.
/// </remarks>
public class IconSourceElement : IconElement public class IconSourceElement : IconElement
{ {
/// <summary>
/// Identifies the IconSource dependency property.
/// </summary>
public static readonly StyledProperty<IconSource?> IconSourceProperty = public static readonly StyledProperty<IconSource?> IconSourceProperty =
AvaloniaProperty.Register<IconSourceElement, IconSource?>(nameof(IconSource)); AvaloniaProperty.Register<IconSourceElement, IconSource?>(nameof(IconSource));
/// <summary>
/// Gets or sets the IconSource used as the icon content.
/// </summary>
[Content] [Content]
public IconSource? IconSource public IconSource? IconSource
{ {
@ -19,17 +32,28 @@ namespace Avalonia.Controls
} }
} }
/// <summary>
/// Represents the base class for an icon source.
/// </summary>
/// <remarks>
/// <see cref="IconSource"/> is similar to IconElement. However, because it is not a <see cref="Control"/>, it can be shared.
/// </remarks>
public abstract class IconSource : AvaloniaObject public abstract class IconSource : AvaloniaObject
{ {
/// <inheritdoc cref="TemplatedControl.ForegroundProperty" />
public static StyledProperty<IBrush?> ForegroundProperty = public static StyledProperty<IBrush?> ForegroundProperty =
TemplatedControl.ForegroundProperty.AddOwner<IconSource>(); TemplatedControl.ForegroundProperty.AddOwner<IconSource>();
/// <inheritdoc cref="TemplatedControl.Foreground" />
public IBrush? Foreground public IBrush? Foreground
{ {
get => GetValue(ForegroundProperty); get => GetValue(ForegroundProperty);
set => SetValue(ForegroundProperty, value); set => SetValue(ForegroundProperty, value);
} }
/// <summary>
/// Gets the data template used to display <see cref="IconElement"/>.
/// </summary>
public abstract IDataTemplate IconElementTemplate { get; } public abstract IDataTemplate IconElementTemplate { get; }
} }
} }

22
src/Avalonia.Controls/ImageIcon.cs

@ -3,17 +3,16 @@ using Avalonia.Media;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary>
/// Represents an icon that uses a image source as its content.
/// </summary>
public class ImageIcon : IconElement public class ImageIcon : IconElement
{ {
/// <summary> /// <inheritdoc cref="Image.SourceProperty" />
/// Defines the <see cref="Source"/> property.
/// </summary>
public static readonly StyledProperty<IImage> SourceProperty = public static readonly StyledProperty<IImage> SourceProperty =
Image.SourceProperty.AddOwner<ImageIcon>(); Image.SourceProperty.AddOwner<ImageIcon>();
/// <summary> /// <inheritdoc cref="Image.Source" />
/// Gets or sets the image that will be displayed.
/// </summary>
public IImage Source public IImage Source
{ {
get => GetValue(SourceProperty); get => GetValue(SourceProperty);
@ -21,17 +20,16 @@ namespace Avalonia.Controls
} }
} }
/// <summary>
/// Represents an icon source that uses a image source as its content.
/// </summary>
public class ImageIconSource : IconSource public class ImageIconSource : IconSource
{ {
/// <summary> /// <inheritdoc cref="Image.SourceProperty" />
/// Defines the <see cref="Source"/> property.
/// </summary>
public static readonly StyledProperty<IImage> SourceProperty = public static readonly StyledProperty<IImage> SourceProperty =
Image.SourceProperty.AddOwner<ImageIcon>(); Image.SourceProperty.AddOwner<ImageIcon>();
/// <summary> /// <inheritdoc cref="Image.Source" />
/// Gets or sets the image that will be displayed.
/// </summary>
public IImage Source public IImage Source
{ {
get => GetValue(SourceProperty); get => GetValue(SourceProperty);

4
src/Avalonia.Controls/PathIcon.cs

@ -11,9 +11,11 @@ namespace Avalonia.Controls
AffectsRender<PathIcon>(DataProperty); AffectsRender<PathIcon>(DataProperty);
} }
/// <inheritdoc cref="Path.DataProperty" />
public static readonly StyledProperty<Geometry> DataProperty = public static readonly StyledProperty<Geometry> DataProperty =
Path.DataProperty.AddOwner<PathIcon>(); Path.DataProperty.AddOwner<PathIcon>();
/// <inheritdoc cref="Path.Data" />
public Geometry Data public Geometry Data
{ {
get => GetValue(DataProperty); get => GetValue(DataProperty);
@ -23,9 +25,11 @@ namespace Avalonia.Controls
public class PathIconSource : IconSource public class PathIconSource : IconSource
{ {
/// <inheritdoc cref="Path.DataProperty" />
public static readonly StyledProperty<Geometry> DataProperty = public static readonly StyledProperty<Geometry> DataProperty =
Path.DataProperty.AddOwner<PathIcon>(); Path.DataProperty.AddOwner<PathIcon>();
/// <inheritdoc cref="Path.Data" />
public Geometry Data public Geometry Data
{ {
get => GetValue(DataProperty); get => GetValue(DataProperty);

Loading…
Cancel
Save