-
-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding automation peer for RibbonGroupBox #647
- Loading branch information
Showing
3 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Fluent.Ribbon/Automation/Peers/RibbonControlDataAutomationPeer.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,52 @@ | ||
namespace Fluent.Automation.Peers | ||
{ | ||
using System.Windows.Automation.Peers; | ||
using Fluent.Extensions; | ||
|
||
/// <summary> | ||
/// Automation peer for ribbon control items. | ||
/// </summary> | ||
public class RibbonControlDataAutomationPeer : ItemAutomationPeer | ||
{ | ||
/// <summary> | ||
/// Creates a new instance. | ||
/// </summary> | ||
public RibbonControlDataAutomationPeer(object item, ItemsControlAutomationPeer itemsControlPeer) | ||
: base(item, itemsControlPeer) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.ListItem; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override string GetClassNameCore() | ||
{ | ||
var wrapperPeer = this.GetWrapperPeer(); | ||
|
||
if (wrapperPeer != null) | ||
{ | ||
return wrapperPeer.GetClassName(); | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override object GetPattern(PatternInterface patternInterface) | ||
{ | ||
object result = null; | ||
var wrapperPeer = this.GetWrapperPeer(); | ||
|
||
if (wrapperPeer != null) | ||
{ | ||
result = wrapperPeer.GetPattern(patternInterface); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
Fluent.Ribbon/Automation/Peers/RibbonGroupBoxAutomationPeer.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,102 @@ | ||
namespace Fluent.Automation.Peers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows.Automation; | ||
using System.Windows.Automation.Peers; | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// Automation peer for <see cref="RibbonGroupBox"/>. | ||
/// </summary> | ||
public class RibbonGroupBoxAutomationPeer : ItemsControlAutomationPeer | ||
{ | ||
private RibbonGroupHeaderAutomationPeer headerPeer; | ||
|
||
private RibbonGroupBox OwningGroup => (RibbonGroupBox)this.Owner; | ||
|
||
private RibbonGroupHeaderAutomationPeer HeaderPeer | ||
{ | ||
get | ||
{ | ||
if (this.headerPeer == null | ||
|| !this.headerPeer.Owner.IsDescendantOf(this.OwningGroup)) | ||
{ | ||
if (this.OwningGroup.State == RibbonGroupBoxState.Collapsed) | ||
{ | ||
if (this.OwningGroup.DropDownPopup != null) | ||
{ | ||
this.headerPeer = new RibbonGroupHeaderAutomationPeer(this.OwningGroup.DropDownPopup); | ||
} | ||
} | ||
else if (this.OwningGroup.Header != null) | ||
{ | ||
this.headerPeer = new RibbonGroupHeaderAutomationPeer(this.OwningGroup); | ||
} | ||
} | ||
|
||
return this.headerPeer; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance. | ||
/// </summary> | ||
public RibbonGroupBoxAutomationPeer([NotNull] RibbonGroupBox owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override List<AutomationPeer> GetChildrenCore() | ||
{ | ||
var list = base.GetChildrenCore(); | ||
|
||
if (this.HeaderPeer != null) | ||
{ | ||
if (list == null) | ||
{ | ||
list = new List<AutomationPeer>(1); | ||
} | ||
|
||
list.Add(this.HeaderPeer); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override string GetClassNameCore() | ||
{ | ||
return this.Owner.GetType().Name; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override object GetPattern(PatternInterface patternInterface) | ||
{ | ||
if (patternInterface == PatternInterface.Scroll) | ||
{ | ||
return null; | ||
} | ||
|
||
return base.GetPattern(patternInterface); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void SetFocusCore() | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override ItemAutomationPeer CreateItemAutomationPeer(object item) | ||
{ | ||
return new RibbonControlDataAutomationPeer(item, this); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
internal void RaiseExpandCollapseAutomationEvent(bool oldValue, bool newValue) | ||
{ | ||
this.EventsSource?.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, oldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed, newValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed); | ||
} | ||
} | ||
} |
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