Skip to content

Commit

Permalink
Merge pull request #36 from MartinTopfstedt/develop
Browse files Browse the repository at this point in the history
Version 2.1.4
  • Loading branch information
Codinion authored Jul 15, 2021
2 parents ddd6af1 + ddafc75 commit a66b9d4
Show file tree
Hide file tree
Showing 20 changed files with 600 additions and 492 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.1.4
- Removed ResourceDictionary(FontAwesome5Dictionary.xaml)
- Added new function for Font saving and loading to Fonts class.
- fonts now get saved to temporary directory and referenced from there to prevent memory leak
# 2.1.3
- Added ImageSourceSvgConverter
- Made the Font Families adjustable on the static Fonts class
- Introduced a new ReosurceDictionary (FontAwesome5Dictionary.xaml) to prevent memory leaks
# 2.1.2
- Fixed issue #31
# 2.1.1
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ Font Awesome: https://github.com/FortAwesome/Font-Awesome

#### Installation

```Install-Package FontAwesome5```
1. Install the FontAwesome5 NuGet Package: ```Install-Package FontAwesome5```

https://www.nuget.org/packages/FontAwesome5

#### Usage XAML

The usage is the same like the version from charri, just the FontAwesomeIcon enumeration has changed to EFontAwesomeIcon and has the Styles included, which means "Flag" changed to "Solid_Flag" or "Regular_Flag", and the name space changed from "http://schemas.fontawesome.io" to "http://schemas.fontawesome.com".

https://github.com/charri/Font-Awesome-WPF/blob/master/README-WPF.md#usage-xaml



#### Usage XAML SVG

The SvgAwesome can be used like the ImageAwesome.
Expand All @@ -44,6 +45,10 @@ The SvgAwesome can be used like the ImageAwesome.

https://github.com/charri/Font-Awesome-WPF/blob/master/README-WPF.md#imagesourceconverter

#### ImageSourceSvgConverter

This is the same like the *ImageSourceConverter*, except it does use the Svg information to draw the icon instead of the font.

#### LabelConverter

Gets the Label/Name of a EFontAwesomeIcon. The converter parameter can contain a format string, where {0} is the label/name and {1} is the style.
Expand Down
181 changes: 83 additions & 98 deletions src/Examples/FontAwesome5.Net40.Example/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,110 +7,95 @@
xmlns:fa5="http://schemas.fontawesome.com/icons/"
mc:Ignorable="d"
Title="FontAwesome5.Net40.Example" SizeToContent="WidthAndHeight">
<Window.Resources>
<fa5:LabelConverter x:Key="LabelConverter"/>
<fa5:StyleConverter x:Key="StyleConverter"/>
<fa5:ImageSourceConverter x:Key="ImageSourceConverter"/>
<fa5:DrawingConverter x:Key="DrawingConverter"/>
</Window.Resources>
<Window.Icon>
<DrawingImage Drawing="{Binding SelectedIcon, Converter={StaticResource DrawingConverter}}">
</DrawingImage>
</Window.Icon>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="5">
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Font Size:" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="60" Value="{Binding FontSize, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<TextBlock Text="{Binding FontSize, StringFormat={}{0:#.##}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Spin:" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding SpinIsEnabled, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="10" Value="{Binding SpinDuration, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="5,0,0,0"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Pulse:" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding PulseIsEnabled, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="10" Value="{Binding PulseDuration, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="5,0,0,0"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Rotation:" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="360" Value="{Binding Rotation, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Flip:" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding FlipOrientations}" SelectedItem="{Binding FlipOrientation, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Visibility:" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding Visibilities}" SelectedItem="{Binding Visibility, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
</StackPanel>
</StackPanel>

<ListView Grid.Column="0" Grid.Row="1" ItemsSource="{Binding AllIcons}" SelectedItem="{Binding SelectedIcon}">
<ListView.View>
<GridView>
<GridViewColumn Header="Icon">
<GridViewColumn.CellTemplate>
<DataTemplate>
<fa5:ImageAwesome Icon="{Binding}" Width="32" Height="32" Foreground="Black" HorizontalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Converter={StaticResource LabelConverter}}"/>
<GridViewColumn Header="Style" DisplayMemberBinding="{Binding Converter={StaticResource StyleConverter}}"/>
</GridView>
</ListView.View>
</ListView>
<Window.Resources>
<fa5:LabelConverter x:Key="LabelConverter"/>
<fa5:StyleConverter x:Key="StyleConverter"/>
<fa5:ImageSourceConverter x:Key="ImageSourceConverter"/>
<fa5:ImageSourceSvgConverter x:Key="ImageSourceSvgConverter"/>
<fa5:DrawingConverter x:Key="DrawingConverter"/>
</Window.Resources>
<Window.Icon>
<DrawingImage Drawing="{Binding SelectedIcon, Converter={StaticResource DrawingConverter}}">
</DrawingImage>
</Window.Icon>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="5">
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Font Size:" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="60" Value="{Binding FontSize, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<TextBlock Text="{Binding FontSize, StringFormat={}{0:#.##}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Spin:" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding SpinIsEnabled, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="10" Value="{Binding SpinDuration, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="5,0,0,0"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Pulse:" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding PulseIsEnabled, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="10" Value="{Binding PulseDuration, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="5,0,0,0"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Rotation:" VerticalAlignment="Center"/>
<Slider Minimum="0" Maximum="360" Value="{Binding Rotation, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Flip:" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding FlipOrientations}" SelectedItem="{Binding FlipOrientation, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
<Separator Width="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="5,0,5,0"/>
</StackPanel>
<StackPanel Margin="0,0,5,0" Orientation="Horizontal">
<TextBlock Text="Visibility:" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding Visibilities}" SelectedItem="{Binding Visibility, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" VerticalAlignment="Center" Width="100"/>
</StackPanel>
</StackPanel>

<StackPanel Grid.Column="1" Grid.Row="1">
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Enum Member: "/>
<TextBlock Grid.Column="1" Text="{Binding SelectedIcon, StringFormat=EFontAwesomeIcon.{0}}"/>
<ListView Grid.Column="0" Grid.Row="1" ItemsSource="{Binding AllIcons}" SelectedItem="{Binding SelectedIcon}">
<ListView.View>
<GridView>
<GridViewColumn Header="Icon">
<GridViewColumn.CellTemplate>
<DataTemplate>
<fa5:ImageAwesome Icon="{Binding}" Width="32" Height="32" Foreground="Black" HorizontalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Converter={StaticResource LabelConverter}}"/>
<GridViewColumn Header="Style" DisplayMemberBinding="{Binding Converter={StaticResource StyleConverter}}"/>
</GridView>
</ListView.View>
</ListView>

<TextBlock Grid.Row="1" Grid.Column="0" Text="Label: "/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding SelectedIcon, Converter={StaticResource LabelConverter}}"/>
<StackPanel Grid.Column="1" Grid.Row="1">

<TextBlock Grid.Row="2" Grid.Column="0" Text="Label + Style: "/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding SelectedIcon, Converter={StaticResource LabelConverter}, ConverterParameter='{}{0} ({1})'}"/>
</Grid>
<fa5:SvgAwesome Icon="{Binding SelectedIcon}" Height="100" Width="100" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="SvgAwesome" HorizontalAlignment="Center" FontWeight="Bold"/>

<fa5:SvgAwesome Icon="{Binding SelectedIcon}" Height="100" Width="100" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="{Binding SVGText}" HorizontalAlignment="Center" FontWeight="Bold"/>
<fa5:ImageAwesome Icon="{Binding SelectedIcon}" Width="50" Height="50" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="ImageAwesome" HorizontalAlignment="Center" FontWeight="Bold"/>

<fa5:ImageAwesome Icon="{Binding SelectedIcon}" Width="50" Height="50" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="{Binding ImageText}" HorizontalAlignment="Center" FontWeight="Bold"/>
<fa5:FontAwesome Icon="{Binding SelectedIcon}" FontSize="{Binding FontSize}" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="FontAwesome" HorizontalAlignment="Center" FontWeight="Bold"/>

<fa5:FontAwesome Icon="{Binding SelectedIcon}" FontSize="{Binding FontSize}" Spin="{Binding SpinIsEnabled}" SpinDuration="{Binding SpinDuration}" Pulse="{Binding PulseIsEnabled}" PulseDuration="{Binding PulseDuration}" FlipOrientation="{Binding FlipOrientation}" Rotation="{Binding Rotation}" Visibility="{Binding Visibility}" Margin="10"/>
<TextBlock Text="{Binding FontText}" HorizontalAlignment="Center" FontWeight="Bold"/>
<Image Source="{Binding SelectedIcon, Converter={StaticResource ImageSourceConverter}}" Visibility="{Binding Visibility}" Width="50" Height="50" Margin="10"/>
<TextBlock Text="ImageSourceConverter" HorizontalAlignment="Center" FontWeight="Bold"/>

<Image Source="{Binding SelectedIcon, Converter={StaticResource ImageSourceConverter}}" Visibility="{Binding Visibility}" Width="50" Height="50" Margin="10"/>
<TextBlock Text="Using a converter" HorizontalAlignment="Center" FontWeight="Bold"/>
<Image Source="{Binding SelectedIcon, Converter={StaticResource ImageSourceSvgConverter}}" Visibility="{Binding Visibility}" Width="50" Height="50" Margin="10"/>
<TextBlock Text="ImageSourceSvgConverter" HorizontalAlignment="Center" FontWeight="Bold"/>

<Button fa5:Awesome.Content="{Binding SelectedIcon}" FontSize="{Binding FontSize}" Visibility="{Binding Visibility}" Margin="10"></Button>
</StackPanel>
</Grid>
<Button fa5:Awesome.Content="{Binding SelectedIcon}" FontSize="{Binding FontSize}" Visibility="{Binding Visibility}" Margin="10"></Button>
</StackPanel>
</Grid>
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public MainWindowViewModel()
public List<EFlipOrientation> FlipOrientations { get; set; } = new List<EFlipOrientation>();
public List<EFontAwesomeIcon> AllIcons { get; set; } = new List<EFontAwesomeIcon>();

public string SVGText => $"<fa5:SvgAwesome Icon=\"{SelectedIcon}\" Height=\"100\" Width=\"100\">";
public string ImageText => $"<fa5:ImageAwesome Icon=\"{SelectedIcon}\" Height=\"100\" Width=\"100\">";
public string FontText => $"<fa5:FontAwesome Icon=\"{SelectedIcon}\" FontSize=\"{FontSize}\">";

public event PropertyChangedEventHandler PropertyChanged;
}
}
4 changes: 2 additions & 2 deletions src/Examples/FontAwesome5.NetCore.Example/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
xmlns:local="clr-namespace:FontAwesome5.NetCore30"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>

</Application.Resources>
</Application>
10 changes: 10 additions & 0 deletions src/Examples/FontAwesome5.NetCore.Example/FodyWeavers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PropertyChanged.Fody" Version="3.1.3" />
<PackageReference Include="PropertyChanged.Fody" Version="3.2.7" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit a66b9d4

Please sign in to comment.