Skip to content

Commit 0c7408a

Browse files
committed
Update the UI automation classes
1 parent e49e479 commit 0c7408a

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/Files.App.Controls/Sidebar/SidebarItemAutomationPeer.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace Files.App.Controls
1111
{
12+
/// <summary>
13+
/// Exposes <see cref="SidebarItem"/> types to Microsoft UI Automation.
14+
/// </summary>
1215
public sealed partial class SidebarItemAutomationPeer : FrameworkElementAutomationPeer, IInvokeProvider, IExpandCollapseProvider, ISelectionItemProvider
1316
{
1417
public ExpandCollapseState ExpandCollapseState
@@ -17,6 +20,7 @@ public ExpandCollapseState ExpandCollapseState
1720
{
1821
if (Owner.HasChildren)
1922
return Owner.IsExpanded ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed;
23+
2024
return ExpandCollapseState.LeafNode;
2125
}
2226
}
@@ -27,7 +31,7 @@ public ExpandCollapseState ExpandCollapseState
2731

2832
public SidebarItemAutomationPeer(SidebarItem owner) : base(owner)
2933
{
30-
this.Owner = owner;
34+
Owner = owner;
3135
}
3236

3337
protected override AutomationControlType GetAutomationControlTypeCore()
@@ -49,28 +53,22 @@ protected override object GetPatternCore(PatternInterface patternInterface)
4953
else if (patternInterface == PatternInterface.ExpandCollapse)
5054
{
5155
if (Owner.CollapseEnabled)
52-
{
5356
return this;
54-
}
5557
}
58+
5659
return base.GetPatternCore(patternInterface);
5760
}
5861

5962
public void Collapse()
6063
{
6164
if (Owner.CollapseEnabled)
62-
{
6365
Owner.IsExpanded = false;
64-
}
6566
}
6667

6768
public void Expand()
6869
{
69-
7070
if (Owner.CollapseEnabled)
71-
{
7271
Owner.IsExpanded = true;
73-
}
7472
}
7573

7674
public void Invoke()
@@ -106,13 +104,11 @@ protected override int GetPositionInSetCore()
106104
private IList GetOwnerCollection()
107105
{
108106
if (Owner.FindAscendant<SidebarItem>() is SidebarItem parent && parent.Item?.Children is IList list)
109-
{
110107
return list;
111-
}
108+
112109
if (Owner?.Owner is not null && Owner.Owner.ViewModel.SidebarItems is IList items)
113-
{
114110
return items;
115-
}
111+
116112
return new List<object>();
117113
}
118114
}

src/Files.App.Controls/Sidebar/SidebarViewAutomationPeer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Files.App.Controls
88
{
9+
/// <summary>
10+
/// Exposes <see cref="SidebarView"/> types to Microsoft UI Automation.
11+
/// </summary>
912
public sealed partial class SidebarViewAutomationPeer : FrameworkElementAutomationPeer, ISelectionProvider
1013
{
1114
public bool CanSelectMultiple => false;
@@ -20,20 +23,17 @@ public SidebarViewAutomationPeer(SidebarView owner) : base(owner)
2023

2124
protected override object GetPatternCore(PatternInterface patternInterface)
2225
{
23-
if (patternInterface == PatternInterface.Selection)
24-
{
26+
if (patternInterface is PatternInterface.Selection)
2527
return this;
26-
}
28+
2729
return base.GetPatternCore(patternInterface);
2830
}
2931

3032
public IRawElementProviderSimple[] GetSelection()
3133
{
3234
if (Owner.SelectedItemContainer != null)
33-
return
34-
[
35-
ProviderFromPeer(CreatePeerForElement(Owner.SelectedItemContainer))
36-
];
35+
return [ProviderFromPeer(CreatePeerForElement(Owner.SelectedItemContainer))];
36+
3737
return [];
3838
}
3939
}

0 commit comments

Comments
 (0)