wip videoviewer

This commit is contained in:
Paddy Xu
2017-08-08 23:19:46 +03:00
parent 2b3338cc43
commit efaca311fc
10 changed files with 127 additions and 75 deletions

View File

@@ -60,7 +60,7 @@ namespace QuickLook.Plugin.VideoViewer
{
_context = context;
var def = new Size(450, 450);
var def = new Size(500, 300);
_mediaSize = GetMediaSizeWithVlc(path);

View File

@@ -1,9 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#44FFFFFF" />
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />

View File

@@ -9,7 +9,7 @@
xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer;assembly=QuickLook"
mc:Ignorable="d"
x:Name="viewerPanel"
d:DesignHeight="450" d:DesignWidth="450">
d:DesignHeight="300" d:DesignWidth="500">
<Grid>
<Grid.Resources>
<ResourceDictionary>
@@ -19,31 +19,71 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<vlc:VlcPlayer x:Name="mediaElement" LibVlcPath="{Binding LibVlcPath, ElementName=viewerPanel}"
VlcOption="{Binding VlcOption, ElementName=viewerPanel}" />
<Image>
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="{Binding CoverArt, ElementName=viewerPanel}" />
<Setter Property="Visibility" Value="Collapsed" />
<Grid>
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="False">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger
Binding="{Binding CoverArt.Length, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
Value="0">
<Setter Property="Source" Value="Resources/compact-disc.png" />
<Setter Property="Margin" Value="50" />
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="True">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*" />
<ColumnDefinition Width="6*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Grid.ColumnSpan="2" ClipToBounds="True">
<Rectangle.Effect>
<BlurEffect Radius="100"/>
</Rectangle.Effect>
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Viewbox="0.15,0,0.7,1" Stretch="UniformToFill" />
</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"/>
</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}"
Value="0">
<Setter Property="Source" Value="Resources/compact-disc.png" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
<Grid x:Name="videoControlContainer" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
<Grid.Resources>
<Storyboard x:Key="ShowControlStoryboard" Completed="AutoHideViedoControlContainer">
<DoubleAnimation
Storyboard.Target="{Binding Source={x:Reference videoControlContainer}}"
Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.05">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="HideControlStoryboard">
<DoubleAnimationUsingKeyFrames
Storyboard.Target="{Binding Source={x:Reference videoControlContainer}}"
Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames.KeyFrames>
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:0" />
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:3" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:3.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<glassLayer:GlassLayer BlurredElement="{Binding ElementName=mediaElement}" OverlayColor="#FF3B3B3B" />
<DockPanel>
<Button x:Name="buttonPlayPause" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Left">

View File

@@ -22,6 +22,7 @@ using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using Meta.Vlc;
using Meta.Vlc.Interop.Media;
using QuickLook.Annotations;
@@ -48,6 +49,9 @@ namespace QuickLook.Plugin.VideoViewer
{
InitializeComponent();
ShowViedoControlContainer(null, null);
viewerPanel.PreviewMouseMove += ShowViedoControlContainer;
mediaElement.PropertyChanged += PlayerPropertyChanged;
mediaElement.StateChanged += PlayerStateChanged;
@@ -175,6 +179,23 @@ namespace QuickLook.Plugin.VideoViewer
public event PropertyChangedEventHandler PropertyChanged;
private void ShowViedoControlContainer(object sender, MouseEventArgs e)
{
var show = (Storyboard) videoControlContainer.FindResource("ShowControlStoryboard");
if (videoControlContainer.Opacity == 0 || videoControlContainer.Opacity == 1)
show.Begin();
}
private void AutoHideViedoControlContainer(object sender, EventArgs e)
{
if (videoControlContainer.IsMouseOver)
return;
var hide = (Storyboard) videoControlContainer.FindResource("HideControlStoryboard");
hide.Begin();
}
private void PlayerStop(object sender, MouseButtonEventArgs e)
{
HasEnded = false;

View File

@@ -10,6 +10,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/ScrollBarStyleDictionary.xaml" />
<ResourceDictionary Source="Styles/BusyDecorator.xaml" />
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -19,9 +19,6 @@
ShowActivated="False" ShowInTaskbar="False">
<controls:MainWindowBase.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
<converters:BooleanToKeyTimeConverter x:Key="BooleanToKeyTimeConverter" />
<converters:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter" />
@@ -33,7 +30,7 @@
</controls:MainWindowBase.Resources>
<controls:MainWindowBase.Style>
<Style TargetType="controls:MainWindowBase">
<Setter Property="Foreground" Value="{DynamicResource MainWindowForeground}" />
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
<Setter Property="ResizeMode"
Value="{Binding ContextObject.CanResize, ElementName=mainWindow, Converter={StaticResource BooleanToResizeModeConverter}}" />
<Setter Property="WindowChrome.WindowChrome">
@@ -61,29 +58,29 @@
</Border.Effect>
<Grid x:Name="windowFrameContainer" Background="{DynamicResource MainWindowBackground}"
Margin="{Binding WindowState, ElementName=mainWindow, Converter={StaticResource WindowStateToThicknessConverter}, ConverterParameter={StaticResource MainWindowShadowPaddingThinkness}}">
<Grid.Resources>
<Storyboard x:Key="ShowCaptionStoryboard">
<DoubleAnimation
Storyboard.Target="{Binding Source={x:Reference windowCaptionContainer}}"
Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.05">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="ShowAndHideTitlebarStoryboard">
<DoubleAnimationUsingKeyFrames
Storyboard.Target="{Binding Source={x:Reference windowCaptionContainer}}"
Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames.KeyFrames>
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:0.05" />
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:3" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:3.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<Grid x:Name="viewerRootContainer" ZIndex="190">
<Grid x:Name="windowCaptionContainer" Height="{StaticResource MainWindowCaptionHeight}"
VerticalAlignment="Top"
ZIndex="100">
<Grid.Resources>
<Storyboard x:Key="ShowCaptionContainerStoryboard" Completed="AutoHideCaptionContainer">
<DoubleAnimation
Storyboard.Target="{Binding Source={x:Reference windowCaptionContainer}}"
Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.05">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="HideCaptionContainerStoryboard">
<DoubleAnimationUsingKeyFrames
Storyboard.Target="{Binding Source={x:Reference windowCaptionContainer}}"
Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames.KeyFrames>
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:0" />
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:3" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:3.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<glassLayer:GlassLayer OverlayColor="{DynamicResource CaptionBackground}" BlurredElement="{Binding ElementName=containerPanel}" />
<DockPanel>
<Button x:Name="buttonCloseWindow" Style="{StaticResource CaptionCloseButtonStyle}"

View File

@@ -103,22 +103,26 @@ namespace QuickLook
private void ShowWindowCaptionContainer(object sender, MouseEventArgs e)
{
var show = (Storyboard) windowFrameContainer.FindResource("ShowCaptionStoryboard");
var showAndHide = (Storyboard) windowFrameContainer.FindResource("ShowAndHideTitlebarStoryboard");
var show = (Storyboard) windowCaptionContainer.FindResource("ShowCaptionContainerStoryboard");
if (!ContextObject.TitlebarOverlap)
{
if (windowCaptionContainer.Opacity == 0 || windowCaptionContainer.Opacity == 1)
show.Begin();
showAndHide.Stop();
}
private void AutoHideCaptionContainer(object sender, EventArgs e)
{
if (!ContextObject.TitlebarOverlap)
return;
}
if (windowCaptionContainer.IsMouseOver)
show.Begin();
else
showAndHide.Begin();
return;
var hide = (Storyboard) windowCaptionContainer.FindResource("HideCaptionContainerStoryboard");
hide.Begin();
}
public bool Pinned
{
get => _pinned;
@@ -401,16 +405,6 @@ namespace QuickLook
ProcessHelper.PerformAggressiveGC();
}
public void ShowTitlebar()
{
}
public void HideTitlebar()
{
var sb = FindResource("HideTitlebarStoryboard") as Storyboard;
sb?.Begin();
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
@@ -421,13 +415,13 @@ namespace QuickLook
{
if (dark)
{
if (!Resources.MergedDictionaries.Contains(_darkDict))
Resources.MergedDictionaries.Add(_darkDict);
if (!Application.Current.Resources.MergedDictionaries.Contains(_darkDict))
Application.Current.Resources.MergedDictionaries.Add(_darkDict);
}
else
{
if (Resources.MergedDictionaries.Contains(_darkDict))
Resources.MergedDictionaries.Remove(_darkDict);
if (Application.Current.Resources.MergedDictionaries.Contains(_darkDict))
Application.Current.Resources.MergedDictionaries.Remove(_darkDict);
}
}
}

View File

@@ -54,11 +54,11 @@
FilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilename.ext
</TextBlock>
<TextBlock x:Name="modDate" Grid.Row="3" Grid.Column="1" Padding="3" FontWeight="Light"
Foreground="DimGray">
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"
Foreground="DimGray">
Foreground="{DynamicResource WindowTextForegroundAlternative}">
Calculating size...
</TextBlock>
</Grid>

View File

@@ -4,7 +4,8 @@
xmlns:fa="http://schemas.fontawesome.io/icons/">
<Color x:Key="MainWindowShadowColor">Gray</Color>
<SolidColorBrush x:Key="MainWindowBackground" Color="#FF565656" />
<SolidColorBrush x:Key="MainWindowForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FFB9B9B9" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />

View File

@@ -7,7 +7,8 @@
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
<Color x:Key="MainWindowShadowColor">Gray</Color>
<SolidColorBrush x:Key="MainWindowBackground" Color="#FFF8F8FB" />
<SolidColorBrush x:Key="MainWindowForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5626262" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FF3D3D3D" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5868686" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#44FFFFFF" />
@@ -19,7 +20,7 @@
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource MainWindowForeground}" />
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />