Skip to content

Commit 0455c89

Browse files
committed
Add CopyDetailsToClipboard button and notification to ProcessWindow
Add ElementToggleExpander style and icons; update ProcessWindow to use new style Implement cleanup logic in ProcessViewModel and ProcessWindow on close event
1 parent c2580cc commit 0455c89

File tree

6 files changed

+93
-58
lines changed

6 files changed

+93
-58
lines changed

src/FlaUInspect/Resources/Icons.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,24 @@
673673
</Path>
674674
</Canvas>
675675
</Canvas>
676+
677+
<Canvas x:Key="ExpandedIcon"
678+
Width="24"
679+
Height="24"
680+
x:Shared="False"
681+
UseLayoutRounding="False">
682+
<Path Data="M 12,19.330856 0.1121287,7.4429845 2.885964,4.6691442 12,13.78318 21.114036,4.6691442 23.887871,7.4429845 Z"
683+
Fill="#ff000000" />
684+
</Canvas>
685+
686+
<Canvas x:Key="CollapsedIcon"
687+
Width="24"
688+
Height="24"
689+
x:Shared="False"
690+
UseLayoutRounding="False">
691+
<Path Data="M 13.776065,12 4.6983994,2.9223347 7.4611676,0.15956707 19.301601,12 7.4611676,23.840433 4.6983994,21.077665 Z"
692+
Fill="#ff000000" />
693+
</Canvas>
676694

677695

678696
</ResourceDictionary>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<ResourceDictionary.MergedDictionaries>
5+
<ResourceDictionary Source="../Resources/Icons.xaml" />
6+
</ResourceDictionary.MergedDictionaries>
7+
8+
<Style x:Key="ElementToggleExpanderStyle"
9+
BasedOn="{StaticResource {x:Type ToggleButton}}"
10+
TargetType="ToggleButton">
11+
<Setter Property="Background" Value="Transparent" />
12+
<Setter Property="Template">
13+
<Setter.Value>
14+
<ControlTemplate TargetType="ToggleButton">
15+
<Border Background="Transparent"
16+
BorderBrush="Transparent"
17+
BorderThickness="0">
18+
<Viewbox Width="12"
19+
Height="12"
20+
Stretch="Fill">
21+
<ContentControl x:Name="IconTemplate"
22+
Content="{StaticResource CollapsedIcon}" />
23+
</Viewbox>
24+
</Border>
25+
<ControlTemplate.Triggers>
26+
<Trigger Property="IsChecked" Value="True">
27+
<Setter TargetName="IconTemplate" Property="Content" Value="{StaticResource ExpandedIcon}" />
28+
</Trigger>
29+
<Trigger Property="IsChecked" Value="False">
30+
<Setter TargetName="IconTemplate" Property="Content" Value="{StaticResource CollapsedIcon}" />
31+
</Trigger>
32+
</ControlTemplate.Triggers>
33+
</ControlTemplate>
34+
</Setter.Value>
35+
</Setter>
36+
</Style>
37+
</ResourceDictionary>

src/FlaUInspect/Styles/PatternExpanderStyle.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<ResourceDictionary.MergedDictionaries>
5+
<ResourceDictionary Source="../Resources/Icons.xaml" />
6+
</ResourceDictionary.MergedDictionaries>
7+
38
<Style x:Key="PatternExpanderStyle"
49
TargetType="Expander">
510
<Setter Property="BorderThickness" Value="1" />

src/FlaUInspect/ViewModels/ProcessViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public ProcessViewModel(AutomationBase automation, int processId, IntPtr mainWin
8585

8686
ClosingCommand = new RelayCommand(_ => {
8787
HoverManager.RemoveListener(_windowHandle);
88+
_trackHighlighterOverlay?.Dispose();
89+
_focusTrackingMode?.Stop();
90+
_focusTrackingMode = null;
8891
});
8992

9093
CopyDetailsToClipboardCommand = new RelayCommand(_ => {

src/FlaUInspect/Views/ProcessWindow.xaml

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<ResourceDictionary Source="/Resources/RibbonIcons.xaml" />
2222
<ResourceDictionary Source="/Styles/PatternExpanderStyle.xaml" />
2323
<ResourceDictionary Source="/Styles/GroupStyle.xaml" />
24+
<ResourceDictionary Source="/Styles/ElementToggleExpander.xaml" />
2425
</ResourceDictionary.MergedDictionaries>
2526

2627
<Style x:Key="SelectableLabel"
@@ -213,6 +214,28 @@
213214
Text="Copied." />
214215
</Grid>
215216
</Grid>
217+
218+
<Grid>
219+
<Button Command="{Binding CopyDetailsToClipboardCommand}"
220+
Style="{StaticResource RibbonButtonStyle}"
221+
ToolTip="Copy current element state to clipboard">
222+
<StackPanel Orientation="Vertical">
223+
<Viewbox Width="20"
224+
Height="20"
225+
Stretch="Uniform">
226+
<ContentControl Content="{StaticResource PropertiesIcon}" />
227+
</Viewbox>
228+
</StackPanel>
229+
</Button>
230+
<Grid x:Name="CopiedNotificationGrid"
231+
Background="DarkBlue"
232+
Visibility="Collapsed">
233+
<TextBlock HorizontalAlignment="Center"
234+
VerticalAlignment="Center"
235+
Foreground="White"
236+
Text="Copied." />
237+
</Grid>
238+
</Grid>
216239

217240
<ToggleButton IsChecked="{Binding EnableXPath}"
218241
Style="{StaticResource RibbonButtonStyle}">
@@ -265,6 +288,7 @@
265288
Height="16"
266289
Click="ToggleButton_Click"
267290
Focusable="False"
291+
Style="{StaticResource ElementToggleExpanderStyle}"
268292
IsChecked="{Binding IsExpanded}"
269293
Visibility="{Binding Children.Count, Converter={StaticResource CountToVisibilityConverter}}" />
270294

@@ -304,64 +328,6 @@
304328
<Grid>
305329
<DockPanel LastChildFill="True"
306330
Visibility="{Binding TreeViewControl.SelectedItem, Converter={StaticResource NullToVisibilityConverter}}">
307-
<StackPanel Height="40"
308-
HorizontalAlignment="Left"
309-
VerticalAlignment="Top"
310-
DockPanel.Dock="Top"
311-
Orientation="Horizontal">
312-
<StackPanel.Resources>
313-
<Style x:Key="RibbonButtonStyle"
314-
TargetType="{x:Type ButtonBase}">
315-
<Setter Property="Width" Value="32" />
316-
<Setter Property="Height" Value="32" />
317-
<Setter Property="Margin" Value="4" />
318-
</Style>
319-
</StackPanel.Resources>
320-
<Grid>
321-
<Button Command="{Binding CopyDetailsToClipboardCommand}"
322-
Style="{StaticResource RibbonButtonStyle}"
323-
ToolTip="Copy current element state to clipboard">
324-
<StackPanel Orientation="Vertical">
325-
<Viewbox Width="20"
326-
Height="20"
327-
Stretch="Uniform">
328-
<ContentControl Content="{StaticResource PropertiesIcon}" />
329-
</Viewbox>
330-
</StackPanel>
331-
</Button>
332-
<Grid x:Name="CopiedNotificationGrid"
333-
Background="DarkBlue"
334-
Visibility="Collapsed">
335-
<TextBlock HorizontalAlignment="Center"
336-
VerticalAlignment="Center"
337-
Foreground="White"
338-
Text="Copied." />
339-
</Grid>
340-
</Grid>
341-
<Grid Width="8" />
342-
<Button Command="{Binding CollapseAllDetailsCommand}"
343-
Style="{StaticResource RibbonButtonStyle}"
344-
ToolTip="Collapse all details">
345-
<StackPanel Orientation="Vertical">
346-
<Viewbox Width="20"
347-
Height="20"
348-
Stretch="Uniform">
349-
<ContentControl Content="{StaticResource CollapseIcon}" />
350-
</Viewbox>
351-
</StackPanel>
352-
</Button>
353-
<Button Command="{Binding ExpandAllDetailsCommand}"
354-
Style="{StaticResource RibbonButtonStyle}"
355-
ToolTip="Expand all details">
356-
<StackPanel Orientation="Vertical">
357-
<Viewbox Width="20"
358-
Height="20"
359-
Stretch="Uniform">
360-
<ContentControl Content="{StaticResource ExpandIcon}" />
361-
</Viewbox>
362-
</StackPanel>
363-
</Button>
364-
</StackPanel>
365331
<ScrollViewer>
366332
<ItemsControl ItemsSource="{Binding ElementPatterns}">
367333
<ItemsControl.ItemTemplate>

src/FlaUInspect/Views/ProcessWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ private async void ShowCopiedNotificationCurrentElementSaveStateRequested() {
4141

4242
private void ProcessWindow_Closed(object? sender, EventArgs e) {
4343
if (Application.Current.Windows.Count == 1 && Application.Current.MainWindow is StartupWindow startupWindow) {
44+
if (DataContext is ProcessViewModel processViewModel) {
45+
if (processViewModel.ClosingCommand.CanExecute(DataContext)) {
46+
processViewModel.ClosingCommand.Execute(DataContext);
47+
}
48+
}
49+
4450
startupWindow.Show();
4551
}
4652
}

0 commit comments

Comments
 (0)