diff options
Diffstat (limited to 'Ryujinx.Ava/Ui/Controls/GlyphValueConverter.cs')
-rw-r--r-- | Ryujinx.Ava/Ui/Controls/GlyphValueConverter.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Ryujinx.Ava/Ui/Controls/GlyphValueConverter.cs b/Ryujinx.Ava/Ui/Controls/GlyphValueConverter.cs new file mode 100644 index 00000000..63c6a17d --- /dev/null +++ b/Ryujinx.Ava/Ui/Controls/GlyphValueConverter.cs @@ -0,0 +1,49 @@ +using Avalonia.Data; +using Avalonia.Markup.Xaml; +using FluentAvalonia.UI.Controls; +using System; +using System.Collections.Generic; + +namespace Ryujinx.Ava.Ui.Controls +{ + public class GlyphValueConverter : MarkupExtension + { + private string _key; + + private static Dictionary<Glyph, string> _glyphs = new Dictionary<Glyph, string> + { + { Glyph.List, char.ConvertFromUtf32((int)Symbol.List).ToString() }, + { Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll).ToString() }, + { Glyph.Chip, char.ConvertFromUtf32(59748).ToString() } + }; + + public GlyphValueConverter(string key) + { + _key = key; + } + + public string this[string key] + { + get + { + if (_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out var val)) + { + return val; + } + + return string.Empty; + } + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension binding = new($"[{_key}]") + { + Mode = BindingMode.OneWay, + Source = this + }; + + return binding.ProvideValue(serviceProvider); + } + } +}
\ No newline at end of file |