From b8041d98c87d2a998c56761422d79980088e68d6 Mon Sep 17 00:00:00 2001 From: Dominik Titl <78549750+morning4coffe-dev@users.noreply.github.com> Date: Sat, 9 Mar 2024 23:27:34 +0100 Subject: [PATCH] feat: Implement `SliderAutomationPeer` --- .../Automation/Peers/SliderAutomationPeer.cs | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs b/src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs index 3eff1613c47e..18bac3e640ce 100644 --- a/src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs +++ b/src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs @@ -1,66 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -// MUX Reference SliderAutomationPeer_Partial.cpp - +// MUX Reference SliderAutomationPeer_Partial.cpp, tag winui3/release/1.4.2 using System; using DirectUI; using Windows.Foundation; using Microsoft.UI.Xaml.Controls; -namespace Microsoft.UI.Xaml.Automation.Peers +namespace Microsoft.UI.Xaml.Automation.Peers; + +/// +/// Exposes Slider types to Microsoft UI Automation. +/// +public partial class SliderAutomationPeer : RangeBaseAutomationPeer { + private readonly Slider _owner; + /// - /// Exposes Slider types to Microsoft UI Automation. + /// Initializes a new instance of the SliderAutomationPeer class. /// - public partial class SliderAutomationPeer : RangeBaseAutomationPeer + /// The Slider to create a peer for. + public SliderAutomationPeer(Slider owner) : base(owner) { - private readonly Slider _owner; - - /// - /// Initializes a new instance of the SliderAutomationPeer class. - /// - /// The Slider to create a peer for. - public SliderAutomationPeer(Slider owner) : base(owner) - { - _owner = owner ?? throw new ArgumentNullException(nameof(owner)); - } + _owner = owner ?? throw new ArgumentNullException(nameof(owner)); + } - protected override string GetClassNameCore() => nameof(Slider); + protected override string GetClassNameCore() => nameof(Slider); - protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Slider; + protected override AutomationControlType GetAutomationControlTypeCore() + => AutomationControlType.Slider; - protected override Point GetClickablePointCore() => new Point(DoubleUtil.NaN, DoubleUtil.NaN); + protected override Point GetClickablePointCore() + => new(DoubleUtil.NaN, DoubleUtil.NaN); - protected override AutomationOrientation GetOrientationCore() + protected override AutomationOrientation GetOrientationCore() + { + var orientation = _owner.Orientation; + if (orientation == Orientation.Horizontal) { - var orientation = _owner.Orientation; - if (orientation == Orientation.Horizontal) - { - return AutomationOrientation.Horizontal; - } - else - { - return AutomationOrientation.Vertical; - } + return AutomationOrientation.Horizontal; } + else + { + return AutomationOrientation.Vertical; + } + } - private protected override bool ChildIsAcceptable(UIElement element) + private protected override bool ChildIsAcceptable(UIElement element) + { + var childIsAcceptable = base.ChildIsAcceptable(element); + + if (childIsAcceptable) { - var childIsAcceptable = base.ChildIsAcceptable(element); + var elementHorizontalTemplate = _owner.ElementHorizontalTemplate; + var elementVerticalTemplate = _owner.ElementVerticalTemplate; - if (childIsAcceptable) + if (element == elementHorizontalTemplate || element == elementVerticalTemplate) { - var elementHorizontalTemplate = _owner.ElementHorizontalTemplate; - var elementVerticalTemplate = _owner.ElementVerticalTemplate; - - if (element == elementHorizontalTemplate || element == elementVerticalTemplate) - { - var visibility = element.Visibility; - childIsAcceptable = visibility == Visibility.Visible; - } + var visibility = element.Visibility; + childIsAcceptable = visibility == Visibility.Visible; } - - return childIsAcceptable; } + + return childIsAcceptable; } }