Skip to content

Commit

Permalink
feat: Implement SemanticZoomAutomationPeer
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 b8041d9 commit 1714da1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#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 SemanticZoomAutomationPeer : global::Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, global::Microsoft.UI.Xaml.Automation.Provider.IToggleProvider
{
#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 global::Microsoft.UI.Xaml.Automation.ToggleState ToggleState
{
Expand All @@ -18,7 +18,7 @@ public partial class SemanticZoomAutomationPeer : global::Microsoft.UI.Xaml.Auto
}
}
#endif
#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 SemanticZoomAutomationPeer(global::Microsoft.UI.Xaml.Controls.SemanticZoom owner) : base(owner)
{
Expand All @@ -27,7 +27,7 @@ public SemanticZoomAutomationPeer(global::Microsoft.UI.Xaml.Controls.SemanticZoo
#endif
// Forced skipping of method Microsoft.UI.Xaml.Automation.Peers.SemanticZoomAutomationPeer.SemanticZoomAutomationPeer(Microsoft.UI.Xaml.Controls.SemanticZoom)
// Forced skipping of method Microsoft.UI.Xaml.Automation.Peers.SemanticZoomAutomationPeer.ToggleState.get
#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 Toggle()
{
Expand Down
63 changes: 63 additions & 0 deletions src/Uno.UI/UI/Xaml/Automation/Peers/SemanticZoomAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference SemanticZoomAutomationPeer_Partial.cpp, tag winui3/release/1.4.2
namespace Microsoft.UI.Xaml.Automation.Peers;

/// <summary>
/// Exposes SemanticZoom types to Microsoft UI Automation.
/// </summary>
public partial class SemanticZoomAutomationPeer : FrameworkElementAutomationPeer, Provider.IToggleProvider
{
public SemanticZoomAutomationPeer(Controls.SemanticZoom owner) : base(owner)
{

}

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

protected override string GetClassNameCore() => nameof(Controls.SemanticZoom);

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

/// <summary>
/// Cycles through the toggle states of a control.
/// </summary>
public void Toggle()
{
if (!IsEnabled())
{
throw new ElementNotEnabledException();
}

(Owner as Controls.SemanticZoom).ToggleActiveView();
}

/// <summary>
/// Gets a value that indicates whether the Toggle method can be called and result in a toggled view.
/// </summary>
public ToggleState ToggleState
{
get
{
if ((Owner as Controls.SemanticZoom).IsZoomedInViewActive)
{
return ToggleState.On;
}
else
{
return ToggleState.Off;
}
}
}
}

0 comments on commit 1714da1

Please sign in to comment.