2020-09-02 13:34:07 -07:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Automation.Peers;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PowerLauncher
|
|
|
|
|
|
{
|
2023-03-16 15:51:31 +01:00
|
|
|
|
public sealed class CustomSearchBox : TextBox
|
2020-09-02 13:34:07 -07:00
|
|
|
|
{
|
|
|
|
|
|
public List<UIElement> ControlledElements { get; } = new List<UIElement>();
|
|
|
|
|
|
|
|
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new AutoSuggestTextBoxAutomationPeer(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-16 15:51:31 +01:00
|
|
|
|
internal sealed class AutoSuggestTextBoxAutomationPeer : TextBoxAutomationPeer
|
2020-09-02 13:34:07 -07:00
|
|
|
|
{
|
|
|
|
|
|
public AutoSuggestTextBoxAutomationPeer(CustomSearchBox owner)
|
|
|
|
|
|
: base(owner)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override List<AutomationPeer> GetControlledPeersCore()
|
|
|
|
|
|
{
|
|
|
|
|
|
var controlledPeers = new List<AutomationPeer>();
|
|
|
|
|
|
foreach (UIElement controlledElement in ((CustomSearchBox)Owner).ControlledElements)
|
|
|
|
|
|
{
|
|
|
|
|
|
controlledPeers.Add(UIElementAutomationPeer.CreatePeerForElement(controlledElement));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return controlledPeers;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|