Skip to content

Commit

Permalink
feat: RepeatButtonAutomationPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 1, 2023
1 parent ae43868 commit bb1b1ea
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.Xaml.Automation.Peers
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class RepeatButtonAutomationPeer : global::Windows.UI.Xaml.Automation.Peers.ButtonBaseAutomationPeer, global::Windows.UI.Xaml.Automation.Provider.IInvokeProvider
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public RepeatButtonAutomationPeer(global::Windows.UI.Xaml.Controls.Primitives.RepeatButton owner) : base(owner)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Automation.Peers.RepeatButtonAutomationPeer", "RepeatButtonAutomationPeer.RepeatButtonAutomationPeer(RepeatButton owner)");
}
#endif
// Forced skipping of method Windows.UI.Xaml.Automation.Peers.RepeatButtonAutomationPeer.RepeatButtonAutomationPeer(Windows.UI.Xaml.Controls.Primitives.RepeatButton)
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Invoke()
{
Expand Down
37 changes: 37 additions & 0 deletions src/Uno.UI/UI/Xaml/Automation/Peers/RepeatButtonAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference RepeatButtonAutomationPeer_Partial.cpp, tag winui3/release/1.4.2

using System;
using Windows.UI.Xaml.Automation.Provider;
using Windows.UI.Xaml.Controls.Primitives;

namespace Windows.UI.Xaml.Automation.Peers;

public partial class RepeatButtonAutomationPeer : ButtonBaseAutomationPeer, IInvokeProvider
{
public RepeatButtonAutomationPeer(RepeatButton owner) : base(owner)
{
}

protected override object GetPatternCore(PatternInterface patternInterface) =>
patternInterface == PatternInterface.Invoke ?
this : base.GetPatternCore(patternInterface);

protected override string GetClassNameCore() => nameof(RepeatButton);

protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Button;

public void Invoke()
{
bool bIsEnabled = IsEnabled();

if (!bIsEnabled)
{
throw new InvalidOperationException("Button not enabled");
}

var owner = (ButtonBase)Owner;
owner.ProgrammaticClick();
}
}

0 comments on commit bb1b1ea

Please sign in to comment.