Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/FlaUInspect/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
Task.Run(() => startupViewModel.Init());

return;
AssemblyFileVersionAttribute? versionAttribute = Assembly.GetEntryAssembly()?.GetCustomAttribute(typeof(AssemblyFileVersionAttribute)) as AssemblyFileVersionAttribute;

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Unreachable code detected

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Unreachable code detected

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Unreachable code detected

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Unreachable code detected

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Unreachable code detected

Check warning on line 45 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Unreachable code detected
string applicationVersion = versionAttribute?.Version ?? "N/A";
string windowHandle = string.Empty;

Expand Down Expand Up @@ -90,12 +90,13 @@
});

FlaUiAppOptions.AutoCloseOnProcessExit = settings.AutoCloseOnProcessExit;
FlaUiAppOptions.DefaultUiaVersion = settings.DefaultUiaVersion;

ThicknessConverter converter = new ();
FlaUiAppSettings cloneSetting = settings.Clone() as FlaUiAppSettings;

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Converting null literal or possible null value to non-nullable type.

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Converting null literal or possible null value to non-nullable type.

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Converting null literal or possible null value to non-nullable type.

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Converting null literal or possible null value to non-nullable type.

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Converting null literal or possible null value to non-nullable type.

Check warning on line 96 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Converting null literal or possible null value to non-nullable type.

if (settings.HoverOverlay != null) {
Thickness hoverMargin = (Thickness)converter.ConvertFromString(cloneSetting.HoverOverlay.Margin);

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Unboxing a possibly null value.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Unboxing a possibly null value.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA3)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Dereference of a possibly null reference.

Check warning on line 99 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Dereference of a possibly null reference.
FlaUiAppOptions.HoverOverlay = () => new ElementOverlay(new ElementOverlayConfiguration(cloneSetting.HoverOverlay.Size,
hoverMargin,
ColorTranslator.FromHtml(cloneSetting.HoverOverlay.OverlayColor),
Expand All @@ -105,7 +106,7 @@
}

if (settings.SelectionOverlay != null) {
Thickness selectionMargin = (Thickness)converter.ConvertFromString(cloneSetting.SelectionOverlay.Margin);

Check warning on line 109 in src/FlaUInspect/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build (UIA2)

Dereference of a possibly null reference.
FlaUiAppOptions.SelectionOverlay = () => new ElementOverlay(new ElementOverlayConfiguration(cloneSetting.SelectionOverlay.Size,
selectionMargin,
ColorTranslator.FromHtml(cloneSetting.SelectionOverlay.OverlayColor),
Expand Down
1 change: 1 addition & 0 deletions src/FlaUInspect/Settings/FlaUiAppOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace FlaUInspect.Settings;

public class FlaUiAppOptions {
public bool AutoCloseOnProcessExit { get; set; } = true;
public string DefaultUiaVersion { get; set; } = "UIA3";
public Func<ElementOverlay?> HoverOverlay { get; set; } = () => null;
public Func<ElementOverlay?> SelectionOverlay { get; set; } = () => null;
public Func<ElementOverlay?> PickOverlay { get; set; } = () => null;
Expand Down
8 changes: 8 additions & 0 deletions src/FlaUInspect/Settings/FlaUiAppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class FlaUiAppSettings : ObservableObject, ICloneable {
private OverlaySettings? _selectionOverlay = new ();
private string _theme = "Light";
private bool _autoCloseOnProcessExit = true;
private string _defaultUiaVersion = "UIA3";

public string Theme {
get => _theme;
Expand All @@ -19,6 +20,11 @@ public bool AutoCloseOnProcessExit {
set => SetProperty(ref _autoCloseOnProcessExit, value);
}

public string DefaultUiaVersion {
get => _defaultUiaVersion;
set => SetProperty(ref _defaultUiaVersion, value);
}

public OverlaySettings? HoverOverlay {
get => _hoverOverlay;
set => SetProperty(ref _hoverOverlay, value);
Expand All @@ -38,6 +44,7 @@ public object Clone() {
return new FlaUiAppSettings {
Theme = Theme,
AutoCloseOnProcessExit = AutoCloseOnProcessExit,
DefaultUiaVersion = DefaultUiaVersion,
HoverOverlay = HoverOverlay?.Clone() as OverlaySettings,
SelectionOverlay = SelectionOverlay?.Clone() as OverlaySettings,
PickOverlay = PickOverlay?.Clone() as OverlaySettings
Expand All @@ -47,6 +54,7 @@ public object Clone() {
public void CopyTo(FlaUiAppSettings to) {
to.Theme = Theme;
to.AutoCloseOnProcessExit = AutoCloseOnProcessExit;
to.DefaultUiaVersion = DefaultUiaVersion;
to.PickOverlay?.CoppyTo(PickOverlay);
to.SelectionOverlay?.CoppyTo(SelectionOverlay);
to.HoverOverlay?.CoppyTo(HoverOverlay);
Expand Down
1 change: 1 addition & 0 deletions src/FlaUInspect/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public SettingsViewModel() {

public IEnumerable<string> Themes { get; } = new List<string> { "Light", "Dark" };
public IEnumerable<string> OverlayModes { get; } = new List<string> { "Fill", "Border" };
public IEnumerable<string> UiaVersions { get; } = new List<string> { "UIA2", "UIA3" };

public void Save() {
_settingsService.Save(Settings.Current);
Expand Down
9 changes: 6 additions & 3 deletions src/FlaUInspect/ViewModels/StartupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ public StartupViewModel() {
closableViewModel.Save();
DialogContent = null;

if (settingsViewModel != null) {
App.ApplyAppOption(settingsViewModel.Settings.Current);
}
if (settingsViewModel != null) {
App.ApplyAppOption(settingsViewModel.Settings.Current);
OnPropertyChanged(nameof(DefaultUiaVersion));
}
}
},
_ => DialogContent is IDialogViewModel { CanClose: true });
Expand Down Expand Up @@ -105,6 +106,8 @@ public bool IsBusy {
set => SetProperty(value);
}

public string DefaultUiaVersion => App.FlaUiAppOptions.DefaultUiaVersion;

public ProcessWindowInfo? SelectedProcess {
get => GetProperty<ProcessWindowInfo>();
set => SetProperty(value);
Expand Down
11 changes: 9 additions & 2 deletions src/FlaUInspect/Views/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@
HorizontalAlignment="Left"
Header="General"
Style="{StaticResource GroupBoxStyle}">
<CheckBox Content="Auto close on process exit"
IsChecked="{Binding Settings.Current.AutoCloseOnProcessExit}" />
<StackPanel>
<CheckBox Content="Auto close on process exit"
IsChecked="{Binding Settings.Current.AutoCloseOnProcessExit}" />
<TextBlock Margin="0,8,0,2"
Foreground="{DynamicResource TextBrush}"
Text="Default UIA version (double-click):" />
<ComboBox ItemsSource="{Binding UiaVersions}"
SelectedItem="{Binding Settings.Current.DefaultUiaVersion}" />
</StackPanel>
</GroupBox>
<WrapPanel>
<GroupBox Header="Application pick overlay">
Expand Down
139 changes: 65 additions & 74 deletions src/FlaUInspect/Views/StartupWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@
</Grid>
</StackPanel>
<Grid IsEnabled="{Binding IsBusy, Converter={StaticResource InvertBooleanConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0"
Margin="8"
<DockPanel Margin="8"
LastChildFill="True">
<Button Width="128"
HorizontalAlignment="Left"
Expand Down Expand Up @@ -107,22 +101,79 @@
Background="{DynamicResource PrimaryBorderBrush}"
DockPanel.Dock="Bottom" />
<Grid DockPanel.Dock="Bottom">
<TextBlock Text="Double click to open by selected UIA." />
<TextBlock Text="Double-click to open with default UIA version." />
</Grid>
<Grid>
<ListBox x:Name="ProcessesListBox"
HorizontalContentAlignment="Stretch"
ItemsSource="{Binding FilteredProcesses}"
MouseDoubleClick="ProcessesListBoxOnMouseDoubleClick"
SelectedItem="{Binding SelectedProcess}"
Visibility="{Binding Processes.Count, Converter={StaticResource IntToVisibilityConverter}, ConverterParameter=GreaterThanZero}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type viewModels:ProcessWindowInfo}">
<TextBlock>
<Run Text="[" />
<Run Text="{Binding ProcessId}" />
<Run Text="] " />
<Run Text="{Binding WindowTitle}" />
</TextBlock>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Padding="2"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis">
<Run Text="[" />
<Run Text="{Binding ProcessId}" />
<Run Text="] " />
<Run Text="{Binding WindowTitle}" />
</TextBlock>
<StackPanel x:Name="UiaPanel"
Grid.Column="1"
VerticalAlignment="Center"
Orientation="Horizontal"
Visibility="Collapsed">
<Button Width="48"
Margin="0,0,4,0"
Padding="6,2"
Click="Uia2Click"
Content="UIA2">
<Button.Style>
<Style BasedOn="{StaticResource {x:Type Button}}"
TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.DefaultUiaVersion, RelativeSource={RelativeSource AncestorType=Window}}"
Value="UIA2">
<Setter Property="Background" Value="{DynamicResource AccentBrush}" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button Width="48"
Padding="6,2"
Click="Uia3Click"
Content="UIA3">
<Button.Style>
<Style BasedOn="{StaticResource {x:Type Button}}"
TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.DefaultUiaVersion, RelativeSource={RelativeSource AncestorType=Window}}"
Value="UIA3">
<Setter Property="Background" Value="{DynamicResource AccentBrush}" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
Value="True">
<Setter TargetName="UiaPanel" Property="Visibility" Value="Visible" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Expand All @@ -133,66 +184,6 @@
</Grid>
</DockPanel>
</DockPanel>

<Border Grid.Column="1"
Width="1"
Margin="8"
VerticalAlignment="Stretch"
Background="{DynamicResource PrimaryBorderBrush}" />

<StackPanel Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsEnabled="{Binding IsBusy, Converter={StaticResource InvertBooleanConverter}}"
Orientation="Vertical">
<StackPanel.Resources>
<Style BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}">
<Setter Property="Margin" Value="10" />
</Style>
</StackPanel.Resources>
<DockPanel LastChildFill="True">
<RadioButton x:Name="Uia2RadioButton"
VerticalAlignment="Center"
DockPanel.Dock="Left"
GroupName="UiaVersion" />
<Button Padding="10"
Click="Uia2Click"
IsEnabled="{Binding ElementName=ProcessesListBox, Path=SelectedItem, Converter={StaticResource NullToVisibilityConverter}}">
<StackPanel Orientation="Vertical">
<Viewbox Width="48"
Height="48"
Stretch="Uniform">
<ContentControl Content="{StaticResource Uia2Icon}" />
</Viewbox>
<TextBlock TextAlignment="Center">
UIA2<LineBreak />
Uia2Icon</TextBlock>
</StackPanel>
</Button>
</DockPanel>
<DockPanel LastChildFill="True">
<RadioButton x:Name="Uia3RadioButton"
VerticalAlignment="Center"
DockPanel.Dock="Left"
GroupName="UiaVersion"
IsChecked="True" />
<Button Padding="10"
Click="Uia3Click"
IsEnabled="{Binding ElementName=ProcessesListBox, Path=SelectedItem, Converter={StaticResource NullToVisibilityConverter}}">
<StackPanel Orientation="Vertical">
<Viewbox Width="48"
Height="48"
Stretch="Uniform">
<ContentControl Content="{StaticResource Uia3Icon}" />
</Viewbox>
<TextBlock TextAlignment="Center">
UIA3<LineBreak />
Uia3Icon</TextBlock>
</StackPanel>
</Button>
</DockPanel>
</StackPanel>
</Grid>
</DockPanel>
<Grid Background="#cc000000"
Expand Down
6 changes: 4 additions & 2 deletions src/FlaUInspect/Views/StartupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public StartupWindow(InternalLogger logger) {
}

private void Uia2Click(object sender, RoutedEventArgs e) {
e.Handled = true;
OpenProcessWindow(new UIA2Automation());
}

private void Uia3Click(object sender, RoutedEventArgs e) {
e.Handled = true;
OpenProcessWindow(new UIA3Automation());
}

Expand Down Expand Up @@ -80,9 +82,9 @@ private void PickWindowButton_PreviewMouseDown(object sender, MouseButtonEventAr
}

private void ProcessesListBoxOnMouseDoubleClick(object sender, MouseButtonEventArgs e) {
if (Uia2RadioButton.IsChecked == true) {
if (App.FlaUiAppOptions.DefaultUiaVersion == "UIA2") {
OpenProcessWindow(new UIA2Automation());
} else if (Uia3RadioButton.IsChecked == true) {
} else {
OpenProcessWindow(new UIA3Automation());
}
}
Expand Down
Loading