blob: 4e4b971ebf1b58cde7b424d24f22ba20db31f6b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
using Avalonia.Data;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.MarkupExtensions;
using FluentAvalonia.UI.Controls;
using System;
using System.Collections.Generic;
namespace Ryujinx.Ava.UI.Helpers
{
public class GlyphValueConverter : MarkupExtension
{
private readonly string _key;
private static readonly Dictionary<Glyph, string> _glyphs = new()
{
{ Glyph.List, char.ConvertFromUtf32((int)Symbol.List) },
{ Glyph.Grid, char.ConvertFromUtf32((int)Symbol.ViewAll) },
{ Glyph.Chip, char.ConvertFromUtf32(59748) },
};
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)
{
ReflectionBindingExtension binding = new($"[{_key}]")
{
Mode = BindingMode.OneWay,
Source = this,
};
return binding.ProvideValue(serviceProvider);
}
}
}
|