mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-10-19 01:54:08 +00:00
remove transparent window
This commit is contained in:
@@ -30,7 +30,6 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
private ArchiveInfoPanel _panel;
|
||||
|
||||
public int Priority => 0;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -26,7 +26,6 @@ namespace QuickLook.Plugin.CsvViewer
|
||||
private CsvViewerPanel _panel;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -30,7 +30,6 @@ namespace QuickLook.Plugin.HtmlViewer
|
||||
private WebpagePanel _panel;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -36,7 +36,6 @@ namespace QuickLook.Plugin.IPreviewHandlers
|
||||
private PreviewPanel _panel;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -42,7 +42,6 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
private ImagePanel _ip;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -31,7 +31,6 @@ namespace QuickLook.Plugin.MailViewer
|
||||
private string _tmpDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -30,7 +30,6 @@ namespace QuickLook.Plugin.MarkdownViewer
|
||||
private WebpagePanel _panel;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -30,7 +30,6 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
private PdfViewerControl _pdfControl;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -26,7 +26,6 @@ namespace QuickLook.Plugin.TextViewer
|
||||
private TextViewerPanel _tvp;
|
||||
|
||||
public int Priority => 0;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -44,7 +44,6 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
private FFprobe probe;
|
||||
|
||||
public int Priority => 0 - 10; // make it lower than TextViewer
|
||||
public bool AllowsTransparency => false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -27,7 +27,6 @@ namespace QuickLook.Controls
|
||||
public MainWindowBase()
|
||||
{
|
||||
WindowStyle = WindowStyle.None;
|
||||
AllowsTransparency = true;
|
||||
|
||||
SourceInitialized += SourceInitializedHandler;
|
||||
}
|
||||
|
@@ -1,30 +0,0 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Windows;
|
||||
|
||||
namespace QuickLook
|
||||
{
|
||||
internal class MainWindowNoTransparent : MainWindowTransparent
|
||||
{
|
||||
public MainWindowNoTransparent()
|
||||
{
|
||||
AllowsTransparency = false;
|
||||
windowFrameContainer.Margin = new Thickness(0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,204 +0,0 @@
|
||||
<controls:MainWindowBase
|
||||
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"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:busyDecorator="clr-namespace:QuickLook.Controls.BusyDecorator"
|
||||
xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer"
|
||||
xmlns:converters="clr-namespace:QuickLook.Converters"
|
||||
xmlns:controls="clr-namespace:QuickLook.Controls"
|
||||
mc:Ignorable="d" x:Class="QuickLook.MainWindowTransparent" x:Name="mainWindow"
|
||||
UseLayoutRounding="True"
|
||||
d:DesignWidth="624" d:DesignHeight="700"
|
||||
MinWidth="400" MinHeight="200"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Focusable="False" WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowActivated="False" ShowInTaskbar="False">
|
||||
<controls:MainWindowBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
|
||||
<converters:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter" />
|
||||
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
|
||||
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</ResourceDictionary>
|
||||
</controls:MainWindowBase.Resources>
|
||||
<controls:MainWindowBase.Style>
|
||||
<Style TargetType="controls:MainWindowBase">
|
||||
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
|
||||
<Setter Property="ResizeMode"
|
||||
Value="{Binding ContextObject.CanResize, ElementName=mainWindow, Converter={StaticResource BooleanToResizeModeConverter}}" />
|
||||
<Setter Property="WindowChrome.WindowChrome">
|
||||
<Setter.Value>
|
||||
<WindowChrome CaptionHeight="0" CornerRadius="0"
|
||||
ResizeBorderThickness="{Binding ContextObject.CanResize, Converter={StaticResource BooleanToResizeBorderThicknessConverter}, ElementName=mainWindow}"
|
||||
UseAeroCaptionButtons="False" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="WindowState" Value="Maximized">
|
||||
<Setter Property="WindowChrome.WindowChrome">
|
||||
<Setter.Value>
|
||||
<WindowChrome CaptionHeight="0" CornerRadius="0" ResizeBorderThickness="0" UseAeroCaptionButtons="False" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</controls:MainWindowBase.Style>
|
||||
<Border>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="{StaticResource MainWindowShadowBlurRadius}" ShadowDepth="0" Opacity="0.6"
|
||||
Color="{DynamicResource MainWindowShadowColor}" />
|
||||
</Border.Effect>
|
||||
<Grid x:Name="windowFrameContainer" Background="{DynamicResource MainWindowBackground}"
|
||||
Margin="{Binding WindowState, ElementName=mainWindow, Converter={StaticResource WindowStateToThicknessConverter}, ConverterParameter={StaticResource MainWindowShadowPaddingThinkness}}">
|
||||
<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="{Binding ContextObject.TitlebarBlurVisibility, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" x:Name="buttonCloseWindow"
|
||||
Style="{StaticResource CaptionCloseButtonStyle}" Content="" />
|
||||
<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="" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding WindowState, ElementName=mainWindow}"
|
||||
Value="Maximized">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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></TextBlock>
|
||||
<TextBlock></TextBlock>
|
||||
</Grid>
|
||||
</Button.Resources>
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Content" Value="" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag" Value="Auto">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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></TextBlock>
|
||||
<TextBlock></TextBlock>
|
||||
</Grid>
|
||||
</Button.Resources>
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Content" Value="" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag" Value="Auto">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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="" />
|
||||
<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>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
<Grid x:Name="busyIndicatorLayer" Background="{DynamicResource MainWindowBackground}" 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>
|
||||
</Border>
|
||||
</controls:MainWindowBase>
|
@@ -45,7 +45,7 @@ namespace QuickLook.Plugin
|
||||
/// <summary>
|
||||
/// Get the viewer window.
|
||||
/// </summary>
|
||||
public MainWindowTransparent ViewerWindow { get; internal set; }
|
||||
public ViewerWindow ViewerWindow { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the title of Viewer window.
|
||||
|
@@ -28,11 +28,6 @@ namespace QuickLook.Plugin
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the viewer window has blur effect.
|
||||
/// </summary>
|
||||
bool AllowsTransparency { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Do ont-time job when application starts. You may extract nessessary resource here.
|
||||
/// </summary>
|
||||
|
@@ -24,7 +24,6 @@ namespace QuickLook.Plugin.InfoPanel
|
||||
private InfoPanel _ip;
|
||||
|
||||
public int Priority => int.MinValue;
|
||||
public bool AllowsTransparency => true;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@@ -136,7 +136,6 @@
|
||||
<Compile Include="Helpers\FileHelper.cs" />
|
||||
<Compile Include="Helpers\ProcessHelper.cs" />
|
||||
<Compile Include="Helpers\TranslationHelper.cs" />
|
||||
<Compile Include="MainWindowNoTransparent.cs" />
|
||||
<Compile Include="PipeServerManager.cs" />
|
||||
<Compile Include="PluginManager.cs" />
|
||||
<Compile Include="Plugin\InfoPanel\FileHelper.cs" />
|
||||
@@ -175,7 +174,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindowTransparent.xaml">
|
||||
<Page Include="ViewerWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@@ -189,8 +188,8 @@
|
||||
<Compile Include="NativeMethods\User32.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="GlobalKeyboardHook.cs" />
|
||||
<Compile Include="MainWindowTransparent.xaml.cs">
|
||||
<DependentUpon>MainWindowTransparent.xaml</DependentUpon>
|
||||
<Compile Include="ViewerWindow.xaml.cs">
|
||||
<DependentUpon>ViewerWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Controls\BusyDecorator\BusyDecorator.xaml">
|
||||
|
@@ -1,8 +1,6 @@
|
||||
<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">
|
||||
<system:Double x:Key="MainWindowShadowBlurRadius">6</system:Double>
|
||||
<Thickness x:Key="MainWindowShadowPaddingThinkness">6</Thickness>
|
||||
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
|
||||
<Color x:Key="MainWindowShadowColor">Gray</Color>
|
||||
<SolidColorBrush x:Key="MainWindowBackground" Color="#FFFAFAFA" />
|
||||
|
@@ -28,19 +28,13 @@ namespace QuickLook
|
||||
internal class ViewWindowManager : IDisposable
|
||||
{
|
||||
private static ViewWindowManager _instance;
|
||||
private MainWindowTransparent _currentMainWindow;
|
||||
private ViewerWindow _viewerWindow;
|
||||
|
||||
private string _invokedPath = string.Empty;
|
||||
|
||||
private MainWindowNoTransparent _viewWindowNoTransparent;
|
||||
private MainWindowTransparent _viewWindowTransparent;
|
||||
|
||||
internal ViewWindowManager()
|
||||
{
|
||||
_viewWindowTransparent = new MainWindowTransparent();
|
||||
_viewWindowNoTransparent = new MainWindowNoTransparent();
|
||||
|
||||
_currentMainWindow = _viewWindowTransparent;
|
||||
_viewerWindow = new ViewerWindow();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -51,7 +45,7 @@ namespace QuickLook
|
||||
|
||||
public void RunAndClosePreview()
|
||||
{
|
||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||
if (_viewerWindow.Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
// if the current focus is in Desktop or explorer windows, just close the preview window and leave the task to System.
|
||||
@@ -59,7 +53,7 @@ namespace QuickLook
|
||||
if (focus != NativeMethods.QuickLook.FocusedWindowType.Invalid)
|
||||
{
|
||||
StopFocusMonitor();
|
||||
_currentMainWindow.BeginHide();
|
||||
_viewerWindow.BeginHide();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,21 +62,21 @@ namespace QuickLook
|
||||
return;
|
||||
|
||||
StopFocusMonitor();
|
||||
_currentMainWindow.RunAndHide();
|
||||
_viewerWindow.RunAndHide();
|
||||
}
|
||||
|
||||
public void ClosePreview()
|
||||
{
|
||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||
if (_viewerWindow.Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
StopFocusMonitor();
|
||||
_currentMainWindow.BeginHide();
|
||||
_viewerWindow.BeginHide();
|
||||
}
|
||||
|
||||
public void TogglePreview(string path)
|
||||
{
|
||||
if (_currentMainWindow.Visibility == Visibility.Visible)
|
||||
if (_viewerWindow.Visibility == Visibility.Visible)
|
||||
ClosePreview();
|
||||
else
|
||||
InvokePreview(path);
|
||||
@@ -102,12 +96,7 @@ namespace QuickLook
|
||||
{
|
||||
StopFocusMonitor();
|
||||
|
||||
if (ReferenceEquals(_currentMainWindow, _viewWindowTransparent))
|
||||
_viewWindowTransparent = new MainWindowTransparent();
|
||||
else
|
||||
_viewWindowNoTransparent = new MainWindowNoTransparent();
|
||||
|
||||
_currentMainWindow = _viewWindowTransparent;
|
||||
_viewerWindow = new ViewerWindow();
|
||||
}
|
||||
|
||||
public void SwitchPreview(string path)
|
||||
@@ -115,7 +104,7 @@ namespace QuickLook
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return;
|
||||
|
||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||
if (_viewerWindow.Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
InvokePreview(path);
|
||||
@@ -126,7 +115,7 @@ namespace QuickLook
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return;
|
||||
|
||||
if (_currentMainWindow.Visibility == Visibility.Visible && path == _invokedPath)
|
||||
if (_viewerWindow.Visibility == Visibility.Visible && path == _invokedPath)
|
||||
return;
|
||||
|
||||
if (!Directory.Exists(path) && !File.Exists(path))
|
||||
@@ -143,24 +132,16 @@ namespace QuickLook
|
||||
|
||||
private void BeginShowNewWindow(string path, IViewer matchedPlugin)
|
||||
{
|
||||
_currentMainWindow.UnloadPlugin();
|
||||
|
||||
// switch window
|
||||
var oldWindow = _currentMainWindow;
|
||||
_currentMainWindow = matchedPlugin.AllowsTransparency
|
||||
? _viewWindowTransparent
|
||||
: _viewWindowNoTransparent;
|
||||
if (!ReferenceEquals(oldWindow, _currentMainWindow))
|
||||
oldWindow.BeginHide();
|
||||
|
||||
_currentMainWindow.BeginShow(matchedPlugin, path, CurrentPluginFailed);
|
||||
_viewerWindow.UnloadPlugin();
|
||||
|
||||
_viewerWindow.BeginShow(matchedPlugin, path, CurrentPluginFailed);
|
||||
}
|
||||
|
||||
private void CurrentPluginFailed(string path, ExceptionDispatchInfo e)
|
||||
{
|
||||
var plugin = _currentMainWindow.Plugin.GetType();
|
||||
var plugin = _viewerWindow.Plugin.GetType();
|
||||
|
||||
_currentMainWindow.BeginHide();
|
||||
_viewerWindow.BeginHide();
|
||||
|
||||
TrayIconManager.ShowNotification("", $"Failed to preview {Path.GetFileName(path)}", true);
|
||||
|
||||
|
185
QuickLook/ViewerWindow.xaml
Normal file
185
QuickLook/ViewerWindow.xaml
Normal file
@@ -0,0 +1,185 @@
|
||||
<controls:MainWindowBase
|
||||
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"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:busyDecorator="clr-namespace:QuickLook.Controls.BusyDecorator"
|
||||
xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer"
|
||||
xmlns:converters="clr-namespace:QuickLook.Converters"
|
||||
xmlns:controls="clr-namespace:QuickLook.Controls"
|
||||
mc:Ignorable="d" x:Class="QuickLook.ViewerWindow" x:Name="mainWindow"
|
||||
UseLayoutRounding="True"
|
||||
d:DesignWidth="624" d:DesignHeight="700"
|
||||
MinWidth="400" MinHeight="200"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Focusable="False" WindowStyle="None"
|
||||
Background="Transparent"
|
||||
ShowActivated="False" ShowInTaskbar="False">
|
||||
<controls:MainWindowBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
|
||||
<converters:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter" />
|
||||
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
|
||||
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</ResourceDictionary>
|
||||
</controls:MainWindowBase.Resources>
|
||||
<controls:MainWindowBase.Style>
|
||||
<Style TargetType="controls:MainWindowBase">
|
||||
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
|
||||
<Setter Property="WindowChrome.WindowChrome">
|
||||
<Setter.Value>
|
||||
<WindowChrome CaptionHeight="0" CornerRadius="0" GlassFrameThickness="0,0,0,1"
|
||||
ResizeBorderThickness="{Binding ContextObject.CanResize, Converter={StaticResource BooleanToResizeBorderThicknessConverter}, ElementName=mainWindow}"
|
||||
UseAeroCaptionButtons="False" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</controls:MainWindowBase.Style>
|
||||
<Grid x:Name="windowFrameContainer" Background="{DynamicResource MainWindowBackground}">
|
||||
<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="{Binding ContextObject.TitlebarBlurVisibility, ElementName=mainWindow, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" x:Name="buttonCloseWindow"
|
||||
Style="{StaticResource CaptionCloseButtonStyle}" Content="" />
|
||||
<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="" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding WindowState, ElementName=mainWindow}"
|
||||
Value="Maximized">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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></TextBlock>
|
||||
<TextBlock></TextBlock>
|
||||
</Grid>
|
||||
</Button.Resources>
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Content" Value="" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag" Value="Auto">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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></TextBlock>
|
||||
<TextBlock></TextBlock>
|
||||
</Grid>
|
||||
</Button.Resources>
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Content" Value="" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag" Value="Auto">
|
||||
<Setter Property="Content" Value="" />
|
||||
</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="" />
|
||||
<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>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
<Grid x:Name="busyIndicatorLayer" Background="{DynamicResource MainWindowBackground}" 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>
|
@@ -36,9 +36,9 @@ using QuickLook.Plugin;
|
||||
namespace QuickLook
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindowTransparent.xaml
|
||||
/// Interaction logic for ViewerWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindowTransparent : MainWindowBase, INotifyPropertyChanged
|
||||
public partial class ViewerWindow : MainWindowBase, INotifyPropertyChanged
|
||||
{
|
||||
private readonly ResourceDictionary _darkDict = new ResourceDictionary
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace QuickLook
|
||||
private bool _pinned;
|
||||
private bool _restoreForDragMove;
|
||||
|
||||
internal MainWindowTransparent()
|
||||
internal ViewerWindow()
|
||||
{
|
||||
// this object should be initialized before loading UI components, because many of which are binding to it.
|
||||
ContextObject = new ContextObject();
|
Reference in New Issue
Block a user