Skip to content

Commit

Permalink
fix issue 11243 TreeNodeCollection.AddRange has been broken in .NET 8…
Browse files Browse the repository at this point in the history
… and no longer results in TreeNodes being drawn at the correct location
  • Loading branch information
Epica3055 authored and Tanya-Solyanik committed May 23, 2024
1 parent 3365859 commit c7c7953
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;

namespace System.Windows.Forms;

internal class ArraySubsetEnumerator : IEnumerator
{
private readonly object[] _array;
private readonly int _total;
private int _current;

public ArraySubsetEnumerator(object[] array, int count)
{
Debug.Assert(count == 0 || array is not null, "if array is null, count should be 0");
Debug.Assert(array is null || count <= array.Length, "Trying to enumerate more than the array contains");
_array = array!;
_total = count;
_current = -1;
}

public bool MoveNext()
{
if (_current < _total - 1)
{
_current++;
return true;
}

return false;
}

public void Reset() => _current = -1;

public object? Current => _current == -1 ? null : _array[_current];
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ internal override void SelectItem()
internal override bool IsPatternSupported(UiaCore.UIA patternId)
=> patternId switch
{
UiaCore.UIA.ExpandCollapsePatternId => _owningTreeNode.childNodes.Count > 0,
UiaCore.UIA.ExpandCollapsePatternId => _owningTreeNode.childCount > 0,
UiaCore.UIA.LegacyIAccessiblePatternId => true,
UiaCore.UIA.ScrollItemPatternId => true,
UiaCore.UIA.SelectionItemPatternId => true,
Expand Down
Loading

0 comments on commit c7c7953

Please sign in to comment.