forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpanderButtonAutomationPeer.cs
More file actions
121 lines (100 loc) · 3.68 KB
/
Copy pathExpanderButtonAutomationPeer.cs
File metadata and controls
121 lines (100 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//-----------------------------------------------------------------------
// <copyright file="ExpanderButtonAutomationPeer.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.Management.UI.Internal
{
#region Using Directives
using System.Diagnostics.CodeAnalysis;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
#endregion
/// <summary>
/// Provides an automation peer for <see cref="ExpanderButton"/>.
/// </summary>
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
public class ExpanderButtonAutomationPeer : ToggleButtonAutomationPeer, IExpandCollapseProvider
{
#region Fields
private ExpanderButton expanderButton;
#endregion
#region Structors
/// <summary>
/// Initializes a new instance of the <see cref="ExpanderButtonAutomationPeer" /> class.
/// </summary>
/// <param name="owner">The owner of the automation peer.</param>
public ExpanderButtonAutomationPeer(ExpanderButton owner)
: base(owner)
{
this.expanderButton = owner;
}
#endregion
#region Overrides
/// <summary>
/// Gets the class name.
/// </summary>
/// <returns>The class name.</returns>
protected override string GetClassNameCore()
{
return this.Owner.GetType().Name;
}
/// <summary>
/// Gets the control pattern for the <see cref="ExpanderButton"/> that is associated with this <see cref="ExpanderButtonAutomationPeer"/>.
/// </summary>
/// <param name="patternInterface">Specifies the control pattern that is returned.</param>
/// <returns>The control pattern for the <see cref="ExpanderButton"/> that is associated with this <see cref="ExpanderButtonAutomationPeer"/>.</returns>
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.ExpandCollapse ||
patternInterface == PatternInterface.Toggle)
{
return this;
}
return null;
}
#endregion
#region IExpandCollapseProvider Implementations
/// <summary>
/// Gets the expand/collapse state of this <see cref="ExpanderButton"/> instance.
/// </summary>
ExpandCollapseState IExpandCollapseProvider.ExpandCollapseState
{
get
{
if (true == this.expanderButton.IsChecked)
{
return ExpandCollapseState.Expanded;
}
else
{
return ExpandCollapseState.Collapsed;
}
}
}
/// <summary>
/// Expands this instance of <see cref="ExpanderButton"/>.
/// </summary>
void IExpandCollapseProvider.Expand()
{
if (!this.IsEnabled())
{
throw new ElementNotEnabledException();
}
this.expanderButton.IsChecked = true;
}
/// <summary>
/// Collapses this instance of <see cref="ExpanderButton"/>.
/// </summary>
void IExpandCollapseProvider.Collapse()
{
if (!this.IsEnabled())
{
throw new ElementNotEnabledException();
}
this.expanderButton.IsChecked = false;
}
#endregion
}
}