GlyphValueConverter.cs
1 using Avalonia.Markup.Xaml; 2 using FluentAvalonia.UI.Controls; 3 using System; 4 using System.Collections.Generic; 5 6 namespace Ryujinx.Ava.UI.Helpers 7 { 8 public class GlyphValueConverter : MarkupExtension 9 { 10 private readonly string _key; 11 12 private static readonly Dictionary<Glyph, string> _glyphs = new() 13 { 14 { Glyph.List, char.ConvertFromUtf32((int)Symbol.List) }, 15 { Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll) }, 16 { Glyph.Chip, char.ConvertFromUtf32(59748) }, 17 }; 18 19 public GlyphValueConverter(string key) 20 { 21 _key = key; 22 } 23 24 public string this[string key] 25 { 26 get 27 { 28 if (_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out var val)) 29 { 30 return val; 31 } 32 33 return string.Empty; 34 } 35 } 36 37 public override object ProvideValue(IServiceProvider serviceProvider) 38 { 39 return this[_key]; 40 } 41 } 42 }