diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index ba9b1abfd01..8bf114a5377 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -6731,4 +6731,7 @@ Stack trace where the illegal operation occurred was: Drop down control holder + + Edit + diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf index aa1dda3b9ef..47a4a5c7683 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -10801,6 +10801,11 @@ Trasování zásobníku, kde došlo k neplatné operaci: Nahoru + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Určuje, zda má být vykreslování textu kompatibilní s předchozími verzemi knihovny Windows Forms. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf index 8314eb4c901..d686ab59fce 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -10801,6 +10801,11 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Nach oben + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Gibt an, ob die Textdarstellung kompatibel mit Windows Forms-Vorgängerversionen sein soll. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf index 96fbdcf136e..ff07f30461d 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -10801,6 +10801,11 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Arriba + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Especifica si la representación del texto debería ser compatible con versiones anteriores de Windows Forms. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf index b4a518dce26..6d32b01407d 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -10801,6 +10801,11 @@ Cette opération non conforme s'est produite sur la trace de la pile : Haut + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Spécifie si le rendu de texte doit être compatible avec les versions antérieures de Windows Forms. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf index 8bccc7de4d2..bd65c289caa 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -10801,6 +10801,11 @@ Traccia dello stack da cui si è verificata l'operazione non valida: SU + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Specifica se il rendering del testo deve essere compatibile con le versioni precedenti di Windows Form. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf index c9c0f7374f7..a1ba5d5ad91 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -10801,6 +10801,11 @@ Stack trace where the illegal operation occurred was: + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. テキストの表示が Windows Forms の以前のリリースとの互換性を維持するかどうかを指定します。 diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf index fc78c545d5a..772097982de 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -10801,6 +10801,11 @@ Stack trace where the illegal operation occurred was: 위쪽 + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. 텍스트 렌더링이 Windows Forms의 이전 버전과 호환되는지 여부를 지정합니다. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf index 64d2efb740c..7f178c57a90 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -10801,6 +10801,11 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: W górę + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Określa, czy renderowanie tekstu powinno być zgodne z poprzednimi wydaniami formantów systemu Windows. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf index 881e7ca189d..09712f7ae00 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf @@ -10801,6 +10801,11 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Acima + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Especifica se o texto renderizado deve ser compatível com versões anteriores do Windows Forms. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf index d1760fabbba..573a3dee197 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -10802,6 +10802,11 @@ Stack trace where the illegal operation occurred was: Вверх + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Определяет, должен ли отображаемый текст быть совместимым с предыдущими версиями Windows Forms. @@ -11134,4 +11139,4 @@ Stack trace where the illegal operation occurred was: - \ No newline at end of file + diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf index 498d69bebb1..9253cc0bfee 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -10801,6 +10801,11 @@ Geçersiz işlemin gerçekleştiği yığın izi: Yukarı + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. Metin işlemenin Windows Forms'un derlemeleriyle uyumlu olması gerekip gerekmediğini belirtir. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf index f3d2cf80e78..0d18059bd35 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf @@ -10801,6 +10801,11 @@ Stack trace where the illegal operation occurred was: 向上键 + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. 指定文本呈现是否应该与早期版本的 Windows 窗体兼容。 diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf index 879922305ac..af312b2088c 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf @@ -10801,6 +10801,11 @@ Stack trace where the illegal operation occurred was: 向上鍵 + + Edit + Edit + + Specifies whether text rendering should be compatible with previous releases of Windows Forms. 指定文字呈現是否應與 Windows Form 以前的版本相容。 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs new file mode 100644 index 00000000000..2d2c45e654a --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObject.cs @@ -0,0 +1,57 @@ +// 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; + +namespace System.Windows.Forms +{ + public abstract partial class UpDownBase + { + internal partial class UpDownEdit + { + internal class UpDownEditAccessibleObject : ControlAccessibleObject + { + private readonly UpDownEdit _owningUpDownEdit; + private readonly TextBoxBaseUiaTextProvider _textProvider; + private readonly UpDownBase _parent; + + public UpDownEditAccessibleObject(UpDownEdit owner, UpDownBase parent) : base(owner) + { + _parent = parent ?? throw new ArgumentNullException(nameof(parent)); + _owningUpDownEdit = owner; + _textProvider = new TextBoxBaseUiaTextProvider(owner); + UseTextProviders(_textProvider, _textProvider); + } + + internal override bool IsIAccessibleExSupported() => true; + + public override string? Name + { + get => _parent.AccessibilityObject.Name; + set => _parent.AccessibilityObject.Name = value; + } + + public override string? KeyboardShortcut => _parent.AccessibilityObject.KeyboardShortcut; + + internal override object? GetPropertyValue(UiaCore.UIA propertyID) + => propertyID switch + { + UiaCore.UIA.IsTextPatternAvailablePropertyId => IsPatternSupported(UiaCore.UIA.TextPatternId), + UiaCore.UIA.IsTextPattern2AvailablePropertyId => IsPatternSupported(UiaCore.UIA.TextPattern2Id), + _ => base.GetPropertyValue(propertyID), + }; + + internal override bool IsPatternSupported(UiaCore.UIA patternId) + => patternId switch + { + UiaCore.UIA.TextPatternId => true, + UiaCore.UIA.TextPattern2Id => true, + _ => base.IsPatternSupported(patternId) + }; + + internal override bool IsReadOnly => _owningUpDownEdit.ReadOnly; + } + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs index 8c585eedf06..a4af4676577 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownEdit.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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. @@ -11,7 +11,7 @@ namespace System.Windows.Forms { public abstract partial class UpDownBase { - internal class UpDownEdit : TextBox + internal partial class UpDownEdit : TextBox { private readonly UpDownBase _parent; private bool _doubleClickFired; @@ -30,11 +30,13 @@ public override string Text set { bool valueChanged = (value != base.Text); - base.Text = value; if (valueChanged) { - AccessibilityNotifyClients(AccessibleEvents.NameChange, -1); + AccessibilityObject.RaiseAutomationNotification(Automation.AutomationNotificationKind.ActionCompleted, + Automation.AutomationNotificationProcessing.CurrentThenMostRecent, SR.UpDownEditLocalizedControlTypeName); + AccessibilityObject.RaiseAutomationEvent(UiaCore.UIA.Text_TextChangedEventId); } + base.Text = value; } } @@ -108,24 +110,6 @@ protected override void OnGotFocus(EventArgs e) protected override void OnLostFocus(EventArgs e) => _parent.InvokeLostFocus(_parent, e); - - internal class UpDownEditAccessibleObject : ControlAccessibleObject - { - readonly UpDownBase _parent; - - public UpDownEditAccessibleObject(UpDownEdit owner, UpDownBase parent) : base(owner) - { - _parent = parent; - } - - public override string Name - { - get => _parent.AccessibilityObject.Name; - set => _parent.AccessibilityObject.Name = value; - } - - public override string KeyboardShortcut => _parent.AccessibilityObject.KeyboardShortcut; - } } } } diff --git a/src/System.Windows.Forms/tests/UnitTests/AccessibleObjects/UpDownEditAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/AccessibleObjects/UpDownEditAccessibleObjectTests.cs deleted file mode 100644 index 43d38c58ea0..00000000000 --- a/src/System.Windows.Forms/tests/UnitTests/AccessibleObjects/UpDownEditAccessibleObjectTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 Xunit; -using static Interop.UiaCore; - -namespace System.Windows.Forms.Tests.AccessibleObjects -{ - public class UpDownEditAccessibleObjectTests - { - [WinFormsFact] - public void UpDownEditAccessibleObject_ctor_default() - { - using UpDownBase upDown = new SubUpDownBase(); - using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); - Assert.NotNull(upDownEdit.AccessibilityObject); - Assert.False(upDown.IsHandleCreated); - } - - private class SubUpDownBase : UpDownBase - { - public override void DownButton() { } - - public override void UpButton() { } - - protected override void UpdateEditText() { } - } - } -} diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObjectTests.cs new file mode 100644 index 00000000000..76727b959b9 --- /dev/null +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/UpDownBase.UpDownEdit.UpDownEditAccessibleObjectTests.cs @@ -0,0 +1,133 @@ +// 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 Xunit; +using static Interop; + +namespace System.Windows.Forms.Tests +{ + public class UpDownEditAccessibleObjectTests + { + [WinFormsFact] + public void UpDownEditAccessibleObject_ctor_default() + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + UpDownBase.UpDownEdit.UpDownEditAccessibleObject accessibleObject = new UpDownBase.UpDownEdit.UpDownEditAccessibleObject(upDownEdit, upDown); + Assert.Equal(upDownEdit, accessibleObject.Owner); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_ctor_ThrowsException_IfParentIsNull() + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + Assert.Throws(() => new UpDownBase.UpDownEdit.UpDownEditAccessibleObject(upDownEdit, null)); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_ctor_ThrowsException_IfOwnerIsNull() + { + using UpDownBase upDown = new SubUpDownBase(); + Assert.Throws(() => new UpDownBase.UpDownEdit.UpDownEditAccessibleObject(null, upDown)); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_IsIAccessibleExSupported_ReturnsTrue() + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.True(accessibleObject.IsIAccessibleExSupported()); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_Custom_Name_ReturnsCorrectValue() + { + using UpDownBase upDown = new SubUpDownBase(); + string name = "Custom name"; + upDown.AccessibleName = name; + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.Equal(name, accessibleObject.Name); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_Default_Name_ReturnsNull() + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.Null(accessibleObject.Name); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsFact] + public void UpDownEditAccessibleObject_KeyboardShortcut_ReturnsParentsKeyboardShortcut() + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.Equal(upDown.AccessibilityObject.KeyboardShortcut, accessibleObject.KeyboardShortcut); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsTheory] + [InlineData(true)] + [InlineData(false)] + public void UpDownEditAccessibleObject_IsReadOnly_IsExpected(bool readOnly) + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + upDownEdit.ReadOnly = readOnly; + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.Equal(readOnly, accessibleObject.IsReadOnly); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsTheory] + [InlineData((int)UiaCore.UIA.IsTextPatternAvailablePropertyId)] + [InlineData((int)UiaCore.UIA.IsTextPattern2AvailablePropertyId)] + public void UpDownEditAccessibleObject_GetPropertyValue_PatternsSuported(int propertyID) + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.True((bool)accessibleObject.GetPropertyValue((UiaCore.UIA)propertyID)); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + [WinFormsTheory] + [InlineData((int)UiaCore.UIA.TextPatternId)] + [InlineData((int)UiaCore.UIA.TextPattern2Id)] + public void UpDownEditAccessibleObject_IsPatternSupported_PatternsSuported(int patternId) + { + using UpDownBase upDown = new SubUpDownBase(); + using UpDownBase.UpDownEdit upDownEdit = new UpDownBase.UpDownEdit(upDown); + AccessibleObject accessibleObject = upDownEdit.AccessibilityObject; + Assert.True(accessibleObject.IsPatternSupported((UiaCore.UIA)patternId)); + Assert.False(upDown.IsHandleCreated); + Assert.False(upDownEdit.IsHandleCreated); + } + + private class SubUpDownBase : UpDownBase + { + public override void DownButton() { } + + public override void UpButton() { } + + protected override void UpdateEditText() { } + } + } +}