Skip to content

Commit

Permalink
Allow user to select subdirectory search option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Jun 29, 2020
1 parent d78d5a3 commit 2a3d6df
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
3 changes: 3 additions & 0 deletions PicView/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<setting name="MagentaAlpha" serializeAs="String">
<value>#F2FF6CD4</value>
</setting>
<setting name="IncludeSubDirectories" serializeAs="String">
<value>False</value>
</setting>
</PicView.Properties.Settings>
</userSettings>
<runtime>
Expand Down
4 changes: 2 additions & 2 deletions PicView/FileHandling/FileLists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ internal static List<string> FileList(string path, SortFilesBy sortFilesBy)
return null;
}

// TODO make search option a user setting
var items = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories)
var searchOption = Properties.Settings.Default.IncludeSubDirectories;
var items = Directory.EnumerateFiles(path, "*.*", searchOption ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)
.AsParallel()
.Where(file =>

Expand Down
12 changes: 12 additions & 0 deletions PicView/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions PicView/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,8 @@
<Setting Name="MagentaAlpha" Type="System.Windows.Media.Color" Scope="User">
<Value Profile="(Default)">#F2FF6CD4</Value>
</Setting>
<Setting Name="IncludeSubDirectories" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
8 changes: 4 additions & 4 deletions PicView/UI/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@
VerticalAlignment="Top"
Orientation="Horizontal">
<CheckBox
x:Name="LoopRadio"
Width="131"
x:Name="SubDirRadio"
Width="225"
Height="40"
Margin="5,3"
BorderThickness="2"
Content="Enable Looping"
Content="Enable Subdirectory Searching"
Style="{StaticResource Checkstyle}">
<CheckBox.Background>
<SolidColorBrush x:Name="LoopBrush" Color="{StaticResource BackgroundColorAlt}" />
<SolidColorBrush x:Name="SubDirBrush" Color="{StaticResource BackgroundColorAlt}" />
</CheckBox.Background>
</CheckBox>
<CheckBox
Expand Down
34 changes: 19 additions & 15 deletions PicView/UI/Windows/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using PicView.UI.Animations;
using PicView.ChangeImage;
using PicView.UI.Animations;
using System;
using System.Windows;
using System.Windows.Input;
Expand Down Expand Up @@ -150,12 +151,15 @@ public SettingsWindow()
GreyRadio.MouseLeave += GreyRadio_MouseLeave;
GreyRadio.Click += Grey;

// LoopRadio
LoopRadio.PreviewMouseLeftButtonDown += LoopRadio_PreviewMouseLeftButtonDown;
LoopRadio.MouseEnter += LoopRadio_MouseEnter;
LoopRadio.MouseLeave += LoopRadio_MouseLeave;
LoopRadio.IsChecked = Properties.Settings.Default.Looping;
LoopRadio.Click += UpdateUIValues.SetLooping;
// SubDirRadio
SubDirRadio.PreviewMouseLeftButtonDown += SubDirRadio_PreviewMouseLeftButtonDown;
SubDirRadio.MouseEnter += SubDirRadio_MouseEnter;
SubDirRadio.MouseLeave += SubDirRadio_MouseLeave;
SubDirRadio.IsChecked = Properties.Settings.Default.IncludeSubDirectories;
SubDirRadio.Click += delegate {
Properties.Settings.Default.IncludeSubDirectories = !Properties.Settings.Default.IncludeSubDirectories;
Error_Handling.Reload();
};

// BorderColorRadio
BorderRadio.PreviewMouseLeftButtonDown += BorderRadio_PreviewMouseLeftButtonDown;
Expand Down Expand Up @@ -625,34 +629,34 @@ private void GreyRadio_PreviewMouseLeftButtonDown(object sender, MouseButtonEven
AnimationHelper.PreviewMouseLeftButtonDownColorEvent(GreyBrush, 12);
}

// Loop
private void LoopRadio_MouseLeave(object sender, MouseEventArgs e)
// SubDirRadio
private void SubDirRadio_MouseLeave(object sender, MouseEventArgs e)
{
AnimationHelper.MouseLeaveColorEvent(
backgroundBorderColor.A,
backgroundBorderColor.R,
backgroundBorderColor.G,
backgroundBorderColor.B,
LoopBrush,
SubDirBrush,
false
);
}

private void LoopRadio_MouseEnter(object sender, MouseEventArgs e)
private void SubDirRadio_MouseEnter(object sender, MouseEventArgs e)
{
AnimationHelper.MouseOverColorEvent(
backgroundBorderColor.A,
backgroundBorderColor.R,
backgroundBorderColor.G,
backgroundBorderColor.B,
LoopBrush,
SubDirBrush,
false
);
}

private void LoopRadio_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
private void SubDirRadio_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
AnimationHelper.MouseLeaveColorEvent(0, 0, 0, 0, LoopBrush, false);
AnimationHelper.MouseLeaveColorEvent(0, 0, 0, 0, SubDirBrush, false);
}

// BorderColor
Expand Down Expand Up @@ -722,7 +726,7 @@ private static void Red(object sender, RoutedEventArgs e)
private static void Teal(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.ColorTheme = 6;
ConfigColors.UpdateColor();
UpdateColor();
}

private static void Aqua(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 2a3d6df

Please sign in to comment.