Skip to content

Commit

Permalink
Merge pull request #46 from deadlydog/ChangeDefaultFont
Browse files Browse the repository at this point in the history
Use monospace font for paths in grid
  • Loading branch information
deadlydog authored Oct 25, 2020
2 parents 91e62c6 + 44d6534 commit e146423
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 94 deletions.
39 changes: 35 additions & 4 deletions src/PathLengthCheckerGUI/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
<Application x:Class="PathLengthCheckerGUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
Startup="Application_Startup"
Exit="Application_Exit">
<Application.Resources>

</Application.Resources>
<Style x:Key="DefaultWindowStyle" TargetType="{x:Type Window}">
<Setter Property="FontSize" Value="14" />
</Style>

<!-- Default all tooltips to show for 60 seconds -->
<Style TargetType="{x:Type Button}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type extToolkit:IntegerUpDown}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
</Application.Resources>
</Application>
85 changes: 42 additions & 43 deletions src/PathLengthCheckerGUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,6 @@ public partial class App : Application
public App() : base()
{
SetupUnhandledExceptionHandling();
Startup += App_Startup;
Exit += App_Exit;
}

private void App_Exit(object sender, ExitEventArgs e)
{
// Save any application settings that were changed when exiting (such as window size and position).
PathLengthCheckerGUI.Properties.Settings.Default.Save();
}

private void App_Startup(object sender, StartupEventArgs e)
{
var mainWindow = new MainWindow();

// If a directory was drag-and-dropped onto the GUI executable, launch with the app searching the given directory.
if (e.Args.Length == 1 && Directory.Exists(e.Args[0]))
{
mainWindow.txtRootDirectory.Text = e.Args[0];
mainWindow.btnGetPathLengths.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
else if (e.Args.Length >= 1)
{
try
{
var searchOptions = PathLengthChecker.ArgumentParser.ParseArgs(e.Args);
mainWindow.SetUIControlsFromSearchOptions(searchOptions);

// Only start the search if a root dir was specified
if (!String.IsNullOrEmpty(searchOptions?.RootDirectory))
{
mainWindow.btnGetPathLengths.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
}
catch (ArgumentException ex)
{
string title = "Incorrect arguments";
string message = "Incorrectly-formatted arguments were passed to the program.\n\n";
message += ex.Message + "\n\n" + PathLengthChecker.ArgumentParser.ArgumentUsage;
MessageBox.Show(message, title);
}
}

mainWindow.Show();
}

private void SetupUnhandledExceptionHandling()
Expand Down Expand Up @@ -115,5 +72,47 @@ void ShowUnhandledException(Exception e, string unhandledExceptionType, bool pro
Application.Current.Shutdown();
}
}

private void Application_Startup(object sender, StartupEventArgs e)
{
InitializeComponent();
var mainWindow = new MainWindow();

// If a directory was drag-and-dropped onto the GUI executable, launch with the app searching the given directory.
if (e.Args.Length == 1 && Directory.Exists(e.Args[0]))
{
mainWindow.txtRootDirectory.Text = e.Args[0];
mainWindow.btnGetPathLengths.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
else if (e.Args.Length >= 1)
{
try
{
var searchOptions = PathLengthChecker.ArgumentParser.ParseArgs(e.Args);
mainWindow.SetUIControlsFromSearchOptions(searchOptions);

// Only start the search if a root dir was specified
if (!String.IsNullOrEmpty(searchOptions?.RootDirectory))
{
mainWindow.btnGetPathLengths.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
}
catch (ArgumentException ex)
{
string title = "Incorrect arguments";
string message = "Incorrectly-formatted arguments were passed to the program.\n\n";
message += ex.Message + "\n\n" + PathLengthChecker.ArgumentParser.ArgumentUsage;
MessageBox.Show(message, title);
}
}

mainWindow.Show();
}

private void Application_Exit(object sender, ExitEventArgs e)
{
// Save any application settings that were changed when exiting (such as window size and position).
PathLengthCheckerGUI.Properties.Settings.Default.Save();
}
}
}
67 changes: 20 additions & 47 deletions src/PathLengthCheckerGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:extToolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:PathLengthChecker="clr-namespace:PathLengthChecker;assembly=PathLengthChecker"
Style="{StaticResource DefaultWindowStyle}"
MinWidth="770" MinHeight="400"
Width="{local:ApplicationSettingsBinding WindowWidth}"
Height="{local:ApplicationSettingsBinding WindowHeight}"
Expand All @@ -13,34 +14,6 @@
WindowState="{local:ApplicationSettingsBinding WindowState}"
FocusManager.FocusedElement="{Binding ElementName=txtRootDirectory}">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

<!-- Default all tooltips to show for 60 seconds -->
<Style TargetType="{x:Type Button}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>
<Style TargetType="{x:Type extToolkit:IntegerUpDown}">
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
</Style>

<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="FileSystemTypesEnumValues" IsAsynchronous="True">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="PathLengthChecker:FileSystemTypes" />
Expand Down Expand Up @@ -77,9 +50,9 @@
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" Text="Starting Directory:" FontSize="14" ToolTip="The root directory to look for files and/or directories in." />
<TextBox Grid.Column="2" Name="txtRootDirectory" FontSize="14" HorizontalAlignment="Stretch" ToolTip="The directory to look for files and/or directories in." />
<Button Grid.Column="3" Content="..." x:Name="btnBrowseForRootDirectory" Click="btnBrowseForRootDirectory_Click" FontSize="14" ToolTip="Browse for a folder to search in." />
<TextBlock Grid.Column="0" Text="Starting Directory:" ToolTip="The root directory to look for files and/or directories in." />
<TextBox Grid.Column="2" Name="txtRootDirectory" HorizontalAlignment="Stretch" ToolTip="The directory to look for files and/or directories in." />
<Button Grid.Column="3" Content="..." x:Name="btnBrowseForRootDirectory" Click="btnBrowseForRootDirectory_Click" ToolTip="Browse for a folder to search in." />
</Grid>

<Grid Grid.Row="2">
Expand All @@ -97,21 +70,21 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" Text="Include:" FontSize="14" Margin="0,0,5,0" VerticalAlignment="Center" ToolTip="The file system types to find and return the path length of." />
<ComboBox Grid.Column="1" Name="cmbTypesToInclude" ItemsSource="{Binding Source={StaticResource FileSystemTypesEnumValues}}" FontSize="14" ToolTip="The file system types to find and return the path length of." />
<TextBlock Grid.Column="0" Text="Include:" Margin="0,0,5,0" VerticalAlignment="Center" ToolTip="The file system types to find and return the path length of." />
<ComboBox Grid.Column="1" Name="cmbTypesToInclude" ItemsSource="{Binding Source={StaticResource FileSystemTypesEnumValues}}" ToolTip="The file system types to find and return the path length of." />

<CheckBox Grid.Column="3" Content="Include Subdirectories" Name="chkIncludeSubdirectories" IsChecked="True" FontSize="14" VerticalAlignment="Center" ToolTip="If enabled it will search for files/directories in all subdirectories of the Starting Directory." />
<CheckBox Grid.Column="3" Content="Include Subdirectories" Name="chkIncludeSubdirectories" IsChecked="True" VerticalAlignment="Center" ToolTip="If enabled it will search for files/directories in all subdirectories of the Starting Directory." />

<TextBlock Grid.Column="5" FontSize="14" Margin="0,0,5,0" Text="Min Path Length:" VerticalAlignment="Center" ToolTip="Only paths with this many or more characters will be returned in the search results. Use 260 to identify long paths." />
<extToolkit:IntegerUpDown Grid.Column="6" Name="numMinPathLength" Value="0" DefaultValue="0" Minimum="0" Maximum="999999" MinWidth="50" FontSize="14" ToolTip="Only paths with this many or more characters will be returned in the search results. Use 260 to identify long paths." />
<TextBlock Grid.Column="5" Margin="0,0,5,0" Text="Min Path Length:" VerticalAlignment="Center" ToolTip="Only paths with this many or more characters will be returned in the search results. Use 260 to identify long paths." />
<extToolkit:IntegerUpDown Grid.Column="6" Name="numMinPathLength" Value="0" DefaultValue="0" Minimum="0" Maximum="999999" MinWidth="50" ToolTip="Only paths with this many or more characters will be returned in the search results. Use 260 to identify long paths." />

<TextBlock Grid.Column="8" FontSize="14" Margin="0,0,5,0" Text="Max Path Length:" VerticalAlignment="Center" ToolTip="Only paths with this many or less characters will be returned in the search results." />
<extToolkit:IntegerUpDown Grid.Column="9" DefaultValue="0" FontSize="14" Minimum="0" Maximum="999999" MinWidth="50" Name="numMaxPathLength" ToolTip="Only paths with this many or less characters will be returned in the search results." Value="999999" />
<TextBlock Grid.Column="8" Margin="0,0,5,0" Text="Max Path Length:" VerticalAlignment="Center" ToolTip="Only paths with this many or less characters will be returned in the search results." />
<extToolkit:IntegerUpDown Grid.Column="9" DefaultValue="0" Minimum="0" Maximum="999999" MinWidth="50" Name="numMaxPathLength" ToolTip="Only paths with this many or less characters will be returned in the search results." Value="999999" />
</Grid>

<DockPanel Grid.Row="4">
<TextBlock Text="Search Pattern:" FontSize="14" Margin="0,0,5,0" ToolTip="Only files/directories that match the given pattern will be returned." />
<TextBox Name="txtSearchPattern" FontSize="14" HorizontalAlignment="Stretch" ToolTip="Only files/directories that match the given pattern will be returned. The * is a wildcard." Text="" />
<TextBlock Text="Search Pattern:" Margin="0,0,5,0" ToolTip="Only files/directories that match the given pattern will be returned." />
<TextBox Name="txtSearchPattern" HorizontalAlignment="Stretch" ToolTip="Only files/directories that match the given pattern will be returned. The * is a wildcard." Text="" />
</DockPanel>

<Grid Grid.Row="6">
Expand All @@ -125,16 +98,16 @@
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>

<CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Content="Replace the Starting Directory in the returned paths with:" Name="chkReplaceRootDirectory" FontSize="14" ToolTip="If this is not enabled, the Starting Directory will not be modified in the returned paths." />
<CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Content="Replace the Starting Directory in the returned paths with:" Name="chkReplaceRootDirectory" ToolTip="If this is not enabled, the Starting Directory will not be modified in the returned paths." />

<TextBox Grid.Row="1" Grid.Column="1" Name="txtReplaceRootDirectory" FontSize="14" HorizontalAlignment="Stretch" ToolTip="The path to replace the Starting Directory with in the paths that are returned." IsEnabled="{Binding ElementName=chkReplaceRootDirectory, Path=IsChecked}" />
<Button Grid.Row="1" Grid.Column="2" Content="..." Name="btnBrowseForReplaceRootDirectory" Click="btnBrowseForReplaceRootDirectory_Click" FontSize="14" ToolTip="Browse for a path to replace the Starting Directory path with." IsEnabled="{Binding ElementName=chkReplaceRootDirectory, Path=IsChecked}" />
<TextBox Grid.Row="1" Grid.Column="1" Name="txtReplaceRootDirectory" HorizontalAlignment="Stretch" ToolTip="The path to replace the Starting Directory with in the paths that are returned." IsEnabled="{Binding ElementName=chkReplaceRootDirectory, Path=IsChecked}" />
<Button Grid.Row="1" Grid.Column="2" Content="..." Name="btnBrowseForReplaceRootDirectory" Click="btnBrowseForReplaceRootDirectory_Click" ToolTip="Browse for a path to replace the Starting Directory path with." IsEnabled="{Binding ElementName=chkReplaceRootDirectory, Path=IsChecked}" />
</Grid>

<Button Grid.Row="8" Content="Get Path Lengths..." Name="btnGetPathLengths" FontSize="40" Click="btnGetPathLengths_Click" IsDefault="True" Margin="30,0,30,0" />
<Button Grid.Row="8" Content="Cancel retrieving paths" Name="btnCancelGetPathLengths" FontSize="40" Click="btnCancelGetPathLengths_Click" Margin="30,0,30,0" Visibility="Collapsed" />

<DataGrid Grid.Row="10" AutoGenerateColumns="False" Name="dgPaths" IsReadOnly="True" IsTabStop="False" Grid.ColumnSpan="4" LoadingRow="dgPaths_LoadingRow" ItemsSource="{Binding Source={StaticResource PathsCollectionViewSource}}" SelectedItem="{Binding Path=SelectedPath, Mode=TwoWay}">
<DataGrid Grid.Row="10" AutoGenerateColumns="False" Name="dgPaths" IsReadOnly="True" IsTabStop="False" Grid.ColumnSpan="4" LoadingRow="dgPaths_LoadingRow" ItemsSource="{Binding Source={StaticResource PathsCollectionViewSource}}" SelectedItem="{Binding Path=SelectedPath, Mode=TwoWay}" FontFamily="Courier New">
<DataGrid.Columns>
<DataGridTextColumn Header="Length" IsReadOnly="True" Binding="{Binding Path=Length}" />
<DataGridTextColumn Header="Path" IsReadOnly="True" Binding="{Binding Path=Path}" />
Expand All @@ -148,11 +121,11 @@
</DataGrid.ContextMenu>
</DataGrid>

<TextBlock Grid.Row="12" FontSize="14" Name="txtNumberOfPaths" Text="" />
<TextBlock Grid.Row="14" FontSize="14" Name="txtMinAndMaxPathLengths" Text="" />
<TextBlock Grid.Row="12" Name="txtNumberOfPaths" Text="" />
<TextBlock Grid.Row="14" Name="txtMinAndMaxPathLengths" Text="" />

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="12" Grid.RowSpan="4">
<extToolkit:SplitButton x:Name="splitbtnCopyToClipboard" Content="Copy Paths to Clipboard" Click="splitbtnCopyToClipboard_Click" FontSize="14" Width="350">
<extToolkit:SplitButton x:Name="splitbtnCopyToClipboard" Content="Copy Paths to Clipboard" Click="splitbtnCopyToClipboard_Click" Width="350">
<extToolkit:SplitButton.DropDownContent>
<StackPanel Orientation="Vertical" Width="345">
<Button x:Name="btnCopyToClipboardWithoutLengths" Content="Copy Paths to Clipboard without Lengths" Click="btnCopyToClipboardWithoutLengths_Click" />
Expand Down

0 comments on commit e146423

Please sign in to comment.