Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ListView control UIA accessibility #3224

Merged
merged 3 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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("6278cab1-b556-4a1a-b4e0-418acc523201")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMultipleViewProvider
{
string? GetViewName(int viewId);

void SetCurrentView(int viewId);

int CurrentView { get; }

int[]? GetSupportedViews();
}
}
}
3 changes: 3 additions & 0 deletions src/System.Windows.Forms/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6719,4 +6719,7 @@ Stack trace where the illegal operation occurred was:
<data name="ConstructorArgumentInvalidValueType" xml:space="preserve">
<value>Argument '{0}' cannot be converted to type '{1}'.</value>
</data>
<data name="AccessibleActionDoubleClick" xml:space="preserve">
<value>Double Click</value>
M-Lipin marked this conversation as resolved.
Show resolved Hide resolved
</data>
</root>
5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public partial class AccessibleObject :
UiaCore.ISelectionProvider,
UiaCore.ISelectionItemProvider,
UiaCore.IRawElementProviderHwndOverride,
UiaCore.IScrollItemProvider
UiaCore.IScrollItemProvider,
UiaCore.IMultipleViewProvider
{
/// <summary>
/// Specifies the <see cref='IAccessible'/> interface used by this <see cref='AccessibleObject'/>.
Expand Down Expand Up @@ -482,6 +483,16 @@ internal virtual void SetValue(string? newValue)

internal virtual UiaCore.IRawElementProviderSimple? GetOverrideProviderForHwnd(IntPtr hwnd) => null;

internal virtual int GetMultiViewProviderCurrentView() => 0;

internal virtual int[]? GetMultiViewProviderSupportedViews() => Array.Empty<int>();
RussKie marked this conversation as resolved.
Show resolved Hide resolved

internal virtual string GetMultiViewProviderViewName(int viewId) => string.Empty;

internal virtual void SetMultiViewProviderCurrentView(int viewId)
{
}

internal virtual void SetValue(double newValue)
{
}
Expand Down Expand Up @@ -1782,6 +1793,14 @@ MemberInfo[] IReflect.GetMembers(BindingFlags bindingAttr)
UiaCore.IRawElementProviderSimple? UiaCore.IRawElementProviderHwndOverride.GetOverrideProviderForHwnd(IntPtr hwnd)
=> GetOverrideProviderForHwnd(hwnd);

int UiaCore.IMultipleViewProvider.CurrentView => GetMultiViewProviderCurrentView();

int[]? UiaCore.IMultipleViewProvider.GetSupportedViews() => GetMultiViewProviderSupportedViews();

string? UiaCore.IMultipleViewProvider.GetViewName(int viewId) => GetMultiViewProviderViewName(viewId);

void UiaCore.IMultipleViewProvider.SetCurrentView(int viewId) => SetMultiViewProviderCurrentView(viewId);

BOOL UiaCore.IRangeValueProvider.IsReadOnly => IsReadOnly ? BOOL.TRUE : BOOL.FALSE;

double UiaCore.IRangeValueProvider.LargeChange => LargeChange;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 static Interop.UiaCore;

namespace System.Windows.Forms
{
public partial class ColumnHeader
{
internal class ListViewColumnHeaderAccessibleObject : AccessibleObject
{
private readonly ColumnHeader _owningColumnHeader;

public ListViewColumnHeaderAccessibleObject(ColumnHeader columnHeader)
{
_owningColumnHeader = columnHeader ?? throw new ArgumentNullException(nameof(columnHeader));
}

internal override object? GetPropertyValue(UIA propertyID)
=> propertyID switch
{
UIA.ControlTypePropertyId => UIA.HeaderItemControlTypeId,
UIA.NamePropertyId => _owningColumnHeader.Text,
_ => base.GetPropertyValue(propertyID)
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace System.Windows.Forms
[DesignTimeVisible(false)]
[DefaultProperty(nameof(Text))]
[TypeConverter(typeof(ColumnHeaderConverter))]
public class ColumnHeader : Component, ICloneable
public partial class ColumnHeader : Component, ICloneable
{
// disable csharp compiler warning #0414: field assigned unused value
#pragma warning disable 0414
Expand All @@ -32,6 +32,7 @@ public class ColumnHeader : Component, ICloneable
// Use TextAlign property instead of this member variable, always
private HorizontalAlignment _textAlign = HorizontalAlignment.Left;
private bool _textAlignInitialized;
private AccessibleObject _accessibilityObject;
private readonly ColumnHeaderImageListIndexer _imageIndexer;

// We need to send some messages to ListView when it gets initialized.
Expand Down Expand Up @@ -76,6 +77,19 @@ public ColumnHeader(string imageKey) : this()
ImageKey = imageKey;
}

internal AccessibleObject AccessibilityObject
{
get
{
if (_accessibilityObject is null)
{
_accessibilityObject = new ListViewColumnHeaderAccessibleObject(this);
}

return _accessibilityObject;
}
}

internal int ActualImageIndex_Internal
{
get
Expand Down
Loading