diff --git a/Toolkit.Avalonia/ClassicDesktopStyleApplicationHandler.cs b/Toolkit.Avalonia/ClassicDesktopStyleApplicationHandler.cs index 94d3087..f93024e 100644 --- a/Toolkit.Avalonia/ClassicDesktopStyleApplicationHandler.cs +++ b/Toolkit.Avalonia/ClassicDesktopStyleApplicationHandler.cs @@ -5,7 +5,7 @@ using Toolkit.Foundation; namespace Toolkit.Avalonia; -public class ClassicDesktopStyleApplicationHandler(INavigationContext navigationContext) : +public class ClassicDesktopStyleApplicationHandler : INavigateHandler { public Task Handle(Navigate args, @@ -18,8 +18,6 @@ public class ClassicDesktopStyleApplicationHandler(INavigationContext navigation { lifeTime.MainWindow = window; window.DataContext = args.Content; - - navigationContext.Set(window); } } diff --git a/Toolkit.Avalonia/ContentControlHandler.cs b/Toolkit.Avalonia/ContentControlHandler.cs index 3905680..cf958a7 100644 --- a/Toolkit.Avalonia/ContentControlHandler.cs +++ b/Toolkit.Avalonia/ContentControlHandler.cs @@ -4,7 +4,7 @@ using Toolkit.Foundation; namespace Toolkit.Avalonia; -public class ContentControlHandler(INavigationContext navigationContext) : +public class ContentControlHandler : INavigateHandler { public async Task Handle(Navigate args, @@ -51,8 +51,6 @@ public class ContentControlHandler(INavigationContext navigationContext) : control.DataContext = args.Content; contentControl.Content = control; - - navigationContext.Set(control); await taskCompletionSource.Task; } } diff --git a/Toolkit.Avalonia/ContentTemplate.cs b/Toolkit.Avalonia/ContentTemplate.cs index 5a02417..5ccc0c7 100644 --- a/Toolkit.Avalonia/ContentTemplate.cs +++ b/Toolkit.Avalonia/ContentTemplate.cs @@ -17,7 +17,7 @@ public class ContentTemplate : if (observableViewModel.Provider is IServiceProvider provider) { IContentTemplateDescriptorProvider? contentTemplateProvider = provider.GetService(); - INavigationContext? viewModelContentBinder = provider.GetService(); + INavigationRegion? viewModelContentBinder = provider.GetService(); if (contentTemplateProvider?.Get(item.GetType().Name) is IContentTemplateDescriptor descriptor) { @@ -55,7 +55,7 @@ public class ContentTemplate : control.Loaded += HandleLoaded; control.Unloaded += HandleUnloaded; - viewModelContentBinder?.Set(control); + //viewModelContentBinder?.Register(control); return control; } diff --git a/Toolkit.Avalonia/FrameHandler.cs b/Toolkit.Avalonia/FrameHandler.cs index 0a38126..22cd7e1 100644 --- a/Toolkit.Avalonia/FrameHandler.cs +++ b/Toolkit.Avalonia/FrameHandler.cs @@ -8,7 +8,7 @@ using Toolkit.UI.Controls.Avalonia; namespace Toolkit.Avalonia; -public class FrameHandler(INavigationContext navigationContext) : +public class FrameHandler : INavigateHandler, INavigateBackHandler { @@ -45,32 +45,6 @@ public class FrameHandler(INavigationContext navigationContext) : { await deactivating.Deactivating(); } - - Type contentType = content.GetType(); - if (contentType.GetInterfaces() is Type[] contracts) - { - foreach (Type contract in contracts) - { - if (contract.Name == typeof(IDeactivating<>).Name && - contract.GetGenericArguments() is { Length: 1 } arguments) - { - if (contentType.GetMethods().FirstOrDefault(x => - x.Name == "Deactivating" && x.ReturnType == typeof(Task<>) - .MakeGenericType(arguments[0])) - is MethodInfo methodInfo) - { - if (methodInfo.GetCustomAttribute() - is NavigationContextAttribute attribute) - { - if (await methodInfo.InvokeAsync(content) is object result) - { - results.Add(attribute.Name, result); - } - } - } - } - } - } } } } @@ -100,33 +74,6 @@ public class FrameHandler(INavigationContext navigationContext) : { await deactivated.Deactivated(); } - - Type contentType = content.GetType(); - if (contentType.GetInterfaces() is Type[] contracts) - { - foreach (Type contract in contracts) - { - if (contract.Name == typeof(IActivated<>).Name && - contract.GetGenericArguments() is { Length: 1 } arguments) - { - if (contentType.GetMethods().FirstOrDefault(x => - x.Name == "NavigatedToAsync" && - x.GetCustomAttribute() - is NavigationContextAttribute attribute && results.ContainsKey(attribute.Name)) - is MethodInfo methodInfo) - { - if (methodInfo.GetCustomAttribute() - is NavigationContextAttribute attribute) - { - if (results.TryGetValue(attribute.Name, out object? value)) - { - await methodInfo.InvokeAsync(content, value); - } - } - } - } - } - } } } @@ -181,8 +128,6 @@ public class FrameHandler(INavigationContext navigationContext) : } control.DataContext = args.Content; - navigationContext.Set(control); - NavigatedTo(args.Sender, control); frame.NavigateFromObject(control, new FrameNavigationOptions { TransitionInfoOverride = new SuppressNavigationTransitionInfo() }); } diff --git a/Toolkit.Avalonia/INavigationContext.cs b/Toolkit.Avalonia/INavigationContext.cs deleted file mode 100644 index 53d3792..0000000 --- a/Toolkit.Avalonia/INavigationContext.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Avalonia.Controls; - -namespace Toolkit.Avalonia; - -public interface INavigationContext -{ - void Set(Control control); -} \ No newline at end of file diff --git a/Toolkit.Avalonia/IServiceCollectionExtensions.cs b/Toolkit.Avalonia/IServiceCollectionExtensions.cs index 6f3ae03..737a798 100644 --- a/Toolkit.Avalonia/IServiceCollectionExtensions.cs +++ b/Toolkit.Avalonia/IServiceCollectionExtensions.cs @@ -126,7 +126,7 @@ public static class IServiceCollectionExtensions services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddNavigateHandler(); services.AddNavigateHandler(); @@ -134,7 +134,7 @@ public static class IServiceCollectionExtensions services.AddNavigateHandler(); services.AddNavigateHandler(); - services.AddScoped(provider => new NavigationContextCollection + services.AddScoped(provider => new NavigationRegionCollection { { typeof(IClassicDesktopStyleApplicationLifetime), typeof(IClassicDesktopStyleApplicationLifetime) }, { typeof(ISingleViewApplicationLifetime), typeof(ISingleViewApplicationLifetime) } @@ -148,7 +148,7 @@ public static class IServiceCollectionExtensions services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddNavigateHandler(); services.AddNavigateHandler(); diff --git a/Toolkit.Avalonia/NavigationContext.cs b/Toolkit.Avalonia/NavigationContext.cs deleted file mode 100644 index 4ea4635..0000000 --- a/Toolkit.Avalonia/NavigationContext.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Controls.Primitives; -using Avalonia.Interactivity; -using System.Reflection; -using Toolkit.Foundation; - -namespace Toolkit.Avalonia; - -public class NavigationContext(INavigationContextCollection contexts) : - INavigationContext -{ - public void Set(Control control) - { - if (control.GetType().GetCustomAttributes() - is IEnumerable attributes) - { - foreach (NavigationTargetAttribute attribute in attributes) - { - if (!contexts.ContainsKey(attribute.Name)) - { - if (control.Find(attribute.Name) is TemplatedControl content) - { - contexts.Add(attribute.Name, content); - void HandleUnloaded(object? sender, RoutedEventArgs args) - { - control.Unloaded -= HandleUnloaded; - contexts.Remove(attribute.Name); - } - - control.Unloaded += HandleUnloaded; - } - } - } - } - } -} \ No newline at end of file diff --git a/Toolkit.Avalonia/NavigationRegion.cs b/Toolkit.Avalonia/NavigationRegion.cs new file mode 100644 index 0000000..82d2897 --- /dev/null +++ b/Toolkit.Avalonia/NavigationRegion.cs @@ -0,0 +1,28 @@ +using Avalonia.Controls; +using Avalonia.Interactivity; +using Toolkit.Foundation; + +namespace Toolkit.Avalonia; + +public class NavigationRegion(INavigationRegionCollection collection) : + INavigationRegion +{ + public void Register(string name, + object target) + { + if (target is Control control) + { + if (!collection.ContainsKey(name)) + { + collection.Add(name, control); + void HandleUnloaded(object? sender, RoutedEventArgs args) + { + control.Unloaded -= HandleUnloaded; + collection.Remove(name); + } + + control.Unloaded += HandleUnloaded; + } + } + } +} \ No newline at end of file diff --git a/Toolkit.Avalonia/SingleViewApplicationHandler.cs b/Toolkit.Avalonia/SingleViewApplicationHandler.cs index 5dc4d4f..ff6ba63 100644 --- a/Toolkit.Avalonia/SingleViewApplicationHandler.cs +++ b/Toolkit.Avalonia/SingleViewApplicationHandler.cs @@ -5,7 +5,7 @@ using Toolkit.Foundation; namespace Toolkit.Avalonia; -public class SingleViewApplicationHandler(INavigationContext navigationContext) : +public class SingleViewApplicationHandler : INavigateHandler { public Task Handle(Navigate args, @@ -18,8 +18,6 @@ public class SingleViewApplicationHandler(INavigationContext navigationContext) { lifeTime.MainView = control; control.DataContext = args.Content; - - navigationContext.Set(control); } } diff --git a/Toolkit.Foundation/ComponentBuilder.cs b/Toolkit.Foundation/ComponentBuilder.cs index 2f90b1a..4bb92d1 100644 --- a/Toolkit.Foundation/ComponentBuilder.cs +++ b/Toolkit.Foundation/ComponentBuilder.cs @@ -39,8 +39,8 @@ public class ComponentBuilder : services.AddTransient(); services.AddTransient(); - services.AddScoped(); - services.AddTransient(); + services.AddScoped(); + services.AddTransient(); services.AddHandler(); services.AddHandler(); diff --git a/Toolkit.Foundation/ComponentFactory.cs b/Toolkit.Foundation/ComponentFactory.cs index d341915..68c32c0 100644 --- a/Toolkit.Foundation/ComponentFactory.cs +++ b/Toolkit.Foundation/ComponentFactory.cs @@ -25,10 +25,10 @@ public class ComponentFactory(IServiceProvider provider, provider.GetRequiredService>()); services.AddScoped(_ => - provider.GetRequiredService()); + provider.GetRequiredService()); services.AddScoped(_ => - provider.GetRequiredService()); + provider.GetRequiredService()); services.AddScoped(_ => provider.GetRequiredService()); @@ -37,7 +37,7 @@ public class ComponentFactory(IServiceProvider provider, provider.GetRequiredService()); services.AddRange(proxy.Services); - services.AddSingleton(new ComponentScope(name)); + services.AddSingleton(new NamedComponent(name)); if (servicesDelegate is not null) { @@ -45,7 +45,7 @@ public class ComponentFactory(IServiceProvider provider, } }); - builder.AddConfiguration(name, configuration); + builder.AddConfiguration(name, configuration); IComponentHost host = builder.Build(); scopes.Add(new ComponentScopeDescriptor(name, diff --git a/Toolkit.Foundation/ComponentInitializer.cs b/Toolkit.Foundation/ComponentInitializer.cs index 3221117..768e780 100644 --- a/Toolkit.Foundation/ComponentInitializer.cs +++ b/Toolkit.Foundation/ComponentInitializer.cs @@ -23,10 +23,10 @@ public class ComponentInitializer(IEnumerable components, provider.GetRequiredService>()); services.AddScoped(_ => - provider.GetRequiredService()); + provider.GetRequiredService()); services.AddScoped(_ => - provider.GetRequiredService()); + provider.GetRequiredService()); services.AddScoped(_ => provider.GetRequiredService()); @@ -36,7 +36,7 @@ public class ComponentInitializer(IEnumerable components, services.AddRange(typedServices.Services); - services.AddSingleton(new ComponentScope(component.GetType().Name)); + services.AddSingleton(new NamedComponent(component.GetType().Name)); }); IComponentHost host = builder.Build(); diff --git a/Toolkit.Foundation/ComponentScope.cs b/Toolkit.Foundation/ComponentScope.cs deleted file mode 100644 index 1c50570..0000000 --- a/Toolkit.Foundation/ComponentScope.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Toolkit.Foundation; - -public record ComponentScope(string Name); \ No newline at end of file diff --git a/Toolkit.Foundation/DefaultHostBuilder.cs b/Toolkit.Foundation/DefaultHostBuilder.cs index c238e97..e48a207 100644 --- a/Toolkit.Foundation/DefaultHostBuilder.cs +++ b/Toolkit.Foundation/DefaultHostBuilder.cs @@ -33,8 +33,8 @@ public class DefaultHostBuilder : services.AddScoped>(provider => new ProxyService(provider.GetRequiredService())); - services.AddScoped>(provider => - new ProxyService(provider.GetRequiredService())); + services.AddScoped>(provider => + new ProxyService(provider.GetRequiredService())); services.AddScoped>(provider => new ProxyService(provider.GetRequiredService())); @@ -45,12 +45,12 @@ public class DefaultHostBuilder : services.AddTransient(); - services.AddScoped(); - services.AddTransient(); + services.AddScoped(); + services.AddTransient(); services.AddTransient(); - services.AddSingleton(new ComponentScope("Root")); + services.AddSingleton(new NamedComponent("Root")); services.AddScoped(provider => new ComponentScopeCollection { new ComponentScopeDescriptor("Root", provider.GetRequiredService()) diff --git a/Toolkit.Foundation/INavigationRegion.cs b/Toolkit.Foundation/INavigationRegion.cs new file mode 100644 index 0000000..9fbf297 --- /dev/null +++ b/Toolkit.Foundation/INavigationRegion.cs @@ -0,0 +1,7 @@ +namespace Toolkit.Foundation; + +public interface INavigationRegion +{ + void Register(string name, + object target); +} diff --git a/Toolkit.Foundation/INavigationContextCollection.cs b/Toolkit.Foundation/INavigationRegionCollection.cs similarity index 58% rename from Toolkit.Foundation/INavigationContextCollection.cs rename to Toolkit.Foundation/INavigationRegionCollection.cs index 9bdae1f..8f242bd 100644 --- a/Toolkit.Foundation/INavigationContextCollection.cs +++ b/Toolkit.Foundation/INavigationRegionCollection.cs @@ -1,4 +1,4 @@ namespace Toolkit.Foundation; -public interface INavigationContextCollection : +public interface INavigationRegionCollection : IDictionary; \ No newline at end of file diff --git a/Toolkit.Foundation/INavigationContextProvider.cs b/Toolkit.Foundation/INavigationRegionProvider.cs similarity index 73% rename from Toolkit.Foundation/INavigationContextProvider.cs rename to Toolkit.Foundation/INavigationRegionProvider.cs index fb44955..1553415 100644 --- a/Toolkit.Foundation/INavigationContextProvider.cs +++ b/Toolkit.Foundation/INavigationRegionProvider.cs @@ -1,6 +1,6 @@ namespace Toolkit.Foundation; -public interface INavigationContextProvider +public interface INavigationRegionProvider { object? Get(object key); diff --git a/Toolkit.Foundation/NamedComponent.cs b/Toolkit.Foundation/NamedComponent.cs new file mode 100644 index 0000000..3c7b4d7 --- /dev/null +++ b/Toolkit.Foundation/NamedComponent.cs @@ -0,0 +1,6 @@ +namespace Toolkit.Foundation; + +public record NamedComponent(string Name) +{ + public override string ToString() => Name; +} \ No newline at end of file diff --git a/Toolkit.Foundation/NavigateHandler.cs b/Toolkit.Foundation/NavigateHandler.cs index f1a4905..9ee3d04 100644 --- a/Toolkit.Foundation/NavigateHandler.cs +++ b/Toolkit.Foundation/NavigateHandler.cs @@ -2,7 +2,7 @@ namespace Toolkit.Foundation; -public class NavigateHandler(ComponentScope scope, +public class NavigateHandler(NamedComponent scope, IComponentScopeProvider provider) : INotificationHandler { diff --git a/Toolkit.Foundation/NavigationContextAttribute.cs b/Toolkit.Foundation/NavigationContextAttribute.cs deleted file mode 100644 index 62a889b..0000000 --- a/Toolkit.Foundation/NavigationContextAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Toolkit.Foundation; - -[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] -public class NavigationContextAttribute : Attribute -{ - public NavigationContextAttribute(string name) - { - Name = name; - } - - public string Name { get; } -} \ No newline at end of file diff --git a/Toolkit.Foundation/NavigationContextCollection.cs b/Toolkit.Foundation/NavigationContextCollection.cs deleted file mode 100644 index 0cdf540..0000000 --- a/Toolkit.Foundation/NavigationContextCollection.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Toolkit.Foundation; - -public class NavigationContextCollection : Dictionary, - INavigationContextCollection; \ No newline at end of file diff --git a/Toolkit.Foundation/NavigationRegionCollection.cs b/Toolkit.Foundation/NavigationRegionCollection.cs new file mode 100644 index 0000000..b1c2f5a --- /dev/null +++ b/Toolkit.Foundation/NavigationRegionCollection.cs @@ -0,0 +1,4 @@ +namespace Toolkit.Foundation; + +public class NavigationRegionCollection : Dictionary, + INavigationRegionCollection; \ No newline at end of file diff --git a/Toolkit.Foundation/NavigationContextProvider.cs b/Toolkit.Foundation/NavigationRegionProvider.cs similarity index 80% rename from Toolkit.Foundation/NavigationContextProvider.cs rename to Toolkit.Foundation/NavigationRegionProvider.cs index a0173ef..9a5d7f0 100644 --- a/Toolkit.Foundation/NavigationContextProvider.cs +++ b/Toolkit.Foundation/NavigationRegionProvider.cs @@ -1,7 +1,7 @@ namespace Toolkit.Foundation; -public class NavigationContextProvider(INavigationContextCollection contexts) : - INavigationContextProvider +public class NavigationRegionProvider(INavigationRegionCollection contexts) : + INavigationRegionProvider { public object? Get(object key) => contexts.TryGetValue(key, out object? target) ? target : default; diff --git a/Toolkit.Foundation/NavigationScope.cs b/Toolkit.Foundation/NavigationScope.cs index bc8320e..c2cefd7 100644 --- a/Toolkit.Foundation/NavigationScope.cs +++ b/Toolkit.Foundation/NavigationScope.cs @@ -6,7 +6,7 @@ public class NavigationScope(IPublisher publisher, IServiceProvider provider, IServiceFactory factory, INavigationProvider navigationProvider, - INavigationContextProvider navigationContextProvider, + INavigationRegionProvider navigationContextProvider, IContentTemplateDescriptorProvider contentTemplateDescriptorProvider) : INavigationScope { diff --git a/Toolkit.UI.Avalonia/ConditionAction.cs b/Toolkit.UI.Avalonia/ConditionAction.cs index 23cf491..36519ed 100644 --- a/Toolkit.UI.Avalonia/ConditionAction.cs +++ b/Toolkit.UI.Avalonia/ConditionAction.cs @@ -9,8 +9,7 @@ public class ConditionAction : IAction { public static readonly DirectProperty ActionsProperty = - AvaloniaProperty.RegisterDirect(nameof(Actions), - x => x.Actions); + AvaloniaProperty.RegisterDirect(nameof(Actions), x => x.Actions); public static readonly StyledProperty ConditionProperty = AvaloniaProperty.Register(nameof(Condition)); diff --git a/Toolkit.UI.Avalonia/NavigateAction.cs b/Toolkit.UI.Avalonia/NavigateAction.cs index 9cb4ce3..93be81e 100644 --- a/Toolkit.UI.Avalonia/NavigateAction.cs +++ b/Toolkit.UI.Avalonia/NavigateAction.cs @@ -74,7 +74,8 @@ public class NavigateAction : ParameterBindings.Select(binding => new KeyValuePair(binding.Key, binding.Value)).ToArray() : Enumerable.Empty>()]; - observableViewModel.Publisher.Publish(new Navigate(Route, Context == this ? control : Context, Scope ?? null, control.DataContext, Navigated, parameters)); + observableViewModel.Publisher.Publish(new Navigate(Route, Context == this ? control : Context, Scope ?? null, + control.DataContext, Navigated, parameters)).ConfigureAwait(false); } } diff --git a/Toolkit.UI.Avalonia/NavigateBackAction.cs b/Toolkit.UI.Avalonia/NavigateBackAction.cs index 10bd27c..502c680 100644 --- a/Toolkit.UI.Avalonia/NavigateBackAction.cs +++ b/Toolkit.UI.Avalonia/NavigateBackAction.cs @@ -35,7 +35,7 @@ public class NavigateBackAction : if (control.DataContext is IObservableViewModel observableViewModel) { observableViewModel.Publisher.Publish(new NavigateBack(Context - ?? null, Scope ?? null)).GetAwaiter().GetResult(); + ?? null, Scope ?? null)).ConfigureAwait(false); } } diff --git a/Toolkit.UI.Avalonia/NavigateRegionAction.cs b/Toolkit.UI.Avalonia/NavigateRegionAction.cs new file mode 100644 index 0000000..cd103e2 --- /dev/null +++ b/Toolkit.UI.Avalonia/NavigateRegionAction.cs @@ -0,0 +1,47 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Metadata; +using Avalonia.Xaml.Interactivity; +using Microsoft.Extensions.DependencyInjection; +using Toolkit.Foundation; + +namespace Toolkit.UI.Avalonia; + +public class NavigateRegionAction : + AvaloniaObject, + IAction +{ + public static readonly DirectProperty ActionsProperty = + AvaloniaProperty.RegisterDirect(nameof(Actions), x => x.Actions); + + public static readonly StyledProperty NameProperty = + AvaloniaProperty.Register(nameof(Name)); + + private ActionCollection? actions; + + [Content] + public ActionCollection Actions => actions ??= []; + public string Name + { + get => GetValue(NameProperty); + set => SetValue(NameProperty, value); + } + + public object? Execute(object? sender, + object? parameter) + { + if (sender is Control control) + { + if (control.DataContext is IObservableViewModel observableViewModel) + { + if (observableViewModel.Provider.GetRequiredService() is INavigationRegion navigationRegion) + { + navigationRegion.Register(Name, sender); + Interaction.ExecuteActions(sender, Actions, parameter); + } + } + } + + return true; + } +} diff --git a/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPicture.axaml b/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPicture.axaml index e40798d..a0741ce 100644 --- a/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPicture.axaml +++ b/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPicture.axaml @@ -2,6 +2,24 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:Toolkit.UI.Controls.Avalonia"> + + + + + + + + + + + + + + + + + + 1 1 1 diff --git a/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPictureInitialsGenerator.cs b/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPictureInitialsGenerator.cs index d0ba9ed..a3ed77e 100644 --- a/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPictureInitialsGenerator.cs +++ b/Toolkit.UI.Controls.Avalonia/PersonPicture/PersonPictureInitialsGenerator.cs @@ -2,39 +2,41 @@ internal class PersonPictureInitialsGenerator { - public static PersonPictureCharacterType GetCharacterType(string str) + public static PersonPictureCharacterType GetCharacterType(string content) { - PersonPictureCharacterType result = PersonPictureCharacterType.Other; - for (int i = 0; i < 3; i++) + if (content is { Length: > 0 }) { - if ((i >= str.Length) || (str[i] == '\0') || (str[i] == 0xFEFF)) + for (int i = 0; i < 3; i++) { - break; - } + if ((i >= content.Length) || (content[i] == '\0') || (content[i] == 0xFEFF)) + { + break; + } - char character = str[i]; - PersonPictureCharacterType evaluationResult = GetCharacterType(character); + char character = content[i]; + PersonPictureCharacterType evaluationResult = GetCharacterType(character); - switch (evaluationResult) - { - case PersonPictureCharacterType.Glyph: - result = PersonPictureCharacterType.Glyph; - break; - case PersonPictureCharacterType.Symbolic: - if (result != PersonPictureCharacterType.Glyph) - { - result = PersonPictureCharacterType.Symbolic; - } - break; - case PersonPictureCharacterType.Standard: - if ((result != PersonPictureCharacterType.Glyph) && (result != PersonPictureCharacterType.Symbolic)) - { - result = PersonPictureCharacterType.Standard; - } - break; - default: - break; + switch (evaluationResult) + { + case PersonPictureCharacterType.Glyph: + result = PersonPictureCharacterType.Glyph; + break; + case PersonPictureCharacterType.Symbolic: + if (result != PersonPictureCharacterType.Glyph) + { + result = PersonPictureCharacterType.Symbolic; + } + break; + case PersonPictureCharacterType.Standard: + if ((result != PersonPictureCharacterType.Glyph) && (result != PersonPictureCharacterType.Symbolic)) + { + result = PersonPictureCharacterType.Standard; + } + break; + default: + break; + } } } return result; diff --git a/Toolkit.UI.Controls.Avalonia/Themes/ControlResources.axaml b/Toolkit.UI.Controls.Avalonia/Themes/ControlResources.axaml index 70fcccf..4955d66 100644 --- a/Toolkit.UI.Controls.Avalonia/Themes/ControlResources.axaml +++ b/Toolkit.UI.Controls.Avalonia/Themes/ControlResources.axaml @@ -6,6 +6,7 @@ +