Skip to content

Commit

Permalink
Added delete current image using button or "delete" key, added save f…
Browse files Browse the repository at this point in the history
…unctionality on rotated image - using top border button or "ctrl+s" combination, added backup functionality - move image to "backup" folder on delete, other small fixes and improvements. Updated the version number.
  • Loading branch information
martinchrzan committed Jan 9, 2022
1 parent 4961b70 commit 4aeae87
Show file tree
Hide file tree
Showing 37 changed files with 845 additions and 58 deletions.
8 changes: 5 additions & 3 deletions FileExplorerGallery.nuspec
Expand Up @@ -2,18 +2,20 @@
<package>
<metadata>
<id>FileExplorerGallery</id>
<version>1.0.1</version>
<version>1.1.0</version>
<authors>Martin Chrzan</authors>
<owners>Martin Chrzan</owners>
<licenseUrl>https://github.com/martinchrzan/FileExplorerGallery/blob/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/martinchrzan/FileExplorerGallery</projectUrl>
<!--<iconUrl></iconUrl>-->
<releaseNotes>
Updated signing certificate
Added delete functionality
Added backup on delete functionality
Added save rotated image functionality
</releaseNotes>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>FileExplorerGallery</description>
<copyright>Martin Chrzan Copyright 2020-2021</copyright>
<copyright>Martin Chrzan Copyright 2020-2022</copyright>
<tags>file explorer gallery</tags>
</metadata>
<files>
Expand Down
6 changes: 6 additions & 0 deletions FileExplorerGallery/App.config
Expand Up @@ -25,6 +25,12 @@
<setting name="SlideshowDuration" serializeAs="String">
<value>3</value>
</setting>
<setting name="ShowDeleteConfirmation" serializeAs="String">
<value>True</value>
</setting>
<setting name="BackupDeletedImages" serializeAs="String">
<value>False</value>
</setting>
</FileExplorerGallery.Properties.Settings>
</userSettings>
</configuration>
23 changes: 23 additions & 0 deletions FileExplorerGallery/Behaviors/BehaviorExtensions.cs
@@ -0,0 +1,23 @@
using System.Windows;
using System.Windows.Media;

namespace FileExplorerGallery.Behaviors
{
public static class BehaviorExtensions
{
public static T GetChildOfType<T>(this DependencyObject depObj)
where T : DependencyObject
{
if (depObj == null) return null;

for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
var child = VisualTreeHelper.GetChild(depObj, i);

var result = (child as T) ?? GetChildOfType<T>(child);
if (result != null) return result;
}
return null;
}
}
}
29 changes: 29 additions & 0 deletions FileExplorerGallery/Behaviors/CloseWindowOnEsc.cs
@@ -0,0 +1,29 @@
using System.Windows;
using System.Windows.Interactivity;

namespace FileExplorerGallery.Behaviors
{
public class CloseWindowOnEsc : Behavior<Window>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Loaded += AssociatedObject_Loaded;
}

private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
{
AssociatedObject.KeyDown += AssociatedObject_KeyDown;
}

private void AssociatedObject_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Escape)
{
AssociatedObject.Loaded -= AssociatedObject_Loaded;
AssociatedObject.KeyDown -= AssociatedObject_KeyDown;
AssociatedObject.Close();
}
}
}
}
20 changes: 20 additions & 0 deletions FileExplorerGallery/Behaviors/FocusFirstButtonBehavior.cs
@@ -0,0 +1,20 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;

namespace FileExplorerGallery.Behaviors
{
public class FocusFirstButtonBehavior : Behavior<Window>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Loaded += AssociatedObject_Loaded;
}

private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
{
AssociatedObject.GetChildOfType<Button>().Focus();
}
}
}
6 changes: 6 additions & 0 deletions FileExplorerGallery/Behaviors/GalleryCacheProvider.cs
Expand Up @@ -84,6 +84,12 @@ public static ScrollViewer GetGalleryScrollViewer(FrameworkElement childItem)
return _scrollViewer;
}

public static void ResetThumbnail(string pathToImage)
{
_thumbnails.Remove(pathToImage);
GetThumbnailImageWidth(pathToImage);
}

public static void ClearCache()
{
_thumbnails.Clear();
Expand Down
2 changes: 1 addition & 1 deletion FileExplorerGallery/Behaviors/GalleryKeyBindingBehavior.cs
Expand Up @@ -18,7 +18,7 @@ private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)

private void AssociatedObject_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if(e.Key == System.Windows.Input.Key.Escape)
if (e.Key == System.Windows.Input.Key.Escape)
{
Application.Current.MainWindow.Close();
}
Expand Down
20 changes: 20 additions & 0 deletions FileExplorerGallery/Behaviors/GallerySlideshowBehavior.cs
Expand Up @@ -36,6 +36,24 @@ public Button SlideshowButton
public static readonly DependencyProperty SlideshowButtonProperty = DependencyProperty.Register(
"SlideshowButton", typeof(Button), typeof(GallerySlideshowBehavior));

public Button DeleteButton
{
get { return (Button)GetValue(DeleteButtonProperty); }
set { SetValue(DeleteButtonProperty, value); }
}

public static readonly DependencyProperty DeleteButtonProperty = DependencyProperty.Register(
"DeleteButton", typeof(Button), typeof(GallerySlideshowBehavior));

public Button SaveButton
{
get { return (Button)GetValue(SaveButtonProperty); }
set { SetValue(SaveButtonProperty, value); }
}

public static readonly DependencyProperty SaveButtonProperty = DependencyProperty.Register(
"SaveButton", typeof(Button), typeof(GallerySlideshowBehavior));

protected override void OnAttached()
{
AssociatedObject.Loaded += AssociatedObject_Loaded;
Expand Down Expand Up @@ -68,6 +86,8 @@ private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
MainGrid.BeginAnimation(Grid.BackgroundProperty, brushAnimation);
RotateButton.Visibility = Visibility.Collapsed;
SaveButton.Visibility = Visibility.Collapsed;
DeleteButton.Visibility = Visibility.Collapsed;
SlideshowButton.Visibility = Visibility.Collapsed;
};
}
Expand Down
21 changes: 13 additions & 8 deletions FileExplorerGallery/Controls/ZoomBorder.cs
@@ -1,4 +1,5 @@
using FileExplorerGallery.ViewModelContracts;
using FileExplorerGallery.Helpers;
using FileExplorerGallery.ViewModelContracts;
using System;
using System.Linq;
using System.Windows;
Expand Down Expand Up @@ -40,6 +41,15 @@ public IImagePreviewItemViewModel PreviewItemViewModel
public static readonly DependencyProperty PreviewItemProperty = DependencyProperty.Register(
"PreviewItemViewModel", typeof(IImagePreviewItemViewModel), typeof(ZoomBorder), new PropertyMetadata(PropertyChangedCallback));


public int Rotation
{
get { return (int)GetValue(RotationProperty); }
set { SetValue(RotationProperty, value); }
}

public static readonly DependencyProperty RotationProperty = DependencyProperty.Register("Rotation", typeof(int), typeof(ZoomBorder));

private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var caller = (ZoomBorder)d;
Expand Down Expand Up @@ -121,14 +131,9 @@ private void Rotate()
if (_child != null)
{
var rt = GetRotateTransform(_child);
if (rt.Angle == -360)
{
rt.Angle = 0;
}

var to = rt.Angle;
var to = Math.Round(rt.Angle);
to -= 90;

Rotation = (int)to;
AnimateRotateTransform(rt, to, 400);
}
}
Expand Down
4 changes: 2 additions & 2 deletions FileExplorerGallery/Converters/ToLowResImageConverter.cs
Expand Up @@ -16,10 +16,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn

var fullPath = new Uri((string)value, UriKind.Absolute);

BitmapImage smallerBitmapImage = new BitmapImage();
var smallerBitmapImage = new BitmapImage();
smallerBitmapImage.BeginInit();
smallerBitmapImage.DecodePixelWidth = 300;
smallerBitmapImage.CacheOption = BitmapCacheOption.None;
smallerBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
smallerBitmapImage.UriSource = fullPath;
smallerBitmapImage.EndInit();

Expand Down
40 changes: 40 additions & 0 deletions FileExplorerGallery/Converters/UriToCachedImageConverter.cs
@@ -0,0 +1,40 @@
using FileExplorerGallery.ViewModelContracts;
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace FileExplorerGallery.Converters
{
public class UriToCachedImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value == null)
{
return null;
}

var image = (IImagePreviewItemViewModel)value;

var fullPath = new Uri(image.Path, UriKind.Absolute);

var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.CreateOptions = image.NeedRefresh ? BitmapCreateOptions.IgnoreImageCache : BitmapCreateOptions.None;
bitmapImage.UriSource = fullPath;
bitmapImage.EndInit();
bitmapImage.Freeze();

image.NeedRefresh = false;

return bitmapImage;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
18 changes: 18 additions & 0 deletions FileExplorerGallery/DialogWindow.xaml
@@ -0,0 +1,18 @@
<Window x:Class="FileExplorerGallery.DialogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FileExplorerGallery"
xmlns:e="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:FileExplorerGallery.Behaviors"
mc:Ignorable="d"
Title="" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" ShowInTaskbar="False" ResizeMode="NoResize" Topmost="True" Background="Transparent" Height="450" Width="800" SizeToContent="WidthAndHeight">
<e:Interaction.Behaviors>
<behaviors:FocusFirstButtonBehavior />
<behaviors:CloseWindowOnEsc />
</e:Interaction.Behaviors>
<Grid>

</Grid>
</Window>
27 changes: 27 additions & 0 deletions FileExplorerGallery/DialogWindow.xaml.cs
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace FileExplorerGallery
{
/// <summary>
/// Interaction logic for DialogWindow.xaml
/// </summary>
public partial class DialogWindow : Window
{
public DialogWindow()
{
InitializeComponent();
}
}
}
22 changes: 22 additions & 0 deletions FileExplorerGallery/FileExplorerGallery.csproj
Expand Up @@ -65,6 +65,9 @@
</Page>
<Compile Include="Animations\BrushAnimation.cs" />
<Compile Include="Animations\GridLengthAnimation.cs" />
<Compile Include="Behaviors\BehaviorExtensions.cs" />
<Compile Include="Behaviors\CloseWindowOnEsc.cs" />
<Compile Include="Behaviors\FocusFirstButtonBehavior.cs" />
<Compile Include="Behaviors\GalleryCacheBehavior.cs" />
<Compile Include="Behaviors\GalleryCacheProvider.cs" />
<Compile Include="Behaviors\GalleryKeyBindingBehavior.cs" />
Expand All @@ -82,12 +85,18 @@
<Compile Include="Converters\PathToThumbnailConverter.cs" />
<Compile Include="Converters\PathToThumbnailWidthConverter.cs" />
<Compile Include="Converters\ToLowResImageConverter.cs" />
<Compile Include="Converters\UriToCachedImageConverter.cs" />
<Compile Include="DialogWindow.xaml.cs">
<DependentUpon>DialogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\SortingExtensions.cs" />
<Compile Include="Extensions\WpfHelpers.cs" />
<Compile Include="Helpers\ApplicationDispatcher.cs" />
<Compile Include="Helpers\AppStateHandler.cs" />
<Compile Include="Helpers\AppUpdateManager.cs" />
<Compile Include="Helpers\DialogHelper.cs" />
<Compile Include="Helpers\FileExplorerSortingProvider.cs" />
<Compile Include="Helpers\ImageHelper.cs" />
<Compile Include="Helpers\IThrottledActionInvoker.cs" />
<Compile Include="Helpers\IThrottledActionInvokerFactory.cs" />
<Compile Include="Helpers\MonitorResolutionHelper.cs" />
Expand All @@ -102,14 +111,19 @@
<Compile Include="Settings\IUserSettings.cs" />
<Compile Include="Settings\SettingItem.cs" />
<Compile Include="Settings\UserSettings.cs" />
<Compile Include="ViewModelContracts\IDialogViewModel.cs" />
<Compile Include="ViewModelContracts\IImagePreviewItemViewModel.cs" />
<Compile Include="ViewModelContracts\IImagePreviewViewModel.cs" />
<Compile Include="ViewModelContracts\ISettingsViewModel.cs" />
<Compile Include="VIewModelFactories\IImagePreviewItemViewModelFactory.cs" />
<Compile Include="VIewModelFactories\ImagePreviewItemViewModelFactory.cs" />
<Compile Include="ViewModels\DialogViewModel.cs" />
<Compile Include="ViewModels\ImagePreviewItemViewModel.cs" />
<Compile Include="ViewModels\ImagePreviewViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="Views\DialogView.xaml.cs">
<DependentUpon>DialogView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ImagePreviewView.xaml.cs">
<DependentUpon>ImagePreviewView.xaml</DependentUpon>
</Compile>
Expand All @@ -119,6 +133,10 @@
<Compile Include="WelcomeWindow.xaml.cs">
<DependentUpon>WelcomeWindow.xaml</DependentUpon>
</Compile>
<Page Include="DialogWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -150,6 +168,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DialogView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ImagePreviewView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

0 comments on commit 4aeae87

Please sign in to comment.