@@ -23,7 +23,7 @@ namespace FlaUInspect.ViewModels;
2323[ SuppressMessage ( "Interoperability" , "CA1416:Validate platform compatibility" ) ]
2424public class MainViewModel : ObservableObject {
2525
26- private readonly object _itemsLock = new ( ) ;
26+ private readonly object _itemsLock = new ( ) ;
2727 private readonly InternalLogger _logger ;
2828 private AutomationBase ? _automation ;
2929 private RelayCommand ? _captureSelectedItemCommand ;
@@ -51,12 +51,11 @@ public MainViewModel(AutomationType automationType, InternalLogger logger) {
5151
5252 public ICommand OpenErrorListCommand =>
5353 _openErrorListCommand ??= new RelayCommand ( _ => {
54- if ( ! _logger . Messages . IsEmpty ) {
55- ErrorListWindow errorListWindow = new ( _logger ) ;
56- errorListWindow . ShowDialog ( ) ;
57- }
58- } ,
59- _ => ! _logger . Messages . IsEmpty ) ;
54+ if ( ! _logger . Messages . IsEmpty ) {
55+ ErrorListWindow errorListWindow = new ( _logger ) ;
56+ errorListWindow . ShowDialog ( ) ;
57+ }
58+ } , _ => ! _logger . Messages . IsEmpty ) ;
6059
6160 public int ErrorCount {
6261 get => GetProperty < int > ( ) ;
@@ -69,8 +68,7 @@ public bool EnableHoverMode {
6968 if ( SetProperty ( value ) ) {
7069 if ( value ) {
7170 _hoverMode ? . Start ( ) ;
72- }
73- else {
71+ } else {
7472 _hoverMode ? . Stop ( ) ;
7573 }
7674 }
@@ -83,8 +81,7 @@ public bool EnableFocusTrackingMode {
8381 if ( SetProperty ( value ) ) {
8482 if ( value ) {
8583 _focusTrackingMode ? . Start ( ) ;
86- }
87- else {
84+ } else {
8885 _focusTrackingMode ? . Stop ( ) ;
8986 }
9087 }
@@ -105,7 +102,7 @@ public AutomationType SelectedAutomationType {
105102
106103 public ICommand StartNewInstanceCommand =>
107104 _startNewInstanceCommand ??= new RelayCommand ( _ => {
108- ProcessStartInfo info = new ( Assembly . GetExecutingAssembly ( ) . Location ) ;
105+ ProcessStartInfo info = new ( Assembly . GetExecutingAssembly ( ) . Location ) ;
109106 Process . Start ( info ) ;
110107 } ) ;
111108
@@ -115,8 +112,7 @@ public AutomationType SelectedAutomationType {
115112 return ;
116113 }
117114 Bitmap capturedImage = SelectedItem . AutomationElement . Capture ( ) ;
118- SaveFileDialog saveDialog = new ( )
119- {
115+ SaveFileDialog saveDialog = new ( ) {
120116 Filter = "Png file (*.png)|*.png"
121117 } ;
122118
@@ -186,8 +182,7 @@ private void ReadPatternsForSelectedItem(AutomationElement? selectedItemAutomati
186182 elementPattern . IsVisible = false ;
187183 }
188184 }
189- }
190- catch ( Exception e ) {
185+ } catch ( Exception e ) {
191186 _logger . LogError ( e . ToString ( ) ) ;
192187 }
193188 }
@@ -196,7 +191,7 @@ public void Initialize() {
196191 _automation = ( SelectedAutomationType == AutomationType . UIA2 ? ( AutomationBase ? ) new UIA2Automation ( ) : new UIA3Automation ( ) ) ?? new UIA3Automation ( ) ;
197192 _patternItemsFactory = new PatternItemsFactory ( _automation ) ;
198193 _rootElement = _automation . GetDesktop ( ) ;
199- ElementViewModel desktopViewModel = new ( _rootElement , _logger ) ;
194+ ElementViewModel desktopViewModel = new ( _rootElement , _logger ) ;
200195
201196 desktopViewModel . SelectionChanged += obj => {
202197 SelectedItem = obj ;
@@ -227,27 +222,24 @@ public void Initialize() {
227222 }
228223
229224 private ObservableCollection < ElementPatternItem > GetDefaultPatternList ( ) {
230- return new ObservableCollection < ElementPatternItem > (
231- new [ ]
232- {
233- new ElementPatternItem ( "Identification" , PatternItemsFactory . Identification , true , true ) ,
234- new ElementPatternItem ( "Details" , PatternItemsFactory . Details , true , true ) ,
235- new ElementPatternItem ( "Pattern Support" , PatternItemsFactory . PatternSupport , true , true )
236- }
237- . Concat (
238- ( _automation ? . PatternLibrary . AllForCurrentFramework ?? [ ] )
239- . Select ( x => {
240- ElementPatternItem patternItem = new ( x . Name , x . Name )
241- {
242- IsVisible = true
243- } ;
244- return patternItem ;
245- } ) ) ) ;
225+ return new ObservableCollection < ElementPatternItem > ( new [ ] {
226+ new ElementPatternItem ( "Identification" , PatternItemsFactory . Identification , true , true ) ,
227+ new ElementPatternItem ( "Details" , PatternItemsFactory . Details , true , true ) ,
228+ new ElementPatternItem ( "Pattern Support" , PatternItemsFactory . PatternSupport , true , true )
229+ }
230+ . Concat (
231+ ( _automation ? . PatternLibrary . AllForCurrentFramework ?? [ ] )
232+ . Select ( x => {
233+ ElementPatternItem patternItem = new ( x . Name , x . Name ) {
234+ IsVisible = true
235+ } ;
236+ return patternItem ;
237+ } ) ) ) ;
246238 }
247239
248240 private void ElementToSelectChanged ( AutomationElement ? obj ) {
249241 // Build a stack from the root to the hovered item
250- Stack < AutomationElement > pathToRoot = new ( ) ;
242+ Stack < AutomationElement > pathToRoot = new ( ) ;
251243
252244 while ( obj != null ) {
253245 // Break on circular relationship (should not happen?)
@@ -259,8 +251,7 @@ private void ElementToSelectChanged(AutomationElement? obj) {
259251
260252 try {
261253 obj = _treeWalker ? . GetParent ( obj ) ;
262- }
263- catch ( Exception ex ) {
254+ } catch ( Exception ex ) {
264255 _logger . LogError ( $ "Exception: { ex . Message } ") ;
265256 }
266257 }
0 commit comments