forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Primitives to implement TextPattern support
- Add ITextRange and ITextProvider interfaces as a base of TextPattern Refer to: https://docs.microsoft.com/dotnet/api/system.windows.automation.provider.itextprovider https://docs.microsoft.com/dotnet/api/system.windows.automation.provider.itextrangeprovider - Implement UiaTextRange and UiaTextProvider to support text pattern in textbox controls - Add tests - Move IAutomationLiveRegion to Primitives
- Loading branch information
1 parent
118ba6d
commit 7545756
Showing
38 changed files
with
3,121 additions
and
98 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
30 changes: 30 additions & 0 deletions
30
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider.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,30 @@ | ||
// 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.Drawing; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
[ComImport] | ||
[Guid("3589c92c-63f3-4367-99bb-ada653b77cf2")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface ITextProvider | ||
{ | ||
ITextRangeProvider[]? GetSelection(); | ||
|
||
ITextRangeProvider[]? GetVisibleRanges(); | ||
|
||
ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement); | ||
|
||
ITextRangeProvider? RangeFromPoint(Point screenLocation); | ||
|
||
ITextRangeProvider? DocumentRange { get; } | ||
|
||
SupportedTextSelection SupportedTextSelection { get; } | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextProvider2.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,34 @@ | ||
// 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.Drawing; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
[ComImport] | ||
[Guid("0dc5e6ed-3e16-4bf1-8f9a-a979878bc195")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface ITextProvider2 : ITextProvider | ||
{ | ||
new ITextRangeProvider[]? GetSelection(); | ||
|
||
new ITextRangeProvider[]? GetVisibleRanges(); | ||
|
||
new ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement); | ||
|
||
new ITextRangeProvider? RangeFromPoint(Point screenLocation); | ||
|
||
new ITextRangeProvider? DocumentRange { get; } | ||
|
||
new SupportedTextSelection SupportedTextSelection { get; } | ||
|
||
ITextRangeProvider? RangeFromAnnotation(IRawElementProviderSimple annotation); | ||
|
||
ITextRangeProvider? GetCaretRange(out BOOL isActive); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.ITextRangeProvider.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,53 @@ | ||
// 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.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
[ComImport] | ||
[Guid("5347ad7b-c355-46f8-aff5-909033582f63")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface ITextRangeProvider | ||
{ | ||
ITextRangeProvider Clone(); | ||
|
||
BOOL Compare(ITextRangeProvider range); | ||
|
||
int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint); | ||
|
||
void ExpandToEnclosingUnit(TextUnit unit); | ||
|
||
ITextRangeProvider? FindAttribute(int attribute, object value, BOOL backward); | ||
|
||
ITextRangeProvider? FindText(string text, BOOL backward, BOOL ignoreCase); | ||
|
||
object? GetAttributeValue(int attribute); | ||
|
||
double[] GetBoundingRectangles(); | ||
|
||
IRawElementProviderSimple GetEnclosingElement(); | ||
|
||
string GetText(int maxLength); | ||
|
||
int Move(TextUnit unit, int count); | ||
|
||
int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count); | ||
|
||
void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint); | ||
|
||
void Select(); | ||
|
||
void AddToSelection(); | ||
|
||
void RemoveFromSelection(); | ||
|
||
void ScrollIntoView(BOOL alignToTop); | ||
|
||
IRawElementProviderSimple[] GetChildren(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.SupportedTextSelection.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,19 @@ | ||
// 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; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
[Flags] | ||
public enum SupportedTextSelection | ||
{ | ||
None = 0, | ||
Single = 1, | ||
Multiple = 2 | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextAttributeIdentifier.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,56 @@ | ||
// 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. | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
public enum TextAttributeIdentifier | ||
{ | ||
AnimationStyleAttributeId = 40000, | ||
BackgroundColorAttributeId = 40001, | ||
BulletStyleAttributeId = 40002, | ||
CapStyleAttributeId = 40003, | ||
CultureAttributeId = 40004, | ||
FontNameAttributeId = 40005, | ||
FontSizeAttributeId = 40006, | ||
FontWeightAttributeId = 40007, | ||
ForegroundColorAttributeId = 40008, | ||
HorizontalTextAlignmentAttributeId = 40009, | ||
IndentationFirstLineAttributeId = 40010, | ||
IndentationLeadingAttributeId = 40011, | ||
IndentationTrailingAttributeId = 40012, | ||
IsHiddenAttributeId = 40013, | ||
IsItalicAttributeId = 40014, | ||
IsReadOnlyAttributeId = 40015, | ||
IsSubscriptAttributeId = 40016, | ||
IsSuperscriptAttributeId = 40017, | ||
MarginBottomAttributeId = 40018, | ||
MarginLeadingAttributeId = 40019, | ||
MarginTopAttributeId = 40020, | ||
MarginTrailingAttributeId = 40021, | ||
OutlineStylesAttributeId = 40022, | ||
OverlineColorAttributeId = 40023, | ||
OverlineStyleAttributeId = 40024, | ||
StrikethroughColorAttributeId = 40025, | ||
StrikethroughStyleAttributeId = 40026, | ||
TabsAttributeId = 40027, | ||
TextFlowDirectionsAttributeId = 40028, | ||
UnderlineColorAttributeId = 40029, | ||
UnderlineStyleAttributeId = 40030, | ||
AnnotationTypesAttributeId = 40031, | ||
AnnotationObjectsAttributeId = 40032, | ||
StyleNameAttributeId = 40033, | ||
StyleIdAttributeId = 40034, | ||
LinkAttributeId = 40035, | ||
IsActiveAttributeId = 40036, | ||
SelectionActiveEndAttributeId = 40037, | ||
CaretPositionAttributeId = 40038, | ||
CaretBidiModeAttributeId = 40039, | ||
LineSpacingAttributeId = 40040, | ||
BeforeParagraphSpacingAttributeId = 40041, | ||
AfterParagraphSpacingAttributeId = 40042 | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextPatternRangeEndpoint.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,18 @@ | ||
// 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; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
public enum TextPatternRangeEndpoint | ||
{ | ||
Start = 0, | ||
End = 1 | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.TextUnit.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,22 @@ | ||
// 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.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
public enum TextUnit | ||
{ | ||
Character = 0, | ||
Format = 1, | ||
Word = 2, | ||
Line = 3, | ||
Paragraph = 4, | ||
Page = 5, | ||
Document = 6 | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/System.Windows.Forms.Primitives/src/Interop/UiaCore/Interop.UiaCoreTypes.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,26 @@ | ||
// 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.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class UiaCore | ||
{ | ||
private static object? s_notSupportedValue; | ||
|
||
[DllImport(Libraries.UiaCore, ExactSpelling = true)] | ||
private static extern int UiaGetReservedNotSupportedValue([MarshalAs(UnmanagedType.IUnknown)] out object notSupportedValue); | ||
|
||
public static object UiaGetReservedNotSupportedValue() | ||
{ | ||
if (s_notSupportedValue == null) | ||
{ | ||
UiaGetReservedNotSupportedValue(out s_notSupportedValue); | ||
} | ||
|
||
return s_notSupportedValue; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.Atom.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,32 @@ | ||
// 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; | ||
|
||
internal static partial class Interop | ||
{ | ||
/// <summary> | ||
/// Simple wrapper for an ATOM | ||
/// </summary> | ||
public struct Atom | ||
{ | ||
// #define MAXINTATOM 0xC000 | ||
// #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i))) | ||
// #define INVALID_ATOM ((ATOM)0) | ||
|
||
// Strange uses for window class atoms | ||
// https://blogs.msdn.microsoft.com/oldnewthing/20080501-00/?p=22503/ | ||
|
||
public ushort ATOM; | ||
|
||
public Atom(ushort atom) => ATOM = atom; | ||
|
||
public static Atom Null = new Atom(0); | ||
|
||
public bool IsValid => ATOM != 0; | ||
|
||
public static implicit operator uint(Atom atom) => atom.ATOM; | ||
public static implicit operator Atom(IntPtr atom) => new Atom((ushort)atom); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.GCL.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,22 @@ | ||
// 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. | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class User32 | ||
{ | ||
public enum GCL : int | ||
{ | ||
/// <summary> | ||
/// (GCL_WNDPROC) | ||
/// </summary> | ||
WNDPROC = -24, | ||
|
||
/// <summary> | ||
/// (GCW_ATOM) | ||
/// </summary> | ||
ATOM = -32, | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.GetCaretPos.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,15 @@ | ||
// 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.Drawing; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class User32 | ||
{ | ||
[DllImport(Libraries.User32, ExactSpelling = true)] | ||
public static extern BOOL GetCaretPos(out Point pt); | ||
} | ||
} |
Oops, something went wrong.