-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…wCommands Fix Accessibility Insights issues with WindowCommands
- Loading branch information
Showing
4 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/MahApps.Metro/Automation/Peers/WindowCommandsAutomationPeer.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,65 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Windows; | ||
using System.Windows.Automation.Peers; | ||
using JetBrains.Annotations; | ||
using MahApps.Metro.Controls; | ||
|
||
namespace MahApps.Metro.Automation.Peers | ||
{ | ||
public class WindowCommandsAutomationPeer : FrameworkElementAutomationPeer | ||
{ | ||
public WindowCommandsAutomationPeer([NotNull] WindowCommands owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override string GetClassNameCore() | ||
{ | ||
return "WindowCommands"; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.ToolBar; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override string GetNameCore() | ||
{ | ||
string nameCore = base.GetNameCore(); | ||
|
||
if (string.IsNullOrEmpty(nameCore)) | ||
{ | ||
nameCore = ((WindowCommands)this.Owner).Name; | ||
} | ||
|
||
if (string.IsNullOrEmpty(nameCore)) | ||
{ | ||
nameCore = this.GetClassNameCore(); | ||
} | ||
|
||
return nameCore; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override bool IsOffscreenCore() | ||
{ | ||
return !((WindowCommands)this.Owner).HasItems || base.IsOffscreenCore(); | ||
} | ||
|
||
protected override Point GetClickablePointCore() | ||
{ | ||
if (!((WindowCommands)this.Owner).HasItems) | ||
{ | ||
return new Point(double.NaN, double.NaN); | ||
} | ||
|
||
return base.GetClickablePointCore(); | ||
} | ||
} | ||
} |
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
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
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