Skip to content

Commit

Permalink
Merge pull request #3224 from M-Lipin/Issue_3223_ListView_UIA_Accessi…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
RussKie authored Aug 12, 2020
2 parents 1d92ce9 + 85330c4 commit d93a2d4
Show file tree
Hide file tree
Showing 32 changed files with 2,860 additions and 801 deletions.
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 @@ -6722,4 +6722,7 @@ Stack trace where the illegal operation occurred was:
<data name="TextFormatFlagsModifyStringNotAllowed" xml:space="preserve">
<value>TextFormatFlags.ModifyString is not allowed.</value>
</data>
<data name="AccessibleActionDoubleClick" xml:space="preserve">
<value>Double Click</value>
</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>();

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

0 comments on commit d93a2d4

Please sign in to comment.