Browse Source

Convert ExpandCollapseState to its UIA wire value in the Win32 automation layer; Avalonia declares PartiallyExpanded and LeafNode in the opposite order from UIA. (#21693)

pull/21695/head
Jumar Macato 3 months ago
committed by GitHub
parent
commit
facc253b21
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      src/Windows/Avalonia.Win32.Automation/AutomationNode.ExpandCollapse.cs
  2. 4
      src/Windows/Avalonia.Win32.Automation/AutomationNode.cs
  3. 3
      src/Windows/Avalonia.Win32.Automation/Interop/IExpandCollapseProvider.cs

15
src/Windows/Avalonia.Win32.Automation/AutomationNode.ExpandCollapse.cs

@ -6,11 +6,22 @@ namespace Avalonia.Win32.Automation
{
internal partial class AutomationNode : UIA.IExpandCollapseProvider
{
ExpandCollapseState UIA.IExpandCollapseProvider.GetExpandCollapseState()
int UIA.IExpandCollapseProvider.GetExpandCollapseState()
{
return InvokeSync<IExpandCollapseProvider, ExpandCollapseState>(x => x.ExpandCollapseState);
return ToUiaExpandCollapseState(InvokeSync<IExpandCollapseProvider, ExpandCollapseState>(x => x.ExpandCollapseState));
}
// Avalonia declares PartiallyExpanded and LeafNode in the opposite order
// from the UIA wire values.
internal static int ToUiaExpandCollapseState(ExpandCollapseState state) => state switch
{
ExpandCollapseState.Collapsed => 0,
ExpandCollapseState.Expanded => 1,
ExpandCollapseState.PartiallyExpanded => 2,
ExpandCollapseState.LeafNode => 3,
_ => 0,
};
void UIA.IExpandCollapseProvider.Expand() => InvokeSync<IExpandCollapseProvider>(x => x.Expand());
void UIA.IExpandCollapseProvider.Collapse() => InvokeSync<IExpandCollapseProvider>(x => x.Collapse());
}

4
src/Windows/Avalonia.Win32.Automation/AutomationNode.cs

@ -301,8 +301,8 @@ namespace Avalonia.Win32.Automation
UiaCoreProviderApi.UiaRaiseAutomationPropertyChangedEvent(
this,
(int)id,
e.OldValue as IConvertible,
e.NewValue as IConvertible);
e.OldValue is ExpandCollapseState o ? ToUiaExpandCollapseState(o) : e.OldValue as IConvertible,
e.NewValue is ExpandCollapseState n ? ToUiaExpandCollapseState(n) : e.NewValue as IConvertible);
}
if (id == UiaPropertyId.Name && Peer.GetLiveSetting() != AutomationLiveSetting.Off)

3
src/Windows/Avalonia.Win32.Automation/Interop/IExpandCollapseProvider.cs

@ -1,6 +1,5 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Avalonia.Automation;
namespace Avalonia.Win32.Automation.Interop;
@ -10,5 +9,5 @@ internal partial interface IExpandCollapseProvider
{
void Expand();
void Collapse();
ExpandCollapseState GetExpandCollapseState();
int GetExpandCollapseState();
}

Loading…
Cancel
Save