|
| 1 | +using Avalonia.Data.Converters; |
| 2 | +using BangumiNet.Api.V0.V0.Search.Subjects; |
| 3 | +using BangumiNet.ViewModels; |
| 4 | +using System.Globalization; |
| 5 | + |
| 6 | +namespace BangumiNet.Converters; |
| 7 | + |
| 8 | +public class SearchSortCvt : IValueConverter |
| 9 | +{ |
| 10 | + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
| 11 | + => (SubjectsPostRequestBody_sort?)value switch |
| 12 | + { |
| 13 | + SubjectsPostRequestBody_sort.Match => "相关", |
| 14 | + SubjectsPostRequestBody_sort.Heat => "热度", |
| 15 | + SubjectsPostRequestBody_sort.Rank => "排名", |
| 16 | + SubjectsPostRequestBody_sort.Score => "评分", |
| 17 | + null => "默认", |
| 18 | + _ => throw new NotImplementedException(), |
| 19 | + }; |
| 20 | + |
| 21 | + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
| 22 | + => throw new NotImplementedException(); |
| 23 | +} |
| 24 | +public class SearchTypeCvt : IValueConverter |
| 25 | +{ |
| 26 | + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
| 27 | + => (SearchType?)value switch |
| 28 | + { |
| 29 | + SearchType.Subject => "项目", |
| 30 | + SearchType.Character => "角色", |
| 31 | + SearchType.Person => "人物", |
| 32 | + null => string.Empty, |
| 33 | + _ => throw new NotImplementedException(), |
| 34 | + }; |
| 35 | + |
| 36 | + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
| 37 | + => throw new NotImplementedException(); |
| 38 | +} |
0 commit comments