mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-06 09:16:35 +08:00
feat: enhance search.
This commit is contained in:
@@ -25,21 +25,21 @@ public partial class IconDemoViewModel : ObservableObject
|
|||||||
|
|
||||||
foreach (var provider in _resources.MergedDictionaries)
|
foreach (var provider in _resources.MergedDictionaries)
|
||||||
{
|
{
|
||||||
var dic = provider as ResourceDictionary;
|
if (provider is not ResourceDictionary dic) continue;
|
||||||
if (dic?.Keys is null) continue;
|
|
||||||
foreach (var key in dic.Keys)
|
foreach (var key in dic.Keys)
|
||||||
{
|
{
|
||||||
if (dic[key] is not Geometry geometry) continue;
|
if (dic[key] is not Geometry geometry) continue;
|
||||||
var icon = new IconItem { ResourceKey = key.ToString(), Geometry = geometry };
|
var icon = new IconItem
|
||||||
|
{
|
||||||
|
ResourceKey = key.ToString(),
|
||||||
|
Geometry = geometry
|
||||||
|
};
|
||||||
|
|
||||||
if (key.ToString().EndsWith("Stroked"))
|
if (key.ToString().EndsWith("Stroked"))
|
||||||
{
|
_strokedIcons[key.ToString().ToLowerInvariant()] = icon;
|
||||||
_strokedIcons[key.ToString()] = icon;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
_filledIcons[key.ToString().ToLowerInvariant()] = icon;
|
||||||
_filledIcons[key.ToString()] = icon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,16 +51,15 @@ public partial class IconDemoViewModel : ObservableObject
|
|||||||
var search = value?.ToLowerInvariant() ?? string.Empty;
|
var search = value?.ToLowerInvariant() ?? string.Empty;
|
||||||
|
|
||||||
FilteredFilledIcons.Clear();
|
FilteredFilledIcons.Clear();
|
||||||
foreach (var icon in _filledIcons.Values.Where(i => i.ResourceKey?.ToLowerInvariant().Contains(search) == true))
|
foreach (var key in _filledIcons.Keys.Where(i => i.Contains(search)))
|
||||||
{
|
{
|
||||||
FilteredFilledIcons.Add(icon);
|
FilteredFilledIcons.Add(_filledIcons[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilteredStrokedIcons.Clear();
|
FilteredStrokedIcons.Clear();
|
||||||
foreach (var icon in
|
foreach (var key in _strokedIcons.Keys.Where(i => i.Contains(search)))
|
||||||
_strokedIcons.Values.Where(i => i.ResourceKey?.ToLowerInvariant().Contains(search) == true))
|
|
||||||
{
|
{
|
||||||
FilteredStrokedIcons.Add(icon);
|
FilteredStrokedIcons.Add(_strokedIcons[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user