Skip to content

Commit

Permalink
Merge pull request #47 from deadlydog/SaveUserSearchOptionsBetweenSes…
Browse files Browse the repository at this point in the history
…sions

Save user search options between sessions
  • Loading branch information
deadlydog authored Oct 26, 2020
2 parents e146423 + e4e6177 commit 390021b
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 24 deletions.
89 changes: 68 additions & 21 deletions src/PathLengthCheckerGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
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}"
Style="{StaticResource ResourceKey=DefaultWindowStyle}"
MinWidth="770" MinHeight="400"
Width="{local:ApplicationSettingsBinding WindowWidth}"
Height="{local:ApplicationSettingsBinding WindowHeight}"
Left="{local:ApplicationSettingsBinding WindowLeftPosition}"
Top="{local:ApplicationSettingsBinding WindowTopPosition}"
WindowState="{local:ApplicationSettingsBinding WindowState}"
Width="{local:ApplicationSettingsBinding Path=WindowWidth}"
Height="{local:ApplicationSettingsBinding Path=WindowHeight}"
Left="{local:ApplicationSettingsBinding Path=WindowLeftPosition}"
Top="{local:ApplicationSettingsBinding Path=WindowTopPosition}"
WindowState="{local:ApplicationSettingsBinding Path=WindowState}"
FocusManager.FocusedElement="{Binding ElementName=txtRootDirectory}">
<Window.Resources>
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="FileSystemTypesEnumValues" IsAsynchronous="True">
Expand Down Expand Up @@ -51,7 +51,7 @@
</Grid.ColumnDefinitions>

<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." />
<TextBox Grid.Column="2" Name="txtRootDirectory" Text="{local:ApplicationSettingsBinding Path=SearchOption_RootDirectory, UpdateSourceTrigger=PropertyChanged}" 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>

Expand All @@ -71,20 +71,56 @@
</Grid.ColumnDefinitions>

<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" VerticalAlignment="Center" ToolTip="If enabled it will search for files/directories in all subdirectories of the Starting Directory." />

<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" 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" />
<ComboBox Grid.Column="1" Name="cmbTypesToInclude" ItemsSource="{Binding Source={StaticResource FileSystemTypesEnumValues}}" SelectedValue="{local:ApplicationSettingsBinding Path=SearchOption_FileSystemTypesToInclude}" ToolTip="The file system types to find and return the path length of." />

<CheckBox Grid.Column="3" Content="Include Subdirectories" Name="chkIncludeSubdirectories" IsChecked="{local:ApplicationSettingsBinding Path=SearchOption_IncludeSubdirectories}" VerticalAlignment="Center" ToolTip="If enabled it will search for files/directories in all subdirectories of the Starting Directory." />

<TextBlock Grid.Column="5" Margin="0,0,5,0" Text="Min Path Length:" VerticalAlignment="Center">
<TextBlock.ToolTip>
<TextBlock>
Only paths with this many or more characters will be returned in the search results.
<LineBreak />
Use 260 to identify long paths that Windows may have trouble handling.
<LineBreak />
Use 0 to not filter any paths by minimum length.
</TextBlock>
</TextBlock.ToolTip>
</TextBlock>
<extToolkit:IntegerUpDown Grid.Column="6" Name="numMinPathLength" Value="{local:ApplicationSettingsBinding Path=SearchOption_MinPathLength}" DefaultValue="0" Minimum="0" Maximum="999999" MinWidth="50">
<extToolkit:IntegerUpDown.ToolTip>
<TextBlock>
Only paths with this many or more characters will be returned in the search results.
<LineBreak />
Use 260 to identify long paths that Windows may have trouble handling.
<LineBreak />
Use 0 to not filter any paths by minimum length.
</TextBlock>
</extToolkit:IntegerUpDown.ToolTip>
</extToolkit:IntegerUpDown>

<TextBlock Grid.Column="8" Margin="0,0,5,0" Text="Max Path Length:" VerticalAlignment="Center">
<TextBlock.ToolTip>
<TextBlock>
Only paths with this many or less characters will be returned in the search results.
<LineBreak />
Use a large value like 999999 to not filter any paths by maximum length.
</TextBlock>
</TextBlock.ToolTip>
</TextBlock>
<extToolkit:IntegerUpDown Grid.Column="9" Name="numMaxPathLength" Value="{local:ApplicationSettingsBinding Path=SearchOption_MaxPathLength}" DefaultValue="0" Minimum="0" Maximum="999999" MinWidth="50">
<extToolkit:IntegerUpDown.ToolTip>
<TextBlock>
Only paths with this many or less characters will be returned in the search results.
<LineBreak />
Use a large value like 999999 to not filter any paths by maximum length.
</TextBlock>
</extToolkit:IntegerUpDown.ToolTip>
</extToolkit:IntegerUpDown>
</Grid>

<DockPanel Grid.Row="4">
<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="" />
<TextBox Name="txtSearchPattern" Text="{local:ApplicationSettingsBinding Path=SearchOption_SearchPattern, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" ToolTip="Only files/directories that match the given pattern will be returned. The * is a wildcard." />
</DockPanel>

<Grid Grid.Row="6">
Expand All @@ -98,14 +134,25 @@
<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" 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" IsChecked="{local:ApplicationSettingsBinding Path=SearchOption_ReplaceRootDirectory}" 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" HorizontalAlignment="Stretch" ToolTip="The path to replace the Starting Directory with in the paths that are returned." IsEnabled="{Binding ElementName=chkReplaceRootDirectory, Path=IsChecked}" />
<TextBox Grid.Row="1" Grid.Column="1" Name="txtReplaceRootDirectory" Text="{local:ApplicationSettingsBinding Path=SearchOption_RootDirectoryReplacementText, UpdateSourceTrigger=PropertyChanged}" 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" />
<Grid Grid.Row="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Content="Get Path Lengths..." Name="btnGetPathLengths" FontSize="40" Click="btnGetPathLengths_Click" IsDefault="True" />
<Button Grid.Column="1" Content="Cancel retrieving paths" Name="btnCancelGetPathLengths" FontSize="40" Click="btnCancelGetPathLengths_Click" Visibility="Collapsed" />
<Button Grid.Column="3" Name="btnResetSearchOptions" Margin="0,10,0,10" ToolTip="Reset all of the search fields to their default values." Click="btnResetSearchOptions_Click">
<TextBlock TextWrapping="Wrap" TextAlignment="Center">Reset search options</TextBlock>
</Button>
</Grid>

<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>
Expand Down
25 changes: 22 additions & 3 deletions src/PathLengthCheckerGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public MainWindow()
InitializeComponent();
this.DataContext = this;

// Set the default type for the combo boxes.
cmbTypesToInclude.SelectedValue = FileSystemTypes.All;

SetWindowTitle();
}

Expand Down Expand Up @@ -360,5 +357,27 @@ protected internal void SetUIControlsFromSearchOptions(PathLengthSearchOptions a
numMinPathLength.Value = argSearchOptions.MinimumPathLength;
numMaxPathLength.Value = argSearchOptions.MaximumPathLength;
}

private void btnResetSearchOptions_Click(object sender, RoutedEventArgs e)
{
ResetAllUiSearchOptionsToDefaultValues();
}

private void ResetAllUiSearchOptionsToDefaultValues()
{
// Values specified here should match the default values in the Properties\Settings.settings file.

txtRootDirectory.Text = string.Empty;
txtSearchPattern.Text = string.Empty;

numMinPathLength.Value = 0;
numMaxPathLength.Value = PathLengthSearchOptions.MaximumPathLengthMaxValue;

chkIncludeSubdirectories.IsChecked = true;
cmbTypesToInclude.SelectedValue = FileSystemTypes.All;

txtReplaceRootDirectory.Text = string.Empty;
chkReplaceRootDirectory.IsChecked = false;
}
}
}
96 changes: 96 additions & 0 deletions src/PathLengthCheckerGUI/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/PathLengthCheckerGUI/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,29 @@
<Setting Name="WindowState" Type="System.String" Scope="User">
<Value Profile="(Default)">Normal</Value>
</Setting>
<Setting Name="SearchOption_RootDirectory" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SearchOption_ReplaceRootDirectory" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="SearchOption_FileSystemTypesToInclude" Type="PathLengthChecker.FileSystemTypes" Scope="User">
<Value Profile="(Default)">All</Value>
</Setting>
<Setting Name="SearchOption_IncludeSubdirectories" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="SearchOption_MinPathLength" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="SearchOption_MaxPathLength" Type="System.Int32" Scope="User">
<Value Profile="(Default)">999999</Value>
</Setting>
<Setting Name="SearchOption_SearchPattern" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SearchOption_RootDirectoryReplacementText" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
24 changes: 24 additions & 0 deletions src/PathLengthCheckerGUI/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@
<setting name="WindowState" serializeAs="String">
<value>Normal</value>
</setting>
<setting name="SearchOption_RootDirectory" serializeAs="String">
<value />
</setting>
<setting name="SearchOption_ReplaceRootDirectory" serializeAs="String">
<value>False</value>
</setting>
<setting name="SearchOption_FileSystemTypesToInclude" serializeAs="String">
<value>All</value>
</setting>
<setting name="SearchOption_IncludeSubdirectories" serializeAs="String">
<value>True</value>
</setting>
<setting name="SearchOption_MinPathLength" serializeAs="String">
<value>0</value>
</setting>
<setting name="SearchOption_MaxPathLength" serializeAs="String">
<value>999999</value>
</setting>
<setting name="SearchOption_SearchPattern" serializeAs="String">
<value />
</setting>
<setting name="SearchOption_RootDirectoryReplacementText" serializeAs="String">
<value />
</setting>
</PathLengthCheckerGUI.Properties.Settings>
</userSettings>
</configuration>

0 comments on commit 390021b

Please sign in to comment.