mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-21 00:44:52 +00:00
almost done videoviewer. WIP modify app style to per-window one.
This commit is contained in:
@@ -22,16 +22,22 @@ using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
public sealed class BooleanToVisibilityHiddenConverter : DependencyObject, IValueConverter
|
||||
public sealed class TimeSpanToShortStringConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return Visibility.Collapsed;
|
||||
return "00:00";
|
||||
|
||||
var v = (bool) value;
|
||||
var v = (TimeSpan) value;
|
||||
|
||||
return v ? Visibility.Collapsed : Visibility.Visible;
|
||||
var s = string.Empty;
|
||||
if (v.Hours > 0)
|
||||
s += $"{v.Hours:D2}:";
|
||||
|
||||
s += $"{v.Minutes:D2}:{v.Seconds:D2}";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -40,7 +40,6 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
};
|
||||
private ContextObject _context;
|
||||
|
||||
private Size _mediaSize = Size.Empty;
|
||||
private ViewerPanel _vp;
|
||||
|
||||
public int Priority => 0 - 10; // make it lower than TextViewer
|
||||
@@ -62,15 +61,25 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
var def = new Size(500, 300);
|
||||
|
||||
_mediaSize = GetMediaSizeWithVlc(path);
|
||||
var hasVideo = HasVideoStream(path, out Size mediaSize);
|
||||
|
||||
var windowSize = _mediaSize == Size.Empty ? def : _mediaSize;
|
||||
var windowSize = mediaSize == Size.Empty ? def : mediaSize;
|
||||
windowSize.Width = Math.Max(def.Width, windowSize.Width);
|
||||
windowSize.Height = Math.Max(def.Height, windowSize.Height);
|
||||
|
||||
context.SetPreferredSizeFit(windowSize, 0.6);
|
||||
context.UseDarkTheme = true;
|
||||
context.TitlebarOverlap = true;
|
||||
if (!hasVideo)
|
||||
{
|
||||
context.CanResize = false;
|
||||
context.TitlebarAutoHide = false;
|
||||
context.TitlebarBlurVisibility = false;
|
||||
context.TitlebarColourVisibility = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.UseDarkTheme = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
@@ -79,15 +88,11 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
context.ViewerContent = _vp;
|
||||
|
||||
|
||||
_vp.mediaElement.VlcMediaPlayer.Opening += MarkReady;
|
||||
|
||||
_vp.LoadAndPlay(path);
|
||||
|
||||
var info = _mediaSize == Size.Empty ? "Audio" : $"{_mediaSize.Width}×{_mediaSize.Height}";
|
||||
|
||||
context.Title =
|
||||
$"{Path.GetFileName(path)} ({info})";
|
||||
context.Title = $"{Path.GetFileName(path)}";
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
@@ -105,7 +110,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
_context.IsBusy = false;
|
||||
}
|
||||
|
||||
private Size GetMediaSizeWithVlc(string path)
|
||||
private bool HasVideoStream(string path, out Size size)
|
||||
{
|
||||
using (var vlc = new Vlc(VlcSettings.VlcOptions))
|
||||
{
|
||||
@@ -115,7 +120,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
var tracks = media.GetTracks();
|
||||
var video = tracks.FirstOrDefault(mt => mt.Type == TrackType.Video) as VideoTrack;
|
||||
|
||||
return video == null ? Size.Empty : new Size(video.Width, video.Height);
|
||||
size = video == null ? Size.Empty : new Size(video.Width, video.Height);
|
||||
|
||||
return video != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
|
@@ -1,61 +1,32 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonIconForeground}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CaptionButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonBaseStyle}">
|
||||
<Style x:Key="ControlButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Padding" Value="9,9,9,9" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonHoverBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressBackground}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<SolidColorBrush x:Key="CustomSliderForegroundBrush" Color="#FFEFEFEF" />
|
||||
<SolidColorBrush x:Key="CustomSliderBackgroundBrush" Color="#EE000000" />
|
||||
<SolidColorBrush x:Key="CustomSliderHighlightBrush" Color="#FFEFEFEF" />
|
||||
|
||||
<!-- Postion Slider Control -->
|
||||
<ControlTemplate x:Key="PositionSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
|
||||
<Path x:Name="grip" Data="M 0,0 A 180,180 180 1 1 1,1 Z" Fill="Transparent" Stretch="Fill"
|
||||
Stroke="{StaticResource CustomSliderForegroundBrush}" StrokeThickness="1" UseLayoutRounding="True"
|
||||
Stroke="{DynamicResource WindowTextForeground}" StrokeThickness="1" UseLayoutRounding="True"
|
||||
VerticalAlignment="Center"
|
||||
Margin="-1,-1" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsDragging" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
<Setter Property="Stroke" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Visibility" TargetName="grip" Value="Hidden" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -68,11 +39,11 @@
|
||||
<DockPanel LastChildFill="True">
|
||||
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="1" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="10,0,-10,0"
|
||||
Fill="{StaticResource CustomSliderForegroundBrush}" />
|
||||
Fill="{DynamicResource WindowTextForeground}" />
|
||||
</Border>
|
||||
<Border ClipToBounds="True" Height="1" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="10,0,10,0"
|
||||
Fill="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
Fill="{DynamicResource MainWindowBackground}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
<Track x:Name="PART_Track">
|
||||
@@ -106,20 +77,20 @@
|
||||
<!-- Custom Slider Control -->
|
||||
<ControlTemplate x:Key="CustomSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
|
||||
<Rectangle x:Name="grip" Fill="{StaticResource CustomSliderForegroundBrush}" Width="8"
|
||||
<Rectangle x:Name="grip" Fill="{DynamicResource WindowTextForeground}" Width="8"
|
||||
Height="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
StrokeThickness="0"
|
||||
UseLayoutRounding="True" Stretch="Fill" RadiusX="3" RadiusY="3" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsDragging" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource MainWindowBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -132,11 +103,11 @@
|
||||
<DockPanel LastChildFill="True">
|
||||
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="3" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="4,0,-4,0"
|
||||
Fill="{StaticResource CustomSliderForegroundBrush}" />
|
||||
Fill="{DynamicResource WindowTextForeground}" />
|
||||
</Border>
|
||||
<Border ClipToBounds="True" Height="3" Visibility="Visible">
|
||||
<Rectangle x:Name="PART_NegativeSelection" RadiusX="1" RadiusY="1" Margin="8,0,4,0"
|
||||
Fill="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
Fill="{DynamicResource MainWindowBackground}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
<Track x:Name="PART_Track">
|
||||
@@ -168,79 +139,4 @@
|
||||
<Setter Property="SelectionEnd" Value="{Binding Path=Value, RelativeSource={RelativeSource Self}}" />
|
||||
<Setter Property="Template" Value="{StaticResource CustomSliderTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="NetworkProgressBarStyle" TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Height" Value="3" />
|
||||
<Setter Property="Margin" Value="10,0" />
|
||||
<Setter Property="Minimum" Value="0" />
|
||||
<Setter Property="Maximum" Value="1" />
|
||||
<Setter Property="Background" Value="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ModernToggleButtonStyle" TargetType="ToggleButton">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#22FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Width" Value="45" />
|
||||
<Setter Property="Height" Value="45" />
|
||||
<Setter Property="Padding" Value="12" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ModernButtonStyle" TargetType="{x:Type Button}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#22FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Width" Value="45" />
|
||||
<Setter Property="Height" Value="45" />
|
||||
<Setter Property="Padding" Value="12" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ControlsGridStyle" TargetType="{x:Type Grid}">
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="Height" Value="250" />
|
||||
<Setter Property="Background" Value="{DynamicResource ShadedBackgroundBrush}" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
@@ -10,18 +10,19 @@
|
||||
mc:Ignorable="d"
|
||||
x:Name="viewerPanel"
|
||||
d:DesignHeight="300" d:DesignWidth="500">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<local:TimeSpanToShortStringConverter x:Key="TimeSpanToShortStringConverter" />
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<ResourceDictionary>
|
||||
<local:BooleanToVisibilityHiddenConverter x:Key="BooleanToVisibilityHiddenConverter" />
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Grid.Resources>
|
||||
<vlc:VlcPlayer x:Name="mediaElement" LibVlcPath="{Binding LibVlcPath, ElementName=viewerPanel}"
|
||||
VlcOption="{Binding VlcOption, ElementName=viewerPanel}" />
|
||||
<Grid>
|
||||
<Grid x:Name="coverArtPersenter" ClipToBounds="True" Background="{StaticResource MainWindowBackground}">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
@@ -36,25 +37,24 @@
|
||||
<ColumnDefinition Width="4*" />
|
||||
<ColumnDefinition Width="6*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Column="0" Grid.ColumnSpan="2" ClipToBounds="True">
|
||||
<Rectangle Margin="-50" Grid.Column="0" Grid.ColumnSpan="2">
|
||||
<Rectangle.Effect>
|
||||
<BlurEffect Radius="100"/>
|
||||
<BlurEffect Radius="100" />
|
||||
</Rectangle.Effect>
|
||||
<Rectangle.Fill>
|
||||
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Viewbox="0.15,0,0.7,1" Stretch="UniformToFill" />
|
||||
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Stretch="UniformToFill" Opacity="0.9" />
|
||||
</Rectangle.Fill>
|
||||
|
||||
</Rectangle>
|
||||
<Image Grid.Column="0" x:Name="imageCoverArt" Margin="20,40,20,40">
|
||||
<Image.Effect>
|
||||
<DropShadowEffect Direction="0" BlurRadius="6" Color="#FF898989" ShadowDepth="0"/>
|
||||
<DropShadowEffect Direction="0" BlurRadius="6" Color="#FF898989" ShadowDepth="0" />
|
||||
</Image.Effect>
|
||||
<Image.Style>
|
||||
<Style TargetType="Image">
|
||||
<Setter Property="Source" Value="{Binding CoverArt, ElementName=viewerPanel}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding CoverArt.Length, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
|
||||
Binding="{Binding CoverArt, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
|
||||
Value="0">
|
||||
<Setter Property="Source" Value="Resources/compact-disc.png" />
|
||||
</DataTrigger>
|
||||
@@ -62,6 +62,36 @@
|
||||
</Style>
|
||||
</Image.Style>
|
||||
</Image>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" BlurRadius="2" Opacity="0.7" Color="#B2FFFFFF" />
|
||||
</Grid.Effect>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="metaTitle" Grid.Row="1" FontSize="22" Padding="3"
|
||||
TextWrapping="Wrap"
|
||||
LineHeight="28" MaxHeight="80" TextTrimming="CharacterEllipsis" FontWeight="SemiBold">
|
||||
ときめきポポロン♪
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaArtists" Grid.Row="3" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}">
|
||||
チマメ隊
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaAlbum" Grid.Row="4" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}">
|
||||
ときめきポポロン♪
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaLength" Grid.Row="5" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}"
|
||||
Text="{Binding ElementName=mediaElement, Path=Length, Converter={StaticResource TimeSpanToShortStringConverter}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="videoControlContainer" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
|
||||
@@ -84,9 +114,22 @@
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Grid.Resources>
|
||||
<glassLayer:GlassLayer BlurredElement="{Binding ElementName=mediaElement}" OverlayColor="#FF3B3B3B" />
|
||||
<glassLayer:GlassLayer OverlayColor="{DynamicResource CaptionBackground}"
|
||||
GlassVisibility="{Binding ElementName=viewerPanel, Path=HasVideo,Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
ColorOverlayVisibility="{Binding ElementName=viewerPanel, Path=HasVideo,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<glassLayer:GlassLayer.Style>
|
||||
<Style TargetType="glassLayer:GlassLayer">
|
||||
<Setter Property="BlurredElement" Value="{Binding ElementName=viewerPanel}"></Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=viewerPanel,Path=HasVideo}" Value="True">
|
||||
<Setter Property="BlurredElement" Value="{Binding ElementName=mediaElement}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</glassLayer:GlassLayer.Style>
|
||||
</glassLayer:GlassLayer>
|
||||
<DockPanel>
|
||||
<Button x:Name="buttonPlayPause" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Left">
|
||||
<Button x:Name="buttonPlayPause" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Left">
|
||||
<fa:ImageAwesome Foreground="{DynamicResource CaptionButtonIconForeground}">
|
||||
<fa:ImageAwesome.Style>
|
||||
<Style>
|
||||
@@ -101,7 +144,7 @@
|
||||
</fa:ImageAwesome.Style>
|
||||
</fa:ImageAwesome>
|
||||
</Button>
|
||||
<Button x:Name="buttonMute" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Right">
|
||||
<Button x:Name="buttonMute" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
|
||||
<fa:ImageAwesome Icon="VolumeUp" Foreground="{DynamicResource CaptionButtonIconForeground}">
|
||||
<fa:ImageAwesome.Style>
|
||||
<Style TargetType="fa:ImageAwesome">
|
||||
@@ -116,10 +159,10 @@
|
||||
</fa:ImageAwesome.Style>
|
||||
</fa:ImageAwesome>
|
||||
</Button>
|
||||
<Button Width="Auto" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Right">
|
||||
<Button Width="Auto" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
|
||||
<TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="11"
|
||||
Foreground="{DynamicResource CaptionButtonIconForeground}"
|
||||
Text="{Binding Time, StringFormat=hh\\:mm\\:ss, ElementName=mediaElement}"/>
|
||||
Text="{Binding ElementName=mediaElement, Path=Time, Converter={StaticResource TimeSpanToShortStringConverter}}" />
|
||||
</Button>
|
||||
<Slider x:Name="sliderProgress" Style="{StaticResource PositionSliderStyle}"
|
||||
SmallChange="0.00001" LargeChange="0.01" Maximum="1"
|
||||
|
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
@@ -26,6 +27,7 @@ using System.Windows.Media.Animation;
|
||||
using Meta.Vlc;
|
||||
using Meta.Vlc.Interop.Media;
|
||||
using QuickLook.Annotations;
|
||||
using QuickLook.ExtensionMethods;
|
||||
using MediaState = Meta.Vlc.Interop.Media.MediaState;
|
||||
|
||||
namespace QuickLook.Plugin.VideoViewer
|
||||
@@ -37,7 +39,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
private readonly ContextObject _context;
|
||||
|
||||
private string _coverArt;
|
||||
private Uri _coverArt;
|
||||
private bool _hasAudio;
|
||||
private bool _hasEnded;
|
||||
private bool _hasVideo;
|
||||
@@ -49,6 +51,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// apply global theme
|
||||
Resources.MergedDictionaries[0].MergedDictionaries.Clear();
|
||||
|
||||
ShowViedoControlContainer(null, null);
|
||||
viewerPanel.PreviewMouseMove += ShowViedoControlContainer;
|
||||
|
||||
@@ -145,7 +150,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
}
|
||||
}
|
||||
|
||||
public string CoverArt
|
||||
public Uri CoverArt
|
||||
{
|
||||
get => _coverArt;
|
||||
private set
|
||||
@@ -188,6 +193,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
private void AutoHideViedoControlContainer(object sender, EventArgs e)
|
||||
{
|
||||
if (!HasVideo)
|
||||
return;
|
||||
|
||||
if (videoControlContainer.IsMouseOver)
|
||||
return;
|
||||
|
||||
@@ -220,6 +228,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
var state = e.Value;
|
||||
|
||||
Debug.WriteLine(state);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MediaState.Opening:
|
||||
@@ -227,8 +237,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
HasAudio = mediaElement.VlcMediaPlayer.AudioTrackCount > 0;
|
||||
break;
|
||||
case MediaState.Playing:
|
||||
CoverArt = mediaElement.VlcMediaPlayer.Media.GetMeta(
|
||||
MetaDataType.ArtworkUrl);
|
||||
UpdateMeta();
|
||||
DetermineTheme();
|
||||
HasVideo = mediaElement.VlcMediaPlayer.VideoTrackCount > 0;
|
||||
HasAudio = mediaElement.VlcMediaPlayer.AudioTrackCount > 0;
|
||||
IsPlaying = true;
|
||||
@@ -246,6 +256,37 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMeta()
|
||||
{
|
||||
if (HasVideo)
|
||||
return;
|
||||
|
||||
var path = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.ArtworkUrl);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
CoverArt = new Uri(path);
|
||||
|
||||
metaTitle.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Title);
|
||||
metaArtists.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Artist);
|
||||
metaAlbum.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Album);
|
||||
}
|
||||
|
||||
private void DetermineTheme()
|
||||
{
|
||||
if (HasVideo)
|
||||
return;
|
||||
|
||||
if (CoverArt == null)
|
||||
return;
|
||||
|
||||
var dark = false;
|
||||
using (var bitmap = new Bitmap(CoverArt.LocalPath))
|
||||
{
|
||||
dark = bitmap.IsDarkImage();
|
||||
}
|
||||
|
||||
_context.UseDarkTheme = dark;
|
||||
}
|
||||
|
||||
private void ChangeVolume(double delta)
|
||||
{
|
||||
IsMuted = false;
|
||||
|
@@ -1,42 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Converters
|
||||
{
|
||||
public sealed class BooleanToVisibilityConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return Visibility.Visible;
|
||||
|
||||
var v = (bool) value;
|
||||
|
||||
return v ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,27 +15,36 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using PixelFormat = System.Windows.Media.PixelFormat;
|
||||
|
||||
namespace QuickLook.ExtensionMethods
|
||||
{
|
||||
public static class BitmapExtensions
|
||||
{
|
||||
public static BitmapSource ToBitmapSource(this Bitmap old_source)
|
||||
public static BitmapSource ToBitmapSource(this Bitmap source)
|
||||
{
|
||||
// BitmapSource.Create throws an exception when the image is scanned backward.
|
||||
// The Clone() will make it back scanning forward.
|
||||
var source = (Bitmap) old_source.Clone();
|
||||
|
||||
var orgSource = source;
|
||||
BitmapSource bs = null;
|
||||
try
|
||||
{
|
||||
var data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
|
||||
ImageLockMode.ReadOnly, source.PixelFormat);
|
||||
|
||||
// BitmapSource.Create throws an exception when the image is scanned backward.
|
||||
// The Clone() will make it back scanning forward.
|
||||
if (data.Stride < 0)
|
||||
{
|
||||
source.UnlockBits(data);
|
||||
source = (Bitmap) source.Clone();
|
||||
data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
|
||||
ImageLockMode.ReadOnly, source.PixelFormat);
|
||||
}
|
||||
bs = BitmapSource.Create(source.Width, source.Height, source.HorizontalResolution,
|
||||
source.VerticalResolution, ConvertPixelFormat(source.PixelFormat), null,
|
||||
data.Scan0, data.Stride * source.Height, data.Stride);
|
||||
@@ -50,13 +59,14 @@ namespace QuickLook.ExtensionMethods
|
||||
}
|
||||
finally
|
||||
{
|
||||
source.Dispose();
|
||||
if (orgSource != source)
|
||||
source.Dispose();
|
||||
}
|
||||
|
||||
return bs;
|
||||
}
|
||||
|
||||
private static System.Windows.Media.PixelFormat ConvertPixelFormat(
|
||||
private static PixelFormat ConvertPixelFormat(
|
||||
System.Drawing.Imaging.PixelFormat sourceFormat)
|
||||
{
|
||||
switch (sourceFormat)
|
||||
@@ -70,7 +80,46 @@ namespace QuickLook.ExtensionMethods
|
||||
case System.Drawing.Imaging.PixelFormat.Format32bppRgb:
|
||||
return PixelFormats.Bgr32;
|
||||
}
|
||||
return new System.Windows.Media.PixelFormat();
|
||||
return new PixelFormat();
|
||||
}
|
||||
|
||||
public static bool IsDarkImage(this Bitmap image)
|
||||
{
|
||||
// convert to 24-bit RGB image
|
||||
image = image.Clone(new Rectangle(0, 0, image.Width, image.Height),
|
||||
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
|
||||
var sampleCount = (int) (0.2 * image.Width * image.Height);
|
||||
const int pixelSize = 24 / 8;
|
||||
var data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
|
||||
ImageLockMode.ReadWrite, image.PixelFormat);
|
||||
|
||||
var darks = 0;
|
||||
unsafe
|
||||
{
|
||||
var pFirst = (byte*) data.Scan0;
|
||||
|
||||
Parallel.For(0, sampleCount, n =>
|
||||
{
|
||||
var rand = new Random(n);
|
||||
var row = rand.Next(0, data.Height);
|
||||
var col = rand.Next(0, data.Width);
|
||||
var pos = pFirst + row * data.Stride + col * pixelSize;
|
||||
|
||||
var b = pos[0];
|
||||
var g = pos[1];
|
||||
var r = pos[2];
|
||||
|
||||
var y = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
||||
|
||||
if (y < 0.5)
|
||||
darks++;
|
||||
});
|
||||
}
|
||||
image.UnlockBits(data);
|
||||
image.Dispose();
|
||||
|
||||
return darks > 0.65 * sampleCount;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary
|
||||
{
|
||||
public static class BlurWindow
|
||||
{
|
||||
private static readonly IWindowBlurController BlurController;
|
||||
|
||||
static BlurWindow()
|
||||
{
|
||||
BlurController = Helpers.GetWindowControllerForOs(OsHelper.GetOsType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current blur state
|
||||
/// </summary>
|
||||
public static bool Enabled => BlurController.Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if blur can be enabled.
|
||||
/// </summary>
|
||||
public static bool CanBeEnabled => BlurController.CanBeEnabled;
|
||||
|
||||
private static void EnableWindowBlur(IntPtr hwnd)
|
||||
{
|
||||
if (!CanBeEnabled)
|
||||
return;
|
||||
|
||||
BlurController.EnableBlur(hwnd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable blur for window
|
||||
/// </summary>
|
||||
/// <param name="window">Window object</param>
|
||||
public static void EnableWindowBlur(Window window)
|
||||
{
|
||||
EnableWindowBlur(new WindowInteropHelper(window).Handle);
|
||||
}
|
||||
|
||||
private static void DisableWindowBlur(IntPtr hwnd)
|
||||
{
|
||||
if (!CanBeEnabled)
|
||||
return;
|
||||
|
||||
BlurController.DisableBlur(hwnd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable blur for window
|
||||
/// </summary>
|
||||
/// <param name="window">Window object</param>
|
||||
public static void DisableWindowBlur(Window window)
|
||||
{
|
||||
DisableWindowBlur(new WindowInteropHelper(window).Handle);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using QuickLook.Helpers.BlurLibrary.PlatformsImpl;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary
|
||||
{
|
||||
internal static class Helpers
|
||||
{
|
||||
internal static IWindowBlurController GetWindowControllerForOs(OsType osType)
|
||||
{
|
||||
switch (osType)
|
||||
{
|
||||
case OsType.WindowsVista:
|
||||
return new WindowsVistaWindowBlurController();
|
||||
case OsType.Windows7:
|
||||
return new Windows7WindowBlurController();
|
||||
case OsType.Windows8:
|
||||
return new Windows8WindowBlurController();
|
||||
case OsType.Windows81:
|
||||
return new Windows81WindowBlurController();
|
||||
case OsType.Windows10:
|
||||
return new Windows10WindowBlurController();
|
||||
case OsType.Other:
|
||||
return new OsNotSupportedWindowBlurController();
|
||||
default:
|
||||
return new OsNotSupportedWindowBlurController();
|
||||
}
|
||||
}
|
||||
|
||||
internal static IntPtr GetWindowHandle(Window window)
|
||||
{
|
||||
return new WindowInteropHelper(window).Handle;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary
|
||||
{
|
||||
internal interface IWindowBlurController
|
||||
{
|
||||
/// <summary>
|
||||
/// Current blur state
|
||||
/// </summary>
|
||||
bool Enabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks if blur can be enabled.
|
||||
/// </summary>
|
||||
bool CanBeEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable blur for window
|
||||
/// </summary>
|
||||
/// <param name="hwnd">Pointer to Window</param>
|
||||
/// <exception cref="NotImplementedException">Throws when blur is not supported.</exception>
|
||||
void EnableBlur(IntPtr hwnd);
|
||||
|
||||
/// <summary>
|
||||
/// Disable blur for window
|
||||
/// </summary>
|
||||
/// <param name="hwnd">Pointer to Window</param>
|
||||
/// <exception cref="NotImplementedException">Throws when blur is not supported.</exception>
|
||||
void DisableBlur(IntPtr hwnd);
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Security;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings
|
||||
{
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal static class NativeMethods
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.Windows10
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct AccentPolicy
|
||||
{
|
||||
public AccentState AccentState;
|
||||
public int AccentFlags;
|
||||
public int GradientColor;
|
||||
public int AnimationId;
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.Windows10
|
||||
{
|
||||
internal enum AccentState
|
||||
{
|
||||
ACCENT_DISABLED = 0,
|
||||
ACCENT_ENABLE_GRADIENT = 1,
|
||||
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||
ACCENT_INVALID_STATE = 4
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.Windows10
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.Windows10
|
||||
{
|
||||
internal enum WindowCompositionAttribute
|
||||
{
|
||||
// ...
|
||||
WCA_ACCENT_POLICY = 19
|
||||
// ...
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.Windows10
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WindowCompositionAttributeData
|
||||
{
|
||||
public WindowCompositionAttribute Attribute;
|
||||
public IntPtr Data;
|
||||
public int SizeOfData;
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable FieldCanBeMadeReadOnly.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.NativeThings.WindowsVistaAnd7
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[Flags]
|
||||
public enum DWM_BB
|
||||
{
|
||||
DWM_BB_ENABLE = 1,
|
||||
DWM_BB_BLURREGION = 2,
|
||||
DWM_BB_TRANSITIONONMAXIMIZED = 4
|
||||
}
|
||||
|
||||
public const int WM_DWMCOMPOSITIONCHANGED = 0x031E;
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern bool DwmIsCompositionEnabled();
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMargins);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DWM_BLURBEHIND
|
||||
{
|
||||
public DWM_BB dwFlags;
|
||||
public bool fEnable;
|
||||
public IntPtr hRgnBlur;
|
||||
public bool fTransitionOnMaximized;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MARGINS
|
||||
{
|
||||
public int cxLeftWidth;
|
||||
public int cxRightWidth;
|
||||
public int cyTopHeight;
|
||||
public int cyBottomHeight;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary
|
||||
{
|
||||
internal static class OsHelper
|
||||
{
|
||||
public static OsType GetOsType()
|
||||
{
|
||||
if (Environment.OSVersion.Version.Major != 6 && Environment.OSVersion.Version.Major != 10)
|
||||
return OsType.Other;
|
||||
|
||||
if (Environment.OSVersion.Version.Major != 6)
|
||||
return Environment.OSVersion.Version.Major == 10
|
||||
? OsType.Windows10
|
||||
: OsType.Other;
|
||||
|
||||
switch (Environment.OSVersion.Version.Minor)
|
||||
{
|
||||
case 0:
|
||||
return OsType.WindowsVista;
|
||||
case 1:
|
||||
return OsType.Windows7;
|
||||
case 2:
|
||||
return OsType.Windows8;
|
||||
case 3:
|
||||
return OsType.Windows81;
|
||||
default:
|
||||
return OsType.Other;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary
|
||||
{
|
||||
internal enum OsType
|
||||
{
|
||||
WindowsVista,
|
||||
Windows7,
|
||||
Windows8,
|
||||
Windows81,
|
||||
Windows10,
|
||||
Other
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
public class OsNotSupportedWindowBlurController : IWindowBlurController
|
||||
{
|
||||
public void EnableBlur(IntPtr hwnd)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void DisableBlur(IntPtr hwnd)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Enabled { get; } = false;
|
||||
public bool CanBeEnabled { get; } = false;
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using QuickLook.Helpers.BlurLibrary.NativeThings.Windows10;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
internal class Windows10WindowBlurController : IWindowBlurController
|
||||
{
|
||||
public void EnableBlur(IntPtr hwnd)
|
||||
{
|
||||
var accent = new AccentPolicy {AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND};
|
||||
|
||||
var accentStructSize = Marshal.SizeOf(accent);
|
||||
|
||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||
|
||||
var data = new WindowCompositionAttributeData
|
||||
{
|
||||
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
|
||||
SizeOfData = accentStructSize,
|
||||
Data = accentPtr
|
||||
};
|
||||
|
||||
NativeThings.Windows10.NativeMethods.SetWindowCompositionAttribute(hwnd, ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public void DisableBlur(IntPtr hwnd)
|
||||
{
|
||||
var accent = new AccentPolicy {AccentState = AccentState.ACCENT_DISABLED};
|
||||
|
||||
var accentStructSize = Marshal.SizeOf(accent);
|
||||
|
||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||
|
||||
var data = new WindowCompositionAttributeData
|
||||
{
|
||||
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
|
||||
SizeOfData = accentStructSize,
|
||||
Data = accentPtr
|
||||
};
|
||||
|
||||
NativeThings.Windows10.NativeMethods.SetWindowCompositionAttribute(hwnd, ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
|
||||
Enabled = false;
|
||||
}
|
||||
|
||||
public bool Enabled { get; private set; }
|
||||
public bool CanBeEnabled { get; } = true;
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
internal class Windows7WindowBlurController : WindowsVistaWindowBlurController
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
internal class Windows81WindowBlurController : Windows8WindowBlurController
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
internal class Windows8WindowBlurController : OsNotSupportedWindowBlurController
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
{
|
||||
internal class WindowsVistaWindowBlurController : IWindowBlurController
|
||||
{
|
||||
public void EnableBlur(IntPtr hwnd)
|
||||
{
|
||||
if (!NativeThings.WindowsVistaAnd7.NativeMethods.DwmIsCompositionEnabled())
|
||||
return;
|
||||
|
||||
HwndSource.FromHwnd(hwnd)?.AddHook(WndProc);
|
||||
|
||||
InitializeGlass(hwnd);
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public void DisableBlur(IntPtr hwnd)
|
||||
{
|
||||
if (!NativeThings.WindowsVistaAnd7.NativeMethods.DwmIsCompositionEnabled())
|
||||
return;
|
||||
|
||||
HwndSource.FromHwnd(hwnd)?.RemoveHook(WndProc);
|
||||
|
||||
DeinitializeGlass(hwnd);
|
||||
Enabled = false;
|
||||
}
|
||||
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
public bool CanBeEnabled { get; } = true;
|
||||
|
||||
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg != NativeThings.WindowsVistaAnd7.NativeMethods.WM_DWMCOMPOSITIONCHANGED)
|
||||
return IntPtr.Zero;
|
||||
|
||||
InitializeGlass(hwnd);
|
||||
handled = false;
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
private static void InitializeGlass(IntPtr hwnd)
|
||||
{
|
||||
// fill the background with glass
|
||||
var margins = new NativeThings.WindowsVistaAnd7.NativeMethods.MARGINS();
|
||||
margins.cxLeftWidth = margins.cxRightWidth = margins.cyBottomHeight = margins.cyTopHeight = -1;
|
||||
NativeThings.WindowsVistaAnd7.NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref margins);
|
||||
|
||||
// initialize blur for the window
|
||||
var bbh = new NativeThings.WindowsVistaAnd7.NativeMethods.DWM_BLURBEHIND
|
||||
{
|
||||
fEnable = true,
|
||||
dwFlags = NativeThings.WindowsVistaAnd7.NativeMethods.DWM_BB.DWM_BB_ENABLE
|
||||
};
|
||||
|
||||
NativeThings.WindowsVistaAnd7.NativeMethods.DwmEnableBlurBehindWindow(hwnd, ref bbh);
|
||||
}
|
||||
|
||||
private static void DeinitializeGlass(IntPtr hwnd)
|
||||
{
|
||||
// fill the background with glass
|
||||
var margins = new NativeThings.WindowsVistaAnd7.NativeMethods.MARGINS();
|
||||
margins.cxLeftWidth = margins.cxRightWidth = margins.cyBottomHeight = margins.cyTopHeight = -1;
|
||||
NativeThings.WindowsVistaAnd7.NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref margins);
|
||||
|
||||
// initialize blur for the window
|
||||
var bbh = new NativeThings.WindowsVistaAnd7.NativeMethods.DWM_BLURBEHIND
|
||||
{
|
||||
fEnable = false,
|
||||
dwFlags = NativeThings.WindowsVistaAnd7.NativeMethods.DWM_BB.DWM_BB_ENABLE
|
||||
};
|
||||
|
||||
NativeThings.WindowsVistaAnd7.NativeMethods.DwmEnableBlurBehindWindow(hwnd, ref bbh);
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@
|
||||
Focusable="False" WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowActivated="False" ShowInTaskbar="False">
|
||||
ShowActivated="False" ShowInTaskbar="True">
|
||||
<controls:MainWindowBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
|
||||
@@ -24,7 +24,7 @@
|
||||
<converters:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter" />
|
||||
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
|
||||
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<converters:ScaledValueConverter x:Key="ScaledValueConverter" />
|
||||
</ResourceDictionary>
|
||||
</controls:MainWindowBase.Resources>
|
||||
@@ -81,7 +81,10 @@
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Grid.Resources>
|
||||
<glassLayer:GlassLayer OverlayColor="{DynamicResource CaptionBackground}" BlurredElement="{Binding ElementName=containerPanel}" />
|
||||
<glassLayer:GlassLayer OverlayColor="{DynamicResource CaptionBackground}" BlurredElement="{Binding ElementName=containerPanel}"
|
||||
ColorOverlayVisibility="{Binding ContextObject.TitlebarColourVisibility, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
GlassVisibility="{Binding ContextObject.TitlebarBlurVisibility, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
NoiseVisibility="{Binding ContextObject.TitlebarBlurVisibility, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<DockPanel>
|
||||
<Button x:Name="buttonCloseWindow" Style="{StaticResource CaptionCloseButtonStyle}"
|
||||
DockPanel.Dock="Right">
|
||||
@@ -134,7 +137,7 @@
|
||||
<Grid DockPanel.Dock="Top" Height="{StaticResource MainWindowCaptionHeight}"
|
||||
Visibility="{Binding ContextObject.TitlebarOverlap, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
|
||||
<ContentControl x:Name="container"
|
||||
Foreground="{DynamicResource CaptionButtonIconForeground}"
|
||||
Foreground="{DynamicResource WindowTextForeground}"
|
||||
Content="{Binding ContextObject.ViewerContent, ElementName=mainWindow}" />
|
||||
<DockPanel.Style>
|
||||
<Style TargetType="{x:Type DockPanel}">
|
||||
|
@@ -111,6 +111,9 @@ namespace QuickLook
|
||||
|
||||
private void AutoHideCaptionContainer(object sender, EventArgs e)
|
||||
{
|
||||
if (!ContextObject.TitlebarAutoHide)
|
||||
return;
|
||||
|
||||
if (!ContextObject.TitlebarOverlap)
|
||||
return;
|
||||
|
||||
|
@@ -34,10 +34,13 @@ namespace QuickLook.Plugin
|
||||
private bool _canResize = true;
|
||||
private bool _fullWindowDragging;
|
||||
private bool _isBusy = true;
|
||||
private string _title = "";
|
||||
private string _title = string.Empty;
|
||||
private bool _titlebarAutoHide;
|
||||
private bool _titlebarBlurVisibility = true;
|
||||
private bool _titlebarColourVisibility = true;
|
||||
private bool _titlebarOverlap;
|
||||
private object _viewerContent;
|
||||
private bool _useDarkTheme;
|
||||
private object _viewerContent;
|
||||
|
||||
/// <summary>
|
||||
/// Get the viewer window.
|
||||
@@ -127,9 +130,54 @@ namespace QuickLook.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the title bar shows a blurred background
|
||||
/// </summary>
|
||||
public bool TitlebarBlurVisibility
|
||||
{
|
||||
get => _titlebarBlurVisibility;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarBlurVisibility) return;
|
||||
_titlebarBlurVisibility = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the title bar shows a colour overlay
|
||||
/// </summary>
|
||||
public bool TitlebarColourVisibility
|
||||
{
|
||||
get => _titlebarColourVisibility;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarColourVisibility) return;
|
||||
_titlebarColourVisibility = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should the titlebar hides itself after a short period of inactivity?
|
||||
/// </summary>
|
||||
public bool TitlebarAutoHide
|
||||
{
|
||||
get => _titlebarAutoHide;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarAutoHide) return;
|
||||
_titlebarAutoHide = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch to dark theme?
|
||||
/// </summary>
|
||||
public bool UseDarkTheme
|
||||
{
|
||||
get { return _useDarkTheme; }
|
||||
get => _useDarkTheme;
|
||||
set
|
||||
{
|
||||
_useDarkTheme = value;
|
||||
@@ -137,13 +185,13 @@ namespace QuickLook.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void ApplyViewerWindowTheme()
|
||||
{
|
||||
ViewerWindow?.SwitchTheme(UseDarkTheme);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Get a string from translation Xml document.
|
||||
/// </summary>
|
||||
@@ -190,13 +238,17 @@ namespace QuickLook.Plugin
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
Title = "";
|
||||
Title = string.Empty;
|
||||
IsBusy = true;
|
||||
PreferredSize = new Size();
|
||||
CanResize = true;
|
||||
FullWindowDragging = false;
|
||||
TitlebarOverlap = false;
|
||||
|
||||
UseDarkTheme = false;
|
||||
TitlebarOverlap = false;
|
||||
TitlebarAutoHide = false;
|
||||
TitlebarBlurVisibility = true;
|
||||
TitlebarColourVisibility = true;
|
||||
|
||||
ViewerContent = null;
|
||||
ViewerWindow = null;
|
||||
|
@@ -5,10 +5,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:QuickLook.Plugin.InfoPanel"
|
||||
FontSize="14"
|
||||
mc:Ignorable="d" Width="453" Height="172" UseLayoutRounding="True" TextOptions.TextHintingMode="Animated">
|
||||
mc:Ignorable="d" Width="453" Height="172" UseLayoutRounding="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="15" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -50,14 +50,14 @@
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="filename" Grid.Row="1" Grid.Column="1" FontSize="19" Padding="3"
|
||||
TextWrapping="Wrap"
|
||||
LineHeight="25" MaxHeight="60" TextTrimming="CharacterEllipsis" FontWeight="Normal">
|
||||
LineHeight="25" MaxHeight="60" TextTrimming="CharacterEllipsis" FontWeight="SemiBold">
|
||||
FilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilename.ext
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="modDate" Grid.Row="3" Grid.Column="1" Padding="3" FontWeight="Light"
|
||||
<TextBlock x:Name="modDate" Grid.Row="3" Grid.Column="1" Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}">
|
||||
Last modified at 01/01/2017 00:00:00
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="totalSize" Grid.Row="4" Grid.Column="1" Padding="3" FontWeight="Light"
|
||||
<TextBlock x:Name="totalSize" Grid.Row="4" Grid.Column="1" Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}">
|
||||
Calculating size...
|
||||
</TextBlock>
|
||||
|
@@ -50,7 +50,6 @@ namespace QuickLook.Plugin.InfoPanel
|
||||
context.ViewerContent = _ip;
|
||||
|
||||
_ip.DisplayInfo(path);
|
||||
context.UseDarkTheme = true;
|
||||
context.IsBusy = false;
|
||||
}
|
||||
|
||||
|
@@ -65,6 +65,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\Build\Release\</OutputPath>
|
||||
@@ -120,7 +121,6 @@
|
||||
<Compile Include="Converters\WindowStateToThicknessConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToResizeModeConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToVisibilityCollapsedConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToResizeBorderThicknessConverter.cs" />
|
||||
<Compile Include="Converters\ScaledValueConverter.cs" />
|
||||
<Compile Include="ExtensionMethods\BitmapExtensions.cs" />
|
||||
@@ -132,24 +132,6 @@
|
||||
<Compile Include="Controls\BusyDecorator\BusyDecorator.cs" />
|
||||
<Compile Include="Controls\BusyDecorator\VisualTargetPresentationSource.cs" />
|
||||
<Compile Include="ExtensionMethods\TypeExtensions.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\BlurWindow.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\Helpers.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\IWindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\NativeMethods.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\Windows10\AccentPolicy.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\Windows10\AccentState.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\Windows10\NativeMethods.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\Windows10\WindowCompositionAttribute.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\Windows10\WindowCompositionAttributeData.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\NativeThings\WindowsVistaAnd7\NativeMethods.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\OsHelper.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\OsType.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\OsNotSupportedWindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\Windows10WindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\Windows7WindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\Windows81WindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\Windows8WindowBlurController.cs" />
|
||||
<Compile Include="Helpers\BlurLibrary\PlatformsImpl\WindowsVistaWindowBlurController.cs" />
|
||||
<Compile Include="Helpers\FileHelper.cs" />
|
||||
<Compile Include="Helpers\ProcessHelper.cs" />
|
||||
<Compile Include="Helpers\TranslationHelper.cs" />
|
||||
|
Reference in New Issue
Block a user