// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
namespace Microsoft.Management.UI.Internal
{
///
/// Provides a base automation peer for FrameworkElement controls.
///
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
public class ExtendedFrameworkElementAutomationPeer : FrameworkElementAutomationPeer
{
#region Fields
///
/// Gets or sets the control type of the element that is associated with this automation peer.
///
private AutomationControlType controlType = AutomationControlType.Custom;
///
/// Gets or sets a value that indicates whether the control should show in the logical tree.
///
private bool isControlElement = true;
#endregion
#region Structors
///
/// Initializes a new instance of the class.
///
/// The owner of the automation peer.
public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner)
: base(owner)
{
// This constructor intentionally left blank
}
///
/// Initializes a new instance of the class.
///
/// The owner of the automation peer.
/// The control type of the element that is associated with the automation peer.
public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType)
: this(owner)
{
this.controlType = controlType;
}
///
/// Initializes a new instance of the class.
///
/// The owner of the automation peer.
/// The control type of the element that is associated with the automation peer.
/// Whether the element should show in the logical tree.
public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType, bool isControlElement)
: this(owner, controlType)
{
this.isControlElement = isControlElement;
}
#endregion
#region Overrides
///
/// Gets the class name.
///
/// The class name.
protected override string GetClassNameCore()
{
return this.Owner.GetType().Name;
}
///
/// Gets the control type of the element that is associated with the automation peer.
///
/// Returns the control type of the element that is associated with the automation peer.
protected override AutomationControlType GetAutomationControlTypeCore()
{
return this.controlType;
}
///
/// Gets a value that indicates whether the element is understood by the user as interactive or as contributing to the logical structure of the control in the GUI. Called by IsControlElement().
///
/// This method always returns true.
protected override bool IsControlElementCore()
{
return this.isControlElement;
}
#endregion
}
}