mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
code style
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources/>
|
||||
<ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.TokenizingTextBox/TokenizingTextBox.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Control/Loading.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Control/Image/CachedImage.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Control/Theme/Card.xaml"/>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using CommunityToolkit.WinUI.Controls;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Snap.Hutao.Control.SuggestBox;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Snap.Hutao.Control.Extension;
|
||||
|
||||
namespace Snap.Hutao.View.Control;
|
||||
namespace Snap.Hutao.Control.AutoSuggestBox;
|
||||
|
||||
[DependencyProperty("FilterCommand", typeof(ICommand))]
|
||||
[DependencyProperty("FilterCommandParameter", typeof(object))]
|
||||
[DependencyProperty("AvailableTokens", typeof(IReadOnlyDictionary<string, SearchToken>))]
|
||||
internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
|
||||
{
|
||||
public AutoSuggestTokenBox()
|
||||
{
|
||||
DefaultStyleKey = typeof(TokenizingTextBox);
|
||||
TextChanged += OnFilterSuggestionRequested;
|
||||
QuerySubmitted += OnQuerySubmitted;
|
||||
TokenItemAdding += OnTokenItemAdding;
|
||||
@@ -20,7 +24,7 @@ internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
|
||||
TokenItemRemoved += OnTokenItemModified;
|
||||
}
|
||||
|
||||
private void OnFilterSuggestionRequested(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||
private void OnFilterSuggestionRequested(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Text))
|
||||
{
|
||||
@@ -30,20 +34,20 @@ internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
|
||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||
{
|
||||
sender.ItemsSource = AvailableTokens.Values.Where(q => q.Value.Contains(Text, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
// TODO: CornerRadius
|
||||
// Popup? popup = this.FindDescendant("SuggestionsPopup") as Popup;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||
private void OnQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||
{
|
||||
if (args.ChosenSuggestion is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FilterCommand.CanExecute(null))
|
||||
{
|
||||
FilterCommand.Execute(null);
|
||||
}
|
||||
CommandExtension.TryExecute(FilterCommand, FilterCommandParameter);
|
||||
}
|
||||
|
||||
private void OnTokenItemAdding(TokenizingTextBox sender, TokenItemAddingEventArgs args)
|
||||
@@ -53,14 +57,11 @@ internal sealed partial class AutoSuggestTokenBox : TokenizingTextBox
|
||||
return;
|
||||
}
|
||||
|
||||
args.Item = AvailableTokens.GetValueOrDefault(args.TokenText) ?? new SearchToken(args.TokenText, SearchTokenKind.Others);
|
||||
args.Item = AvailableTokens.GetValueOrDefault(args.TokenText) ?? new SearchToken(SearchTokenKind.None, args.TokenText);
|
||||
}
|
||||
|
||||
private void OnTokenItemModified(TokenizingTextBox sender, object args)
|
||||
{
|
||||
if (FilterCommand.CanExecute(null))
|
||||
{
|
||||
FilterCommand.Execute(null);
|
||||
}
|
||||
CommandExtension.TryExecute(FilterCommand, FilterCommandParameter);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
using Windows.UI;
|
||||
|
||||
namespace Snap.Hutao.Control.SuggestBox;
|
||||
namespace Snap.Hutao.Control.AutoSuggestBox;
|
||||
|
||||
internal sealed class SearchToken
|
||||
{
|
||||
public SearchToken(string value, SearchTokenKind kind, Uri? iconUri = null, Uri? sideIconUri = null, Color? quality = null)
|
||||
public SearchToken(SearchTokenKind kind, string value, Uri? iconUri = null, Uri? sideIconUri = null, Color? quality = null)
|
||||
{
|
||||
Value = value;
|
||||
Kind = kind;
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Control.AutoSuggestBox;
|
||||
|
||||
internal enum SearchTokenKind
|
||||
{
|
||||
None,
|
||||
AssociationType,
|
||||
Avatar,
|
||||
BodyType,
|
||||
ElementName,
|
||||
FightProperty,
|
||||
ItemQuality,
|
||||
Weapon,
|
||||
WeaponType,
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using CommunityToolkit.WinUI.Behaviors;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Snap.Hutao.Control.Extension;
|
||||
|
||||
namespace Snap.Hutao.Control.Behavior;
|
||||
|
||||
@@ -45,10 +46,6 @@ internal sealed partial class InvokeCommandOnLoadedBehavior : BehaviorBase<UIEle
|
||||
return;
|
||||
}
|
||||
|
||||
if (Command is not null && Command.CanExecute(CommandParameter))
|
||||
{
|
||||
Command.Execute(CommandParameter);
|
||||
executed = true;
|
||||
}
|
||||
executed = Command.TryExecute(CommandParameter);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using CommunityToolkit.WinUI.Behaviors;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Snap.Hutao.Control.Extension;
|
||||
|
||||
namespace Snap.Hutao.Control.Behavior;
|
||||
|
||||
@@ -49,10 +50,7 @@ internal sealed partial class PeriodicInvokeCommandOrOnActualThemeChangedBehavio
|
||||
return;
|
||||
}
|
||||
|
||||
if (Command is not null && Command.CanExecute(CommandParameter))
|
||||
{
|
||||
Command.Execute(CommandParameter);
|
||||
}
|
||||
Command.TryExecute(CommandParameter);
|
||||
}
|
||||
|
||||
private async ValueTask RunCoreAsync()
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Control.Extension;
|
||||
|
||||
internal static class CommandExtension
|
||||
{
|
||||
public static bool TryExecute(this ICommand? command, object? parameter = null)
|
||||
{
|
||||
if (command is not null && command.CanExecute(parameter))
|
||||
{
|
||||
command.Execute(parameter);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Control.SuggestBox;
|
||||
|
||||
internal enum SearchTokenKind
|
||||
{
|
||||
AssociationTypes,
|
||||
Avatars,
|
||||
BodyTypes,
|
||||
ElementNames,
|
||||
FightProperties,
|
||||
ItemQualities,
|
||||
Others,
|
||||
Weapons,
|
||||
WeaponTypes,
|
||||
}
|
||||
@@ -15,6 +15,12 @@ namespace Snap.Hutao.Extension;
|
||||
[HighQuality]
|
||||
internal static partial class EnumerableExtension
|
||||
{
|
||||
public static void Deconstruct<TKey, TElement>(this IGrouping<TKey, TElement> grouping, out TKey key, out IEnumerable<TElement> elements)
|
||||
{
|
||||
key = grouping.Key;
|
||||
elements = grouping;
|
||||
}
|
||||
|
||||
public static TElement? ElementAtOrLastOrDefault<TElement>(this IEnumerable<TElement> source, int index)
|
||||
{
|
||||
return source.ElementAtOrDefault(index) ?? source.LastOrDefault();
|
||||
|
||||
@@ -33,18 +33,18 @@ internal sealed class AssociationTypeIconConverter : ValueConverter<AssociationT
|
||||
{
|
||||
AssociationType.ASSOC_TYPE_MONDSTADT => "Mengde",
|
||||
AssociationType.ASSOC_TYPE_LIYUE => "Liyue",
|
||||
AssociationType.ASSOC_TYPE_FATUI => null,
|
||||
AssociationType.ASSOC_TYPE_FATUI => default,
|
||||
AssociationType.ASSOC_TYPE_INAZUMA => "Inazuma",
|
||||
AssociationType.ASSOC_TYPE_RANGER => null,
|
||||
AssociationType.ASSOC_TYPE_RANGER => default,
|
||||
AssociationType.ASSOC_TYPE_SUMERU => "Sumeru",
|
||||
AssociationType.ASSOC_TYPE_FONTAINE => "Fontaine",
|
||||
AssociationType.ASSOC_TYPE_NATLAN => null,
|
||||
AssociationType.ASSOC_TYPE_SNEZHNAYA => null,
|
||||
AssociationType.ASSOC_TYPE_NATLAN => default,
|
||||
AssociationType.ASSOC_TYPE_SNEZHNAYA => default,
|
||||
_ => throw Must.NeverHappen(),
|
||||
};
|
||||
|
||||
return association is null
|
||||
? null
|
||||
? default
|
||||
: Web.HutaoEndpoints.StaticRaw("ChapterIcon", $"UI_ChapterIcon_{association}.png").ToUri();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,16 @@ internal sealed class QualityColorConverter : ValueConverter<QualityType, Color>
|
||||
KeyValuePair.Create(SH.ModelIntrinsicItemQualityRed, QualityType.QUALITY_ORANGE_SP),
|
||||
]);
|
||||
|
||||
private static readonly FrozenDictionary<QualityType, Color> QualityTypeToColor = FrozenDictionary.ToFrozenDictionary(
|
||||
[
|
||||
KeyValuePair.Create(QualityType.QUALITY_WHITE, KnownColors.White),
|
||||
KeyValuePair.Create(QualityType.QUALITY_GREEN, KnownColors.Green),
|
||||
KeyValuePair.Create(QualityType.QUALITY_BLUE, KnownColors.Blue),
|
||||
KeyValuePair.Create(QualityType.QUALITY_PURPLE, KnownColors.Purple),
|
||||
KeyValuePair.Create(QualityType.QUALITY_ORANGE, KnownColors.Orange),
|
||||
KeyValuePair.Create(QualityType.QUALITY_ORANGE_SP, KnownColors.Orange),
|
||||
]);
|
||||
|
||||
public static Color QualityNameToColor(string qualityName)
|
||||
{
|
||||
return QualityToColor(LocalizedNameToQualityType.GetValueOrDefault(qualityName));
|
||||
@@ -33,15 +43,7 @@ internal sealed class QualityColorConverter : ValueConverter<QualityType, Color>
|
||||
|
||||
public static Color QualityToColor(QualityType quality)
|
||||
{
|
||||
return quality switch
|
||||
{
|
||||
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,
|
||||
};
|
||||
return QualityTypeToColor.GetValueOrDefault(quality, Colors.Transparent);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shca="using:Snap.Hutao.Control.AutoSuggestBox"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
@@ -303,14 +304,12 @@
|
||||
Margin="8,8,0,0"
|
||||
LocalSettingKeySuffixForCurrent="WikiAvatarPage.Avatars"/>
|
||||
</CommandBar.Content>
|
||||
<!--<AppBarButton Icon="{shcm:FontIcon Glyph=}" Label="搜索提示"/>-->
|
||||
<AppBarElementContainer>
|
||||
<shvcont:AutoSuggestTokenBox
|
||||
x:Name="AvatarSuggestBox"
|
||||
<shca:AutoSuggestTokenBox
|
||||
Width="600"
|
||||
Height="44"
|
||||
Margin="6,-2,6,6"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalContentAlignment="Center"
|
||||
AvailableTokens="{Binding AvailableTokens}"
|
||||
FilterCommand="{Binding FilterCommand}"
|
||||
@@ -318,10 +317,20 @@
|
||||
MaximumTokens="5"
|
||||
PlaceholderText="{shcm:ResourceString Name=ViewPageWiKiAvatarAutoSuggestBoxPlaceHolder}"
|
||||
QueryIcon="{cw:FontIconSource Glyph=}"
|
||||
Style="{StaticResource DefaultTokenizingTextBoxStyle}"
|
||||
SuggestedItemTemplate="{StaticResource TokenTemplate}"
|
||||
SuggestedItemsSource="{Binding AvailableTokens.Values}"
|
||||
Text="{Binding FilterToken, Mode=TwoWay}"
|
||||
TokenItemTemplate="{StaticResource TokenTemplate}"/>
|
||||
TokenItemTemplate="{StaticResource TokenTemplate}">
|
||||
<shca:AutoSuggestTokenBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwc:WrapPanel
|
||||
cw:FrameworkElementExtensions.AncestorType="shca:AutoSuggestTokenBox"
|
||||
HorizontalSpacing="2"
|
||||
StretchChild="Last"/>
|
||||
</ItemsPanelTemplate>
|
||||
</shca:AutoSuggestTokenBox.ItemsPanel>
|
||||
</shca:AutoSuggestTokenBox>
|
||||
</AppBarElementContainer>
|
||||
<AppBarButton
|
||||
Command="{Binding CultivateCommand}"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:mxic="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shca="using:Snap.Hutao.Control.AutoSuggestBox"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shci="using:Snap.Hutao.Control.Image"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
@@ -172,7 +173,7 @@
|
||||
LocalSettingKeySuffixForCurrent="WikiWeaponPage.Weapons"/>
|
||||
</CommandBar.Content>
|
||||
<AppBarElementContainer>
|
||||
<shvc:AutoSuggestTokenBox
|
||||
<shca:AutoSuggestTokenBox
|
||||
x:Name="WeaponSuggestBox"
|
||||
Width="600"
|
||||
Height="44"
|
||||
@@ -188,7 +189,16 @@
|
||||
SuggestedItemTemplate="{StaticResource TokenTemplate}"
|
||||
SuggestedItemsSource="{Binding AvailableTokens.Values}"
|
||||
Text="{Binding FilterToken, Mode=TwoWay}"
|
||||
TokenItemTemplate="{StaticResource TokenTemplate}"/>
|
||||
TokenItemTemplate="{StaticResource TokenTemplate}">
|
||||
<shca:AutoSuggestTokenBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<cwc:WrapPanel
|
||||
cw:FrameworkElementExtensions.AncestorType="shca:AutoSuggestTokenBox"
|
||||
HorizontalSpacing="2"
|
||||
StretchChild="Last"/>
|
||||
</ItemsPanelTemplate>
|
||||
</shca:AutoSuggestTokenBox.ItemsPanel>
|
||||
</shca:AutoSuggestTokenBox>
|
||||
</AppBarElementContainer>
|
||||
<AppBarButton
|
||||
Command="{Binding CultivateCommand}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Control.SuggestBox;
|
||||
using Snap.Hutao.Control.AutoSuggestBox;
|
||||
using Snap.Hutao.Model.Intrinsic.Frozen;
|
||||
using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -27,46 +27,46 @@ internal static class AvatarFilter
|
||||
{
|
||||
List<bool> matches = [];
|
||||
|
||||
foreach (IGrouping<SearchTokenKind, string> tokens in input.GroupBy(token => token.Kind, token => token.Value))
|
||||
foreach ((SearchTokenKind kind, IEnumerable<string> tokens) in input.GroupBy(token => token.Kind, token => token.Value))
|
||||
{
|
||||
switch (tokens.Key)
|
||||
switch (kind)
|
||||
{
|
||||
case SearchTokenKind.ElementNames:
|
||||
case SearchTokenKind.ElementName:
|
||||
if (IntrinsicFrozen.ElementNames.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(avatar.FetterInfo.VisionBefore));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.AssociationTypes:
|
||||
case SearchTokenKind.AssociationType:
|
||||
if (IntrinsicFrozen.AssociationTypes.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(avatar.FetterInfo.Association.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.WeaponTypes:
|
||||
case SearchTokenKind.WeaponType:
|
||||
if (IntrinsicFrozen.WeaponTypes.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(avatar.Weapon.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.ItemQualities:
|
||||
case SearchTokenKind.ItemQuality:
|
||||
if (IntrinsicFrozen.ItemQualities.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(avatar.Quality.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.BodyTypes:
|
||||
case SearchTokenKind.BodyType:
|
||||
if (IntrinsicFrozen.BodyTypes.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(avatar.Body.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.Avatars:
|
||||
case SearchTokenKind.Avatar:
|
||||
matches.Add(tokens.Contains(avatar.Name));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Control.SuggestBox;
|
||||
using Snap.Hutao.Control.AutoSuggestBox;
|
||||
using Snap.Hutao.Model.Intrinsic.Frozen;
|
||||
using Snap.Hutao.Model.Metadata.Weapon;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -27,32 +27,32 @@ internal static class WeaponFilter
|
||||
{
|
||||
List<bool> matches = [];
|
||||
|
||||
foreach (IGrouping<SearchTokenKind, string> tokens in input.GroupBy(token => token.Kind, token => token.Value))
|
||||
foreach ((SearchTokenKind kind, IEnumerable<string> tokens) in input.GroupBy(token => token.Kind, token => token.Value))
|
||||
{
|
||||
switch (tokens.Key)
|
||||
switch (kind)
|
||||
{
|
||||
case SearchTokenKind.WeaponTypes:
|
||||
case SearchTokenKind.WeaponType:
|
||||
if (IntrinsicFrozen.WeaponTypes.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(weapon.WeaponType.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.ItemQualities:
|
||||
case SearchTokenKind.ItemQuality:
|
||||
if (IntrinsicFrozen.ItemQualities.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(weapon.Quality.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.FightProperties:
|
||||
case SearchTokenKind.FightProperty:
|
||||
if (IntrinsicFrozen.FightProperties.Overlaps(tokens))
|
||||
{
|
||||
matches.Add(tokens.Contains(weapon.GrowCurves.ElementAtOrDefault(1)?.Type.GetLocalizedDescriptionOrDefault()));
|
||||
}
|
||||
|
||||
break;
|
||||
case SearchTokenKind.Weapons:
|
||||
case SearchTokenKind.Weapon:
|
||||
matches.Add(tokens.Contains(weapon.Name));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Control.AutoSuggestBox;
|
||||
using Snap.Hutao.Control.Collection.AdvancedCollectionView;
|
||||
using Snap.Hutao.Control.SuggestBox;
|
||||
using Snap.Hutao.Factory.ContentDialog;
|
||||
using Snap.Hutao.Model.Calculable;
|
||||
using Snap.Hutao.Model.Entity.Primitive;
|
||||
@@ -116,12 +116,12 @@ internal sealed partial class WikiAvatarViewModel : Abstraction.ViewModel
|
||||
|
||||
availableTokens = FrozenDictionary.ToFrozenDictionary(
|
||||
[
|
||||
.. avatars.Select(avatar => KeyValuePair.Create(avatar.Name, new SearchToken(avatar.Name, SearchTokenKind.Avatars, sideIconUri: AvatarSideIconConverter.IconNameToUri(avatar.SideIcon)))),
|
||||
.. IntrinsicFrozen.AssociationTypes.Select(assoc => KeyValuePair.Create(assoc, new SearchToken(assoc, SearchTokenKind.AssociationTypes, iconUri: AssociationTypeIconConverter.AssociationTypeNameToIconUri(assoc)))),
|
||||
.. IntrinsicFrozen.BodyTypes.Select(b => KeyValuePair.Create(b, new SearchToken(b, SearchTokenKind.BodyTypes))),
|
||||
.. IntrinsicFrozen.ElementNames.Select(e => KeyValuePair.Create(e, new SearchToken(e, SearchTokenKind.ElementNames, iconUri: ElementNameIconConverter.ElementNameToIconUri(e)))),
|
||||
.. IntrinsicFrozen.ItemQualities.Select(i => KeyValuePair.Create(i, new SearchToken(i, SearchTokenKind.ItemQualities, quality: QualityColorConverter.QualityNameToColor(i)))),
|
||||
.. IntrinsicFrozen.WeaponTypes.Select(w => KeyValuePair.Create(w, new SearchToken(w, SearchTokenKind.WeaponTypes, iconUri: WeaponTypeIconConverter.WeaponTypeNameToIconUri(w)))),
|
||||
.. avatars.Select(avatar => KeyValuePair.Create(avatar.Name, new SearchToken(SearchTokenKind.Avatar, avatar.Name, sideIconUri: AvatarSideIconConverter.IconNameToUri(avatar.SideIcon)))),
|
||||
.. IntrinsicFrozen.AssociationTypes.Select(assoc => KeyValuePair.Create(assoc, new SearchToken(SearchTokenKind.AssociationType, assoc, iconUri: AssociationTypeIconConverter.AssociationTypeNameToIconUri(assoc)))),
|
||||
.. IntrinsicFrozen.BodyTypes.Select(b => KeyValuePair.Create(b, new SearchToken(SearchTokenKind.BodyType, b))),
|
||||
.. IntrinsicFrozen.ElementNames.Select(e => KeyValuePair.Create(e, new SearchToken(SearchTokenKind.ElementName, e, iconUri: ElementNameIconConverter.ElementNameToIconUri(e)))),
|
||||
.. IntrinsicFrozen.ItemQualities.Select(i => KeyValuePair.Create(i, new SearchToken(SearchTokenKind.ItemQuality, i, quality: QualityColorConverter.QualityNameToColor(i)))),
|
||||
.. IntrinsicFrozen.WeaponTypes.Select(w => KeyValuePair.Create(w, new SearchToken(SearchTokenKind.WeaponType, w, iconUri: WeaponTypeIconConverter.WeaponTypeNameToIconUri(w)))),
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Control.AutoSuggestBox;
|
||||
using Snap.Hutao.Control.Collection.AdvancedCollectionView;
|
||||
using Snap.Hutao.Control.SuggestBox;
|
||||
using Snap.Hutao.Factory.ContentDialog;
|
||||
using Snap.Hutao.Model.Calculable;
|
||||
using Snap.Hutao.Model.Entity.Primitive;
|
||||
@@ -113,10 +113,10 @@ internal sealed partial class WikiWeaponViewModel : Abstraction.ViewModel
|
||||
|
||||
availableTokens = FrozenDictionary.ToFrozenDictionary(
|
||||
[
|
||||
.. weapons.Select(w => KeyValuePair.Create(w.Name, new SearchToken(w.Name, SearchTokenKind.Weapons, sideIconUri: EquipIconConverter.IconNameToUri(w.Icon)))),
|
||||
.. IntrinsicFrozen.FightProperties.Select(f => KeyValuePair.Create(f, new SearchToken(f, SearchTokenKind.FightProperties))),
|
||||
.. IntrinsicFrozen.ItemQualities.Select(i => KeyValuePair.Create(i, new SearchToken(i, SearchTokenKind.ItemQualities, quality: QualityColorConverter.QualityNameToColor(i)))),
|
||||
.. IntrinsicFrozen.WeaponTypes.Select(w => KeyValuePair.Create(w, new SearchToken(w, SearchTokenKind.WeaponTypes, iconUri: WeaponTypeIconConverter.WeaponTypeNameToIconUri(w)))),
|
||||
.. weapons.Select(w => KeyValuePair.Create(w.Name, new SearchToken(SearchTokenKind.Weapon, w.Name, sideIconUri: EquipIconConverter.IconNameToUri(w.Icon)))),
|
||||
.. IntrinsicFrozen.FightProperties.Select(f => KeyValuePair.Create(f, new SearchToken(SearchTokenKind.FightProperty, f))),
|
||||
.. IntrinsicFrozen.ItemQualities.Select(i => KeyValuePair.Create(i, new SearchToken(SearchTokenKind.ItemQuality, i, quality: QualityColorConverter.QualityNameToColor(i)))),
|
||||
.. IntrinsicFrozen.WeaponTypes.Select(w => KeyValuePair.Create(w, new SearchToken(SearchTokenKind.WeaponType, w, iconUri: WeaponTypeIconConverter.WeaponTypeNameToIconUri(w)))),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user