diff --git a/demo/Semi.Avalonia.Demo/ViewModels/IconDemoViewModel.cs b/demo/Semi.Avalonia.Demo/ViewModels/IconDemoViewModel.cs index 09e8fc8..75bc090 100644 --- a/demo/Semi.Avalonia.Demo/ViewModels/IconDemoViewModel.cs +++ b/demo/Semi.Avalonia.Demo/ViewModels/IconDemoViewModel.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using Avalonia.Controls; -using Avalonia.Markup.Xaml; using Avalonia.Media; using CommunityToolkit.Mvvm.ComponentModel; @@ -11,8 +9,7 @@ namespace Semi.Avalonia.Demo.ViewModels; public partial class IconDemoViewModel : ObservableObject { - private readonly IResourceDictionary? _resources = - AvaloniaXamlLoader.Load(new Uri("avares://Semi.Avalonia/Themes/Shared/Icon.axaml")) as ResourceDictionary; + private readonly IResourceDictionary? _resources = new Icons(); private readonly Dictionary _filledIcons = new(); private readonly Dictionary _strokedIcons = new(); @@ -26,22 +23,27 @@ public partial class IconDemoViewModel : ObservableObject { if (_resources is null) return; - foreach (var key in _resources.Keys) + foreach (var provider in _resources.MergedDictionaries) { - if (_resources[key] is not Geometry geometry) continue; - var icon = new IconItem { ResourceKey = key.ToString(), Geometry = geometry }; + if (provider is not ResourceDictionary dic) continue; - if (key.ToString().EndsWith("Stroked")) + foreach (var key in dic.Keys) { - _strokedIcons[key.ToString()] = icon; - } - else - { - _filledIcons[key.ToString()] = icon; - } + if (dic[key] is not Geometry geometry) continue; + var icon = new IconItem + { + ResourceKey = key.ToString(), + Geometry = geometry + }; - OnSearchTextChanged(string.Empty); + if (key.ToString().EndsWith("Stroked")) + _strokedIcons[key.ToString().ToLowerInvariant()] = icon; + else + _filledIcons[key.ToString().ToLowerInvariant()] = icon; + } } + + OnSearchTextChanged(string.Empty); } partial void OnSearchTextChanged(string? value) @@ -49,16 +51,15 @@ public partial class IconDemoViewModel : ObservableObject var search = value?.ToLowerInvariant() ?? string.Empty; FilteredFilledIcons.Clear(); - foreach (var icon in _filledIcons.Values.Where(i => i.ResourceKey?.ToLowerInvariant().Contains(search) == true)) + foreach (var pair in _filledIcons.Where(i => i.Key.Contains(search))) { - FilteredFilledIcons.Add(icon); + FilteredFilledIcons.Add(pair.Value); } FilteredStrokedIcons.Clear(); - foreach (var icon in - _strokedIcons.Values.Where(i => i.ResourceKey?.ToLowerInvariant().Contains(search) == true)) + foreach (var pair in _strokedIcons.Where(i => i.Key.Contains(search))) { - FilteredStrokedIcons.Add(icon); + FilteredStrokedIcons.Add(pair.Value); } } } diff --git a/src/Semi.Avalonia/Themes/Shared/Icon.axaml b/src/Semi.Avalonia/Icons/Icon.axaml similarity index 100% rename from src/Semi.Avalonia/Themes/Shared/Icon.axaml rename to src/Semi.Avalonia/Icons/Icon.axaml diff --git a/src/Semi.Avalonia/Icons/IconPatch.axaml b/src/Semi.Avalonia/Icons/IconPatch.axaml new file mode 100644 index 0000000..f0b5a49 --- /dev/null +++ b/src/Semi.Avalonia/Icons/IconPatch.axaml @@ -0,0 +1,14 @@ + + + m17.55 15.66-4.8 5.48a1 1 0 0 1-1.5 0l-4.8-5.48A1 1 0 0 1 7.2 14h9.6a1 1 0 0 1 .75 1.66Z + + + m6.45 8.34 4.8-5.48a1 1 0 0 1 1.5 0l4.8 5.48A1 1 0 0 1 16.8 10H7.2a1 1 0 0 1-.75-1.66Z + + + M5 12.5c0-.83.67-1.5 1.5-1.5h11a1.5 1.5 0 0 1 0 3h-11A1.5 1.5 0 0 1 5 12.5Z + + + M17.41 7.3c.66.51.78 1.45.28 2.11l-6.5 8.5a1.5 1.5 0 0 1-2.37.01l-3.5-4.5a1.5 1.5 0 1 1 2.36-1.84L10 14.54l5.32-6.95a1.5 1.5 0 0 1 2.1-.28Z + + \ No newline at end of file diff --git a/src/Semi.Avalonia/Icons/_index.axaml b/src/Semi.Avalonia/Icons/_index.axaml new file mode 100644 index 0000000..48d4869 --- /dev/null +++ b/src/Semi.Avalonia/Icons/_index.axaml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Semi.Avalonia/Icons/_index.axaml.cs b/src/Semi.Avalonia/Icons/_index.axaml.cs new file mode 100644 index 0000000..2a3539c --- /dev/null +++ b/src/Semi.Avalonia/Icons/_index.axaml.cs @@ -0,0 +1,5 @@ +using Avalonia.Controls; + +namespace Semi.Avalonia; + +public class Icons : ResourceDictionary; \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/Index.axaml b/src/Semi.Avalonia/Themes/Index.axaml index 116b7b5..dc9ff25 100644 --- a/src/Semi.Avalonia/Themes/Index.axaml +++ b/src/Semi.Avalonia/Themes/Index.axaml @@ -10,7 +10,8 @@ + - + \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/SemiTheme.axaml b/src/Semi.Avalonia/Themes/SemiTheme.axaml index 9ff7f0e..77181be 100644 --- a/src/Semi.Avalonia/Themes/SemiTheme.axaml +++ b/src/Semi.Avalonia/Themes/SemiTheme.axaml @@ -15,6 +15,7 @@ + diff --git a/src/Semi.Avalonia/Themes/Shared/IconPatch.axaml b/src/Semi.Avalonia/Themes/Shared/IconPatch.axaml deleted file mode 100644 index e20405c..0000000 --- a/src/Semi.Avalonia/Themes/Shared/IconPatch.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Themes/Shared/_index.axaml b/src/Semi.Avalonia/Themes/Shared/_index.axaml index 94e39c2..7d03eff 100644 --- a/src/Semi.Avalonia/Themes/Shared/_index.axaml +++ b/src/Semi.Avalonia/Themes/Shared/_index.axaml @@ -1,8 +1,6 @@  - -