Skip to content

Commit

Permalink
Merge pull request #26 from MartinTopfstedt/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
Codinion authored Jul 3, 2022
2 parents 531ebe0 + fe55c18 commit 9625cbb
Show file tree
Hide file tree
Showing 68 changed files with 736 additions and 316 deletions.
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Font-Awesome Version: 6.1.1

## Breaking Changes

The Package is now separated into two separate packages for SVG and Fonts. Therefore the namespace needed to be separate as well. Which means the old namespace `http://schemas.fontawesome.com/icons` has been split into `http://schemas.fontawesome.com/icons/svg` and `http://schemas.fontawesome.com/icons/fonts`.
The Package is now separated into two packages for SVG and Fonts. Therefore the namespace needed to be separate as well. Which means the old namespace `http://schemas.fontawesome.com/icons` has been split into `http://schemas.fontawesome.com/icons/svg` and `http://schemas.fontawesome.com/icons/fonts`.

## FontAwesome6 (Free)

Expand All @@ -17,6 +17,8 @@ The Package is now separated into two separate packages for SVG and Fonts. There
#### Installation

Install the FontAwesome6.Svg package: `Install-Package FontAwesome6.Svg`
Or
Install the FontAwesome6.Svg.WinUI package: `Install-Package FontAwesome6.Svg.WinUI`

#### Usage

Expand All @@ -26,6 +28,7 @@ Control | .Net Framework & .Net | WinUI | UWP
------- | ---- | ----- | ----
SvgAwesome | :white_check_mark: | :white_check_mark: | :white_check_mark: |
ImageAwesome | :white_check_mark: | :x: | :x: |
Attached Properties | :white_check_mark: | :x: | :x: |

```xaml
<Window x:Class="FontAwesome6.Example.WPF.MainWindow"
Expand All @@ -48,8 +51,8 @@ Available for following controls:
```xaml
<Window x:Class="FontAwesome6.Example.WPF.MainWindow"
xmlns:fa="http://schemas.fontawesome.com/icons/svg/properties">
<Button fa:FontAwesome.Icon="Soild_Flags"/>
<Image fa:FontAwesome.Icon="Soild_Flags"/>
<Button fa:FontAwesome.Icon="Solid_Flags"/>
<Image fa:FontAwesome.Icon="Solid_Flags"/>
</Window>
```

Expand Down Expand Up @@ -82,6 +85,8 @@ See example projects for advanced usage.
#### Installation

Install the FontAwesome6.Fonts package: `Install-Package FontAwesome6.Fonts`
Or
Install the FontAwesome6.Fonts.WinUI package: `Install-Package FontAwesome6.Fonts.WinUI`

#### Usage

Expand All @@ -91,6 +96,7 @@ Control | .Net Framework & .Net | WinUI | UWP
------- | ---- | ----- | ----
FontAwesome | :white_check_mark: | :white_check_mark: | :white_check_mark: |
ImageAwesome | :white_check_mark: | :x: | :x: |
Attached Properties | :white_check_mark: | :x: | :x: |

```xaml
<Window x:Class="FontAwesome6.Example.WPF.MainWindow"
Expand Down Expand Up @@ -150,6 +156,8 @@ See example projects for advanced usage.
#### Installation

1. Install the FontAwesome6.Pro.Svg package: `Install-Package FontAwesome6.Pro.Svg`
Or
Install the FontAwesome6.Pro.Svg.WinUI package: `Install-Package FontAwesome6.Pro.Svg.WinUI`

2. Download the Desktop Version of FontAwesome6 from the website: https://fontawesome.com/download

Expand Down Expand Up @@ -178,6 +186,8 @@ See example projects for advanced usage.
#### Installation

1. Install the FontAwesome6.Pro.Fonts package: `Install-Package FontAwesome6.Pro.Fonts`
Or
Install the FontAwesome6.Pro.Fonts.WInUI package: `Install-Package FontAwesome6.Pro.Fonts.WinUI`

2. Download the Web Version of FontAwesome6 from the website: https://fontawesome.com/download

Expand Down Expand Up @@ -206,7 +216,7 @@ public partial class App : Application

>:warning: *(.Net Framework & .Net only)* Using the fonts from resources will create a memory leak. To prevent it load the font from the file system instead.
The example below shows how to load all font files(with their default names) as resource. The files are located inside the solution in the "Fonts" directory and have "Resource" as Content.
The example below shows how to load all font files (with their default names) as resource. The files are located inside the solution in the "Fonts" directory and have "Resource" as Content.

###### .Net Framework & .Net

Expand Down Expand Up @@ -261,3 +271,38 @@ public sealed partial class MainPage : Page
SwapOpacity="false"/>
</Window>
```
### Load Icons inside Designer

Add a `DesignTimeResource.xaml` inside the `Properties` directory and a new UserControl anywhere(e.x. `DesignTimeFontAwesome.xaml`).
Then add the UserControl to the ResourceDirectory.
```xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FontAwesome6.Example.WPF">
<local:DesignTimeFontAwesome x:Key="NotNeeded"></local:DesignTimeFontAwesome>
</ResourceDictionary>
```
After that, you need to modify the `.csproj` file and change the entry of `DesignTimeResource.xaml` to the following:
```
<Page Include="Properties\DesignTimeResources.xaml" Condition="'$(DesignTime)'=='true' OR ('$(SolutionPath)'!='' AND Exists('$(SolutionPath)') AND '$(BuildingInsideVisualStudio)'!='true' AND '$(BuildingInsideExpressionBlend)'!='true')">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
</Page>
```
Create a new UserControl called `DesignTimeFontAwesome.xaml` and add the icon / font loading inside the constructor.
```csharp
using System.Windows.Controls;
namespace FontAwesome6.Example.WPF
{
public partial class DesignTimeFontAwesome : UserControl
{
public DesignTimeFontAwesome()
{
InitializeComponent();
Svg.FontAwesomeSvg.LoadFromResource("FontAwesome6.Example.WPF.Svg.FontAwesomeSvg.all.json", typeof(App).Assembly);
}
}
}
```
12 changes: 12 additions & 0 deletions build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ steps:
command: 'custom'
arguments: 'pack src/NuGet/${{setting.key}}.Fonts.nuspec -Symbols -SymbolPackageFormat snupkg -Version $(GitVersion.NuGetVersionV2) -OutputDirectory $(Build.ArtifactStagingDirectory)'

- task: NuGetCommand@2
displayName: '${{setting.key}}: Pack Fonts.WinUI'
inputs:
command: 'custom'
arguments: 'pack src/NuGet/${{setting.key}}.Fonts.WinUI.nuspec -Symbols -SymbolPackageFormat snupkg -Version $(GitVersion.NuGetVersionV2) -OutputDirectory $(Build.ArtifactStagingDirectory)'

- task: NuGetCommand@2
displayName: '${{setting.key}}: Pack Svg'
inputs:
command: 'custom'
arguments: 'pack src/NuGet/${{setting.key}}.Svg.nuspec -Symbols -SymbolPackageFormat snupkg -Version $(GitVersion.NuGetVersionV2) -OutputDirectory $(Build.ArtifactStagingDirectory)'

- task: NuGetCommand@2
displayName: '${{setting.key}}: Pack Svg.WinUI'
inputs:
command: 'custom'
arguments: 'pack src/NuGet/${{setting.key}}.Svg.WinUI.nuspec -Symbols -SymbolPackageFormat snupkg -Version $(GitVersion.NuGetVersionV2) -OutputDirectory $(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FontAwesom.Generator.Shared\FontAwesome.Generator.Shared.csproj" />
<ProjectReference Include="..\FontAwesome.Generator.Shared\FontAwesome.Generator.Shared.csproj" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/FontAwesome.Generator/FontAwesome.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FontAwesom.Generator.Shared\FontAwesome.Generator.Shared.csproj" />
<ProjectReference Include="..\FontAwesome.Generator.Shared\FontAwesome.Generator.Shared.csproj" />
</ItemGroup>

</Project>
29 changes: 15 additions & 14 deletions src/FontAwesome.Generator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,42 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FontAwesome.Generator"
mc:Ignorable="d"
SizeToContent="Height"
Title="FontAwesome Generator" Width="800" IsEnabled="{Binding IsWindowsEnabled}">
SizeToContent="Height"
Title="FontAwesome Generator" Width="800" IsEnabled="{Binding IsWindowsEnabled}"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}">
<Window.DataContext>
<local:MainWindowViewModel/>
<local:MainWindowViewModel />
</Window.DataContext>
<StackPanel>
<GroupBox Header="FontAwesome Version">
<DockPanel Grid.Row="0" Grid.Column="1" LastChildFill="True">
<DockPanel LastChildFill="True">
<TextBox Margin="2" Text="{Binding Version}"></TextBox>
</DockPanel>
</GroupBox>
<GroupBox Header="Source File Generation">
<StackPanel>
<DockPanel Grid.Row="1" Grid.Column="1" LastChildFill="True">
<DockPanel LastChildFill="True">
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding GenerateSourceFilesCommand}">Generate</Button>
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding BrowseSourceDirectoryCommand}">Browse</Button>
<TextBox Margin="2" Text="{Binding SourceDirectory}"/>
<TextBox Margin="2" Text="{Binding SourceDirectory}" />
</DockPanel>
</StackPanel>
</GroupBox>
<GroupBox Header="SVG Generation">
<StackPanel>
<CheckBox DockPanel.Dock="Right" VerticalAlignment="Center" Margin="2" IsChecked="{Binding IsPro}">Pro Version</CheckBox>
<DockPanel Grid.Row="1" Grid.Column="1" LastChildFill="True">
<TextBlock Margin="2" DockPanel.Dock="Left" >FontAwesome Svg Directory:</TextBlock>
<DockPanel LastChildFill="True">
<TextBlock Margin="2" DockPanel.Dock="Left">FontAwesome Svg Directory:</TextBlock>
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding BrowseFontAwesomeSvgDirectoryCommand}">Browse</Button>
<TextBox Margin="2" Text="{Binding FontAwesomeSvgDirectory}"/>
<TextBox Margin="2" Text="{Binding FontAwesomeSvgDirectory}" />
</DockPanel>
<DockPanel Grid.Row="3" Grid.Column="1" LastChildFill="True">
<TextBlock Margin="2" DockPanel.Dock="Left" >Output Directory:</TextBlock>
<DockPanel LastChildFill="True">
<TextBlock Margin="2" DockPanel.Dock="Left">Output Directory:</TextBlock>
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding GenerateSvgFilesCommand}">Generate</Button>
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding BrowseOutputDirectoryCommand}">Browse</Button>
<TextBox Margin="2" Text="{Binding SvgOutputDirectory}"/>
<Button Margin="2" DockPanel.Dock="Right" Command="{Binding BrowseSvgOutputDirectoryCommand}">Browse</Button>
<TextBox Margin="2" Text="{Binding SvgOutputDirectory}" />
</DockPanel>
</StackPanel>
</GroupBox>
</StackPanel>
</Window>
</Window>
31 changes: 17 additions & 14 deletions src/FontAwesome.Generator/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Threading;

using MessageBox = System.Windows.MessageBox;

namespace FontAwesome.Generator
{
public class MainWindowViewModel : INotifyPropertyChanged
Expand All @@ -27,15 +29,12 @@ public class MainWindowViewModel : INotifyPropertyChanged
public string SvgOutputFileNamePrefix { get; set; }

public ICommand GenerateSourceFilesCommand { get; set; }

public ICommand GenerateSvgFilesCommand { get; set; }

public ICommand BrowseSourceDirectoryCommand { get; set; }
public ICommand BrowseFontAwesomeSvgDirectoryCommand { get; set; }

public ICommand BrowseSvgOutputDirectoryCommand { get; set; }

public ICommand BrowseSourceDirectoryCommand { get; set; }

public bool IsWindowsEnabled { get; set; } = true;

public MainWindowViewModel()
Expand All @@ -51,9 +50,9 @@ public MainWindowViewModel()

GenerateSourceFilesCommand = new RelayCommand(obj => GenerateSourceFilesExecuted(), obj => CanExecuteGenerateSourceFiles());
GenerateSvgFilesCommand = new RelayCommand(obj => GenerateSvgFilesExecuted(), obj => CanExecuteGenerateSvgFiles());
BrowseSourceDirectoryCommand = new RelayCommand(obj => BrowseSourceDirectoryExecuted());
BrowseFontAwesomeSvgDirectoryCommand = new RelayCommand(obj => BrowseFontAwesomeSvgDirectoryExecuted());
BrowseSvgOutputDirectoryCommand = new RelayCommand(obj => BrowseSvgOutputDirectoryExecuted());
BrowseSourceDirectoryCommand = new RelayCommand(obj => BrowseSourceDirectoryExecuted());
}

public event PropertyChangedEventHandler? PropertyChanged;
Expand Down Expand Up @@ -114,18 +113,22 @@ private async void GenerateSvgFilesExecuted()
}
}

private void BrowseFontAwesomeSvgDirectoryExecuted()
{
private void BrowseSourceDirectoryExecuted() =>
SourceDirectory = BrowseDirectory(SourceDirectory);

}
private void BrowseFontAwesomeSvgDirectoryExecuted() =>
FontAwesomeSvgDirectory = BrowseDirectory(FontAwesomeSvgDirectory);

private void BrowseSvgOutputDirectoryExecuted()
{
private void BrowseSvgOutputDirectoryExecuted() =>
SvgOutputDirectory = BrowseDirectory(SvgOutputDirectory);

}
private void BrowseSourceDirectoryExecuted()
private string BrowseDirectory(string initialDirectory)
{

var folderBrowserDialog = new FolderBrowserDialog
{
InitialDirectory = initialDirectory
};
return folderBrowserDialog.ShowDialog() == DialogResult.OK ? folderBrowserDialog.SelectedPath : initialDirectory;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@
<ProjectReference Include="..\FontAwesome6.Fonts.Net\FontAwesome6.Fonts.Net.csproj" />
<ProjectReference Include="..\FontAwesome6.Svg.Net\FontAwesome6.Svg.Net.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 9625cbb

Please sign in to comment.