Skip to content

Commit

Permalink
add custom image extension support;
Browse files Browse the repository at this point in the history
map f5 to reload view in main window;
bump version number;
  • Loading branch information
Carl Chang committed Dec 8, 2023
1 parent f3852b5 commit 4d9d1a1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 20 deletions.
9 changes: 8 additions & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static string BuildConfig { get {
public static Version Version => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
public static readonly HashSet<string> ImageExtensions =
new HashSet<string>(new[] {
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".gif", ".bmp", ".ico", ".dds", ".jxr", ".hdp", ".wdp", ".heic", "heif"
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".gif", ".bmp", ".ico", ".dds", ".jxr", ".hdp", ".wdp", ".heic", ".heif"
});
public static readonly HashSet<string> ZipExtensions =
new HashSet<string>(new[] {
Expand Down Expand Up @@ -78,6 +78,13 @@ private void App_Startup(object sender, StartupEventArgs e) {
//handle setting changes
Setting.StaticPropertyChanged += Setting_StaticPropertyChanged;

//add custom extensions
foreach (var ext in Setting.CustomImageExt?.Split(' ')
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => '.' + s.Trim('.').ToLowerInvariant())) {
if (!ImageExtensions.Contains(ext)) ImageExtensions.Add(ext);
}

//check arguments
if (e.Args?.Length > 0) {
#if DEBUG
Expand Down
12 changes: 12 additions & 0 deletions Helpers/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ private enum ConfigSection
private static string sevenZipDllPath => Path.Combine(App.ExeDir, $@"7z_{(Environment.Is64BitProcess ? @"x64" : @"x86")}.dll");


private static string customImageExt = string.Empty;
[AppConfig]
public static string CustomImageExt
{
get => customImageExt;
set {
if (customImageExt == value) return;
customImageExt = value;
OnStaticPropertyChanged(nameof(CustomImageExt));
}
}

private static string databaseDir = @".\";
[AppConfig]
public static string DatabaseDir {
Expand Down
3 changes: 3 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ private void MainWin_KeyDown(object sender, KeyEventArgs e) {
case Key.PageUp:
virWrapPanel.ScrollOwner.PageUp();
break;
case Key.F5:
Task.Run(() => LoadPath(CurrentPath));
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.9.0")]
[assembly: AssemblyFileVersion("1.2.9.0")]
[assembly: AssemblyVersion("1.2.10.0")]
[assembly: AssemblyFileVersion("1.2.10.0")]
7 changes: 7 additions & 0 deletions Resources/Localization.en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
<sys:String x:Key="ttl_ThumbnailFormat">Thumbnail Format</sys:String>
<sys:String x:Key="ttl_ThumbSwapDelayMultiplier">Thumbnail Swap Delay Multiplier</sys:String>
<sys:String x:Key="msg_ThumbSwapDelayMultiplierTip">The delay of thumbnail change on folders and archives. Higher value results in longer delay.</sys:String>
<sys:String x:Key="ttl_CustomImageExt">Custom Image Extensions</sys:String>
<Span x:Key="spn_CustomImageExt">
Space-separated list of additional image extensions to load as images.
Whether the additional formats can be loaded depends on the operating system support.
Restart the program for this setting to take effect.<LineBreak/>
For example: .abc .def .ghi
</Span>
<sys:String x:Key="ttl_DatabaseDir">Database Directory</sys:String>
<sys:String x:Key="msg_DatabaseDirTip">The folder to save the all database files (thumbnail cache etc.).</sys:String>
<sys:String x:Key="ttl_ThumbDbSize">Thumbnail Cache Size (Current: {0})</sys:String>
Expand Down
7 changes: 7 additions & 0 deletions Resources/Localization.zh.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
<sys:String x:Key="ttl_ThumbnailFormat">缩略图格式</sys:String>
<sys:String x:Key="ttl_ThumbSwapDelayMultiplier">缩略图切换延迟速率</sys:String>
<sys:String x:Key="msg_ThumbSwapDelayMultiplierTip">目录和压缩文件缩略图的切换延迟。数值越高延迟越高。</sys:String>
<sys:String x:Key="ttl_CustomImageExt">自定义图片扩展名</sys:String>
<Span x:Key="spn_CustomImageExt">
定义要作为图像加载的文件扩展名,以空格分隔。
图片格式是否支持取决于操作系统。
需要重启程序生效。<LineBreak/>
例如:.abc .def .ghi
</Span>
<sys:String x:Key="ttl_DatabaseDir">数据库目录</sys:String>
<sys:String x:Key="msg_DatabaseDirTip">存放数据库文件(缩略图缓存数据库等)的目录</sys:String>
<sys:String x:Key="ttl_ThumbDbSize">缩略图缓存大小 (当前: {0})</sys:String>
Expand Down
47 changes: 30 additions & 17 deletions SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="Auto"/>
Expand Down Expand Up @@ -108,6 +109,18 @@
<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbSwapDelayMultiplierTip}"/>

<Border Grid.Row="2">
<StackPanel>
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_CustomImageExt}"/>
<ContentControl>
<TextBox x:Name="TB_CustomImageExt" Text="{Binding Source={x:Static local:App.Setting}, Path=CustomImageExt}"/>
</ContentControl>
</StackPanel>
</Border>
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<StaticResource ResourceKey="spn_CustomImageExt"/>
</TextBlock>

<Border Grid.Row="3">
<StackPanel>
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_DatabaseDir}"/>
<DockPanel>
Expand All @@ -118,9 +131,9 @@
</DockPanel>
</StackPanel>
</Border>
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_DatabaseDirTip}"/>
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_DatabaseDirTip}"/>

<Border Grid.Row="3">
<Border Grid.Row="4">
<DockPanel>
<Button DockPanel.Dock="Right" Margin="8 0 0 0" VerticalAlignment="Top" Content="{StaticResource ttl_Clean}" Click="Btn_Clean_Click"/>

Expand All @@ -146,18 +159,18 @@
</StackPanel>
</DockPanel>
</Border>
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbDbSizeTip}"/>
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbDbSizeTip}"/>

<Border Grid.Row="4">
<Border Grid.Row="5">
<DockPanel LastChildFill="False">
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_LiteMode}" Margin="0" VerticalAlignment="Center"/>
<CheckBox Width="48" Height="24" VerticalAlignment="Center" DockPanel.Dock="Right"
IsChecked="{Binding Source={x:Static local:App.Setting}, Path=LiteMode}"/>
</DockPanel>
</Border>
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_LiteModeTip}"/>
<TextBlock Grid.Row="5" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_LiteModeTip}"/>

<Border Grid.Row="5">
<Border Grid.Row="6">
<DockPanel LastChildFill="False">
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_ViewerBackground}" Margin="0" VerticalAlignment="Center"/>
<ContentControl DockPanel.Dock="Right">
Expand All @@ -168,7 +181,7 @@
</DockPanel>
</Border>

<Border Grid.Row="6">
<Border Grid.Row="7">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
Expand Down Expand Up @@ -196,18 +209,18 @@
</StackPanel>
</Grid>
</Border>
<TextBlock Grid.Row="6" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ViewerTransitionTip}"/>
<TextBlock Grid.Row="7" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ViewerTransitionTip}"/>

<Border Grid.Row="7">
<Border Grid.Row="8">
<DockPanel LastChildFill="False">
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_ExpMenuSlideshow}" Margin="0" VerticalAlignment="Center"/>
<CheckBox Width="48" Height="24" VerticalAlignment="Center" DockPanel.Dock="Right"
IsChecked="{Binding Source={x:Static local:App.Setting}, Path=ExpMenuSlideshow}"/>
</DockPanel>
</Border>
<TextBlock Grid.Row="7" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ExpMenuSlideshow}"/>
<TextBlock Grid.Row="8" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ExpMenuSlideshow}"/>

<Border Grid.Row="8">
<Border Grid.Row="9">
<DockPanel LastChildFill="False">
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_MasterPassword}" Margin="0" VerticalAlignment="Center"/>
<Button DockPanel.Dock="Left" Margin="8 0 0 0" Content="{StaticResource ttl_Password}" ContentStringFormat="{StaticResource ttl_Update_0}" VerticalAlignment="Center" Click="Btn_ChgMstPwd_Click"
Expand All @@ -216,11 +229,11 @@
IsChecked="{Binding Source={x:Static local:App.Setting}, Path=EncryptPasswords, Converter={StaticResource NullableBoolConverter}}"/>
</DockPanel>
</Border>
<TextBlock Grid.Row="8" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<TextBlock Grid.Row="9" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<StaticResource ResourceKey="spn_MasterPasswordTip"/>
</TextBlock>

<Border Grid.Row="9">
<Border Grid.Row="10">
<DockPanel>
<TextBlock Style="{StaticResource HeaderTextStyle}" DockPanel.Dock="Top" Text="{StaticResource ttl_SavedPasswords}"/>
<TabControl>
Expand Down Expand Up @@ -248,11 +261,11 @@
</TabControl>
</DockPanel>
</Border>
<TextBlock Grid.Row="9" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<TextBlock Grid.Row="10" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<StaticResource ResourceKey="spn_SavedPasswordsTip"/>
</TextBlock>

<Border Grid.Row="10" Margin="8 4 8 8">
<Border Grid.Row="11" Margin="8 4 8 8">
<DockPanel>
<TextBlock Style="{StaticResource HeaderTextStyle}" DockPanel.Dock="Top" Text="{StaticResource ttl_CustomCommands}"/>
<ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
Expand All @@ -268,11 +281,11 @@
</ContentControl>
</DockPanel>
</Border>
<TextBlock Grid.Row="10" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<TextBlock Grid.Row="11" Grid.Column="1" Style="{StaticResource TipTextStyle}">
<StaticResource ResourceKey="spn_CustomCommandsTip"/>
</TextBlock>

<TextBlock Grid.Row="11" Grid.ColumnSpan="2">
<TextBlock Grid.Row="12" Grid.ColumnSpan="2">
<StaticResource ResourceKey="spn_About"/>
</TextBlock>
</local:PaddedGrid>
Expand Down

0 comments on commit 4d9d1a1

Please sign in to comment.