-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #768 by adding automation peer for TwoLineLabel
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Fluent.Ribbon/Automation/Peers/TwoLineLabelAutomationPeer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace Fluent.Automation.Peers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Windows.Automation.Peers; | ||
using System.Windows.Automation.Provider; | ||
using System.Windows.Controls; | ||
|
||
/// <summary> | ||
/// <see cref="AutomationPeer"/> for <see cref="TwoLineLabel"/>. | ||
/// </summary> | ||
public class TwoLineLabelAutomationPeer : FrameworkElementAutomationPeer | ||
{ | ||
/// <summary> | ||
/// Constructor. | ||
/// </summary> | ||
/// <param name="owner">Owner of the AutomationPeer.</param> | ||
public TwoLineLabelAutomationPeer(TwoLineLabel owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="AutomationPeer.GetChildrenCore"/> | ||
/// </summary> | ||
protected override List<AutomationPeer> GetChildrenCore() | ||
{ | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="AutomationPeer.GetAutomationControlTypeCore"/> | ||
/// </summary> | ||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.Text; | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="AutomationPeer.GetClassNameCore"/> | ||
/// </summary> | ||
/// <returns></returns> | ||
protected override string GetClassNameCore() | ||
{ | ||
return "TwoLineLabel"; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override string GetNameCore() | ||
{ | ||
return ((TwoLineLabel)this.Owner).Text; | ||
} | ||
|
||
/// <summary> | ||
/// <see cref="AutomationPeer.IsControlElementCore"/> | ||
/// </summary> | ||
protected override bool IsControlElementCore() | ||
{ | ||
// Return false if TwoLineLabel is part of a ControlTemplate, otherwise return the base method | ||
var tb = (TwoLineLabel)this.Owner; | ||
var templatedParent = tb.TemplatedParent; | ||
|
||
// If the templatedParent is a ContentPresenter, this TextBlock is generated from a DataTemplate | ||
if (templatedParent == null | ||
|| templatedParent is ContentPresenter) | ||
{ | ||
return base.IsControlElementCore(); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters