Skip to content

Commit

Permalink
- Use svg icons instead of png.
Browse files Browse the repository at this point in the history
- Install the application to %AppData% instead of %ProgramFiles%. Admin rights are not needed for the installation.
- Show locking information in alphabetical order
- Bugfix: in some situation extra locking information related to another folder was shown.
- Bugfix: processing of locking information was done several times, decreasing the performance.
  • Loading branch information
PolarGoose committed Dec 12, 2021
1 parent 1fe9aea commit 6018097
Show file tree
Hide file tree
Showing 53 changed files with 524 additions and 225 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{xml,wxs}]
indent_size = 2
33 changes: 22 additions & 11 deletions .github/workflows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ Function FindMsBuild() {
return $msbuild
}

Function RemoveFileIfExists($fileName) {
Info "Remove '$fileName'"
Remove-Item $fileName -Force -Recurse -ErrorAction SilentlyContinue
}

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

$root = Resolve-Path "$PSScriptRoot/../.."
$publishDir = "$root/build/Release"
$buildDir = "$root/build"
$publishDir = "$buildDir/Release"
$projectName = "ShowWhatProcessLocksFile"
$version = GetVersion
$installerVersion = GetInstallerVersion $version
$msbuild = FindMsBuild

Info "Version: '$version'. InstallerVersion: '$installerVersion'"

Info "Remove Publish directory `n $publishDir"
Remove-Item $publishDir -Force -Recurse -ErrorAction SilentlyContinue

Info "Build project"
& $msbuild `
/property:RestorePackagesConfig=true `
Expand All @@ -80,10 +83,18 @@ Info "Build project"
$root/$projectName.sln
CheckReturnCodeOfPreviousCommand "build failed"

# TODO: there are no processes which lock files on Github Actions executors. It makes a lot of test fail.
# Info "Run tests"
# & "$root/build/nuget/nunit.consolerunner/*/tools/nunit3-console.exe" `
# $publishDir/net461/Test.dll `
# --stoponerror `
# --noresult
# CheckReturnCodeOfPreviousCommand "tests failed"
RemoveFileIfExists "$publishDir/${projectName}.msi.zip"
Info "Create zip archive from msi installer"
Compress-Archive -Path "$publishDir/$projectName.msi" -DestinationPath "$publishDir/${projectName}.msi.zip"

# Skip running tests if the build script is run on Github Actions.
# There are no processes which lock files on Github Actions executors. It makes a lot of test fail.
if ($null -eq $env:GITHUB_ACTIONS) {
& "$buildDir/nuget/nunit.consolerunner/*/tools/nunit3-console.exe" `
"$publishDir/net461/Test.dll" `
--stoponerror `
--labels=Before `
--noheader `
--noresult
CheckReturnCodeOfPreviousCommand "tests failed"
}
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
files: Build/Release/*.msi
files: Build/Release/*.msi.zip
- uses: actions/upload-artifact@v2
with:
name: Build artifacts
path: Build/Release/*.msi
path: Build/Release/*.msi.zip
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# ShowWhatProcessLocksFile
An utility to discover what processes lock a specific file or folder.<br>

# Screenshots
## Context menu
![Screenshot](doc/ContextMenu.png)
<br>
## The application
![Screenshot](doc/Screenshot.png)

# System requirements
Expand All @@ -12,8 +15,8 @@ An utility to discover what processes lock a specific file or folder.<br>
The application uses [Handle by Mark Russinovich](https://docs.microsoft.com/en-us/sysinternals/downloads/handle) to get information about locking processes. The output of `handle.exe` is parsed and displayed in the GUI.<br>

# How to use
* Download `ShowWhatProcessLocksFile.msi` from the latest [release](https://github.com/PolarGoose/ShowWhatProcessLocksFile/releases).
* Run the installer. The installer will install this programm to the `C:\Program Files\ShowWhatProcessLocksFile` folder and add a "Show what locks this file" Windows File Explorer context menu element.
* Download `ShowWhatProcessLocksFile.msi.zip` from the latest [release](https://github.com/PolarGoose/ShowWhatProcessLocksFile/releases).
* Run the installer. The installer will install this programm to the `%AppData%\ShowWhatProcessLocksFile` folder and add a "Show what locks this file" Windows File Explorer context menu element.
* Use "Show what locks this file" File Explorer's context menu to select a file or folder
* To terminate selected processes, open a context menu by clicking mouse right button
* If you want to uninstall the program, use `Control Panel\Programs\Programs and Features`, uninstaller will remove an integration with the context menu and all files which were installed.
Expand Down
Binary file modified doc/ContextMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion src/App/Gui/Controls/ExpandToggleButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<ToggleButton.Style> <Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}"> <Setter Property="Content"> <Setter.Value> <Image Source="/Gui/Icons/ExpandRight_md_16x.png"/> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Content"> <Setter.Value> <Image Source="/Gui/Icons/ExpandDown_md_16x.png"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </ToggleButton.Style>
<ToggleButton.Style>
<Style TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="Content">
<Setter.Value>
<svgc:SvgViewbox Source="/Gui/Icons/ExpandRight_md_16x.svg"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content">
<Setter.Value>
<svgc:SvgViewbox Source="/Gui/Icons/ExpandDown_md_16x.svg"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
3 changes: 2 additions & 1 deletion src/App/Gui/Controls/IconButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
x:Name="self"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Image Source="{Binding Icon, ElementName=self}"/>
<svgc:SvgViewbox Source="{Binding Icon, ElementName=self}"/>
</Button>
8 changes: 4 additions & 4 deletions src/App/Gui/Controls/IconButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace ShowWhatProcessLocksFile.Gui.Controls
{
public partial class IconButton : Button
{
public ImageSource Icon
public Uri Icon
{
get => (ImageSource)GetValue(IconProperty);
get => (Uri)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconButton));
DependencyProperty.Register("Icon", typeof(Uri), typeof(IconButton));

public IconButton()
{
Expand Down
4 changes: 2 additions & 2 deletions src/App/Gui/Controls/ProcessInfoListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</Grid.RowDefinitions>

<StackPanel Grid.Row="0" Orientation="Horizontal">
<local:IconButton Height="21" Width="21" Margin="2" Command="{Binding ExpandAllCommand}" Icon="/Gui/Icons/ExpandAll_16x.png" ToolTip="Expand All"/>
<local:IconButton Height="21" Width="21" Margin="2" Command="{Binding CollapseAllCommand}" Icon="/Gui/Icons/CollapseAll_16x.png" ToolTip="Collapse All"/>
<local:IconButton Height="21" Width="21" Margin="2" Command="{Binding ExpandAllCommand}" Icon="/Gui/Icons/ExpandAll_16x.svg" ToolTip="Expand All"/>
<local:IconButton Height="21" Width="21" Margin="2" Command="{Binding CollapseAllCommand}" Icon="/Gui/Icons/CollapseAll_16x.svg" ToolTip="Collapse All"/>
</StackPanel>

<ListBox x:Name="processInfoList" Grid.Row="1" SelectionMode="Extended" ItemsSource="{Binding ProcessInfoViewModels}" ScrollViewer.CanContentScroll="False">
Expand Down
2 changes: 1 addition & 1 deletion src/App/Gui/Controls/ProcessInfoListViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ShowWhatProcessLocksFile.Gui.Utils;
using ShowWhatProcessLocksFile.LockingProcessesInfo;
using ShowWhatProcessLocksFile.LockFinding;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
50 changes: 43 additions & 7 deletions src/App/Gui/Controls/ProcessInfoView.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
<UserControl x:Class="ShowWhatProcessLocksFile.Gui.Controls.ProcessInfoView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
<UserControl x:Class="ShowWhatProcessLocksFile.Gui.Controls.ProcessInfoView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
xmlns:utils="clr-namespace:ShowWhatProcessLocksFile.Gui.Utils" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance Type=local:ProcessInfoViewModel, IsDesignTimeCreatable=False}"> <UserControl.Resources> <utils:BooleanToCollapsedVisibilityConverter x:Key="BooleanToCollapsedVisibilityConverter"/> </UserControl.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <local:ExpandToggleButton IsChecked="{Binding IsExpanded}" Grid.Column="0" Grid.Row="0" Margin="5" Height="20" Width="20"/>
<Image Grid.Column="1" Grid.Row="0" Source="{Binding Process.Icon}" Height="32" Width="32" Margin="5"/>
<TextBlock Grid.Column="2" Grid.Row="0" Margin="5" FontSize="12"> <Run FontWeight="Bold" Text="{Binding Process.Name, Mode=OneWay}"/> <LineBreak/> Pid: <Run Text="{Binding Process.Pid, Mode=OneWay}"/>, <Run Text="{Binding Process.ExecutableFullName, Mode=OneWay}"/> </TextBlock>
<ItemsControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" x:Name="LockedFiles" ItemsSource="{Binding Process.LockedFiles}"
Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToCollapsedVisibilityConverter}}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Margin="20, 2, 2, 2" Text="{Binding}"></TextBlock> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid></UserControl>
xmlns:utils="clr-namespace:ShowWhatProcessLocksFile.Gui.Utils"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance Type=local:ProcessInfoViewModel, IsDesignTimeCreatable=False}">
<UserControl.Resources>
<utils:BooleanToCollapsedVisibilityConverter x:Key="BooleanToCollapsedVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<local:ExpandToggleButton IsChecked="{Binding IsExpanded}" Grid.Column="0" Grid.Row="0" Margin="5" Height="20" Width="20"/>

<Image Grid.Column="1" Grid.Row="0" Source="{Binding Process.Icon}" Height="32" Width="32" Margin="5"/>

<TextBlock Grid.Column="2" Grid.Row="0" Margin="5" FontSize="12">
<Run FontWeight="Bold" Text="{Binding Process.Name, Mode=OneWay}"/> <LineBreak/>
Pid: <Run Text="{Binding Process.Pid, Mode=OneWay}"/>, <Run Text="{Binding Process.ExecutableFullName, Mode=OneWay}"/>
</TextBlock>

<ItemsControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" x:Name="LockedFiles"
ItemsSource="{Binding Process.LockedFiles}"
Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToCollapsedVisibilityConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="20, 2, 2, 2" Text="{Binding}"></TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion src/App/Gui/Controls/ProcessInfoViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ShowWhatProcessLocksFile.LockingProcessesInfo;
using ShowWhatProcessLocksFile.LockFinding;

namespace ShowWhatProcessLocksFile.Gui.Controls
{
Expand Down
20 changes: 15 additions & 5 deletions src/App/Gui/Controls/ResultTextView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:local="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance Type=local:ResultTextView, IsDesignTimeCreatable=False}">
d:DataContext="{d:DesignInstance Type=local:ResultTextViewModel, IsDesignTimeCreatable=False}">
<StackPanel Orientation="Horizontal">
<Image Height="16" Margin="2" VerticalAlignment="Top">
<Image.Style> <Style TargetType="Image"> <Setter Property="Source" Value="/Gui/Icons/StatusCriticalError_16x.png"/> <Style.Triggers> <DataTrigger Binding="{Binding Success}" Value="True"> <Setter Property="Source" Value="/Gui/Icons/Checkmark_16x.png"/> </DataTrigger> </Style.Triggers> </Style> </Image.Style>
</Image>
<svgc:SvgViewbox Height="16" Margin="2" VerticalAlignment="Top">
<svgc:SvgViewbox.Style>
<Style TargetType="svgc:SvgViewbox">
<Setter Property="Source" Value="/Gui/Icons/StatusCriticalError_16x.svg"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Success}" Value="True">
<Setter Property="Source" Value="/Gui/Icons/Checkmark_16x.svg"/>
</DataTrigger>
</Style.Triggers>
</Style>
</svgc:SvgViewbox.Style>
</svgc:SvgViewbox>
<TextBox Background="Transparent"
BorderThickness="0"
VerticalAlignment="Center"
Expand Down
Binary file removed src/App/Gui/Icons/Checkmark_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/Checkmark_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/CollapseAll_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/CollapseAll_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/ExpandAll_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/ExpandAll_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/ExpandDown_md_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/ExpandDown_md_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/ExpandRight_md_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/ExpandRight_md_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/Refresh_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/Refresh_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/App/Gui/Icons/StatusCriticalError_16x.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/App/Gui/Icons/StatusCriticalError_16x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6018097

Please sign in to comment.