Skip to content

Commit b86a0db

Browse files
committed
v1.1.0.316
1 parent 3f86964 commit b86a0db

11 files changed

+249
-14
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,41 @@ ZHAI PICTURE VIEW build for .Net 6
66

77
![Snapshot](/Snapshot.jpg)
88

9+
![Snapshot](/Snapshot2.jpg)
10+
11+
## Future
12+
13+
- [x] Dragging
14+
- [x] Rotate Left/Right
15+
- [x] Zoom In/Out
16+
- [x] Zoom In/Out based on a point
17+
- [x] Double click to zoom in
18+
- [x] Thumb list
19+
- [x] Thumb map
20+
- [x] Auto Play
21+
- [x] Print Picture
22+
- [x] Delete Picture
23+
- [x] Prev Picture
24+
- [x] Next Picture
25+
- [x] Prev Picture Floder
26+
- [x] Next Picture Floder
27+
- [x] Exif
28+
- [x] Effects
29+
- [x] Gallery
30+
31+
## Shortcuts
32+
33+
| Keys | Description |
34+
| ----------- | ----------- |
35+
| Key.Left | Prev Picture or Prev Picture Floder |
36+
| Key.Right | Next Picture or Next Picture Floder |
37+
| Key.Up or Key.OemPlus | Zoom In |
38+
| Key.Down or Key.OemMinus | Zoom Out |
39+
| Key.OemPeriod | Rotate Right |
40+
| Key.OemComma | Rotate Left |
41+
| Key.Back | Reset |
42+
| Key.Tab | Show/Hide Gallery |
43+
944
## File support
1045

1146
```
@@ -17,7 +52,7 @@ ZHAI PICTURE VIEW build for .Net 6
1752

1853
RAW camera formats may be slower to load
1954

20-
# Thanks
55+
## Thanks
2156

2257
[Magick.NET](https://github.com/dlemstra/Magick.NET)
2358

@@ -27,4 +62,6 @@ RAW camera formats may be slower to load
2762

2863
[Pfim](https://nickbabcock.github.io/Pfim/)
2964

30-
[SkiaSharp](https://github.com/mono/SkiaSharp)
65+
[SkiaSharp](https://github.com/mono/SkiaSharp)
66+
67+
[VirtualizingWrapPanel](https://github.com/sbaeumlisberger/VirtualizingWrapPanel)

Snapshot2.jpg

687 KB
Loading

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.1.0.316
2+
1.新增画廊功能
3+
2.新增开屏状态设置
4+
15
v1.1.0.304
26
1.优化了列表加载
37
2.增加图片文件拖入打开功能

src/MainWindow.xaml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:Zhai.PictureView"
7+
xmlns:wpftk="clr-namespace:WpfToolkit.Controls;assembly=VirtualizingWrapPanel"
78
xmlns:Controls="clr-namespace:Zhai.PictureView.Controls"
89
xmlns:XamlServices="clr-namespace:Zhai.PictureView.XamlServices"
910
Title="{Binding CurrentPicture, Converter={StaticResource PictureViewTitleConverter}}"
@@ -357,7 +358,7 @@
357358
</DockPanel>
358359
</Border>
359360
</Grid>
360-
<Grid Grid.ColumnSpan="3" Grid.Row="2">
361+
<Grid Grid.ColumnSpan="3" Grid.Row="2" x:Name="PictureController">
361362
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal" Margin="8">
362363
<StackPanel Orientation="Horizontal" IsEnabled="{Binding CurrentPicture, Converter={StaticResource NullableToBoolConverter}}">
363364
<Button x:Name="PictureListViewToggleButton" Click="PictureListViewToggleButton_Click">
@@ -425,7 +426,7 @@
425426
<Path Data="{StaticResource Icon.RotateRight}"/>
426427
</Button>
427428
<Button x:Name="AutoPlayButton" Click="AutoPlayButton_Click" ToolTip="自动播放"
428-
Visibility="{Binding IsShowPictureListView, Converter={StaticResource BoolToVisibilityConverter}}">
429+
Visibility="{Binding CanPictureCarouselPlay, Converter={StaticResource BoolToVisibilityConverter}}">
429430
<Button.Style>
430431
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource PictureView.IconButton}">
431432
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
@@ -480,5 +481,79 @@
480481
</StackPanel>
481482
</StackPanel>
482483
</Grid>
484+
<Grid Grid.ColumnSpan="3" Grid.RowSpan="3" x:Name="GalleryView"
485+
Background="{StaticResource PictureWindowPaperColorBrush}"
486+
Visibility="{Binding IsShowGallery, Converter={StaticResource BoolToVisibilityConverter}}">
487+
<ListView ItemsSource="{Binding ElementName=PictureList, Path=Items}"
488+
SelectedItem="{Binding CurrentPicture}"
489+
Margin="3 36 3 8" Background="Transparent" BorderThickness="0"
490+
VirtualizingPanel.CacheLengthUnit="Item"
491+
VirtualizingPanel.ScrollUnit="Pixel"
492+
VirtualizingPanel.VirtualizationMode="Standard">
493+
<ListBox.ItemContainerStyle>
494+
<Style TargetType="{x:Type ListBoxItem}">
495+
<Setter Property="Margin" Value="0"/>
496+
<Setter Property="Padding" Value="0"/>
497+
<Setter Property="BorderThickness" Value="2"/>
498+
<Setter Property="BorderBrush" Value="Transparent"/>
499+
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
500+
<Setter Property="RenderTransform">
501+
<Setter.Value>
502+
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="0.95" ScaleY="0.95" />
503+
</Setter.Value>
504+
</Setter>
505+
<Setter Property="Template">
506+
<Setter.Value>
507+
<ControlTemplate TargetType="{x:Type ListBoxItem}">
508+
<Border BorderBrush="{TemplateBinding BorderBrush}" HorizontalAlignment="Center" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
509+
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
510+
</Border>
511+
<ControlTemplate.Triggers>
512+
<Trigger Property="IsMouseOver" Value="True">
513+
<Setter Property="RenderTransform">
514+
<Setter.Value>
515+
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1" ScaleY="1" />
516+
</Setter.Value>
517+
</Setter>
518+
</Trigger>
519+
<Trigger Property="IsSelected" Value="True">
520+
<Setter Property="BorderBrush" Value="DeepSkyBlue"/>
521+
</Trigger>
522+
</ControlTemplate.Triggers>
523+
</ControlTemplate>
524+
</Setter.Value>
525+
</Setter>
526+
</Style>
527+
</ListBox.ItemContainerStyle>
528+
<ListView.ItemsPanel>
529+
<ItemsPanelTemplate>
530+
<wpftk:VirtualizingWrapPanel Orientation="Vertical" SpacingMode="StartAndEndOnly" StretchItems="True"/>
531+
</ItemsPanelTemplate>
532+
</ListView.ItemsPanel>
533+
<ListView.ItemTemplate>
534+
<DataTemplate>
535+
<Border Width="120" Height="120">
536+
<Image Stretch="Uniform" Source="{Binding ThumbSource}" ToolTip="{Binding Name}"
537+
XamlServices:PictureService.Picture="{Binding}"/>
538+
</Border>
539+
</DataTemplate>
540+
</ListView.ItemTemplate>
541+
</ListView>
542+
<Grid.Style>
543+
<Style TargetType="{x:Type Grid}">
544+
<Style.Triggers>
545+
<Trigger Property="Visibility" Value="Visible">
546+
<Trigger.EnterActions>
547+
<BeginStoryboard>
548+
<Storyboard>
549+
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.3"/>
550+
</Storyboard>
551+
</BeginStoryboard>
552+
</Trigger.EnterActions>
553+
</Trigger>
554+
</Style.Triggers>
555+
</Style>
556+
</Grid.Style>
557+
</Grid>
483558
</Grid>
484559
</local:PictureWindow>

src/MainWindow.xaml.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
using System.IO;
55
using System.Linq;
66
using System.Security.AccessControl;
7+
using System.Threading;
78
using System.Threading.Tasks;
8-
using System.Timers;
99
using System.Windows;
1010
using System.Windows.Controls;
1111
using System.Windows.Input;
1212
using System.Windows.Media.Animation;
1313
using System.Windows.Threading;
14+
using Timer = System.Timers.Timer;
1415

1516
namespace Zhai.PictureView
1617
{
@@ -22,6 +23,8 @@ public MainWindow()
2223
{
2324
InitializeComponent();
2425

26+
InitializeMainWindow();
27+
2528
Loaded += MainWindow_Loaded;
2629

2730
ViewModel.CurrentPictureChanged += ViewModel_CurrentPictureChanged;
@@ -42,6 +45,16 @@ public MainWindow()
4245
VisualStateManager.GoToElementState(this.PictureEditView, ViewModel.IsShowPictureEditView ? "PictureEditViewShow" : "PictureEditViewHide", false);
4346
}
4447

48+
private void InitializeMainWindow()
49+
{
50+
var settings = Properties.Settings.Default;
51+
52+
if (settings.StartWindowMaximized)
53+
{
54+
this.WindowState = WindowState.Maximized;
55+
}
56+
}
57+
4558
private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
4659
{
4760
var arg = Application.Current.Properties["ArbitraryArgName"];
@@ -62,10 +75,10 @@ public async Task OpenPicture(DirectoryInfo dir, string filename = null, List<Di
6275

6376
ViewModel.Folder = newFolder;
6477
await ViewModel.Folder.LoadAsync();
65-
ViewModel.IsShowPictureListView = ViewModel.Folder?.Count > 1;
78+
ViewModel.CanPictureCarouselPlay = ViewModel.Folder?.Count > 1;
6679
ViewModel.CurrentPicture = (filename == null ? ViewModel.Folder : ViewModel.Folder.Where(t => t.PicturePath == filename)).FirstOrDefault();
6780

68-
oldFolder?.Clean();
81+
ThreadPool.QueueUserWorkItem(_ => this.Dispatcher.Invoke(() => oldFolder?.Clean()));
6982

7083
ViewModel.IsShowPictureListView = ViewModel.Folder != null && ViewModel.Folder.Count > 1;
7184
VisualStateManager.GoToElementState(this.PictureListView, ViewModel.IsShowPictureListView ? "PictureListViewShow" : "PictureListViewHide", false);
@@ -666,7 +679,10 @@ private void AutoPlayButton_Click(object sender, RoutedEventArgs e)
666679
{
667680
if (ViewModel.Folder == null || ViewModel.Folder.Count <= 1) return;
668681

669-
ViewModel.IsPictureCarouselPlaing = !ViewModel.IsPictureCarouselPlaing;
682+
if (ViewModel.CanPictureCarouselPlay)
683+
{
684+
ViewModel.IsPictureCarouselPlaing = !ViewModel.IsPictureCarouselPlaing;
685+
}
670686
}
671687

672688
private void AdjustButton_Click(object sender, RoutedEventArgs e)
@@ -748,6 +764,10 @@ public void PressShortcutKey(object sender, KeyEventArgs e)
748764
{
749765
ResetPicture();
750766
}
767+
else if (e.Key == Key.Tab)
768+
{
769+
ViewModel.IsShowGallery = !ViewModel.IsShowGallery;
770+
}
751771
}
752772

753773
private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)

src/PictureWindowViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ public double Scale
100100
}
101101
}
102102

103+
private bool canPictureCarouselPlay = false;
104+
public bool CanPictureCarouselPlay
105+
{
106+
get => canPictureCarouselPlay;
107+
set => SetProperty(ref canPictureCarouselPlay, value);
108+
}
109+
103110
private bool isPictureCarouselPlaing = false;
104111
public bool IsPictureCarouselPlaing
105112
{
@@ -119,6 +126,13 @@ public bool IsPictureCarouselPlaing
119126
}
120127
}
121128

129+
private bool isShowGallery = false;
130+
public bool IsShowGallery
131+
{
132+
get => isShowGallery;
133+
set => SetProperty(ref isShowGallery, value);
134+
}
135+
122136
private PictureEffect currentPictureEffect;
123137
public PictureEffect CurrentPictureEffect
124138
{

src/Properties/Settings.Designer.cs

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Properties/Settings.settings

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Zhai.PictureView.Properties" GeneratedClassName="Settings">
3+
<Profiles />
4+
<Settings>
5+
<Setting Name="StartWindowMaximized" Type="System.Boolean" Scope="User">
6+
<Value Profile="(Default)">False</Value>
7+
</Setting>
8+
</Settings>
9+
</SettingsFile>

src/SettingsWindow.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
<Grid Margin="13 36 12 16">
1717
<Border BorderBrush="#56EEEEEE" BorderThickness="1 0 0 0" Margin="60.5 0 0 0" Panel.ZIndex="-100"/>
1818
<TabControl TabStripPlacement="Left">
19+
<TabItem Header="基本设置">
20+
<StackPanel Margin="12 8.5 0 0">
21+
<StackPanel Orientation="Horizontal" Margin="0 0 16 8">
22+
<TextBlock Margin="0 0 8 0" Text="启动时全屏显示"/>
23+
<CheckBox IsChecked="{Binding StartWindowMaximized}"/>
24+
</StackPanel>
25+
</StackPanel>
26+
</TabItem>
1927
<TabItem Header="文件关联">
20-
<StackPanel Margin="12 0 0 0">
21-
<TextBlock Text="设置默认使用ZDY ' PICTURE打开以下文件类型" Margin="-1 8 0 18"/>
28+
<StackPanel Margin="12 8.5 0 0">
29+
<TextBlock Text="设置默认使用ZDY ' PICTURE打开以下文件类型" Margin="-1 0 0 18"/>
2230
<ItemsControl ItemsSource="{Binding AllSupported}" HorizontalAlignment="Left">
2331
<ItemsControl.ItemsPanel>
2432
<ItemsPanelTemplate>

src/SettingsWindowViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ namespace Zhai.PictureView
1212
{
1313
internal class SettingsWindowViewModel: BaseViewModel
1414
{
15+
private bool startWindowMaximized = Properties.Settings.Default.StartWindowMaximized;
16+
public bool StartWindowMaximized
17+
{
18+
get => startWindowMaximized;
19+
set
20+
{
21+
if (SetProperty(ref startWindowMaximized, value))
22+
{
23+
Properties.Settings.Default.StartWindowMaximized = value;
24+
Properties.Settings.Default.Save();
25+
}
26+
}
27+
}
28+
1529
public List<PictureSupportedItem> AllSupported { get; }
1630

1731
public SettingsWindowViewModel()

0 commit comments

Comments
 (0)