Skip to content

Commit

Permalink
Scroll View mode for Photo Viewer. v1.2.2
Browse files Browse the repository at this point in the history
Also some minor code changes.
  • Loading branch information
ChiNoel-osu committed Dec 17, 2022
1 parent 3899216 commit 7e30bf4
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 37 deletions.
2 changes: 1 addition & 1 deletion FolderThumbnailExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<IsPublishable>False</IsPublishable>
<SignAssembly>False</SignAssembly>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<Authors>Victor</Authors>
<Copyright>GNU AFFERO GENERAL PUBLIC LICENSE</Copyright>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
Expand Down
18 changes: 18 additions & 0 deletions Localization/Loc.Designer.cs

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

6 changes: 6 additions & 0 deletions Localization/Loc.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,10 @@ This flips that.</value>
<data name="PVPopUpSettingsTwinDoubleTurnTT" xml:space="preserve">
<value>Normally you would use it under Twin-Page viewing mode.</value>
</data>
<data name="PVPopUpSettingsScrView" xml:space="preserve">
<value>Scroll view the image</value>
</data>
<data name="PVPopUpSettingsScrViewTT" xml:space="preserve">
<value>By enabling this, Slideshow and Twin-Page viewing option will be ignored.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions Localization/Loc.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,10 @@ Esc - 关闭图片浏览器.</value>
<data name="PVPopUpSettingsTwinDoubleTurnTT" xml:space="preserve">
<value>一般来说只会在双页浏览模式下用到.</value>
</data>
<data name="PVPopUpSettingsScrView" xml:space="preserve">
<value>垂直滚动浏览</value>
</data>
<data name="PVPopUpSettingsScrViewTT" xml:space="preserve">
<value>开启此项后, 幻灯片和双页浏览设置会被忽略.</value>
</data>
</root>
2 changes: 1 addition & 1 deletion View/DriveSelect.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace FolderThumbnailExplorer.View
public partial class DriveSelect : UserControl
{
public DriveSelect()
{
{
InitializeComponent();
DataContext = MainWindow.MainVM;
}
Expand Down
46 changes: 31 additions & 15 deletions View/ImageControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,6 @@
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
<!--#region Always on top-->
<DockPanel>
<Label Content="{x:Static loc:Loc.PVPopUpSettingsAOT}"
Foreground="White" />
<ToggleButton DockPanel.Dock="Right"
HorizontalAlignment="Right"
Height="16"
Width="32"
Margin="5"
Focusable="False"
Checked="AOTBtn_Changed"
Unchecked="AOTBtn_Changed"
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
<!--#region Twin Page-->
<DockPanel>
<Label Content="{x:Static loc:Loc.PVPopUpSettingsTwin}"
Expand Down Expand Up @@ -198,6 +183,37 @@
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
<!--#region Scroll View-->
<DockPanel>
<Label Content="{x:Static loc:Loc.PVPopUpSettingsScrView}"
ToolTip="{x:Static loc:Loc.PVPopUpSettingsScrViewTT}"
Foreground="White" />
<ToggleButton DockPanel.Dock="Right"
HorizontalAlignment="Right"
Height="16"
Width="32"
Margin="5"
Focusable="False"
IsChecked="{Binding ScrollView}"
Command="{Binding LoadScrollViewCommand}"
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
<!--#region Always on top-->
<DockPanel>
<Label Content="{x:Static loc:Loc.PVPopUpSettingsAOT}"
Foreground="White" />
<ToggleButton DockPanel.Dock="Right"
HorizontalAlignment="Right"
Height="16"
Width="32"
Margin="5"
Focusable="False"
Checked="AOTBtn_Changed"
Unchecked="AOTBtn_Changed"
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
</StackPanel>
</Border>
</Popup>
Expand Down
6 changes: 4 additions & 2 deletions View/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
Background="{x:Null}"
Foreground="White"
ItemsSource="{Binding MainPageViewModel.Content}"
d:ItemsSource="{d:SampleData ItemCount=14}">
d:ItemsSource="{d:SampleData ItemCount=18}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />
Expand All @@ -262,8 +262,9 @@
<StackPanel>
<Grid>
<Image MaxWidth="{Binding ElementName=ScaleSlider, Path=Value}"
d:MaxWidth="128"
d:MaxWidth="132"
SnapsToDevicePixels="True"
d:Source="pack://application:,,,/folder.png"
Source="{Binding ThumbNail}"
ToolTip="{Binding Header}"
Cursor="Hand">
Expand All @@ -277,6 +278,7 @@
</Image.InputBindings>
</Image>
<Image Source="pack://application:,,,/folder.png"
d:Source="{x:Null}"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Width="20"
Expand Down
16 changes: 10 additions & 6 deletions View/PhotoViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
FlowDirection="RightToLeft"
Grid.ColumnSpan="2">
<StackPanel.Resources>
<Style x:Key="BtnStyle"
TargetType="{x:Type Button}">
<Style TargetType="{x:Type Button}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderThickness"
Expand All @@ -56,22 +55,19 @@
</StackPanel.Resources>
<Button Height="20"
Width="20"
Style="{StaticResource BtnStyle}"
Background="#FF605C"
Click="CloseClick"
ToolTip="{x:Static loc:Loc.PVCloseTT}"
Margin="-1,-2,1,0" />
<Button Height="15"
Width="18"
Margin="1,0,1,0"
Style="{StaticResource BtnStyle}"
Background="#FFBD44"
Click="MaxResClick"
ToolTip="{x:Static loc:Loc.PVMaxTT}" />
<Button Height="10"
Width="18"
Margin="1,0,1,0"
Style="{StaticResource BtnStyle}"
Background="#00CA4E"
Click="MinClick"
ToolTip="{x:Static loc:Loc.PVMinTT}" />
Expand Down Expand Up @@ -152,7 +148,8 @@
ResizeDirection="Columns"
ToolTip="{x:Static loc:Loc.PVGridSplitterTT}" />
<Grid Grid.Column="2"
FlowDirection="{Binding FlowDirection}">
FlowDirection="{Binding FlowDirection}"
Visibility="{Binding MainView, Converter={StaticResource B2CVConverter}, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
Expand All @@ -175,6 +172,13 @@
Visibility="{Binding UseTwinPage, Mode=OneWay, Converter={StaticResource B2CVConverter}}"
Source="{Binding BigImage2}" />
</Grid>
<ScrollViewer Grid.Column="2"
Margin="0,20,0,0"
Visibility="{Binding ScrollView, Converter={StaticResource B2CVConverter}, Mode=OneWay}">
<ItemsControl ItemsSource="{Binding ScrollImg}"
MouseWheel="ScrollImg_MouseWheel"
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Grid}, Mode=FindAncestor}, Path=ActualWidth, Mode=OneTime, Converter={StaticResource DivideBy}, ConverterParameter=2}" />
</ScrollViewer>
</Grid>
</Grid>
</Window>
17 changes: 16 additions & 1 deletion View/PhotoViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void BigImage_MouseWheel(object sender, MouseWheelEventArgs e)
}
private void BigImage_MouseMove(object sender, MouseEventArgs e)
{
Image img = sender as Image;
Image img = (Image)sender;
double w = img.ActualWidth;
double h = img.ActualHeight;
if (e.RightButton == MouseButtonState.Pressed)
Expand All @@ -75,6 +75,21 @@ private void BigImage_MouseMove(object sender, MouseEventArgs e)
img.RenderTransformOrigin = reletivePos;
}
}

private void ScrollImg_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.RightButton == MouseButtonState.Pressed)
{
e.Handled = true;
byte scrDelta = 50;
if (e.Delta > 0 && ((ItemsControl)sender).Width < 8888)
((ItemsControl)sender).Width += scrDelta;
else if (e.Delta < 0 && ((ItemsControl)sender).Width > scrDelta)
((ItemsControl)sender).Width -= scrDelta;
else
return;
}
}
#endregion
#region Window related actions
private void CloseClick(object sender, RoutedEventArgs e)
Expand Down
10 changes: 4 additions & 6 deletions ViewModel/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using FolderThumbnailExplorer.Model;
using FolderThumbnailExplorer.View;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand All @@ -25,7 +24,7 @@ public partial class MainPageViewModel : ObservableObject, IDataErrorInfo
{
public CancellationTokenSource cts = new CancellationTokenSource();
public Task addItemTask;
public static Stack<Window> wnds = new Stack<Window>();
public static List<Window> wnds = new List<Window>();

#region IDataErrorInfo members
public string Error => throw new NotImplementedException();
Expand Down Expand Up @@ -132,7 +131,7 @@ public void ReGetContent()
CancellationToken ct = cts.Token;
//Long ass task, offload to another thread.
//This took me forever.
addItemTask = new Task(async () =>
addItemTask = new Task(() =>
{
if (DirHelper.IsPathValid(_PATHtoShow))
{
Expand All @@ -143,7 +142,6 @@ public void ReGetContent()
List<string> unauthorizedFolders = new List<string>();
foreach (string dir in dirs)
{
bool showSubfolderIcon = false;
try
{
ct.ThrowIfCancellationRequested(); //When task is canceled
Expand Down Expand Up @@ -262,7 +260,7 @@ private void ThumbnailMouseUpHandler(object sender, MouseButtonEventArgs e)
imagePath = imagePath.Remove(imagePath.LastIndexOf('\\'));
PhotoViewer photoViewer = new PhotoViewer(imagePath);
photoViewer.Left = 0; photoViewer.Top = 0; //Spawns window at top left corner.
wnds.Push(photoViewer); //Add this to opened windows list to close it when mainwindows closes
wnds.Add(photoViewer); //Add this to opened windows list to close it when mainwindow closes
photoViewer.Show();
}
}
Expand All @@ -277,7 +275,7 @@ public void AddNewFav(Button button)
{
addBtn = button;
AddNewFav addNewFav = new AddNewFav(_PATHtoShow);
wnds.Push(addNewFav); //Add this to opened windows list to close it when mainwindow closes
wnds.Add(addNewFav); //Add this to opened windows list to close it when mainwindow closes
addNewFav.Show();
addNewFav.Closed += AddNewFav_Closed;
addBtn.IsEnabled = false;
Expand Down
Loading

0 comments on commit 7e30bf4

Please sign in to comment.