Bring back transparent window

This commit is contained in:
Paddy Xu
2018-01-12 23:30:25 +02:00
parent c622ed748a
commit a969687b7b
13 changed files with 244 additions and 337 deletions

View File

@@ -26,7 +26,7 @@
VirtualizingPanel.IsVirtualizing="True" Width="150"
SelectedIndex="0"
Focusable="False"
Background="#00FFFFFF"
Background="Transparent"
ItemsSource="{Binding PageThumbnails, ElementName=thisPdfViewer}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0,0,1,0"
ItemContainerStyle="{Binding Mode=OneWay, Source={StaticResource ListBoxItemStyleNoFocusedBorder}}">
@@ -61,7 +61,7 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Grid.Column="1" Background="#00EFEFEF">
<Grid Grid.Column="1" Background="#FFFAFAFA">
<imageViewer:ImagePanel x:Name="pagePanel" RenderMode="NearestNeighbor" ShowZoomLevelInfo="False"
BackgroundVisibility="Collapsed" MetaIconVisibility="Collapsed" />
</Grid>

View File

@@ -7,10 +7,9 @@
xmlns:local="clr-namespace:QuickLook.Plugin.TextViewer"
mc:Ignorable="d"
d:DesignHeight="317.974"
d:DesignWidth="448.79"
UseLayoutRounding="True">
d:DesignWidth="448.79">
<Grid>
<avalonEdit:TextEditor x:Name="viewer" Background="#00FFFFFF" FontSize="14" ShowLineNumbers="True"
<avalonEdit:TextEditor x:Name="viewer" Background="Transparent" FontSize="14" ShowLineNumbers="True"
WordWrap="True" IsReadOnly="True" IsManipulationEnabled="True" />
</Grid>
</UserControl>

View File

@@ -21,8 +21,9 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<ffme:MediaElement x:Name="mediaElement" />
<Grid x:Name="coverArtPersenter" ClipToBounds="True" Background="{StaticResource MainWindowBackground}">
<ffme:MediaElement x:Name="mediaElement" Background="{DynamicResource MainWindowBackgroundNoTransparent}" />
<Grid x:Name="coverArtPersenter" ClipToBounds="True"
Background="{DynamicResource MainWindowBackgroundNoTransparent}">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed" />
@@ -178,8 +179,8 @@
</TextBlock>
</Button>
<Slider x:Name="sliderProgress" Style="{StaticResource PositionSliderStyle}"
SmallChange="{Binding FrameStepDuration, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}"
LargeChange="{Binding FrameStepDuration, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}"
SmallChange="{Binding FrameStepDuration, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}"
LargeChange="{Binding FrameStepDuration, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}"
Maximum="{Binding NaturalDuration, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}"
Value="{Binding Position, ElementName=mediaElement, Converter={StaticResource TimeSpanToSecondsConverter}}" />
</DockPanel>
@@ -187,7 +188,7 @@
<Grid x:Name="volumeSliderLayer" Background="Transparent" Visibility="Collapsed">
<Grid Height="32" Width="130" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Background="{DynamicResource CaptionButtonHoverBackground}" Margin="0,0,0,32">
<Slider Style="{StaticResource CustomSliderStyle}" Width="110" Maximum="1"
<Slider Style="{StaticResource CustomSliderStyle}" Width="110" Maximum="1"
Value="{Binding ElementName=mediaElement, Path=Volume}" />
</Grid>
</Grid>

View File

@@ -34,10 +34,11 @@ namespace QuickLook
/// </summary>
public partial class App : Application
{
public static readonly bool IsUWP = ProcessHelper.IsRunningAsUWP();
public static readonly bool Is64Bit = Environment.Is64BitProcess;
public static readonly string AppFullPath = Assembly.GetExecutingAssembly().Location;
public static readonly string AppPath = Path.GetDirectoryName(AppFullPath);
public static readonly bool Is64Bit = Environment.Is64BitProcess;
public static readonly bool IsUWP = ProcessHelper.IsRunningAsUWP();
public static readonly bool IsWin10 = Environment.OSVersion.Version >= new Version(10, 0);
private bool _isFirstInstance;
private Mutex _isRunning;
@@ -126,6 +127,7 @@ namespace QuickLook
Process.GetCurrentProcess().Kill(); // just kill current process to avoid subsequence executions
//return;
}
Settings.Default.Upgraded = false;
Settings.Default.Save();
}

View File

@@ -1,54 +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;
namespace QuickLook.Controls
{
public class MainWindowBase : Window
{
public MainWindowBase()
{
//WindowStyle = WindowStyle.None;
SourceInitialized += SourceInitializedHandler;
}
private void SourceInitializedHandler(object sender, EventArgs e)
{
var handle = new WindowInteropHelper(this).Handle;
var handleSource = HwndSource.FromHwnd(handle);
handleSource?.AddHook(WindowProc);
}
private static IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case 0x0024: /* WM_GETMINMAXINFO */
//WindowHelper.WmGetMinMaxInfo(hwnd, lParam);
//handled = true;
break;
}
return (IntPtr) 0;
}
}
}

View File

@@ -26,7 +26,7 @@ using QuickLook.NativeMethods;
namespace QuickLook.Helpers
{
public static class WindowHelper
internal static class WindowHelper
{
public static Rect GetCurrentWindowRect()
{
@@ -57,9 +57,8 @@ namespace QuickLook.Helpers
window.TransformToPixels(left, top,
out pxLeft, out pxTop);
int pxWidth, pxHeight;
window.TransformToPixels(width, height,
out pxWidth, out pxHeight);
out var pxWidth, out var pxHeight);
User32.MoveWindow(new WindowInteropHelper(window).Handle, pxLeft, pxTop, pxWidth, pxHeight, true);
}
@@ -84,7 +83,7 @@ namespace QuickLook.Helpers
pixelY = (int) Math.Round(matrix.M22 * unitY);
}
internal static bool IsForegroundWindowBelongToSelf()
public static bool IsForegroundWindowBelongToSelf()
{
var hwnd = User32.GetForegroundWindow();
if (hwnd == IntPtr.Zero)
@@ -94,59 +93,65 @@ namespace QuickLook.Helpers
return procId == Process.GetCurrentProcess().Id;
}
internal static void SetNoactivate(WindowInteropHelper window)
public static void SetNoactivate(WindowInteropHelper window)
{
User32.SetWindowLong(window.Handle, User32.GWL_EXSTYLE,
User32.GetWindowLong(window.Handle, User32.GWL_EXSTYLE) |
User32.WS_EX_NOACTIVATE);
}
internal static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
public static void EnableBlur(Window window)
{
var mmi = (MinMaxInfo) Marshal.PtrToStructure(lParam, typeof(MinMaxInfo));
var accent = new AccentPolicy();
var accentStructSize = Marshal.SizeOf(accent);
accent.AccentState = AccentState.AccentEnableBlurbehind;
accent.AccentFlags = 2;
accent.GradientColor = 0x99FFFFFF;
// Adjust the maximized size and position to fit the work area of the current monitor
var currentScreen = Screen.FromHandle(hwnd);
var workArea = currentScreen.WorkingArea;
var monitorArea = currentScreen.Bounds;
mmi.ptMaxPosition.x = Math.Abs(workArea.Left - monitorArea.Left);
mmi.ptMaxPosition.y = Math.Abs(workArea.Top - monitorArea.Top);
mmi.ptMaxSize.x = Math.Abs(workArea.Right - workArea.Left);
mmi.ptMaxSize.y = Math.Abs(workArea.Bottom - workArea.Top);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
Marshal.StructureToPtr(mmi, lParam, true);
}
[StructLayout(LayoutKind.Sequential)]
public struct MinMaxInfo
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
/// <summary>
/// x coordinate of point.
/// </summary>
public int x;
/// <summary>
/// y coordinate of point.
/// </summary>
public int y;
/// <summary>
/// Construct a point of coordinates (x,y).
/// </summary>
public POINT(int x, int y)
var data = new WindowCompositionAttributeData
{
this.x = x;
this.y = y;
}
Attribute = WindowCompositionAttribute.WcaAccentPolicy,
SizeOfData = accentStructSize,
Data = accentPtr
};
User32.SetWindowCompositionAttribute(new WindowInteropHelper(window).Handle, ref data);
Marshal.FreeHGlobal(accentPtr);
}
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}
internal enum WindowCompositionAttribute
{
WcaAccentPolicy = 19
}
private enum AccentState
{
AccentDisabled = 0,
AccentEnableGradient = 1,
AccentEnableTransparentgradient = 2,
AccentEnableBlurbehind = 3,
AccentInvalidState = 4
}
[StructLayout(LayoutKind.Sequential)]
private struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public uint GradientColor;
public readonly int AnimationId;
}
}
}

View File

@@ -19,6 +19,7 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
using QuickLook.Helpers;
namespace QuickLook.NativeMethods
{
@@ -69,6 +70,10 @@ namespace QuickLook.NativeMethods
[DllImport("user32.dll")]
internal static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd,
ref WindowHelper.WindowCompositionAttributeData data);
internal delegate int KeyboardHookProc(int code, int wParam, ref KeyboardHookStruct lParam);
[SuppressMessage("ReSharper", "InconsistentNaming")]

View File

@@ -117,7 +117,6 @@
<Compile Include="Controls\GlassLayer\GlassLayer.xaml.cs">
<DependentUpon>GlassLayer.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\MainWindowBase.cs" />
<Compile Include="Converters\BooleanToKeyTimeConverter.cs" />
<Compile Include="Converters\BooleanToVisibilityCollapsedConverter.cs" />
<Compile Include="Converters\WindowStateNormalToThicknessConverter.cs" />

View File

@@ -1,16 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:fa="http://schemas.fontawesome.io/icons/">
<Color x:Key="MainWindowShadowColor">Gray</Color>
<SolidColorBrush x:Key="MainWindowBackground" Color="#FF565656" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5D4D4D4" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FFB9B9B9" />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MainWindowBackground" Color="#CC292929" />
<SolidColorBrush x:Key="MainWindowBackgroundNoTransparent" Color="#FF292929" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#FFEFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#FFD4D4D4" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#DDB9B9B9" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#44FFFFFF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverBackground" Color="#FFE81123" />
<SolidColorBrush x:Key="CaptionCloseButtonPressBackground" Color="#FFB5394B" />
<SolidColorBrush x:Key="CaptionBackground" Color="#FF3B3B3B" />
<SolidColorBrush x:Key="CaptionBackground" Color="#CC0E0E0E" />
</ResourceDictionary>

View File

@@ -4,17 +4,17 @@
<Thickness x:Key="MainWindowShadowMarginThickness">1</Thickness>
<Thickness x:Key="MainWindowResizeThickness">6</Thickness>
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
<Color x:Key="MainWindowShadowColor">Gray</Color>
<SolidColorBrush x:Key="MainWindowBackground" Color="#FFFAFAFA" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#E5626262" />
<SolidColorBrush x:Key="MainWindowBackground" Color="#BBFAFAFA" />
<SolidColorBrush x:Key="MainWindowBackgroundNoTransparent" Color="#FFFAFAFA" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#FF0E0E0E" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#FF626262" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FF3D3D3D" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#44FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#88FFFFFF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverBackground" Color="#FFE81123" />
<SolidColorBrush x:Key="CaptionCloseButtonPressBackground" Color="#FFB5394B" />
<SolidColorBrush x:Key="CaptionBackground" Color="#FFDADADA" />
<SolidColorBrush x:Key="CaptionBackground" Color="#BBDADADA" />
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
<Setter Property="Focusable" Value="False" />

View File

@@ -69,10 +69,9 @@ namespace QuickLook
private Icon GetTrayIconByDPI()
{
var isWin10 = Environment.OSVersion.Version >= new Version(10, 0);
var scale = DpiHelper.GetCurrentScaleFactor().Vertical;
if (isWin10)
if (App.IsWin10)
return scale > 1 ? Resources.app_white : Resources.app_white_16;
return scale > 1 ? Resources.app : Resources.app_16;
}

View File

@@ -1,4 +1,4 @@
<controls:MainWindowBase
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -13,9 +13,10 @@
MinWidth="400" MinHeight="200"
WindowStartupLocation="CenterScreen"
Focusable="False"
Background="{DynamicResource CaptionBackground}"
BorderBrush="{DynamicResource CaptionBackground}"
Background="{DynamicResource MainWindowBackground}"
ShowActivated="False" ShowInTaskbar="False">
<controls:MainWindowBase.Resources>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
@@ -25,165 +26,164 @@
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</ResourceDictionary>
</controls:MainWindowBase.Resources>
</Window.Resources>
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" CornerRadius="0" GlassFrameThickness="0,0,0,1"
ResizeBorderThickness="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateNormalToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}"
<WindowChrome CaptionHeight="{StaticResource MainWindowCaptionHeight}" CornerRadius="0"
GlassFrameThickness=" 1"
ResizeBorderThickness="{StaticResource MainWindowResizeThickness}"
UseAeroCaptionButtons="False" />
</WindowChrome.WindowChrome>
<controls:MainWindowBase.Style>
<Style TargetType="controls:MainWindowBase">
<Window.Style>
<Style TargetType="Window">
<Setter Property="BorderThickness" Value="{StaticResource MainWindowShadowMarginThickness}" />
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
</Style>
</controls:MainWindowBase.Style>
<Grid Background="{DynamicResource CaptionBackground}"
Margin="{Binding ElementName=mainWindow,Path=WindowState,Converter={StaticResource WindowStateNormalToThicknessConverter},ConverterParameter={StaticResource MainWindowShadowMarginThickness}}">
<Grid x:Name="windowFrameContainer"
Margin="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateMaximizedToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}">
<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" />
</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:1" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:1.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<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="Visible" />
<DockPanel>
<DockPanel.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="2" Opacity="0.7" Color="#B2FFFFFF" />
</DockPanel.Effect>
<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}">
<Button.Content>
<TextBlock x:Name="buttonOpenWithText" VerticalAlignment="Center">
Open with <Bold>AppName</Bold>
</TextBlock>
</Button.Content>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonTop" Tag="Auto">
<Button.Resources>
<Grid x:Key="ContentTop">
<TextBlock>&#xE898;</TextBlock>
<TextBlock>&#xE872;</TextBlock>
</Grid>
</Button.Resources>
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
<Setter Property="Content" Value="&#xE898;" />
<Style.Triggers>
<Trigger Property="Tag" Value="Auto">
<Setter Property="Content" Value="&#xE898;" />
</Trigger>
<Trigger Property="Tag" Value="Top">
<Setter Property="Content" Value="{StaticResource ContentTop}" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonPin" Tag="Auto">
<Button.Resources>
<Grid x:Key="ContentPin">
<TextBlock>&#xE840;</TextBlock>
<TextBlock>&#xE842;</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="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"
VerticalAlignment="Center" Margin="5,0" />
</Grid>
</DockPanel>
</Grid>
<DockPanel x:Name="containerPanel" Background="{DynamicResource MainWindowBackground}" ZIndex="80">
<Grid DockPanel.Dock="Top" Height="{StaticResource MainWindowCaptionHeight}"
Visibility="{Binding ContextObject.TitlebarOverlap, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
<ContentControl x:Name="container"
Foreground="{DynamicResource WindowTextForeground}"
Content="{Binding ContextObject.ViewerContent, ElementName=mainWindow}" />
<DockPanel.Style>
<Style TargetType="{x:Type DockPanel}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger
Binding="{Binding ContextObject.IsBusy, ElementName=mainWindow}"
Value="True">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</DockPanel.Style>
</Window.Style>
<Grid x:Name="windowFrameContainer"
Margin="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateMaximizedToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}">
<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" />
</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:1" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:1.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<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="Visible" />
<DockPanel>
<DockPanel.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="2" Opacity="0.7" Color="#B2FFFFFF" />
</DockPanel.Effect>
<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}">
<Button.Content>
<TextBlock x:Name="buttonOpenWithText" VerticalAlignment="Center">
Open with <Bold>AppName</Bold>
</TextBlock>
</Button.Content>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonTop" Tag="Auto">
<Button.Resources>
<Grid x:Key="ContentTop">
<TextBlock>&#xE898;</TextBlock>
<TextBlock>&#xE872;</TextBlock>
</Grid>
</Button.Resources>
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
<Setter Property="Content" Value="&#xE898;" />
<Style.Triggers>
<Trigger Property="Tag" Value="Auto">
<Setter Property="Content" Value="&#xE898;" />
</Trigger>
<Trigger Property="Tag" Value="Top">
<Setter Property="Content" Value="{StaticResource ContentTop}" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button DockPanel.Dock="Left" x:Name="buttonPin" Tag="Auto">
<Button.Resources>
<Grid x:Key="ContentPin">
<TextBlock>&#xE840;</TextBlock>
<TextBlock>&#xE842;</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="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"
VerticalAlignment="Center" Margin="5,0" />
</Grid>
</DockPanel>
</Grid>
<Grid x:Name="busyIndicatorLayer" Background="{DynamicResource MainWindowBackground}" ZIndex="200">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<DockPanel x:Name="containerPanel" ZIndex="80">
<Grid DockPanel.Dock="Top" Height="{StaticResource MainWindowCaptionHeight}"
Visibility="{Binding ContextObject.TitlebarOverlap, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
<ContentControl x:Name="container"
Foreground="{DynamicResource WindowTextForeground}"
Content="{Binding ContextObject.ViewerContent, ElementName=mainWindow}" />
<DockPanel.Style>
<Style TargetType="{x:Type DockPanel}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger
Binding="{Binding ContextObject.IsBusy, ElementName=mainWindow}"
Value="True">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<busyDecorator:BusyDecorator x:Name="busyDecorator"
IsBusyIndicatorShowing="True"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
</DockPanel.Style>
</DockPanel>
</Grid>
<Grid x:Name="busyIndicatorLayer" ZIndex="200">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger
Binding="{Binding ContextObject.IsBusy, ElementName=mainWindow}"
Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<busyDecorator:BusyDecorator x:Name="busyDecorator"
IsBusyIndicatorShowing="True"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
</Grid>
</controls:MainWindowBase>
</Window>

View File

@@ -20,7 +20,6 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using QuickLook.Controls;
using QuickLook.Helpers;
using QuickLook.Plugin;
@@ -29,12 +28,11 @@ namespace QuickLook
/// <summary>
/// Interaction logic for ViewerWindow.xaml
/// </summary>
public partial class ViewerWindow : MainWindowBase
public partial class ViewerWindow : Window
{
private Size _customWindowSize = Size.Empty;
private bool _ignoreNextWindowSizeChange;
private string _path = string.Empty;
private bool _restoreForDragMove;
internal ViewerWindow()
{
@@ -49,10 +47,6 @@ namespace QuickLook
StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;
windowCaptionContainer.MouseLeftButtonDown += WindowDragMoveStart;
windowCaptionContainer.MouseMove += WindowDragMoving;
windowCaptionContainer.MouseLeftButtonUp += WindowDragMoveEnd;
windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;
buttonTop.Click += (sender, e) =>
@@ -93,6 +87,16 @@ namespace QuickLook
buttonShare.Click += Share;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (SystemParameters.IsGlassEnabled && App.IsWin10)
WindowHelper.EnableBlur(this);
else
Background = (Brush) FindResource("MainWindowBackgroundNoTransparent");
}
private void SaveWindowSizeOnSizeChanged(object sender, SizeChangedEventArgs e)
{
// first shown?
@@ -132,56 +136,5 @@ namespace QuickLook
hide.Begin();
}
private void WindowDragMoveEnd(object sender, MouseButtonEventArgs e)
{
_restoreForDragMove = false;
}
private void WindowDragMoving(object sender, MouseEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
if (!_restoreForDragMove)
return;
_restoreForDragMove = false;
var scale = DpiHelper.GetCurrentScaleFactor();
var point = PointToScreen(e.MouseDevice.GetPosition(this));
point.X /= scale.Horizontal;
point.Y /= scale.Vertical;
var monitor = WindowHelper.GetCurrentWindowRect();
var precentLeft = (point.X - monitor.Left) / monitor.Width;
var precentTop = (point.Y - monitor.Top) / monitor.Height;
Left = point.X - RestoreBounds.Width * precentLeft;
Top = point.Y - RestoreBounds.Height * precentTop;
WindowState = WindowState.Normal;
if (e.LeftButton == MouseButtonState.Pressed)
DragMove();
}
private void WindowDragMoveStart(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
if (ResizeMode != ResizeMode.CanResize &&
ResizeMode != ResizeMode.CanResizeWithGrip)
return;
WindowState = WindowState == WindowState.Maximized
? WindowState.Normal
: WindowState.Maximized;
}
else
{
_restoreForDragMove = WindowState == WindowState.Maximized;
if (e.LeftButton == MouseButtonState.Pressed)
DragMove();
}
}
}
}