minor fix

This commit is contained in:
qhy040404
2024-03-05 17:28:01 +08:00
parent 4185336556
commit 2ad6dad282
6 changed files with 15 additions and 11 deletions

View File

@@ -4,12 +4,11 @@
using CommunityToolkit.WinUI.Controls;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Control.SuggestBox;
using System.Collections.Frozen;
namespace Snap.Hutao.View.Control;
[DependencyProperty("FilterCommand", typeof(ICommand))]
[DependencyProperty("AvailableTokens", typeof(FrozenDictionary<string, SearchToken>))]
[DependencyProperty("AvailableTokens", typeof(IReadOnlyDictionary<string, SearchToken>))]
internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
{
public AutoSuggestTokenBox()
@@ -54,7 +53,7 @@ internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
return;
}
args.Item = AvailableTokens[args.TokenText];
args.Item = AvailableTokens.GetValueOrDefault(args.TokenText) ?? new SearchToken(args.TokenText, SearchTokenKind.Others);
}
private void OnTokenItemModified(TokenizingTextBox sender, object args)

View File

@@ -11,6 +11,7 @@ internal enum SearchTokenKind
ElementNames,
FightProperties,
ItemQualities,
Others,
Weapons,
WeaponTypes,
}

View File

@@ -11,4 +11,6 @@ internal static class KnownColors
public static readonly Color Orange = StructMarshal.Color(0xFFBC6932);
public static readonly Color Purple = StructMarshal.Color(0xFFA156E0);
public static readonly Color Blue = StructMarshal.Color(0xFF5180CB);
public static readonly Color Green = StructMarshal.Color(0xFF2A8F72);
public static readonly Color White = StructMarshal.Color(0xFF72778B);
}

View File

@@ -3,8 +3,8 @@
using Microsoft.UI;
using Snap.Hutao.Control;
using Snap.Hutao.Control.Theme;
using Snap.Hutao.Model.Intrinsic;
using Snap.Hutao.Win32;
using System.Collections.Frozen;
using Windows.UI;
@@ -35,11 +35,11 @@ internal sealed class QualityColorConverter : ValueConverter<QualityType, Color>
{
return quality switch
{
QualityType.QUALITY_WHITE => StructMarshal.Color(0xFF72778B),
QualityType.QUALITY_GREEN => StructMarshal.Color(0xFF2A8F72),
QualityType.QUALITY_BLUE => StructMarshal.Color(0xFF5180CB),
QualityType.QUALITY_PURPLE => StructMarshal.Color(0xFFA156E0),
QualityType.QUALITY_ORANGE or QualityType.QUALITY_ORANGE_SP => StructMarshal.Color(0xFFBC6932),
QualityType.QUALITY_WHITE => KnownColors.White,
QualityType.QUALITY_GREEN => KnownColors.Green,
QualityType.QUALITY_BLUE => KnownColors.Blue,
QualityType.QUALITY_PURPLE => KnownColors.Purple,
QualityType.QUALITY_ORANGE or QualityType.QUALITY_ORANGE_SP => KnownColors.Orange,
_ => Colors.Transparent,
};
}

View File

@@ -70,7 +70,8 @@ internal static class AvatarFilter
matches.Add(tokens.Contains(avatar.Name));
break;
default:
throw Must.NeverHappen();
matches.Add(false);
break;
}
}

View File

@@ -56,7 +56,8 @@ internal static class WeaponFilter
matches.Add(tokens.Contains(weapon.Name));
break;
default:
throw Must.NeverHappen();
matches.Add(false);
break;
}
}