Skip to content

Commit 4d9d1a1

Browse files
author
Carl Chang
committed
add custom image extension support;
map f5 to reload view in main window; bump version number;
1 parent f3852b5 commit 4d9d1a1

File tree

7 files changed

+69
-20
lines changed

7 files changed

+69
-20
lines changed

App.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static string BuildConfig { get {
3030
public static Version Version => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
3131
public static readonly HashSet<string> ImageExtensions =
3232
new HashSet<string>(new[] {
33-
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".gif", ".bmp", ".ico", ".dds", ".jxr", ".hdp", ".wdp", ".heic", "heif"
33+
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".gif", ".bmp", ".ico", ".dds", ".jxr", ".hdp", ".wdp", ".heic", ".heif"
3434
});
3535
public static readonly HashSet<string> ZipExtensions =
3636
new HashSet<string>(new[] {
@@ -78,6 +78,13 @@ private void App_Startup(object sender, StartupEventArgs e) {
7878
//handle setting changes
7979
Setting.StaticPropertyChanged += Setting_StaticPropertyChanged;
8080

81+
//add custom extensions
82+
foreach (var ext in Setting.CustomImageExt?.Split(' ')
83+
.Where(s => !string.IsNullOrWhiteSpace(s))
84+
.Select(s => '.' + s.Trim('.').ToLowerInvariant())) {
85+
if (!ImageExtensions.Contains(ext)) ImageExtensions.Add(ext);
86+
}
87+
8188
//check arguments
8289
if (e.Args?.Length > 0) {
8390
#if DEBUG

Helpers/Setting.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ private enum ConfigSection
9797
private static string sevenZipDllPath => Path.Combine(App.ExeDir, $@"7z_{(Environment.Is64BitProcess ? @"x64" : @"x86")}.dll");
9898

9999

100+
private static string customImageExt = string.Empty;
101+
[AppConfig]
102+
public static string CustomImageExt
103+
{
104+
get => customImageExt;
105+
set {
106+
if (customImageExt == value) return;
107+
customImageExt = value;
108+
OnStaticPropertyChanged(nameof(CustomImageExt));
109+
}
110+
}
111+
100112
private static string databaseDir = @".\";
101113
[AppConfig]
102114
public static string DatabaseDir {

MainWindow.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ private void MainWin_KeyDown(object sender, KeyEventArgs e) {
148148
case Key.PageUp:
149149
virWrapPanel.ScrollOwner.PageUp();
150150
break;
151+
case Key.F5:
152+
Task.Run(() => LoadPath(CurrentPath));
153+
break;
151154
}
152155
}
153156

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.2.9.0")]
55-
[assembly: AssemblyFileVersion("1.2.9.0")]
54+
[assembly: AssemblyVersion("1.2.10.0")]
55+
[assembly: AssemblyFileVersion("1.2.10.0")]

Resources/Localization.en.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
<sys:String x:Key="ttl_ThumbnailFormat">Thumbnail Format</sys:String>
1717
<sys:String x:Key="ttl_ThumbSwapDelayMultiplier">Thumbnail Swap Delay Multiplier</sys:String>
1818
<sys:String x:Key="msg_ThumbSwapDelayMultiplierTip">The delay of thumbnail change on folders and archives. Higher value results in longer delay.</sys:String>
19+
<sys:String x:Key="ttl_CustomImageExt">Custom Image Extensions</sys:String>
20+
<Span x:Key="spn_CustomImageExt">
21+
Space-separated list of additional image extensions to load as images.
22+
Whether the additional formats can be loaded depends on the operating system support.
23+
Restart the program for this setting to take effect.<LineBreak/>
24+
For example: .abc .def .ghi
25+
</Span>
1926
<sys:String x:Key="ttl_DatabaseDir">Database Directory</sys:String>
2027
<sys:String x:Key="msg_DatabaseDirTip">The folder to save the all database files (thumbnail cache etc.).</sys:String>
2128
<sys:String x:Key="ttl_ThumbDbSize">Thumbnail Cache Size (Current: {0})</sys:String>

Resources/Localization.zh.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
<sys:String x:Key="ttl_ThumbnailFormat">缩略图格式</sys:String>
1717
<sys:String x:Key="ttl_ThumbSwapDelayMultiplier">缩略图切换延迟速率</sys:String>
1818
<sys:String x:Key="msg_ThumbSwapDelayMultiplierTip">目录和压缩文件缩略图的切换延迟。数值越高延迟越高。</sys:String>
19+
<sys:String x:Key="ttl_CustomImageExt">自定义图片扩展名</sys:String>
20+
<Span x:Key="spn_CustomImageExt">
21+
定义要作为图像加载的文件扩展名,以空格分隔。
22+
图片格式是否支持取决于操作系统。
23+
需要重启程序生效。<LineBreak/>
24+
例如:.abc .def .ghi
25+
</Span>
1926
<sys:String x:Key="ttl_DatabaseDir">数据库目录</sys:String>
2027
<sys:String x:Key="msg_DatabaseDirTip">存放数据库文件(缩略图缓存数据库等)的目录</sys:String>
2128
<sys:String x:Key="ttl_ThumbDbSize">缩略图缓存大小 (当前: {0})</sys:String>

SettingsWindow.xaml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<RowDefinition Height="Auto"/>
4040
<RowDefinition Height="Auto"/>
4141
<RowDefinition Height="Auto"/>
42+
<RowDefinition Height="Auto"/>
4243
<RowDefinition Height="3*"/>
4344
<RowDefinition Height="2*"/>
4445
<RowDefinition Height="Auto"/>
@@ -108,6 +109,18 @@
108109
<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbSwapDelayMultiplierTip}"/>
109110

110111
<Border Grid.Row="2">
112+
<StackPanel>
113+
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_CustomImageExt}"/>
114+
<ContentControl>
115+
<TextBox x:Name="TB_CustomImageExt" Text="{Binding Source={x:Static local:App.Setting}, Path=CustomImageExt}"/>
116+
</ContentControl>
117+
</StackPanel>
118+
</Border>
119+
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TipTextStyle}">
120+
<StaticResource ResourceKey="spn_CustomImageExt"/>
121+
</TextBlock>
122+
123+
<Border Grid.Row="3">
111124
<StackPanel>
112125
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_DatabaseDir}"/>
113126
<DockPanel>
@@ -118,9 +131,9 @@
118131
</DockPanel>
119132
</StackPanel>
120133
</Border>
121-
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_DatabaseDirTip}"/>
134+
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_DatabaseDirTip}"/>
122135

123-
<Border Grid.Row="3">
136+
<Border Grid.Row="4">
124137
<DockPanel>
125138
<Button DockPanel.Dock="Right" Margin="8 0 0 0" VerticalAlignment="Top" Content="{StaticResource ttl_Clean}" Click="Btn_Clean_Click"/>
126139

@@ -146,18 +159,18 @@
146159
</StackPanel>
147160
</DockPanel>
148161
</Border>
149-
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbDbSizeTip}"/>
162+
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ThumbDbSizeTip}"/>
150163

151-
<Border Grid.Row="4">
164+
<Border Grid.Row="5">
152165
<DockPanel LastChildFill="False">
153166
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_LiteMode}" Margin="0" VerticalAlignment="Center"/>
154167
<CheckBox Width="48" Height="24" VerticalAlignment="Center" DockPanel.Dock="Right"
155168
IsChecked="{Binding Source={x:Static local:App.Setting}, Path=LiteMode}"/>
156169
</DockPanel>
157170
</Border>
158-
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_LiteModeTip}"/>
171+
<TextBlock Grid.Row="5" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_LiteModeTip}"/>
159172

160-
<Border Grid.Row="5">
173+
<Border Grid.Row="6">
161174
<DockPanel LastChildFill="False">
162175
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_ViewerBackground}" Margin="0" VerticalAlignment="Center"/>
163176
<ContentControl DockPanel.Dock="Right">
@@ -168,7 +181,7 @@
168181
</DockPanel>
169182
</Border>
170183

171-
<Border Grid.Row="6">
184+
<Border Grid.Row="7">
172185
<Grid>
173186
<Grid.ColumnDefinitions>
174187
<ColumnDefinition/>
@@ -196,18 +209,18 @@
196209
</StackPanel>
197210
</Grid>
198211
</Border>
199-
<TextBlock Grid.Row="6" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ViewerTransitionTip}"/>
212+
<TextBlock Grid.Row="7" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ViewerTransitionTip}"/>
200213

201-
<Border Grid.Row="7">
214+
<Border Grid.Row="8">
202215
<DockPanel LastChildFill="False">
203216
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="{StaticResource ttl_ExpMenuSlideshow}" Margin="0" VerticalAlignment="Center"/>
204217
<CheckBox Width="48" Height="24" VerticalAlignment="Center" DockPanel.Dock="Right"
205218
IsChecked="{Binding Source={x:Static local:App.Setting}, Path=ExpMenuSlideshow}"/>
206219
</DockPanel>
207220
</Border>
208-
<TextBlock Grid.Row="7" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ExpMenuSlideshow}"/>
221+
<TextBlock Grid.Row="8" Grid.Column="1" Style="{StaticResource TipTextStyle}" Text="{StaticResource msg_ExpMenuSlideshow}"/>
209222

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

223-
<Border Grid.Row="9">
236+
<Border Grid.Row="10">
224237
<DockPanel>
225238
<TextBlock Style="{StaticResource HeaderTextStyle}" DockPanel.Dock="Top" Text="{StaticResource ttl_SavedPasswords}"/>
226239
<TabControl>
@@ -248,11 +261,11 @@
248261
</TabControl>
249262
</DockPanel>
250263
</Border>
251-
<TextBlock Grid.Row="9" Grid.Column="1" Style="{StaticResource TipTextStyle}">
264+
<TextBlock Grid.Row="10" Grid.Column="1" Style="{StaticResource TipTextStyle}">
252265
<StaticResource ResourceKey="spn_SavedPasswordsTip"/>
253266
</TextBlock>
254267

255-
<Border Grid.Row="10" Margin="8 4 8 8">
268+
<Border Grid.Row="11" Margin="8 4 8 8">
256269
<DockPanel>
257270
<TextBlock Style="{StaticResource HeaderTextStyle}" DockPanel.Dock="Top" Text="{StaticResource ttl_CustomCommands}"/>
258271
<ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
@@ -268,11 +281,11 @@
268281
</ContentControl>
269282
</DockPanel>
270283
</Border>
271-
<TextBlock Grid.Row="10" Grid.Column="1" Style="{StaticResource TipTextStyle}">
284+
<TextBlock Grid.Row="11" Grid.Column="1" Style="{StaticResource TipTextStyle}">
272285
<StaticResource ResourceKey="spn_CustomCommandsTip"/>
273286
</TextBlock>
274287

275-
<TextBlock Grid.Row="11" Grid.ColumnSpan="2">
288+
<TextBlock Grid.Row="12" Grid.ColumnSpan="2">
276289
<StaticResource ResourceKey="spn_About"/>
277290
</TextBlock>
278291
</local:PaddedGrid>

0 commit comments

Comments
 (0)