mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 02:09:05 +00:00
Avoid audio cover null exception in xaml
Can slightly increase the opening speed of audio file
This commit is contained in:
@@ -19,6 +19,7 @@ using System;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace QuickLook.Plugin.VideoViewer;
|
namespace QuickLook.Plugin.VideoViewer;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ public sealed class TimeTickToShortStringConverter : DependencyObject, IValueCon
|
|||||||
|
|
||||||
public sealed class VolumeToIconConverter : DependencyObject, IValueConverter
|
public sealed class VolumeToIconConverter : DependencyObject, IValueConverter
|
||||||
{
|
{
|
||||||
private static readonly string[] Volumes = { "\xE74F", "\xE993", "\xE994", "\xE995" };
|
private static readonly string[] Volumes = ["\xE74F", "\xE993", "\xE994", "\xE995"];
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
@@ -69,3 +70,19 @@ public sealed class VolumeToIconConverter : DependencyObject, IValueConverter
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class CoverArtConverter : IValueConverter
|
||||||
|
{
|
||||||
|
private static readonly BitmapImage emptyImage =
|
||||||
|
new(new Uri("pack://application:,,,/QuickLook.Plugin.VideoViewer;component/Resources/empty.png", UriKind.Absolute));
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return value ?? emptyImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
<local:TimeTickToShortStringConverter x:Key="TimeTickToShortStringConverter" />
|
<local:TimeTickToShortStringConverter x:Key="TimeTickToShortStringConverter" />
|
||||||
<local:VolumeToIconConverter x:Key="VolumeToIconConverter" />
|
<local:VolumeToIconConverter x:Key="VolumeToIconConverter" />
|
||||||
|
<local:CoverArtConverter x:Key="CoverArtConverter" />
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Styles.xaml" />
|
<ResourceDictionary Source="Styles.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
@@ -54,23 +55,14 @@
|
|||||||
Opacity="0.6" />
|
Opacity="0.6" />
|
||||||
<Image x:Name="imageCoverArt"
|
<Image x:Name="imageCoverArt"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="20,40,20,40">
|
Margin="20,40,20,40"
|
||||||
|
Source="{Binding CoverArt, ElementName=viewerPanel, Converter={StaticResource CoverArtConverter}}">
|
||||||
<Image.Effect>
|
<Image.Effect>
|
||||||
<DropShadowEffect BlurRadius="6"
|
<DropShadowEffect BlurRadius="6"
|
||||||
Direction="0"
|
Direction="0"
|
||||||
ShadowDepth="0"
|
ShadowDepth="0"
|
||||||
Color="#FF898989" />
|
Color="#FF898989" />
|
||||||
</Image.Effect>
|
</Image.Effect>
|
||||||
<Image.Style>
|
|
||||||
<Style TargetType="Image">
|
|
||||||
<Setter Property="Source" Value="{Binding CoverArt, ElementName=viewerPanel}" />
|
|
||||||
<Style.Triggers>
|
|
||||||
<DataTrigger Binding="{Binding CoverArt, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}" Value="0">
|
|
||||||
<Setter Property="Source" Value="Resources/empty.png" />
|
|
||||||
</DataTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</Image.Style>
|
|
||||||
</Image>
|
</Image>
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1">
|
||||||
<Grid.Effect>
|
<Grid.Effect>
|
||||||
|
Reference in New Issue
Block a user