Finish ViedoViewer (except volume slider)

This commit is contained in:
Paddy Xu
2017-08-11 00:29:24 +03:00
parent 9ce0776d53
commit cd9b713c41
30 changed files with 426 additions and 164 deletions

View File

@@ -11,7 +11,8 @@
<Grid>
<Rectangle Visibility="{Binding BackgroundVisibility, ElementName=imagePanel}">
<Rectangle.Fill>
<ImageBrush x:Name="backgroundBrush" ImageSource="Resources/background.png" AlignmentY="Top" Viewport="0,0,32,32"
<ImageBrush x:Name="backgroundBrush" ImageSource="Resources/background.png" AlignmentY="Top"
Viewport="0,0,32,32"
ViewportUnits="Absolute" Stretch="UniformToFill" TileMode="Tile" />
</Rectangle.Fill>
</Rectangle>

View File

@@ -37,6 +37,7 @@ namespace QuickLook.Plugin.ImageViewer
/// </summary>
public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposable
{
private Visibility _backgroundVisibility = Visibility.Visible;
private Point? _dragInitPos;
private Uri _imageSource;
private DateTime _lastZoomTime = DateTime.MinValue;
@@ -45,7 +46,6 @@ namespace QuickLook.Plugin.ImageViewer
private BitmapScalingMode _renderMode = BitmapScalingMode.HighQuality;
private BitmapSource _source;
private double _zoomFactor = 1d;
private Visibility _backgroundVisibility = Visibility.Visible;
private bool _zoomToFit = true;

View File

@@ -64,8 +64,9 @@ namespace QuickLook.Plugin.ImageViewer
context.PreferredSize = new Size(1024, 768);
Directory.SetCurrentDirectory(App.AppPath);
context.TitlebarOverlap = true;
context.TitlebarAutoHide = true;
}
public void View(string path, ContextObject context)

View File

@@ -19,4 +19,4 @@
<es-ES>
<Editor_FontFamily>Consolas</Editor_FontFamily>
</es-ES>
</Translations>
</Translations>

View File

@@ -45,4 +45,28 @@ namespace QuickLook.Plugin.VideoViewer
throw new NotImplementedException();
}
}
public sealed class VolumeToIconConverter : DependencyObject, IValueConverter
{
private static readonly string[] Volumes = {"\xE992", "\xE993", "\xE994", "\xE995"};
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Volumes[0];
var v = (int) value;
if (v == 0)
return Volumes[0];
v = Math.Min(v, 100);
return Volumes[1 + v / 34];
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -78,6 +78,7 @@ namespace QuickLook.Plugin.VideoViewer
}
else
{
context.TitlebarAutoHide = true;
context.UseDarkTheme = true;
}
}

View File

@@ -59,9 +59,6 @@
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
<HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
</Reference>
<Reference Include="Meta.Vlc">
<HintPath>.\Meta.Vlc.dll</HintPath>
</Reference>
@@ -103,7 +100,6 @@
<SubType>Code</SubType>
</Compile>
<None Include="key.snk" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\QuickLook\QuickLook.csproj">
@@ -112,15 +108,11 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\compact-disc.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Content Include="LibVlc\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\empty.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -43,7 +43,7 @@
</Border>
<Border ClipToBounds="True" Height="1" Visibility="Visible">
<Rectangle RadiusX="1" RadiusY="1" Margin="10,0,10,0"
Fill="{DynamicResource MainWindowBackground}" />
Fill="{DynamicResource WindowTextForegroundAlternative}" />
</Border>
</DockPanel>
<Track x:Name="PART_Track">

View File

@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:vlc="clr-namespace:Meta.Vlc.Wpf;assembly=Meta.Vlc.Wpf"
xmlns:local="clr-namespace:QuickLook.Plugin.VideoViewer"
xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer;assembly=QuickLook"
@@ -14,6 +13,7 @@
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<local:TimeSpanToShortStringConverter x:Key="TimeSpanToShortStringConverter" />
<local:VolumeToIconConverter x:Key="VolumeToIconConverter" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
@@ -42,7 +42,8 @@
<BlurEffect Radius="100" />
</Rectangle.Effect>
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Stretch="UniformToFill" Opacity="0.9" />
<ImageBrush ImageSource="{Binding ElementName=viewerPanel, Path=CoverArt}" Stretch="UniformToFill"
Opacity="0.9" />
</Rectangle.Fill>
</Rectangle>
<Image Grid.Column="0" x:Name="imageCoverArt" Margin="20,40,20,40">
@@ -56,7 +57,7 @@
<DataTrigger
Binding="{Binding CoverArt, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
Value="0">
<Setter Property="Source" Value="Resources/compact-disc.png" />
<Setter Property="Source" Value="Resources/empty.png" />
</DataTrigger>
</Style.Triggers>
</Style>
@@ -67,7 +68,7 @@
<DropShadowEffect ShadowDepth="0" BlurRadius="2" Opacity="0.7" Color="#B2FFFFFF" />
</Grid.Effect>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="70" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
@@ -77,20 +78,20 @@
</Grid.RowDefinitions>
<TextBlock x:Name="metaTitle" Grid.Row="1" FontSize="22" Padding="3"
TextWrapping="Wrap"
LineHeight="28" MaxHeight="80" TextTrimming="CharacterEllipsis" FontWeight="SemiBold">
LineHeight="28" MaxHeight="80" TextTrimming="CharacterEllipsis">
ときめきポポロン♪
</TextBlock>
<TextBlock x:Name="metaArtists" Grid.Row="3" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
<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"
<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"
<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}}"/>
Text="{Binding ElementName=mediaElement, Path=Length, Converter={StaticResource TimeSpanToShortStringConverter}}" />
</Grid>
</Grid>
@@ -99,8 +100,7 @@
<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.TargetProperty="Opacity" To="1" Duration="0:0:0.05" />
</Storyboard>
<Storyboard x:Key="HideControlStoryboard">
<DoubleAnimationUsingKeyFrames
@@ -119,7 +119,7 @@
ColorOverlayVisibility="{Binding ElementName=viewerPanel, Path=HasVideo,Converter={StaticResource BooleanToVisibilityConverter}}">
<glassLayer:GlassLayer.Style>
<Style TargetType="glassLayer:GlassLayer">
<Setter Property="BlurredElement" Value="{Binding ElementName=viewerPanel}"></Setter>
<Setter Property="BlurredElement" Value="{Binding ElementName=mediaElement}" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=viewerPanel,Path=HasVideo}" Value="True">
<Setter Property="BlurredElement" Value="{Binding ElementName=mediaElement}" />
@@ -129,38 +129,34 @@
</glassLayer:GlassLayer.Style>
</glassLayer:GlassLayer>
<DockPanel>
<Button x:Name="buttonPlayPause" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Left">
<fa:ImageAwesome Foreground="{DynamicResource CaptionButtonIconForeground}">
<fa:ImageAwesome.Style>
<Style>
<Setter Property="fa:ImageAwesome.Icon" Value="Pause" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsPlaying, ElementName=viewerPanel}"
<Button x:Name="buttonPlayPause" DockPanel.Dock="Left">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource ControlButtonStyle}">
<Setter Property="Content" Value="&#xE769;" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsPlaying, ElementName=viewerPanel}"
Value="False">
<Setter Property="fa:ImageAwesome.Icon" Value="Play" />
</DataTrigger>
</Style.Triggers>
</Style>
</fa:ImageAwesome.Style>
</fa:ImageAwesome>
<Setter Property="Content" Value="&#xE768;" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button x:Name="buttonMute" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
<fa:ImageAwesome Icon="VolumeUp" Foreground="{DynamicResource CaptionButtonIconForeground}">
<fa:ImageAwesome.Style>
<Style TargetType="fa:ImageAwesome">
<Setter Property="Icon" Value="VolumeOff" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMuted, ElementName=viewerPanel}"
Value="False">
<Setter Property="Icon" Value="VolumeUp" />
</DataTrigger>
</Style.Triggers>
</Style>
</fa:ImageAwesome.Style>
</fa:ImageAwesome>
<Button x:Name="buttonMute" DockPanel.Dock="Right">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource ControlButtonStyle}">
<Setter Property="Content" Value="{Binding ElementName=mediaElement, Path=Volume, Converter={StaticResource VolumeToIconConverter}}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMuted, ElementName=viewerPanel}"
Value="True">
<Setter Property="Content" Value="&#xE74F;" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button Width="Auto" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
<TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="11"
<TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="11" FontFamily="{Binding ElementName=viewerPanel, Path=FontFamily}"
Foreground="{DynamicResource CaptionButtonIconForeground}"
Text="{Binding ElementName=mediaElement, Path=Time, Converter={StaticResource TimeSpanToShortStringConverter}}" />
</Button>

View File

@@ -21,6 +21,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
@@ -62,13 +63,13 @@ namespace QuickLook.Plugin.VideoViewer
_context = context;
buttonPlayPause.MouseLeftButtonUp += TogglePlayPause;
buttonPlayPause.Click += TogglePlayPause;
//buttonMute.MouseLeftButtonUp += (sender, e) =>
//{
// mediaElement.IsMuted = false;
// buttonMute.Visibility = Visibility.Collapsed;
//};
buttonMute.MouseLeftButtonUp += (sender, e) => IsMuted = !IsMuted;
buttonMute.Click += (sender, e) => IsMuted = !IsMuted;
sliderProgress.PreviewMouseDown += (sender, e) =>
{
@@ -91,7 +92,7 @@ namespace QuickLook.Plugin.VideoViewer
}
};*/
PreviewMouseWheel += (sender, e) => ChangeVolume((double) e.Delta / 120 * 2);
PreviewMouseWheel += (sender, e) => ChangeVolume((double) e.Delta / 120 * 4);
}
public bool IsMuted
@@ -228,8 +229,6 @@ namespace QuickLook.Plugin.VideoViewer
{
var state = e.Value;
Debug.WriteLine(state);
switch (state)
{
case MediaState.Opening:
@@ -268,6 +267,13 @@ namespace QuickLook.Plugin.VideoViewer
metaTitle.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Title);
metaArtists.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Artist);
metaAlbum.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Album);
metaArtists.Visibility = string.IsNullOrEmpty(metaArtists.Text)
? Visibility.Collapsed
: Visibility.Visible;
metaAlbum.Visibility = string.IsNullOrEmpty(metaAlbum.Text)
? Visibility.Collapsed
: Visibility.Visible;
}
private void DetermineTheme()
@@ -308,7 +314,7 @@ namespace QuickLook.Plugin.VideoViewer
if (_wasPlaying) mediaElement.Play();
}
private void TogglePlayPause(object sender, MouseButtonEventArgs e)
private void TogglePlayPause(object sender, EventArgs e)
{
if (mediaElement.VlcMediaPlayer.IsPlaying)
{

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net452" />
</packages>

View File

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

View File

@@ -29,6 +29,11 @@ namespace QuickLook.Controls.BusyDecorator
{
private readonly BackgroundVisualHost _busyHost = new BackgroundVisualHost();
private readonly ResourceDictionary _styles = new ResourceDictionary
{
Source = new Uri("pack://application:,,,/QuickLook;component/Controls/BusyDecorator/BusyDecorator.xaml")
};
static BusyDecorator()
{
DefaultStyleKeyProperty.OverrideMetadata(
@@ -38,6 +43,8 @@ namespace QuickLook.Controls.BusyDecorator
public BusyDecorator()
{
Resources.MergedDictionaries.Add(_styles);
AddLogicalChild(_busyHost);
AddVisualChild(_busyHost);
@@ -85,9 +92,11 @@ namespace QuickLook.Controls.BusyDecorator
private void SetBinding(DependencyObject obj, DependencyProperty source, DependencyProperty target)
{
var b = new Binding();
b.Source = this;
b.Path = new PropertyPath(source);
var b = new Binding
{
Source = this,
Path = new PropertyPath(source)
};
BindingOperations.SetBinding(obj, target, b);
}

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"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:local="clr-namespace:QuickLook"
xmlns:controls="clr-namespace:QuickLook.Controls"
xmlns:busyDecorator="clr-namespace:QuickLook.Controls.BusyDecorator">
<Style TargetType="{x:Type busyDecorator:BusyDecorator}">
@@ -13,7 +10,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<fa:ImageAwesome Width="40" Height="40" Icon="Cog" Spin="True" SpinDuration="1" />
<busyDecorator:SpinIcon FontFamily="Segoe MDL2 Assets" FontSize="40" Spin="True">&#xE72C;</busyDecorator:SpinIcon>
</ControlTemplate>
</Setter.Value>
</Setter>

View File

@@ -0,0 +1,97 @@
// 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.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace QuickLook.Controls.BusyDecorator
{
/// <summary>
/// Control extensions
/// </summary>
internal static class ControlExtensions
{
/// <summary>
/// The key used for storing the spinner Storyboard.
/// </summary>
private static readonly string SpinnerStoryBoardName = $"{typeof(FrameworkElement).Name}Spinner";
/// <summary>
/// Start the spinning animation
/// </summary>
/// <typeparam name="T">FrameworkElement and ISpinable</typeparam>
/// <param name="control">Control to apply the rotation </param>
public static void BeginSpin<T>(this T control)
where T : FrameworkElement, ISpinable
{
var transformGroup = control.RenderTransform as TransformGroup ?? new TransformGroup();
var rotateTransform = transformGroup.Children.OfType<RotateTransform>().FirstOrDefault();
if (rotateTransform != null)
{
rotateTransform.Angle = 0;
}
else
{
transformGroup.Children.Add(new RotateTransform(0.0));
control.RenderTransform = transformGroup;
control.RenderTransformOrigin = new Point(0.5, 0.5);
}
var storyboard = new Storyboard();
var animation = new DoubleAnimation
{
From = 0,
To = 360,
AutoReverse = false,
RepeatBehavior = RepeatBehavior.Forever,
Duration = new Duration(TimeSpan.FromSeconds(control.SpinDuration))
};
storyboard.Children.Add(animation);
Storyboard.SetTarget(animation, control);
Storyboard.SetTargetProperty(animation,
new PropertyPath("(0).(1)[0].(2)", UIElement.RenderTransformProperty,
TransformGroup.ChildrenProperty, RotateTransform.AngleProperty));
storyboard.Begin();
control.Resources.Add(SpinnerStoryBoardName, storyboard);
}
/// <summary>
/// Stop the spinning animation
/// </summary>
/// <typeparam name="T">FrameworkElement and ISpinable</typeparam>
/// <param name="control">Control to stop the rotation.</param>
public static void StopSpin<T>(this T control)
where T : FrameworkElement, ISpinable
{
var storyboard = control.Resources[SpinnerStoryBoardName] as Storyboard;
if (storyboard == null) return;
storyboard.Stop();
control.Resources.Remove(SpinnerStoryBoardName);
}
}
}

View File

@@ -0,0 +1,35 @@
// 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.Controls.BusyDecorator
{
/// <summary>
/// Represents a spinable control
/// </summary>
internal interface ISpinable
{
/// <summary>
/// Gets or sets the current spin (angle) animation of the icon.
/// </summary>
bool Spin { get; set; }
/// <summary>
/// Gets or sets the duration of the spinning animation (in seconds). This will stop and start the spin animation.
/// </summary>
double SpinDuration { get; set; }
}
}

View File

@@ -0,0 +1,90 @@
// 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.Windows;
using System.Windows.Controls;
namespace QuickLook.Controls.BusyDecorator
{
internal class SpinIcon : TextBlock, ISpinable
{
#region public bool Spin
/// <summary>
/// Identifies the Spin dependency property.
/// </summary>
public static DependencyProperty SpinProperty =
DependencyProperty.Register("Spin", typeof(bool), typeof(SpinIcon),
new PropertyMetadata(false, OnSpinPropertyChanged));
private static void OnSpinPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var b = d as SpinIcon;
if (b == null) return;
if ((bool) e.NewValue)
b.BeginSpin();
else
b.StopSpin();
}
/// <summary>
/// Gets or sets the current spin (angle) animation of the icon.
/// </summary>
public bool Spin
{
get => (bool) GetValue(SpinProperty);
set => SetValue(SpinProperty, value);
}
#endregion public bool Spin
#region public double SpinDuration
/// <summary>
/// Identifies the SpinDuration dependency property.
/// </summary>
public static DependencyProperty SpinDurationProperty =
DependencyProperty.Register("SpinDuration", typeof(double), typeof(SpinIcon),
new PropertyMetadata(1d, SpinDurationChanged));
private static void SpinDurationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var b = d as SpinIcon;
if (null == b || !b.Spin || !(e.NewValue is double) ||
e.NewValue.Equals(e.OldValue)) return;
b.StopSpin();
b.BeginSpin();
}
/// <summary>
/// Gets or sets the duration of the spinning animation (in seconds). This will stop and start the spin animation.
/// </summary>
public double SpinDuration
{
get => (double) GetValue(SpinDurationProperty);
set => SetValue(SpinDurationProperty, value);
}
#endregion public double SpinDuration
}
}

View File

@@ -10,7 +10,8 @@
<Grid>
<Rectangle Panel.ZIndex="100" Visibility="{Binding ElementName=glassLayer, Path=NoiseVisibility}">
<Rectangle.Fill>
<ImageBrush x:Name="noiseBrush" ImageSource="100-50-5-monochrome.png" AlignmentY="Top" ViewportUnits="Absolute"
<ImageBrush x:Name="noiseBrush" ImageSource="100-50-5-monochrome.png" AlignmentY="Top"
ViewportUnits="Absolute"
Opacity="0.5"
Viewport="0,0,100,100" TileMode="FlipY" Stretch="UniformToFill" />
</Rectangle.Fill>

View File

@@ -15,13 +15,10 @@
// 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.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using QuickLook.Helpers;
using Color = System.Windows.Media.Color;
using Size = System.Windows.Size;
namespace QuickLook.Controls.GlassLayer
{
@@ -72,7 +69,6 @@ namespace QuickLook.Controls.GlassLayer
/// </summary>
public SolidColorBrush OverlayColor
{
get => (SolidColorBrush) GetValue(OverlayColorProperty);
set => SetValue(OverlayColorProperty, value);

View File

@@ -15,7 +15,7 @@
// 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.Windows.Media;
using System.Windows;
namespace QuickLook
{
@@ -23,8 +23,8 @@ namespace QuickLook
{
public MainWindowNoTransparent()
{
Background = new SolidColorBrush(Colors.White);
AllowsTransparency = false;
windowFrameContainer.Margin = new Thickness(0);
}
}
}

View File

@@ -1,6 +1,5 @@
<controls:MainWindowBase
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -16,16 +15,17 @@
Focusable="False" WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
ShowActivated="False" ShowInTaskbar="True">
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" />
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:ScaledValueConverter x:Key="ScaledValueConverter" />
</ResourceDictionary>
</controls:MainWindowBase.Resources>
<controls:MainWindowBase.Style>
@@ -66,8 +66,7 @@
<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.TargetProperty="Opacity" To="1" Duration="0:0:0.05" />
</Storyboard>
<Storyboard x:Key="HideCaptionContainerStoryboard">
<DoubleAnimationUsingKeyFrames
@@ -81,36 +80,26 @@
</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">
<fa:ImageAwesome Icon="TimesCircle"
Foreground="{DynamicResource CaptionButtonIconForeground}" />
</Button>
<Button x:Name="buttonWindowStatus" Style="{StaticResource CaptionButtonStyle}"
Visibility="{Binding ContextObject.CanResize, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}"
DockPanel.Dock="Right">
<fa:ImageAwesome Foreground="{DynamicResource CaptionButtonIconForeground}">
<fa:ImageAwesome.Style>
<Style TargetType="{x:Type fa:ImageAwesome}">
<Setter Property="Icon" Value="WindowMaximize" />
<Style.Triggers>
<DataTrigger Binding="{Binding WindowState, ElementName=mainWindow}"
Value="Maximized">
<Setter Property="Icon" Value="WindowRestore" />
</DataTrigger>
<DataTrigger Binding="{Binding WindowState, ElementName=mainWindow}"
Value="Normal">
<Setter Property="Icon" Value="WindowMaximize" />
</DataTrigger>
</Style.Triggers>
</Style>
</fa:ImageAwesome.Style>
</fa:ImageAwesome>
<Button DockPanel.Dock="Right" x:Name="buttonCloseWindow" Style="{StaticResource CaptionCloseButtonStyle}" Content="&#xE894;"/>
<Button DockPanel.Dock="Right" x:Name="buttonWindowStatus"
Visibility="{Binding ContextObject.CanResize, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
<Setter Property="Content" Value="&#xE740;" />
<Style.Triggers>
<DataTrigger Binding="{Binding WindowState, ElementName=mainWindow}"
Value="Maximized">
<Setter Property="Content" Value="&#xE73F;" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button x:Name="buttonOpenWith" DockPanel.Dock="Right"
Style="{StaticResource CaptionTextButtonStyle}">
@@ -120,12 +109,36 @@
</TextBlock>
</Button.Content>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonPin" Style="{StaticResource CaptionButtonStyle}">
<fa:ImageAwesome Icon="ThumbTack" Foreground="{DynamicResource CaptionButtonIconForeground}" />
</Button>
<Button x:Name="buttonShare" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Left">
<fa:ImageAwesome Icon="ShareAlt" Foreground="{DynamicResource CaptionButtonIconForeground}" />
<Button DockPanel.Dock="Left" x:Name="buttonPin" Tag="Auto">
<Button.Resources>
<Grid x:Key="ContentPin">
<TextBlock>&#xE840;</TextBlock>
<TextBlock>&#xE842;</TextBlock>
</Grid>
<Grid x:Key="ContentPinTop">
<TextBlock>&#xE840;</TextBlock>
<TextBlock>&#xE842;</TextBlock>
<TextBlock>&#xE889;</TextBlock>
</Grid>
</Button.Resources>
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
<Setter Property="Content" Value="&#xE840;" />
<Style.Triggers>
<Trigger Property="Tag" Value="Auto">
<Setter Property="Content" Value="&#xE840;" />
</Trigger>
<Trigger Property="Tag" Value="PinTop">
<Setter Property="Content" Value="{StaticResource ContentPinTop}" />
</Trigger>
<Trigger Property="Tag" Value="Pin">
<Setter Property="Content" Value="{StaticResource ContentPin}" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonShare" Style="{StaticResource CaptionButtonStyle}" Content="&#xE72D;" />
<Grid x:Name="titleArea" Background="Transparent">
<TextBlock Text="{Binding ContextObject.Title, ElementName=mainWindow}" FontSize="12"
HorizontalAlignment="Left" TextTrimming="CharacterEllipsis"

View File

@@ -23,6 +23,8 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
@@ -40,15 +42,15 @@ namespace QuickLook
/// </summary>
public partial class MainWindowTransparent : MainWindowBase, INotifyPropertyChanged
{
private string _path;
private bool _pinned;
private bool _restoreForDragMove;
private readonly ResourceDictionary _darkDict = new ResourceDictionary
{
Source = new Uri("pack://application:,,,/QuickLook;component/Styles/MainWindowStyles.Dark.xaml")
};
private string _path;
private bool _pinned;
private bool _restoreForDragMove;
internal MainWindowTransparent()
internal MainWindowTransparent()
{
// this object should be initialized before loading UI components, because many of which are binding to it.
ContextObject = new ContextObject();
@@ -60,21 +62,19 @@ namespace QuickLook
windowCaptionContainer.MouseLeftButtonDown += WindowDragMoveStart;
windowCaptionContainer.MouseMove += WindowDragMoving;
windowCaptionContainer.MouseLeftButtonUp += WindowDragMoveEnd;
windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;
buttonPin.Click += (sender, e) =>
{
if (Pinned)
{
buttonCloseWindow.RaiseEvent(
new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
{
RoutedEvent = MouseLeftButtonUpEvent
});
Topmost = !Topmost;
buttonPin.Tag = Topmost ? "PinTop" : "Pin";
return;
}
Pinned = true;
buttonPin.Tag = "Pin";
ViewWindowManager.GetInstance().ForgetCurrentWindow();
};
@@ -101,10 +101,26 @@ namespace QuickLook
(sender, e) => RunWith("rundll32.exe", $"shell32.dll,OpenAs_RunDLL {_path}");
}
public bool Pinned
{
get => _pinned;
private set
{
_pinned = value;
OnPropertyChanged();
}
}
public IViewer Plugin { get; private set; }
public ContextObject ContextObject { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
private void ShowWindowCaptionContainer(object sender, MouseEventArgs e)
{
var show = (Storyboard) windowCaptionContainer.FindResource("ShowCaptionContainerStoryboard");
if (windowCaptionContainer.Opacity == 0 || windowCaptionContainer.Opacity == 1)
show.Begin();
}
@@ -125,23 +141,6 @@ namespace QuickLook
hide.Begin();
}
public bool Pinned
{
get => _pinned;
private set
{
_pinned = value;
OnPropertyChanged();
}
}
public IViewer Plugin { get; private set; }
public ContextObject ContextObject { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
private void WindowDragMoveEnd(object sender, MouseButtonEventArgs e)
{
_restoreForDragMove = false;
@@ -201,7 +200,7 @@ namespace QuickLook
Process.Start(new ProcessStartInfo(with)
{
Arguments = arg,
WorkingDirectory = System.IO.Path.GetDirectoryName(_path)
WorkingDirectory = Path.GetDirectoryName(_path)
});
}
catch (Exception e)
@@ -219,7 +218,7 @@ namespace QuickLook
{
Process.Start(new ProcessStartInfo(_path)
{
WorkingDirectory = System.IO.Path.GetDirectoryName(_path)
WorkingDirectory = Path.GetDirectoryName(_path)
});
}
catch (Exception e)
@@ -351,7 +350,7 @@ namespace QuickLook
if (Directory.Exists(_path))
{
AddToInlines("MW_BrowseFolder", System.IO.Path.GetFileName(_path));
AddToInlines("MW_BrowseFolder", Path.GetFileName(_path));
return;
}
var isExe = FileHelper.IsExecutable(_path, out string appFriendlyName);
@@ -368,7 +367,7 @@ namespace QuickLook
return;
}
// assoc not found
AddToInlines("MW_Open", System.IO.Path.GetFileName(_path));
AddToInlines("MW_Open", Path.GetFileName(_path));
void AddToInlines(string str, string replaceWith)
{
@@ -395,6 +394,7 @@ namespace QuickLook
WindowState = WindowState.Normal;
Hide();
//Dispatcher.BeginInvoke(new Action(Hide), DispatcherPriority.ApplicationIdle);
ProcessHelper.PerformAggressiveGC();
}
@@ -418,13 +418,13 @@ namespace QuickLook
{
if (dark)
{
if (!Application.Current.Resources.MergedDictionaries.Contains(_darkDict))
Application.Current.Resources.MergedDictionaries.Add(_darkDict);
if (!Resources.MergedDictionaries.Contains(_darkDict))
Resources.MergedDictionaries.Add(_darkDict);
}
else
{
if (Application.Current.Resources.MergedDictionaries.Contains(_darkDict))
Application.Current.Resources.MergedDictionaries.Remove(_darkDict);
if (Resources.MergedDictionaries.Contains(_darkDict))
Resources.MergedDictionaries.Remove(_darkDict);
}
}
}

View File

@@ -6,6 +6,13 @@
xmlns:local="clr-namespace:QuickLook.Plugin.InfoPanel"
FontSize="14"
mc:Ignorable="d" Width="453" Height="172" UseLayoutRounding="True">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15" />

View File

@@ -35,6 +35,9 @@ namespace QuickLook.Plugin.InfoPanel
public InfoPanel()
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
}
public bool Stop

View File

@@ -76,6 +76,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@@ -84,10 +85,6 @@
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
<HintPath>..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
@@ -112,6 +109,8 @@
<Compile Include="..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="Controls\BusyDecorator\ISpinable.cs" />
<Compile Include="Controls\BusyDecorator\SpinIcon.cs" />
<Compile Include="Controls\GlassLayer\GaussianBlurEffect.cs" />
<Compile Include="Controls\GlassLayer\GlassLayer.xaml.cs">
<DependentUpon>GlassLayer.xaml</DependentUpon>
@@ -124,6 +123,7 @@
<Compile Include="Converters\BooleanToResizeBorderThicknessConverter.cs" />
<Compile Include="Converters\ScaledValueConverter.cs" />
<Compile Include="ExtensionMethods\BitmapExtensions.cs" />
<Compile Include="Controls\BusyDecorator\ControlExtensions.cs" />
<Compile Include="ExtensionMethods\EnumerableExtensions.cs" />
<Compile Include="ExtensionMethods\FileExtensions.cs" />
<Compile Include="FocusMonitor.cs" />
@@ -192,7 +192,7 @@
<DependentUpon>MainWindowTransparent.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Styles\BusyDecorator.xaml">
<Page Include="Controls\BusyDecorator\BusyDecorator.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>

View File

@@ -5,7 +5,7 @@
<Color x:Key="MainWindowShadowColor">Gray</Color>
<SolidColorBrush x:Key="MainWindowBackground" Color="#FF565656" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5D4D4D4" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FFB9B9B9" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />

View File

@@ -10,7 +10,7 @@
<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="CaptionButtonIconForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#44FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#88FFFFFF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverBackground" Color="#FFE81123" />
@@ -56,7 +56,9 @@
<Style x:Key="CaptionButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonBaseStyle}">
<Setter Property="Width" Value="40" />
<Setter Property="Height" Value="32" />
<Setter Property="Padding" Value="9,9,9,9" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonIconForeground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">

View File

@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" />
</packages>