Skip to content

Commit

Permalink
feat: MenuFlyoutItemAutomationPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jun 20, 2024
1 parent 279c211 commit b2b8de4
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 34 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 Microsoft.UI.Xaml.Automation.Peers
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class MenuFlyoutItemAutomationPeer : global::Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, global::Microsoft.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 MenuFlyoutItemAutomationPeer(global::Microsoft.UI.Xaml.Controls.MenuFlyoutItem owner) : base(owner)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Automation.Peers.MenuFlyoutItemAutomationPeer", "MenuFlyoutItemAutomationPeer.MenuFlyoutItemAutomationPeer(MenuFlyoutItem owner)");
}
#endif
// Forced skipping of method Microsoft.UI.Xaml.Automation.Peers.MenuFlyoutItemAutomationPeer.MenuFlyoutItemAutomationPeer(Microsoft.UI.Xaml.Controls.MenuFlyoutItem)
#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
21 changes: 10 additions & 11 deletions src/Uno.UI/UI/Xaml/Automation/ElementNotEnabledException.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System;

namespace Microsoft.UI.Xaml.Automation
namespace Microsoft.UI.Xaml.Automation;

public class ElementNotEnabledException : Exception
{
public class ElementNotEnabledException : Exception
public ElementNotEnabledException() : base()
{
public ElementNotEnabledException() : base()
{
}
}

public ElementNotEnabledException(string message) : base(message)
{
}
public ElementNotEnabledException(string message) : base(message)
{
}

public ElementNotEnabledException(string message, Exception innerException) : base(message, innerException)
{
}
public ElementNotEnabledException(string message, Exception innerException) : base(message, innerException)
{
}
}
104 changes: 84 additions & 20 deletions src/Uno.UI/UI/Xaml/Automation/Peers/MenuFlyoutItemAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,92 @@
// <auto-generated>
#pragma warning disable 108 // new keyword hiding
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Automation.Peers
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference dxaml\xcp\dxaml\lib\MenuFlyoutItemAutomationPeer_Partial.cpp, tag winui3/release/1.5.4, commit 98a60c8

using Microsoft.UI.Xaml.Automation.Provider;
using Microsoft.UI.Xaml.Controls;

namespace Microsoft.UI.Xaml.Automation.Peers;

/// <summary>
/// Exposes MenuFlyoutItem types to Microsoft UI Automation.
/// </summary>
public partial class MenuFlyoutItemAutomationPeer : FrameworkElementAutomationPeer, IInvokeProvider
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented]
#endif
public partial class MenuFlyoutItemAutomationPeer : global::Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, global::Microsoft.UI.Xaml.Automation.Provider.IInvokeProvider
/// <summary>
/// Initializes a new instance of the MenuFlyoutItemAutomationPeer class.
/// </summary>
/// <param name="owner">The owner element to create for.</param>
public MenuFlyoutItemAutomationPeer(MenuFlyoutItem owner) : base(owner)
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public MenuFlyoutItemAutomationPeer(global::Microsoft.UI.Xaml.Controls.MenuFlyoutItem owner) : base(owner)
}

protected override object GetPatternCore(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Invoke)
{
return this;
}

return base.GetPatternCore(patternInterface);
}

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

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

protected override string GetAcceleratorKeyCore()
{
var returnValue = base.GetAcceleratorKeyCore();
if (string.IsNullOrEmpty(returnValue))
{
var owner = Owner as MenuFlyoutItem;
if (owner != null)
{
var keyboardAcceleratorTextOverride = owner.KeyboardAcceleratorTextOverride;
returnValue = GetTrimmedKeyboardAcceleratorTextOverride(keyboardAcceleratorTextOverride);
}
}
return returnValue;
}

protected override int GetPositionInSetCore()
{
// First retrieve any valid value being directly set on the container, that value will get precedence.
var returnValue = base.GetPositionInSetCore();

// if it still is default value, calculate it ourselves.
if (returnValue == -1)
{
returnValue = MenuFlyoutPresenter.GetPositionInSetHelper((MenuFlyoutItemBase)Owner);
}

return returnValue;
}

protected override int GetSizeOfSetCore()
{
// First retrieve any valid value being directly set on the container, that value will get precedence.
var returnValue = base.GetSizeOfSetCore();

// if it still is default value, calculate it ourselves.
if (returnValue == -1)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Automation.Peers.MenuFlyoutItemAutomationPeer", "MenuFlyoutItemAutomationPeer.MenuFlyoutItemAutomationPeer(MenuFlyoutItem owner)");
returnValue = MenuFlyoutPresenter.GetSizeOfSetHelper((MenuFlyoutItemBase)Owner);
}
#endif
// Forced skipping of method Microsoft.UI.Xaml.Automation.Peers.MenuFlyoutItemAutomationPeer.MenuFlyoutItemAutomationPeer(Microsoft.UI.Xaml.Controls.MenuFlyoutItem)
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Invoke()

return returnValue;
}

/// <summary>
/// Sends a request to invoke the menu flyout associated with the automation peer.
/// </summary>
public void Invoke()
{
if (!IsEnabled())
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Automation.Peers.MenuFlyoutItemAutomationPeer", "void MenuFlyoutItemAutomationPeer.Invoke()");
throw new ElementNotEnabledException();
}
#endif
// Processing: Microsoft.UI.Xaml.Automation.Provider.IInvokeProvider

((MenuFlyoutItem)Owner).Invoke();
}
}

0 comments on commit b2b8de4

Please sign in to comment.