Skip to content

Commit

Permalink
feat: add all icon packs
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Nov 12, 2024
1 parent 84c514a commit ddb6234
Show file tree
Hide file tree
Showing 362 changed files with 62,906 additions and 593 deletions.
12 changes: 12 additions & 0 deletions src/IconPacks.Avalonia.BootstrapIcons/BootstrapIcons.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://IconPacks.Avalonia.BootstrapIcons/PackIconBootstrapIcons.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>

<StyleInclude Source="avares://IconPacks.Avalonia.Core/PackIcon.axaml" />
</Styles>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Avalonia.Media;
using IconPacks.Avalonia.Core;
using IconPacks.Avalonia.Core.Converter;

namespace IconPacks.Avalonia.BootstrapIcons.Converter
{
public class PackIconBootstrapIconsKindToImageConverter : PackIconKindToImageConverterBase
{
/// <inheritdoc />
protected override string GetPathData(object iconKind)
{
string data = null;
if (iconKind is PackIconBootstrapIconsKind kind)
{
PackIconDataFactory<PackIconBootstrapIconsKind>.DataIndex.Value?.TryGetValue(kind, out data);
}

return data;
}

/// <inheritdoc />
protected override ScaleTransform GetScaleTransform(object iconKind)
{
return new ScaleTransform(1, -1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<DefineConstants>$(DefineConstants);BOOTSTRAPICONS</DefineConstants>
<IconsName>BootstrapIcons</IconsName>
<AssemblyName>IconPacks.Avalonia.BootstrapIcons</AssemblyName>
<Title>IconPacks.Avalonia.BootstrapIcons</Title>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\IconPacks.Avalonia.Core\IconPacks.Avalonia.Core.csproj" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="Resources/**" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions src/IconPacks.Avalonia.BootstrapIcons/PackIconBootstrapIcons.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:iconPacks="https://github.com/MahApps/IconPacks.Avalonia"
x:ClassModifier="internal">

<Design.PreviewWith>
<iconPacks:PackIconBootstrapIcons Kind="_0Circle" />
</Design.PreviewWith>

<ControlTheme x:Key="IconPacks.Avalonia.PackIconBootstrapIcons.Theme"
BasedOn="{StaticResource IconPacks.Avalonia.PackIconControlBase.Theme}"
TargetType="iconPacks:PackIconBootstrapIcons" />

<ControlTheme x:Key="{x:Type iconPacks:PackIconBootstrapIcons}"
BasedOn="{StaticResource IconPacks.Avalonia.PackIconBootstrapIcons.Theme}"
TargetType="iconPacks:PackIconBootstrapIcons" />

</ResourceDictionary>
63 changes: 63 additions & 0 deletions src/IconPacks.Avalonia.BootstrapIcons/PackIconBootstrapIcons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Avalonia;
using Avalonia.Media;
using IconPacks.Avalonia.Core;
using IconPacks.Avalonia.Core.Attributes;

namespace IconPacks.Avalonia.BootstrapIcons
{
/// <summary>
/// Bootstrap Icons are licensed under the [MIT license](<see><cref>https://github.com/twbs/icons?tab=MIT-1-ov-file#readme</cref></see>).
/// Contributions, corrections and requests can be made on GitHub <see><cref>https://github.com/twbs/icons</cref></see>.
/// </summary>
[MetaData("Bootstrap Icons", "https://icons.getbootstrap.com/", "https://github.com/twbs/icons?tab=MIT-1-ov-file#readme")]
public class PackIconBootstrapIcons : PackIconControlBase
{
public PackIconBootstrapIcons()
{
UpdateIconPseudoClasses(true, false, true);
}

public static readonly StyledProperty<PackIconBootstrapIconsKind> KindProperty
= AvaloniaProperty.Register<PackIconBootstrapIcons, PackIconBootstrapIconsKind>(nameof(Kind));

/// <summary>
/// Gets or sets the icon to display.
/// </summary>
public PackIconBootstrapIconsKind Kind
{
get { return GetValue(KindProperty); }
set { SetValue(KindProperty, value); }
}

// We override OnPropertyChanged of the base class. That way we can react on property changes
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);

// if the changed property is the KindProperty, we need to update the stars
if (change.Property == KindProperty)
{
UpdateData();
}
}

protected override void SetKind<TKind>(TKind iconKind)
{
this.SetCurrentValue(KindProperty, iconKind);
}

protected override void UpdateData()
{
if (Kind != default)
{
string data = null;
PackIconDataFactory<PackIconBootstrapIconsKind>.DataIndex.Value?.TryGetValue(Kind, out data);
this.Data = data != null ? StreamGeometry.Parse(data) : null;
}
else
{
this.Data = null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Avalonia.Markup.Xaml;
using IconPacks.Avalonia.Core;

namespace IconPacks.Avalonia.BootstrapIcons
{
public class BootstrapIconsExtension : BasePackIconExtension
{
public BootstrapIconsExtension()
{
}

public BootstrapIconsExtension(PackIconBootstrapIconsKind kind)
{
this.Kind = kind;
}

[ConstructorArgument("kind")] public PackIconBootstrapIconsKind Kind { get; set; }

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this.GetPackIcon<PackIconBootstrapIcons, PackIconBootstrapIconsKind>(this.Kind);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using IconPacks.Avalonia.Core;

namespace IconPacks.Avalonia.BootstrapIcons
{
public class BootstrapIconsImageExtension : BasePackIconImageExtension
{
public BootstrapIconsImageExtension()
{
}

public BootstrapIconsImageExtension(PackIconBootstrapIconsKind kind)
{
this.Kind = kind;
}

[ConstructorArgument("kind")] public PackIconBootstrapIconsKind Kind { get; set; }

public override object ProvideValue(IServiceProvider serviceProvider)
{
return CreateImageSource(this.Kind, this.Brush ?? Brushes.Black);
}

/// <inheritdoc />
protected override string GetPathData(object iconKind)
{
string data = null;
if (iconKind is PackIconBootstrapIconsKind kind)
{
PackIconDataFactory<PackIconBootstrapIconsKind>.DataIndex.Value?.TryGetValue(kind, out data);
}

return data;
}

/// <inheritdoc />
protected override ScaleTransform GetScaleTransform(object iconKind)
{
return new ScaleTransform(1, -1);
}
}
}
Loading

0 comments on commit ddb6234

Please sign in to comment.