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

View File

@@ -7,10 +7,9 @@
xmlns:local="clr-namespace:QuickLook.Plugin.TextViewer" xmlns:local="clr-namespace:QuickLook.Plugin.TextViewer"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="317.974" d:DesignHeight="317.974"
d:DesignWidth="448.79" d:DesignWidth="448.79">
UseLayoutRounding="True">
<Grid> <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" /> WordWrap="True" IsReadOnly="True" IsManipulationEnabled="True" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -21,8 +21,9 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<ffme:MediaElement x:Name="mediaElement" /> <ffme:MediaElement x:Name="mediaElement" Background="{DynamicResource MainWindowBackgroundNoTransparent}" />
<Grid x:Name="coverArtPersenter" ClipToBounds="True" Background="{StaticResource MainWindowBackground}"> <Grid x:Name="coverArtPersenter" ClipToBounds="True"
Background="{DynamicResource MainWindowBackgroundNoTransparent}">
<Grid.Style> <Grid.Style>
<Style TargetType="Grid"> <Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed" /> <Setter Property="Visibility" Value="Collapsed" />

View File

@@ -34,10 +34,11 @@ namespace QuickLook
/// </summary> /// </summary>
public partial class App : Application 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 AppFullPath = Assembly.GetExecutingAssembly().Location;
public static readonly string AppPath = Path.GetDirectoryName(AppFullPath); 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 bool _isFirstInstance;
private Mutex _isRunning; private Mutex _isRunning;
@@ -126,6 +127,7 @@ namespace QuickLook
Process.GetCurrentProcess().Kill(); // just kill current process to avoid subsequence executions Process.GetCurrentProcess().Kill(); // just kill current process to avoid subsequence executions
//return; //return;
} }
Settings.Default.Upgraded = false; Settings.Default.Upgraded = false;
Settings.Default.Save(); 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 namespace QuickLook.Helpers
{ {
public static class WindowHelper internal static class WindowHelper
{ {
public static Rect GetCurrentWindowRect() public static Rect GetCurrentWindowRect()
{ {
@@ -57,9 +57,8 @@ namespace QuickLook.Helpers
window.TransformToPixels(left, top, window.TransformToPixels(left, top,
out pxLeft, out pxTop); out pxLeft, out pxTop);
int pxWidth, pxHeight;
window.TransformToPixels(width, height, 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); 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); pixelY = (int) Math.Round(matrix.M22 * unitY);
} }
internal static bool IsForegroundWindowBelongToSelf() public static bool IsForegroundWindowBelongToSelf()
{ {
var hwnd = User32.GetForegroundWindow(); var hwnd = User32.GetForegroundWindow();
if (hwnd == IntPtr.Zero) if (hwnd == IntPtr.Zero)
@@ -94,59 +93,65 @@ namespace QuickLook.Helpers
return procId == Process.GetCurrentProcess().Id; 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.SetWindowLong(window.Handle, User32.GWL_EXSTYLE,
User32.GetWindowLong(window.Handle, User32.GWL_EXSTYLE) | User32.GetWindowLong(window.Handle, User32.GWL_EXSTYLE) |
User32.WS_EX_NOACTIVATE); 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 accentPtr = Marshal.AllocHGlobal(accentStructSize);
var currentScreen = Screen.FromHandle(hwnd); Marshal.StructureToPtr(accent, accentPtr, false);
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);
Marshal.StructureToPtr(mmi, lParam, true); var data = new WindowCompositionAttributeData
{
Attribute = WindowCompositionAttribute.WcaAccentPolicy,
SizeOfData = accentStructSize,
Data = accentPtr
};
User32.SetWindowCompositionAttribute(new WindowInteropHelper(window).Handle, ref data);
Marshal.FreeHGlobal(accentPtr);
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct MinMaxInfo internal struct WindowCompositionAttributeData
{ {
public POINT ptReserved; public WindowCompositionAttribute Attribute;
public POINT ptMaxSize; public IntPtr Data;
public POINT ptMaxPosition; public int SizeOfData;
public POINT ptMinTrackSize; }
public POINT ptMaxTrackSize;
internal enum WindowCompositionAttribute
{
WcaAccentPolicy = 19
}
private enum AccentState
{
AccentDisabled = 0,
AccentEnableGradient = 1,
AccentEnableTransparentgradient = 2,
AccentEnableBlurbehind = 3,
AccentInvalidState = 4
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct POINT private struct AccentPolicy
{ {
/// <summary> public AccentState AccentState;
/// x coordinate of point. public int AccentFlags;
/// </summary> public uint GradientColor;
public int x; public readonly int AnimationId;
/// <summary>
/// y coordinate of point.
/// </summary>
public int y;
/// <summary>
/// Construct a point of coordinates (x,y).
/// </summary>
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -69,10 +69,9 @@ namespace QuickLook
private Icon GetTrayIconByDPI() private Icon GetTrayIconByDPI()
{ {
var isWin10 = Environment.OSVersion.Version >= new Version(10, 0);
var scale = DpiHelper.GetCurrentScaleFactor().Vertical; 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_white : Resources.app_white_16;
return scale > 1 ? Resources.app : Resources.app_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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -13,9 +13,10 @@
MinWidth="400" MinHeight="200" MinWidth="400" MinHeight="200"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Focusable="False" Focusable="False"
Background="{DynamicResource CaptionBackground}" BorderBrush="{DynamicResource CaptionBackground}"
Background="{DynamicResource MainWindowBackground}"
ShowActivated="False" ShowInTaskbar="False"> ShowActivated="False" ShowInTaskbar="False">
<controls:MainWindowBase.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" /> <ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
@@ -25,19 +26,19 @@
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" /> <converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</ResourceDictionary> </ResourceDictionary>
</controls:MainWindowBase.Resources> </Window.Resources>
<WindowChrome.WindowChrome> <WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="0" CornerRadius="0" GlassFrameThickness="0,0,0,1" <WindowChrome CaptionHeight="{StaticResource MainWindowCaptionHeight}" CornerRadius="0"
ResizeBorderThickness="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateNormalToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}" GlassFrameThickness=" 1"
ResizeBorderThickness="{StaticResource MainWindowResizeThickness}"
UseAeroCaptionButtons="False" /> UseAeroCaptionButtons="False" />
</WindowChrome.WindowChrome> </WindowChrome.WindowChrome>
<controls:MainWindowBase.Style> <Window.Style>
<Style TargetType="controls:MainWindowBase"> <Style TargetType="Window">
<Setter Property="BorderThickness" Value="{StaticResource MainWindowShadowMarginThickness}" />
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" /> <Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
</Style> </Style>
</controls:MainWindowBase.Style> </Window.Style>
<Grid Background="{DynamicResource CaptionBackground}"
Margin="{Binding ElementName=mainWindow,Path=WindowState,Converter={StaticResource WindowStateNormalToThicknessConverter},ConverterParameter={StaticResource MainWindowShadowMarginThickness}}">
<Grid x:Name="windowFrameContainer" <Grid x:Name="windowFrameContainer"
Margin="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateMaximizedToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}"> Margin="{Binding ElementName=mainWindow, Path=WindowState, Converter={StaticResource WindowStateMaximizedToThicknessConverter}, ConverterParameter={StaticResource MainWindowResizeThickness}}">
<Grid x:Name="viewerRootContainer" ZIndex="190"> <Grid x:Name="viewerRootContainer" ZIndex="190">
@@ -146,7 +147,7 @@
</Grid> </Grid>
</DockPanel> </DockPanel>
</Grid> </Grid>
<DockPanel x:Name="containerPanel" Background="{DynamicResource MainWindowBackground}" ZIndex="80"> <DockPanel x:Name="containerPanel" ZIndex="80">
<Grid DockPanel.Dock="Top" Height="{StaticResource MainWindowCaptionHeight}" <Grid DockPanel.Dock="Top" Height="{StaticResource MainWindowCaptionHeight}"
Visibility="{Binding ContextObject.TitlebarOverlap, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" /> Visibility="{Binding ContextObject.TitlebarOverlap, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
<ContentControl x:Name="container" <ContentControl x:Name="container"
@@ -166,7 +167,7 @@
</DockPanel.Style> </DockPanel.Style>
</DockPanel> </DockPanel>
</Grid> </Grid>
<Grid x:Name="busyIndicatorLayer" Background="{DynamicResource MainWindowBackground}" ZIndex="200"> <Grid x:Name="busyIndicatorLayer" ZIndex="200">
<Grid.Style> <Grid.Style>
<Style TargetType="{x:Type Grid}"> <Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed" /> <Setter Property="Visibility" Value="Collapsed" />
@@ -185,5 +186,4 @@
HorizontalAlignment="Center" /> HorizontalAlignment="Center" />
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Window>
</controls:MainWindowBase>

View File

@@ -20,7 +20,6 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using QuickLook.Controls;
using QuickLook.Helpers; using QuickLook.Helpers;
using QuickLook.Plugin; using QuickLook.Plugin;
@@ -29,12 +28,11 @@ namespace QuickLook
/// <summary> /// <summary>
/// Interaction logic for ViewerWindow.xaml /// Interaction logic for ViewerWindow.xaml
/// </summary> /// </summary>
public partial class ViewerWindow : MainWindowBase public partial class ViewerWindow : Window
{ {
private Size _customWindowSize = Size.Empty; private Size _customWindowSize = Size.Empty;
private bool _ignoreNextWindowSizeChange; private bool _ignoreNextWindowSizeChange;
private string _path = string.Empty; private string _path = string.Empty;
private bool _restoreForDragMove;
internal ViewerWindow() internal ViewerWindow()
{ {
@@ -49,10 +47,6 @@ namespace QuickLook
StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true; StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;
windowCaptionContainer.MouseLeftButtonDown += WindowDragMoveStart;
windowCaptionContainer.MouseMove += WindowDragMoving;
windowCaptionContainer.MouseLeftButtonUp += WindowDragMoveEnd;
windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer; windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;
buttonTop.Click += (sender, e) => buttonTop.Click += (sender, e) =>
@@ -93,6 +87,16 @@ namespace QuickLook
buttonShare.Click += Share; 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) private void SaveWindowSizeOnSizeChanged(object sender, SizeChangedEventArgs e)
{ {
// first shown? // first shown?
@@ -132,56 +136,5 @@ namespace QuickLook
hide.Begin(); 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();
}
}
} }
} }