Skip to content

Commit 53e0f09

Browse files
author
EXT-Gweltaz
committed
Element duplication is gone, and element expansion does work as intended.
Thanks Vibe+qwen3.6.
1 parent cad093a commit 53e0f09

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

src/FlaUInspect/ViewModels/ProcessViewModel.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
using System.Collections.ObjectModel;
2-
using System.Drawing.Imaging;
3-
using System.Runtime.CompilerServices;
4-
using System.Windows;
5-
using System.Windows.Input;
6-
using FlaUI.Core;
7-
using FlaUI.Core.AutomationElements;
8-
using FlaUI.Core.Identifiers;
9-
using FlaUInspect.Core;
10-
using FlaUInspect.Core.Exporters;
11-
using FlaUInspect.Core.Logger;
12-
using FlaUInspect.Models;
13-
using Microsoft.Win32;
14-
15-
namespace FlaUInspect.ViewModels;
16-
1+
using System.Collections.ObjectModel;
2+
using System.Drawing.Imaging;
3+
using System.Runtime.CompilerServices;
4+
using System.Windows;
5+
using System.Windows.Input;
6+
using FlaUI.Core;
7+
using FlaUI.Core.AutomationElements;
8+
using FlaUI.Core.Identifiers;
9+
using FlaUInspect.Core;
10+
using FlaUInspect.Core.Exporters;
11+
using FlaUInspect.Core.Logger;
12+
using FlaUInspect.Models;
13+
using Microsoft.Win32;
14+
15+
namespace FlaUInspect.ViewModels;
16+
1717
public class ProcessViewModel : ObservableObject {
1818

1919
private readonly PatternItemsFactory _patternItemsFactory;
@@ -266,8 +266,7 @@ private Stack<AutomationElement> GetPathToRoot(AutomationElement? obj, bool forc
266266
if (nextElementVm is null || (!forceExpand && nextElementVm.IsExpanded))
267267
continue;
268268

269-
if (pathToRoot.Count != 0)
270-
nextElementVm.IsExpanded = true;
269+
nextElementVm.IsExpanded = true;
271270

272271
ExpandElement(nextElementVm);
273272

@@ -343,7 +342,7 @@ private static void ExpandElement(ElementViewModel sender, ObservableCollection<
343342
var children = sender.LoadChildren(1);
344343

345344
foreach (var child in children)
346-
if (!elements.Contains(child))
345+
if (!elements.Any(e => e.AutomationElement?.Equals(child.AutomationElement) == true))
347346
try {
348347
elements.Insert(++senderIndex, child);
349348
}
@@ -380,5 +379,5 @@ private static bool IsDescendantOf(ElementViewModel? node, ElementViewModel? par
380379
while (node is not null && node != parent);
381380

382381
return node is not null && node == parent;
383-
}
382+
}
384383
}

0 commit comments

Comments
 (0)