Skip to content

Commit

Permalink
feat: Implement SliderAutomationPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
morning4coffe-dev authored and MartinZikmund committed Jun 17, 2024
1 parent dd78821 commit b8041d9
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/Uno.UI/UI/Xaml/Automation/Peers/SliderAutomationPeer.cs
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;
}
}

0 comments on commit b8041d9

Please sign in to comment.