Add Glyph Support

This commit is contained in:
Kevin Zhang 2021-07-31 15:44:41 +08:00
parent 309ee29bda
commit fd39b60f7b
3 changed files with 21 additions and 5 deletions

View file

@ -47,7 +47,15 @@ namespace Flow.Launcher.Plugin
public delegate ImageSource IconDelegate(); public delegate ImageSource IconDelegate();
public IconDelegate Icon; /// <summary>
/// Delegate to Get Image Source
/// </summary>
public IconDelegate Icon { get; set; }
/// <summary>
/// Information for Glyph Icon
/// </summary>
public GlyphInfo Glyph { get; init; }
/// <summary> /// <summary>

View file

@ -42,7 +42,10 @@
<ColumnDefinition Width="0" /> <ColumnDefinition Width="0" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image x:Name="ImageIcon" Width="32" Height="32" HorizontalAlignment="Left" <Image x:Name="ImageIcon" Width="32" Height="32" HorizontalAlignment="Left"
Source="{Binding Image.Value}" /> Source="{Binding Image.Value}" Visibility="{Binding ShowImage}" />
<TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center"
Text="{Binding Glyph.Glyph}" FontFamily="{Binding Glyph.FontFamily}" FontSize="24"
Visibility="{Binding ShowGlyph}"/>
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch"> <Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />

View file

@ -66,6 +66,8 @@ namespace Flow.Launcher.ViewModel
{ {
OnPropertyChanged(nameof(Image)); OnPropertyChanged(nameof(Image));
}); });
Glyph = Result.Glyph;
} }
Settings = settings; Settings = settings;
@ -74,7 +76,8 @@ namespace Flow.Launcher.ViewModel
public Settings Settings { get; private set; } public Settings Settings { get; private set; }
public Visibility ShowOpenResultHotkey => Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Hidden; public Visibility ShowOpenResultHotkey => Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Hidden;
public Visibility ShowIcon => Result.IcoPath != null || Result.Icon is not null || Glyph == null ? Visibility.Visible : Visibility.Hidden;
public Visibility ShowGlyph => Glyph is not null ? Visibility.Visible : Visibility.Hidden;
public string OpenResultModifiers => Settings.OpenResultModifiers; public string OpenResultModifiers => Settings.OpenResultModifiers;
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip) public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
@ -87,6 +90,8 @@ namespace Flow.Launcher.ViewModel
public LazyAsync<ImageSource> Image { get; set; } public LazyAsync<ImageSource> Image { get; set; }
public GlyphInfo Glyph { get; set; }
private async ValueTask<ImageSource> SetImage() private async ValueTask<ImageSource> SetImage()
{ {
var imagePath = Result.IcoPath; var imagePath = Result.IcoPath;