diff --git a/src/FlaUInspect/App.xaml.cs b/src/FlaUInspect/App.xaml.cs index 8dc0830..858961d 100644 --- a/src/FlaUInspect/App.xaml.cs +++ b/src/FlaUInspect/App.xaml.cs @@ -1,5 +1,6 @@ using System.Reflection; using System.Windows; +using FlaUI.Core; using FlaUInspect.Core.Logger; using FlaUInspect.ViewModels; using FlaUInspect.Views; @@ -8,30 +9,22 @@ namespace FlaUInspect; public partial class App { private void ApplicationStart(object sender, StartupEventArgs e) { - AssemblyInformationalVersionAttribute? versionAttribute = Assembly.GetEntryAssembly()?.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; - + AssemblyFileVersionAttribute? versionAttribute = Assembly.GetEntryAssembly()?.GetCustomAttribute(typeof(AssemblyFileVersionAttribute)) as AssemblyFileVersionAttribute; + string applicationVersion = versionAttribute?.Version ?? "N/A"; InternalLogger logger = new (); #if AUTOMATION_UIA3 - MainViewModel mainViewModel = new (AutomationType.UIA3, logger); + MainViewModel mainViewModel = new (AutomationType.UIA3, applicationVersion, logger); MainWindow mainWindow = new () { DataContext = mainViewModel }; - if (versionAttribute != null) { - mainWindow.Title += " version" + versionAttribute.InformationalVersion; - } - //Re-enable normal shutdown mode. Current.ShutdownMode = ShutdownMode.OnMainWindowClose; Current.MainWindow = mainWindow; mainWindow.Show(); #elif AUTOMATION_UIA2 - MainViewModel mainViewModel = new (AutomationType.UIA2, logger); + MainViewModel mainViewModel = new (AutomationType.UIA2, applicationVersion, logger); MainWindow mainWindow = new() { DataContext = mainViewModel }; - - if (versionAttribute != null) { - mainWindow.Title += " version" + versionAttribute.InformationalVersion; - } - + //Re-enable normal shutdown mode. Current.ShutdownMode = ShutdownMode.OnMainWindowClose; Current.MainWindow = mainWindow; @@ -41,12 +34,9 @@ private void ApplicationStart(object sender, StartupEventArgs e) { ChooseVersionWindow dialog = new (); if (dialog.ShowDialog() == true) { - MainViewModel mainViewModel = new (dialog.SelectedAutomationType, logger); - MainWindow mainWindow = new() { DataContext = mainViewModel }; - if (versionAttribute != null) { - mainWindow.Title += " version" + versionAttribute.InformationalVersion; - } + MainViewModel mainViewModel = new (dialog.SelectedAutomationType, applicationVersion, logger); + MainWindow mainWindow = new () { DataContext = mainViewModel }; //Re-enable normal shutdown mode. Current.ShutdownMode = ShutdownMode.OnMainWindowClose; diff --git a/src/FlaUInspect/Core/Converters/CountToVisibilityConverter.cs b/src/FlaUInspect/Core/Converters/CountToVisibilityConverter.cs index fa76591..3be9619 100644 --- a/src/FlaUInspect/Core/Converters/CountToVisibilityConverter.cs +++ b/src/FlaUInspect/Core/Converters/CountToVisibilityConverter.cs @@ -4,7 +4,7 @@ namespace FlaUInspect.Core.Converters; -public class CountToVisibilityConverter : IValueConverter { +public class CountToVisibilityConverter : IValueConverter { public Visibility ZeroCountVisibility { get; set; } = Visibility.Collapsed; public Visibility MultipleCountVisibility { get; set; } = Visibility.Visible; diff --git a/src/FlaUInspect/Core/ElementHighlighter.cs b/src/FlaUInspect/Core/ElementHighlighter.cs index 4ab80f2..c1a22a6 100644 --- a/src/FlaUInspect/Core/ElementHighlighter.cs +++ b/src/FlaUInspect/Core/ElementHighlighter.cs @@ -6,12 +6,11 @@ namespace FlaUInspect.Core; public static class ElementHighlighter { - public static void HighlightElement(AutomationElement? automationElement, ILogger logger) { + public static void HighlightElement(AutomationElement? automationElement, ILogger? logger) { try { Task.Run(() => automationElement?.DrawHighlight(false, Color.Red, TimeSpan.FromSeconds(1))); - } - catch (PropertyNotSupportedException ex) { - logger.LogError($"Exception: {ex.Message}"); + } catch (PropertyNotSupportedException ex) { + logger?.LogError($"Exception: {ex.Message}"); } } } \ No newline at end of file diff --git a/src/FlaUInspect/Core/Extensions/AutomationPropertyExtensions.cs b/src/FlaUInspect/Core/Extensions/AutomationPropertyExtensions.cs index 7bb05fb..97c9cff 100644 --- a/src/FlaUInspect/Core/Extensions/AutomationPropertyExtensions.cs +++ b/src/FlaUInspect/Core/Extensions/AutomationPropertyExtensions.cs @@ -7,8 +7,7 @@ public static class AutomationPropertyExtensions { try { bool success = automationProperty.TryGetValue(out T? value); return success ? value == null ? string.Empty : value.ToString() : "Not Supported"; - } - catch (Exception ex) { + } catch (Exception ex) { return $"Exception getting value ({ex.HResult})"; } } diff --git a/src/FlaUInspect/Core/Extensions/TaskExtensions.cs b/src/FlaUInspect/Core/Extensions/TaskExtensions.cs index a294ff9..abdc722 100644 --- a/src/FlaUInspect/Core/Extensions/TaskExtensions.cs +++ b/src/FlaUInspect/Core/Extensions/TaskExtensions.cs @@ -11,8 +11,7 @@ public static async Task WaitAsync(this Task task, TimeSpan period, T d return result; } return defaultValue; - } - catch (Exception) { + } catch (Exception) { return defaultValue; } } diff --git a/src/FlaUInspect/Core/HoverMode.cs b/src/FlaUInspect/Core/HoverMode.cs index d86cbde..b0c9541 100644 --- a/src/FlaUInspect/Core/HoverMode.cs +++ b/src/FlaUInspect/Core/HoverMode.cs @@ -11,10 +11,10 @@ namespace FlaUInspect.Core; public class HoverMode { private readonly AutomationBase? _automation; private readonly DispatcherTimer _dispatcherTimer; - private readonly ILogger _logger; + private readonly ILogger? _logger; private AutomationElement? _currentHoveredElement; - public HoverMode(AutomationBase? automation, ILogger logger) { + public HoverMode(AutomationBase? automation, ILogger? logger) { _automation = automation; _logger = logger; _dispatcherTimer = new DispatcherTimer(); @@ -50,16 +50,13 @@ private void DispatcherTimerTick(object? sender, EventArgs e) { if (!Equals(_currentHoveredElement, hoveredElement)) { _currentHoveredElement = hoveredElement; ElementHovered?.Invoke(hoveredElement); - } - else { + } else { ElementHighlighter.HighlightElement(hoveredElement, _logger); } - } - catch (UnauthorizedAccessException) { - _logger.LogError("You are accessing a protected UI element in hover mode.\nTry to start FlaUInspect as administrator."); - } - catch (Exception ex) { - _logger.LogError($"Exception: {ex.Message}"); + } catch (UnauthorizedAccessException) { + _logger?.LogError("You are accessing a protected UI element in hover mode.\nTry to start FlaUInspect as administrator."); + } catch (Exception ex) { + _logger?.LogError($"Exception: {ex.Message}"); } } } diff --git a/src/FlaUInspect/Core/Logger/LoggerExtensions.cs b/src/FlaUInspect/Core/Logger/LoggerExtensions.cs index 983f561..a7d1671 100644 --- a/src/FlaUInspect/Core/Logger/LoggerExtensions.cs +++ b/src/FlaUInspect/Core/Logger/LoggerExtensions.cs @@ -35,11 +35,11 @@ public static void LogTrace(this ILogger logger, string? message, params object? } List paramsName = Regex.Matches(formattedMessage, @"(\{\w+\})") - .Cast() - .Select(x => x.Groups[1].Value) - .Where(x => !string.IsNullOrEmpty(x)) - .Select(x=>x!) - .ToList(); + .Cast() + .Select(x => x.Groups[1].Value) + .Where(x => !string.IsNullOrEmpty(x)) + .Select(x => x!) + .ToList(); for (var i = 0; i < paramsName.Count; i++) { if (i < args.Length) { diff --git a/src/FlaUInspect/Core/PatternItemsFactory.cs b/src/FlaUInspect/Core/PatternItemsFactory.cs index 41f486e..161357e 100644 --- a/src/FlaUInspect/Core/PatternItemsFactory.cs +++ b/src/FlaUInspect/Core/PatternItemsFactory.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using System.Drawing; using FlaUI.Core; using FlaUI.Core.AutomationElements; @@ -29,8 +28,7 @@ public class PatternItemsFactory(AutomationBase? automationBase) { public const string Details = "Details"; public const string PatternSupport = "Pattern Support"; - private readonly KeyValuePair>>[] _patternsUia2Func = - [ + private readonly KeyValuePair>>[] _patternsUia2Func = [ new (GridItemPattern.Pattern, AddGridItemPatternDetails), new (GridPattern.Pattern, AddGridPatternPatternDetails), new (RangeValuePattern.Pattern, AddRangeValuePatternDetails), @@ -46,8 +44,7 @@ public class PatternItemsFactory(AutomationBase? automationBase) { new (InvokePattern.Pattern, AddInvokePatternDetails) ]; - private readonly KeyValuePair>>[] _patternsUia3Func = - [ + private readonly KeyValuePair>>[] _patternsUia3Func = [ new (FlaUI.UIA3.Patterns.GridItemPattern.Pattern, AddGridItemPatternDetails), new (FlaUI.UIA3.Patterns.GridPattern.Pattern, AddGridPatternPatternDetails), new (LegacyIAccessiblePattern.Pattern, AddLegacyIAccessiblePatternDetails), @@ -61,12 +58,11 @@ public class PatternItemsFactory(AutomationBase? automationBase) { new (FlaUI.UIA3.Patterns.TogglePattern.Pattern, AddTogglePatternDetails), new (FlaUI.UIA3.Patterns.ValuePattern.Pattern, AddValuePatternDetails), new (FlaUI.UIA3.Patterns.WindowPattern.Pattern, AddWindowPatternDetails), - new (FlaUI.UIA3.Patterns.InvokePattern.Pattern, AddInvokePatternDetails) + new (InvokePattern.Pattern, AddInvokePatternDetails) ]; public IDictionary CreatePatternItemsForElement(AutomationElement element, HashSet allSupportedPatterns) { - Dictionary patternItems = new() - { + Dictionary patternItems = new () { { Identification, AddIdentificationDetails(element).ToArray() }, { Details, AddDetailsDetails(element).ToArray() }, { PatternSupport, AddPatternSupportDetails(element).ToArray() } @@ -76,7 +72,7 @@ public IDictionary CreatePatternItemsForElement(Automatio automationBase is UIA3Automation ? _patternsUia3Func : _patternsUia2Func; foreach ((PatternId key, Func> value) in patternsFactory.Where(kvp => allSupportedPatterns.Contains(kvp.Key))) { - patternItems.Add(key.Name, (value.Invoke(element)).ToArray()); + patternItems.Add(key.Name, value.Invoke(element).ToArray()); } return patternItems; diff --git a/src/FlaUInspect/Core/RelayCommand.cs b/src/FlaUInspect/Core/RelayCommand.cs index 20f9003..8de64c5 100644 --- a/src/FlaUInspect/Core/RelayCommand.cs +++ b/src/FlaUInspect/Core/RelayCommand.cs @@ -14,7 +14,7 @@ public bool CanExecute(object? parameter) { if (parameter == null) { return true; } - return (canExecuteEvaluator == null || canExecuteEvaluator.Invoke(parameter)); + return canExecuteEvaluator == null || canExecuteEvaluator.Invoke(parameter); } public event EventHandler? CanExecuteChanged { diff --git a/src/FlaUInspect/FlaUInspect.csproj b/src/FlaUInspect/FlaUInspect.csproj index ba5f3f0..25b3ea9 100644 --- a/src/FlaUInspect/FlaUInspect.csproj +++ b/src/FlaUInspect/FlaUInspect.csproj @@ -20,60 +20,60 @@ - bin\Debug\ - FlaUInspect + bin\Debug\ + FlaUInspect - TRACE;AUTOMATION_UIA2 - bin\UIA2\ - FlaUInspect.UIA2 + TRACE;AUTOMATION_UIA2 + bin\UIA2\ + FlaUInspect.UIA2 - TRACE;AUTOMATION_UIA3 - bin\UIA3\ - FlaUInspect.UIA3 + TRACE;AUTOMATION_UIA3 + bin\UIA3\ + FlaUInspect.UIA3 - - - + + + - - MSBuild:Compile - Wpf - Designer - - - MSBuild:Compile - Wpf - Designer - - - MSBuild:Compile - Wpf - Designer - - - MSBuild:Compile - Wpf - Designer - + + MSBuild:Compile + Wpf + Designer + + + MSBuild:Compile + Wpf + Designer + + + MSBuild:Compile + Wpf + Designer + + + MSBuild:Compile + Wpf + Designer + - - True - - + + True + + - + diff --git a/src/FlaUInspect/Resources/ChooseVersionIcons.xaml b/src/FlaUInspect/Resources/ChooseVersionIcons.xaml index 943c4ef..afed77b 100644 --- a/src/FlaUInspect/Resources/ChooseVersionIcons.xaml +++ b/src/FlaUInspect/Resources/ChooseVersionIcons.xaml @@ -1,32 +1,38 @@ - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/FlaUInspect/Resources/DetailsIcons.xaml b/src/FlaUInspect/Resources/DetailsIcons.xaml index d53a66e..c67599a 100644 --- a/src/FlaUInspect/Resources/DetailsIcons.xaml +++ b/src/FlaUInspect/Resources/DetailsIcons.xaml @@ -1,499 +1,598 @@ - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + \ No newline at end of file diff --git a/src/FlaUInspect/Resources/Icons.xaml b/src/FlaUInspect/Resources/Icons.xaml index 1d1e17d..bc93fd1 100644 --- a/src/FlaUInspect/Resources/Icons.xaml +++ b/src/FlaUInspect/Resources/Icons.xaml @@ -36,7 +36,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/FlaUInspect/Resources/RibbonIcons.xaml b/src/FlaUInspect/Resources/RibbonIcons.xaml index 08aaaac..6eca9c6 100644 --- a/src/FlaUInspect/Resources/RibbonIcons.xaml +++ b/src/FlaUInspect/Resources/RibbonIcons.xaml @@ -1,137 +1,200 @@ - - + + + x:Shared="False" Width="24" Height="24"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/FlaUInspect/ViewModels/ElementViewModel.cs b/src/FlaUInspect/ViewModels/ElementViewModel.cs index f2870bb..941daf1 100644 --- a/src/FlaUInspect/ViewModels/ElementViewModel.cs +++ b/src/FlaUInspect/ViewModels/ElementViewModel.cs @@ -7,8 +7,8 @@ namespace FlaUInspect.ViewModels; -public class ElementViewModel(AutomationElement? automationElement, ILogger logger) : ObservableObject { - private readonly object _lockObject = new(); +public class ElementViewModel(AutomationElement? automationElement, ILogger? logger) : ObservableObject { + private readonly object _lockObject = new (); public AutomationElement? AutomationElement { get; } = automationElement; public bool IsExpanded { @@ -54,7 +54,7 @@ public void LoadChildren(int level) { try { if (AutomationElement != null) { foreach (AutomationElement child in AutomationElement.FindAllChildren()) { - ElementViewModel childViewModel = new(child, logger); + ElementViewModel childViewModel = new (child, logger); childViewModel.Children.Add(null); childViewModel.SelectionChanged += SelectionChanged; @@ -67,7 +67,7 @@ public void LoadChildren(int level) { } } } catch (Exception ex) { - logger.LogError($"Exception: {ex.Message}"); + logger?.LogError($"Exception: {ex.Message}"); } Children.Reset(childrenViewModels); diff --git a/src/FlaUInspect/ViewModels/MainViewModel.cs b/src/FlaUInspect/ViewModels/MainViewModel.cs index 6eb7d58..2cbdae8 100644 --- a/src/FlaUInspect/ViewModels/MainViewModel.cs +++ b/src/FlaUInspect/ViewModels/MainViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.ObjectModel; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Imaging; using System.Reflection; @@ -22,13 +21,15 @@ namespace FlaUInspect.ViewModels; public class MainViewModel : ObservableObject { - private readonly object _itemsLock = new(); - private readonly InternalLogger _logger; + private readonly object _itemsLock = new (); + private readonly InternalLogger? _logger; private AutomationBase? _automation; private RelayCommand? _captureSelectedItemCommand; + private RelayCommand? _closeInfoCommand; private ObservableCollection? _elementPatterns = []; private FocusTrackingMode? _focusTrackingMode; private HoverMode? _hoverMode; + private RelayCommand? _infoCommand; private RelayCommand? _openErrorListCommand; private PatternItemsFactory? _patternItemsFactory; private RelayCommand? _refreshCommand; @@ -37,8 +38,9 @@ public class MainViewModel : ObservableObject { private RelayCommand? _startNewInstanceCommand; private ITreeWalker? _treeWalker; - public MainViewModel(AutomationType automationType, InternalLogger logger) { + public MainViewModel(AutomationType automationType, string applicationVersion, InternalLogger logger) { _logger = logger; + ApplicationVersion = applicationVersion; _logger.LogEvent += (_, _) => { Application.Current.Dispatcher.Invoke(() => ErrorCount = _logger.Messages.Count); }; @@ -46,15 +48,17 @@ public MainViewModel(AutomationType automationType, InternalLogger logger) { SelectedAutomationType = automationType; Elements = []; BindingOperations.EnableCollectionSynchronization(Elements, _itemsLock); + } public ICommand OpenErrorListCommand => _openErrorListCommand ??= new RelayCommand(_ => { - if (!_logger.Messages.IsEmpty) { - ErrorListWindow errorListWindow = new(_logger); - errorListWindow.ShowDialog(); - } - }, _ => !_logger.Messages.IsEmpty); + if (_logger is { Messages.IsEmpty: false }) { + ErrorListWindow errorListWindow = new (_logger); + errorListWindow.ShowDialog(); + } + }, + _ => !_logger?.Messages.IsEmpty ?? false); public int ErrorCount { get => GetProperty(); @@ -74,6 +78,11 @@ public bool EnableHoverMode { } } + public bool EnableHighLightSelectionMode { + get => GetProperty(); + set => SetProperty(value); + } + public bool EnableFocusTrackingMode { get => GetProperty(); set { @@ -101,7 +110,7 @@ public AutomationType SelectedAutomationType { public ICommand StartNewInstanceCommand => _startNewInstanceCommand ??= new RelayCommand(_ => { - ProcessStartInfo info = new(Assembly.GetExecutingAssembly().Location); + ProcessStartInfo info = new (Assembly.GetExecutingAssembly().Location); Process.Start(info); }); @@ -111,7 +120,7 @@ public AutomationType SelectedAutomationType { return; } Bitmap capturedImage = SelectedItem.AutomationElement.Capture(); - SaveFileDialog saveDialog = new() { + SaveFileDialog saveDialog = new () { Filter = "Png file (*.png)|*.png" }; @@ -123,6 +132,9 @@ public AutomationType SelectedAutomationType { public ICommand RefreshCommand => _refreshCommand ??= new RelayCommand(_ => { + EnableHoverMode = false; + EnableFocusTrackingMode = false; + EnableHighLightSelectionMode = false; Elements.Clear(); Initialize(); }); @@ -151,6 +163,23 @@ public IEnumerable ElementPatterns { private set => SetProperty(ref _elementPatterns, value as ObservableCollection); } + public ICommand InfoCommand => _infoCommand ??= new RelayCommand(_ => { + IsInfoVisible = !IsInfoVisible; + }); + + public bool IsInfoVisible { + get => GetProperty(); + set => SetProperty(value); + } + public string? ApplicationVersion { + get => GetProperty(); + set => SetProperty(value); + } + + public ICommand CloseInfoCommand => _closeInfoCommand ??= new RelayCommand(_ => { + IsInfoVisible = false; + }); + private void ReadPatternsForSelectedItem(AutomationElement? selectedItemAutomationElement) { if (SelectedItem?.AutomationElement == null || selectedItemAutomationElement == null) { return; @@ -160,6 +189,10 @@ private void ReadPatternsForSelectedItem(AutomationElement? selectedItemAutomati return; } + if (EnableHighLightSelectionMode) { + ElementHighlighter.HighlightElement(SelectedItem.AutomationElement, _logger); + } + try { HashSet supportedPatterns = [.. selectedItemAutomationElement.GetSupportedPatterns()]; IDictionary patternItemsForElement = _patternItemsFactory.CreatePatternItemsForElement(selectedItemAutomationElement, supportedPatterns); @@ -182,7 +215,7 @@ private void ReadPatternsForSelectedItem(AutomationElement? selectedItemAutomati } } } catch (Exception e) { - _logger.LogError(e.ToString()); + _logger?.LogError(e.ToString()); } } @@ -190,7 +223,7 @@ public void Initialize() { _automation = (SelectedAutomationType == AutomationType.UIA2 ? (AutomationBase?)new UIA2Automation() : new UIA3Automation()) ?? new UIA3Automation(); _patternItemsFactory = new PatternItemsFactory(_automation); _rootElement = _automation.GetDesktop(); - ElementViewModel desktopViewModel = new(_rootElement, _logger); + ElementViewModel desktopViewModel = new (_rootElement, _logger); desktopViewModel.SelectionChanged += obj => { SelectedItem = obj; @@ -222,23 +255,23 @@ public void Initialize() { private ObservableCollection GetDefaultPatternList() { return new ObservableCollection(new[] { - new ElementPatternItem("Identification", PatternItemsFactory.Identification, true, true), - new ElementPatternItem("Details", PatternItemsFactory.Details, true, true), - new ElementPatternItem("Pattern Support", PatternItemsFactory.PatternSupport, true, true) - } - .Concat( - (_automation?.PatternLibrary.AllForCurrentFramework ?? []) - .Select(x => { - ElementPatternItem patternItem = new(x.Name, x.Name) { - IsVisible = true - }; - return patternItem; - }))); + new ElementPatternItem("Identification", PatternItemsFactory.Identification, true, true), + new ElementPatternItem("Details", PatternItemsFactory.Details, true, true), + new ElementPatternItem("Pattern Support", PatternItemsFactory.PatternSupport, true, true) + } + .Concat( + (_automation?.PatternLibrary.AllForCurrentFramework ?? []) + .Select(x => { + ElementPatternItem patternItem = new (x.Name, x.Name) { + IsVisible = true + }; + return patternItem; + }))); } private void ElementToSelectChanged(AutomationElement? obj) { // Build a stack from the root to the hovered item - Stack pathToRoot = new(); + Stack pathToRoot = new (); while (obj != null) { // Break on circular relationship (should not happen?) @@ -251,7 +284,7 @@ private void ElementToSelectChanged(AutomationElement? obj) { try { obj = _treeWalker?.GetParent(obj); } catch (Exception ex) { - _logger.LogError($"Exception: {ex.Message}"); + _logger?.LogError($"Exception: {ex.Message}"); } } @@ -274,7 +307,7 @@ private void ElementToSelectChanged(AutomationElement? obj) { if (nextElementVm == null) { // The next element is still not found, exit the loop - _logger.LogError("Could not find the next element!"); + _logger?.LogError("Could not find the next element!"); break; } } @@ -289,7 +322,19 @@ private void ElementToSelectChanged(AutomationElement? obj) { SelectedItem.IsSelected = true; } - private static ElementViewModel? FindElement(ElementViewModel parent, AutomationElement element) { - return parent.Children.FirstOrDefault(child => child?.AutomationElement?.Equals(element) ?? false); + private ElementViewModel? FindElement(ElementViewModel parent, AutomationElement element) { + return parent.Children.FirstOrDefault(child => { + if (child?.AutomationElement == null) { + return false; + } + + try { + return child.AutomationElement.Equals(element); + } catch (Exception e) { + _logger?.LogError(e.ToString()); + } + + return false; + }); } } \ No newline at end of file diff --git a/src/FlaUInspect/ViewModels/PatternItem.cs b/src/FlaUInspect/ViewModels/PatternItem.cs index dbf18a7..4c1648e 100644 --- a/src/FlaUInspect/ViewModels/PatternItem.cs +++ b/src/FlaUInspect/ViewModels/PatternItem.cs @@ -16,9 +16,7 @@ public string? Value { get => _value; set => SetProperty(ref _value, value); } - public bool HasExecutableAction { - get => Action != null; - } + public bool HasExecutableAction => Action != null; public Action? Action { get; } = action; public static PatternItem FromAutomationProperty(string key, IAutomationProperty value) { diff --git a/src/FlaUInspect/Views/ChooseVersionWindow.xaml b/src/FlaUInspect/Views/ChooseVersionWindow.xaml index af1e7e3..4c9619f 100644 --- a/src/FlaUInspect/Views/ChooseVersionWindow.xaml +++ b/src/FlaUInspect/Views/ChooseVersionWindow.xaml @@ -16,7 +16,7 @@ - + @@ -30,20 +31,20 @@ + FalseVisibility="Hidden" + TrueVisibility="Visible" /> + AlternativeBrush="#ffeeeeee" + Brush="#ffffffff" /> @@ -54,76 +55,144 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -267,7 +336,8 @@ ItemsSource="{Binding Children}"> - + -