From d3a4e67e549139c060421e49e3d319e47a905fd0 Mon Sep 17 00:00:00 2001 From: MartyIX <203266+MartyIX@users.noreply.github.com> Date: Fri, 10 Jan 2025 10:05:52 +0100 Subject: [PATCH] WIP --- .../Extensions/AccessibilityExtensions.cs | 37 +++---------- src/Core/src/Handlers/IElementHandler.cs | 52 +++++++++---------- 2 files changed, 34 insertions(+), 55 deletions(-) diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs index b32154f1a34e..c0f8de3bd6a8 100644 --- a/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs +++ b/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs @@ -25,10 +25,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con _defaultAutomationPropertiesName = currentValue = (string)Control.GetValue(NativeAutomationProperties.NameProperty); } -#pragma warning disable CS0618 // Type or member is obsolete - var elemValue = (string)Element.GetValue(AutomationProperties.NameProperty); -#pragma warning restore CS0618 // Type or member is obsolete - + var elemValue = (string)Element.GetValue(SemanticProperties.DescriptionProperty); string newValue = !string.IsNullOrWhiteSpace(elemValue) ? elemValue : _defaultAutomationPropertiesName; if (currentValue is null || currentValue != newValue) @@ -88,10 +85,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con _defaultAutomationPropertiesHelpText = currentValue = (string)Control.GetValue(NativeAutomationProperties.HelpTextProperty); } -#pragma warning disable CS0618 // Type or member is obsolete - var elemValue = (string)Element.GetValue(AutomationProperties.HelpTextProperty); -#pragma warning restore CS0618 // Type or member is obsolete - + var elemValue = (string)Element.GetValue(SemanticProperties.HintProperty); string newValue = !string.IsNullOrWhiteSpace(elemValue) ? elemValue : _defaultAutomationPropertiesHelpText; if (currentValue is null || newValue != currentValue) @@ -123,9 +117,8 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con { _defaultAutomationPropertiesLabeledBy = currentValue = (UIElement)Control.GetValue(NativeAutomationProperties.LabeledByProperty); } -#pragma warning disable CS0618 // Type or member is obsolete - var elemValue = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty); -#pragma warning restore CS0618 // Type or member is obsolete + + var elemValue = (VisualElement)Element.GetValue(SemanticProperties.DescriptionProperty); FrameworkElement? nativeElement = null; if (mauiContext != null) @@ -137,9 +130,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con if (currentValue is null || newValue != currentValue) { -#pragma warning disable CS0618 // Type or member is obsolete - Control.SetValue(AutomationProperties.LabeledByProperty, newValue); -#pragma warning restore CS0618 // Type or member is obsolete + Control.SetValue(SemanticProperties.DescriptionProperty, newValue); } return _defaultAutomationPropertiesLabeledBy; @@ -161,22 +152,10 @@ public static void SetBackButtonTitle(this PageControl Control, Element? Element static string ConcatenateNameAndHint(Element Element) { - string separator; - -#pragma warning disable CS0618 // Type or member is obsolete - var name = (string)Element.GetValue(AutomationProperties.NameProperty); - - var hint = (string)Element.GetValue(AutomationProperties.HelpTextProperty); -#pragma warning restore CS0618 // Type or member is obsolete + var name = (string)Element.GetValue(SemanticProperties.DescriptionProperty); + var hint = (string)Element.GetValue(SemanticProperties.HintProperty); - if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(hint)) - { - separator = ""; - } - else - { - separator = ". "; - } + string separator = string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(hint) ? "" : ". "; return string.Join(separator, name, hint); diff --git a/src/Core/src/Handlers/IElementHandler.cs b/src/Core/src/Handlers/IElementHandler.cs index 64a9e7e46205..228253f8486e 100644 --- a/src/Core/src/Handlers/IElementHandler.cs +++ b/src/Core/src/Handlers/IElementHandler.cs @@ -6,49 +6,49 @@ /// public interface IElementHandler { - /// + /// /// Sets the .NET MAUI context for the element handler. - /// - /// The .NET MAUI context to set. + /// + /// The .NET MAUI context to set. void SetMauiContext(IMauiContext mauiContext); - /// + /// /// Sets the cross-platform virtual view associated with the handler. - /// - /// The element to handle. + /// + /// The element to handle. void SetVirtualView(IElement view); - /// - /// Updates the value of the specified property on the handler. - /// - /// The name of the property to update. + /// + /// Updates the value of the specified property on the handler. + /// + /// The name of the property to update. void UpdateValue(string property); - /// - /// Invokes the specified command on the element with the given arguments. - /// - /// The name of the command to invoke. - /// Optional arguments to pass to the command. + /// + /// Invokes the specified command on the element with the given arguments. + /// + /// The name of the command to invoke. + /// Optional arguments to pass to the command. void Invoke(string command, object? args = null); - /// + /// /// Disconnects the element handler from the element for clean up. - /// + /// void DisconnectHandler(); - /// - /// Gets the platform-specific view object associated with the handler. - /// + /// + /// Gets the platform-specific view object associated with the handler. + /// object? PlatformView { get; } - /// - /// Gets the cross-platform virtual view associated with the handler. - /// + /// + /// Gets the cross-platform virtual view associated with the handler. + /// IElement? VirtualView { get; } - /// - /// Gets the .NET MAUI context associated with the element. - /// + /// + /// Gets the .NET MAUI context associated with the element. + /// IMauiContext? MauiContext { get; } } } \ No newline at end of file