Skip to content

Commit

Permalink
Develop (#4)
Browse files Browse the repository at this point in the history
* initial

* improvements

* more improvements

* updates

* updated to font awesome 6

* #3: fixed bug when disposing font control

* Update build.yml for Azure Pipelines

* updated to font awesome 6.1.0

* added search text box

* fied some crashs and added search bar to examples

Co-authored-by: Martin Topfstedt <martin.topfstedt@bluetelligence.de>
Co-authored-by: Martin Topfstedt <martin.topfstedt@codinion.com>
  • Loading branch information
3 people authored Mar 16, 2022
1 parent a960192 commit 1d70226
Show file tree
Hide file tree
Showing 20 changed files with 4,744 additions and 487 deletions.
2 changes: 1 addition & 1 deletion Font-Awesome
Submodule Font-Awesome updated 7169 files
2 changes: 1 addition & 1 deletion build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variables:
steps:
- task: GitVersion@5
inputs:
runtime: 'core'
runtime: 'full'
configFilePath: 'build/GitVersion.yml'
updateAssemblyInfo: true

Expand Down
2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.all.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.brands.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.regular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.solid.json

Large diffs are not rendered by default.

3,909 changes: 3,879 additions & 30 deletions src/FontAwesome6.Core/EFontAwesomeIcon.cs

Large diffs are not rendered by default.

257 changes: 133 additions & 124 deletions src/FontAwesome6.Example.UWP/MainPage.xaml

Large diffs are not rendered by default.

77 changes: 50 additions & 27 deletions src/FontAwesome6.Example.UWP/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text.RegularExpressions;

using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
Expand All @@ -13,13 +14,45 @@ namespace FontAwesome6.Example.UWP
{
public class MainWindowViewModel : INotifyPropertyChanged
{
public Visibility Visibility { get; set; }
public EFontAwesomeIcon SelectedIcon { get; set; }

public bool SpinIsEnabled { get; set; }
public double SpinDuration { get; set; }
public bool PulseIsEnabled { get; set; }
public double PulseDuration { get; set; }
public EFlipOrientation FlipOrientation { get; set; }
public double FontSize { get; set; }
public double Rotation { get; set; }

public Brush PrimaryColor { get; set; }

public Brush SecondaryColor { get; set; }
public double PrimaryOpacity { get; set; }

public double SecondaryOpacity { get; set; }

public bool SwapOpacity { get; set; }

public string FilterText { get; set; }

public List<Visibility> Visibilities { get; set; } = new List<Visibility>();

public List<EFlipOrientation> FlipOrientations { get; set; } = new List<EFlipOrientation>();
public List<EFontAwesomeIcon> AllIcons { get; set; } = new List<EFontAwesomeIcon>();

public IEnumerable<EFontAwesomeIcon> VisibleIcons { get; private set; }

public event PropertyChangedEventHandler PropertyChanged;

public MainWindowViewModel()
{
AllIcons = Enum.GetValues(typeof(EFontAwesomeIcon)).Cast<EFontAwesomeIcon>()
.OrderBy(i => i.GetStyle()).ThenBy(i => i.GetIconName()).ToList();
AllIcons.Remove(EFontAwesomeIcon.None);

SelectedIcon = AllIcons.First();
VisibleIcons = AllIcons.ToList();
SelectedIcon = VisibleIcons.First();

FlipOrientations = Enum.GetValues(typeof(EFlipOrientation)).Cast<EFlipOrientation>().ToList();
SpinDuration = 5;
Expand All @@ -44,32 +77,22 @@ public MainWindowViewModel()
SwapOpacity = false;
}

public Visibility Visibility { get; set; }
public EFontAwesomeIcon SelectedIcon { get; set; }

public bool SpinIsEnabled { get; set; }
public double SpinDuration { get; set; }
public bool PulseIsEnabled { get; set; }
public double PulseDuration { get; set; }
public EFlipOrientation FlipOrientation { get; set; }
public double FontSize { get; set; }
public double Rotation { get; set; }

public Brush PrimaryColor { get; set; }

public Brush SecondaryColor { get; set; }
public double PrimaryOpacity { get; set; }

public double SecondaryOpacity { get; set; }

public bool SwapOpacity { get; set; }


public List<Visibility> Visibilities { get; set; } = new List<Visibility>();

public List<EFlipOrientation> FlipOrientations { get; set; } = new List<EFlipOrientation>();
public List<EFontAwesomeIcon> AllIcons { get; set; } = new List<EFontAwesomeIcon>();
private void OnFilterTextChanged()
{
UpdateVisibleIcons();
}

public event PropertyChangedEventHandler PropertyChanged;
private void UpdateVisibleIcons()
{
try
{
VisibleIcons = AllIcons.Where(icon => Regex.IsMatch(icon.GetIconName(), FilterText, RegexOptions.IgnoreCase));
}
catch
{
VisibleIcons = AllIcons;
}
SelectedIcon = VisibleIcons.FirstOrDefault();
}
}
}
378 changes: 195 additions & 183 deletions src/FontAwesome6.Example.WPF.Shared/MainWindow.xaml

Large diffs are not rendered by default.

75 changes: 49 additions & 26 deletions src/FontAwesome6.Example.WPF.Shared/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Media;

namespace FontAwesome6.Example.WPF
{
public class MainWindowViewModel : INotifyPropertyChanged
{
public MainWindowViewModel()
{
AllIcons = Enum.GetValues(typeof(EFontAwesomeIcon)).Cast<EFontAwesomeIcon>()
.OrderBy(i => i.GetStyle()).ThenBy(i => i.GetIconName()).ToList();
AllIcons.Remove(EFontAwesomeIcon.None);

SelectedIcon = AllIcons.First();

FlipOrientations = Enum.GetValues(typeof(EFlipOrientation)).Cast<EFlipOrientation>().ToList();
SpinDuration = 5;
PulseDuration = 5;

FontSize = 30;
Rotation = 0;

Visibilities = Enum.GetValues(typeof(Visibility)).Cast<Visibility>().ToList();
Visibility = Visibility.Visible;

// if you have a default icon color you can overwrite the defaults instead of setting the color for each icon
//FontAwesomeDefaults.PrimaryColor = new SolidColorBrush(Colors.Red);
//FontAwesomeDefaults.SecondaryColor = new SolidColorBrush(Colors.Green);

PrimaryColor = Brushes.Black;
SecondaryColor = Brushes.Black;
}

public Visibility Visibility { get; set; }
public EFontAwesomeIcon SelectedIcon { get; set; }

Expand All @@ -57,12 +32,60 @@ public MainWindowViewModel()

public bool SwapOpacity { get; set; } = false;

public string FilterText { get; set; }

public List<Visibility> Visibilities { get; set; } = new List<Visibility>();

public List<EFlipOrientation> FlipOrientations { get; set; } = new List<EFlipOrientation>();
public List<EFontAwesomeIcon> AllIcons { get; set; } = new List<EFontAwesomeIcon>();

public IEnumerable<EFontAwesomeIcon> VisibleIcons { get; private set; }

public event PropertyChangedEventHandler PropertyChanged;

public MainWindowViewModel()
{
AllIcons = Enum.GetValues(typeof(EFontAwesomeIcon)).Cast<EFontAwesomeIcon>()
.OrderBy(i => i.GetStyle()).ThenBy(i => i.GetIconName()).ToList();
AllIcons.Remove(EFontAwesomeIcon.None);

SelectedIcon = AllIcons.First();
VisibleIcons = AllIcons.ToList();

FlipOrientations = Enum.GetValues(typeof(EFlipOrientation)).Cast<EFlipOrientation>().ToList();
SpinDuration = 5;
PulseDuration = 5;

FontSize = 30;
Rotation = 0;

Visibilities = Enum.GetValues(typeof(Visibility)).Cast<Visibility>().ToList();
Visibility = Visibility.Visible;

// if you have a default icon color you can overwrite the defaults instead of setting the color for each icon
//FontAwesomeDefaults.PrimaryColor = new SolidColorBrush(Colors.Red);
//FontAwesomeDefaults.SecondaryColor = new SolidColorBrush(Colors.Green);

PrimaryColor = Brushes.Black;
SecondaryColor = Brushes.Black;
}

private void OnFilterTextChanged()
{
UpdateVisibleIcons();
}

private void UpdateVisibleIcons()
{
try
{
VisibleIcons = AllIcons.Where(icon => Regex.IsMatch(icon.GetIconName(), FilterText, RegexOptions.IgnoreCase));
}
catch
{
VisibleIcons = AllIcons;
}
SelectedIcon = VisibleIcons.FirstOrDefault();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>FontAwesome6.Example.WinUI</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
28 changes: 18 additions & 10 deletions src/FontAwesome6.Example.WinUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,24 @@
</StackPanel>
</StackPanel>

<ListView Grid.Row="2" Grid.Column="0" ItemsSource="{Binding AllIcons}" SelectedItem="{Binding SelectedIcon, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<faf:FontAwesome Icon="{Binding}" Width="32" Height="32" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid Grid.Row="2" Grid.Column="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Margin="5"
Text="{Binding FilterText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<ListView Grid.Row="1" Grid.Column="0" ItemsSource="{Binding VisibleIcons}" SelectedItem="{Binding SelectedIcon, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<faf:FontAwesome Icon="{Binding}" Width="32" Height="32" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>

<Grid Grid.Row="2" Grid.Column="1">
<Grid.ColumnDefinitions>
Expand Down
Loading

0 comments on commit 1d70226

Please sign in to comment.