forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement
SliderAutomationPeer
- Loading branch information
1 parent
dd78821
commit b8041d9
Showing
1 changed file
with
41 additions
and
41 deletions.
There are no files selected for viewing
82 changes: 41 additions & 41 deletions
82
src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
/// <summary> | ||
/// Exposes Slider types to Microsoft UI Automation. | ||
/// </summary> | ||
public partial class SliderAutomationPeer : RangeBaseAutomationPeer | ||
{ | ||
private readonly Slider _owner; | ||
|
||
/// <summary> | ||
/// Exposes Slider types to Microsoft UI Automation. | ||
/// Initializes a new instance of the SliderAutomationPeer class. | ||
/// </summary> | ||
public partial class SliderAutomationPeer : RangeBaseAutomationPeer | ||
/// <param name="owner">The Slider to create a peer for.</param> | ||
public SliderAutomationPeer(Slider owner) : base(owner) | ||
{ | ||
private readonly Slider _owner; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the SliderAutomationPeer class. | ||
/// </summary> | ||
/// <param name="owner">The Slider to create a peer for.</param> | ||
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; | ||
} | ||
} |