mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 02:09:24 +08:00
[FileLocksmith]Show process files in modal dialog to fix crash (#33804)
## Summary of the Pull Request To prevent a crash, show the individual files of a process within a modal dialog rather than as inline text. Please see the linked issue for more details. ## Detailed Description of the Pull Request / Additional comments - Removed inline list of process files. - Added "Show files" button to expander to show list of process files as a modal dialog. This dialog has the same design as the one used to display the list of selected folders within the same application. - Added unhandled exception hander to application similar to our other applications. ![image](https://github.com/user-attachments/assets/52eddfcc-5e10-40a3-94b2-68bbfb607f1d) ![image](https://github.com/user-attachments/assets/ff996e32-36f6-41a9-a9f0-6dda7a93d09a)
This commit is contained in:
parent
84def18ed5
commit
d40367a860
@ -25,6 +25,8 @@ namespace FileLocksmithUI
|
|||||||
Logger.InitializeLogger("\\File Locksmith\\FileLocksmithUI\\Logs");
|
Logger.InitializeLogger("\\File Locksmith\\FileLocksmithUI\\Logs");
|
||||||
|
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
|
|
||||||
|
UnhandledException += App_UnhandledException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,6 +57,11 @@ namespace FileLocksmithUI
|
|||||||
_window.Activate();
|
_window.Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
Logger.LogError("Unhandled exception", e.Exception);
|
||||||
|
}
|
||||||
|
|
||||||
private Window _window;
|
private Window _window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,27 +141,16 @@
|
|||||||
IsTextSelectionEnabled="True"
|
IsTextSelectionEnabled="True"
|
||||||
Text="{x:Bind user}" />
|
Text="{x:Bind user}" />
|
||||||
</tkcontrols:SettingsCard>
|
</tkcontrols:SettingsCard>
|
||||||
<tkcontrols:SettingsCard ContentAlignment="Vertical">
|
<tkcontrols:SettingsCard>
|
||||||
<tkcontrols:SettingsCard.Header>
|
<tkcontrols:SettingsCard.Header>
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<Run x:Uid="Files" />
|
<Run x:Uid="Files" />
|
||||||
<Run Text="(" /><Run Text="{x:Bind files, Converter={StaticResource fileCountConverter}}" /><Run Text=")" />
|
<Run Text="(" /><Run Text="{x:Bind files, Converter={StaticResource fileCountConverter}}" /><Run Text=")" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</tkcontrols:SettingsCard.Header>
|
</tkcontrols:SettingsCard.Header>
|
||||||
<ItemsRepeater ItemsSource="{x:Bind files}">
|
<Button Click="ShowProcessFiles_Click">
|
||||||
<ItemsRepeater.ItemTemplate>
|
<TextBlock x:Uid="ShowProcessFiles" />
|
||||||
<DataTemplate x:DataType="x:String">
|
</Button>
|
||||||
<TextBlock
|
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
|
||||||
IsTextSelectionEnabled="True"
|
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
|
||||||
Text="{Binding}"
|
|
||||||
TextTrimming="CharacterEllipsis"
|
|
||||||
TextWrapping="NoWrap"
|
|
||||||
ToolTipService.ToolTip="{Binding}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsRepeater.ItemTemplate>
|
|
||||||
</ItemsRepeater>
|
|
||||||
</tkcontrols:SettingsCard>
|
</tkcontrols:SettingsCard>
|
||||||
</tkcontrols:SettingsExpander.Items>
|
</tkcontrols:SettingsExpander.Items>
|
||||||
</tkcontrols:SettingsExpander>
|
</tkcontrols:SettingsExpander>
|
||||||
@ -200,5 +189,13 @@
|
|||||||
Text="{x:Bind ViewModel.PathsToString, Mode=OneWay}"
|
Text="{x:Bind ViewModel.PathsToString, Mode=OneWay}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</ContentDialog>
|
</ContentDialog>
|
||||||
|
<ContentDialog x:Name="ProcessFilesListDialog" x:Uid="ProcessFilesListDialog">
|
||||||
|
<ScrollViewer Padding="15" HorizontalScrollBarVisibility="Auto">
|
||||||
|
<TextBlock
|
||||||
|
x:Name="ProcessFilesListDialogTextBlock"
|
||||||
|
x:Uid="ProcessFilesListDialogTextBlock"
|
||||||
|
IsTextSelectionEnabled="True" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</ContentDialog>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using FileLocksmith.Interop;
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using PowerToys.FileLocksmithUI.ViewModels;
|
using PowerToys.FileLocksmithUI.ViewModels;
|
||||||
|
|
||||||
@ -19,9 +21,17 @@ namespace PowerToys.FileLocksmithUI.Views
|
|||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ShowSelectedPathsButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
private async void ShowSelectedPathsButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await SelectedFilesListDialog.ShowAsync();
|
await SelectedFilesListDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void ShowProcessFiles_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var processResult = (ProcessResult)((FrameworkElement)sender).DataContext;
|
||||||
|
ProcessFilesListDialogTextBlock.Text = string.Join(Environment.NewLine, processResult.files);
|
||||||
|
|
||||||
|
await ProcessFilesListDialog.ShowAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,13 @@
|
|||||||
<data name="Files.Text" xml:space="preserve">
|
<data name="Files.Text" xml:space="preserve">
|
||||||
<value>Files</value>
|
<value>Files</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ProcessFilesListDialog.Title" xml:space="preserve">
|
||||||
|
<value>Files</value>
|
||||||
|
</data>
|
||||||
|
<data name="ProcessFilesListDialog.CloseButtonText" xml:space="preserve">
|
||||||
|
<value>Close</value>
|
||||||
|
<comment>As in, close a dialog prompt.</comment>
|
||||||
|
</data>
|
||||||
<data name="PathsTooltipDescription.Text" xml:space="preserve">
|
<data name="PathsTooltipDescription.Text" xml:space="preserve">
|
||||||
<value>Click to see the entire list of paths.</value>
|
<value>Click to see the entire list of paths.</value>
|
||||||
<comment>Paths as in file paths that were selected for the utility to check.</comment>
|
<comment>Paths as in file paths that were selected for the utility to check.</comment>
|
||||||
@ -164,4 +171,8 @@
|
|||||||
<value>Administrator: File Locksmith</value>
|
<value>Administrator: File Locksmith</value>
|
||||||
<comment>Title of the window when running as administrator.</comment>
|
<comment>Title of the window when running as administrator.</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ShowProcessFiles.Text" xml:space="preserve">
|
||||||
|
<value>Show files</value>
|
||||||
|
<comment>Show files for the selected process</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user