wip plugin installer

This commit is contained in:
Paddy Xu
2018-08-28 23:49:35 +03:00
parent 695b42e82b
commit 4f496f5ab8
27 changed files with 178 additions and 697 deletions

View File

@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.ArchiveViewer
private ArchiveInfoPanel _panel;
public int Priority => 0;
public int Priority => -5;
public void Init()
{

View File

@@ -1,35 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
namespace QuickLook.Plugin.CameraRawViewer
{
internal class DCraw
{
private static readonly string DCrawPath =
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Environment.Is64BitProcess ? "dcraw64.exe" : "dcraw32.exe");
public static string ConvertToTiff(string input)
{
var output = Path.GetTempFileName();
using (var p = new Process())
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = DCrawPath;
p.StartInfo.Arguments = $"-w -W -h -T -O \"{output}\" \"{input}\"";
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start();
p.WaitForExit(10000);
}
return new FileInfo(output).Length > 0 ? output : string.Empty;
}
}
}

View File

@@ -1,85 +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.IO;
using System.Linq;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.CameraRawViewer
{
public class Plugin : IViewer
{
private static readonly string[] Formats =
{
// camera raw
".ari", ".arw", ".bay", ".crw", ".cr2", ".cap", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff",
".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx",
".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".x3f"
};
private string _image = string.Empty;
private ImageViewer.Plugin _imageViewierPlugin;
public int Priority => -1;//int.MaxValue;
public void Init()
{
}
public bool CanHandle(string path)
{
return false;
return !Directory.Exists(path) && Formats.Any(path.ToLower().EndsWith);
}
public void Prepare(string path, ContextObject context)
{
_imageViewierPlugin=new ImageViewer.Plugin();
_imageViewierPlugin.Prepare(path, context);
}
public void View(string path, ContextObject context)
{
_image = DCraw.ConvertToTiff(path);
if (string.IsNullOrEmpty(_image))
throw new Exception("DCraw failed.");
_imageViewierPlugin.View(_image, context);
// correct title
context.Title = Path.GetFileName(path);
}
public void Cleanup()
{
_imageViewierPlugin.Cleanup();
_imageViewierPlugin = null;
try
{
File.Delete(_image);
}
catch (Exception)
{
// ignored
}
}
}
}

View File

@@ -26,7 +26,7 @@ namespace QuickLook.Plugin.CsvViewer
{
private CsvViewerPanel _panel;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.EpubViewer
{
private ContextObject _context;
private EpubViewerControl _epubControl;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.HtmlViewer
private WebpagePanel _panel;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -1,29 +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.Runtime.InteropServices;
namespace QuickLook.Plugin.IPreviewHandlers
{
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")]
internal interface IInitializeWithFile
{
void Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint grfMode);
}
}

View File

@@ -1,40 +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.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace QuickLook.Plugin.IPreviewHandlers
{
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("8895b1c6-b41f-4c1c-a562-0d564250836f")]
internal interface IPreviewHandler
{
void SetWindow(IntPtr hwnd, ref Rectangle rect);
void SetRect(ref Rectangle rect);
void DoPreview();
void Unload();
void SetFocus();
void QueryFocus(out IntPtr phwnd);
[PreserveSig]
uint TranslateAccelerator(ref Message pmsg);
}
}

View File

@@ -1,170 +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.ComponentModel;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.Win32;
namespace QuickLook.Plugin.IPreviewHandlers
{
/// <summary>
/// A Windows Forms host for Preview Handlers.
/// </summary>
public class PreviewHandlerHost : Control
{
/// <summary>
/// The GUID for the IShellItem interface.
/// </summary>
internal const string GuidIshellitem = "43826d1e-e718-42ee-bc55-a1e261c37bfe";
private IPreviewHandler _mCurrentPreviewHandler;
/// <summary>
/// Initialialises a new instance of the PreviewHandlerHost class.
/// </summary>
public PreviewHandlerHost()
{
Size = new Size(320, 240);
}
/// <summary>
/// Gets the GUID of the current preview handler.
/// </summary>
[Browsable(false)]
[ReadOnly(true)]
public Guid CurrentPreviewHandler { get; private set; } = Guid.Empty;
/// <summary>
/// Releases the unmanaged resources used by the PreviewHandlerHost and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
UnloadPreviewHandler();
if (_mCurrentPreviewHandler != null)
{
Marshal.FinalReleaseComObject(_mCurrentPreviewHandler);
_mCurrentPreviewHandler = null;
GC.Collect();
}
base.Dispose(disposing);
}
/// <summary>
/// Returns the GUID of the preview handler associated with the specified file.
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static Guid GetPreviewHandlerGUID(string filename)
{
// open the registry key corresponding to the file extension
var ext = Registry.ClassesRoot.OpenSubKey(Path.GetExtension(filename));
if (ext != null)
{
// open the key that indicates the GUID of the preview handler type
var test = ext.OpenSubKey("shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
if (test != null) return new Guid(Convert.ToString(test.GetValue(null)));
// sometimes preview handlers are declared on key for the class
var className = Convert.ToString(ext.GetValue(null));
if (className != null)
{
test = Registry.ClassesRoot.OpenSubKey(
className + "\\shellex\\{8895b1c6-b41f-4c1c-a562-0d564250836f}");
if (test != null) return new Guid(Convert.ToString(test.GetValue(null)));
}
}
return Guid.Empty;
}
/// <summary>
/// Resizes the hosted preview handler when this PreviewHandlerHost is resized.
/// </summary>
/// <param name="e"></param>
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
var r = ClientRectangle;
_mCurrentPreviewHandler?.SetRect(ref r);
}
/// <summary>
/// Opens the specified file using the appropriate preview handler and displays the result in this PreviewHandlerHost.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public bool Open(string path)
{
UnloadPreviewHandler();
if (string.IsNullOrEmpty(path))
return false;
// try to get GUID for the preview handler
var guid = GetPreviewHandlerGUID(path);
if (guid == Guid.Empty)
return false;
CurrentPreviewHandler = guid;
var o = Activator.CreateInstance(Type.GetTypeFromCLSID(CurrentPreviewHandler, true));
var fileInit = o as IInitializeWithFile;
if (fileInit == null)
return false;
fileInit.Initialize(path, 0);
_mCurrentPreviewHandler = o as IPreviewHandler;
if (_mCurrentPreviewHandler == null)
return false;
if (IsDisposed)
return false;
// bind the preview handler to the control's bounds and preview the content
var r = ClientRectangle;
_mCurrentPreviewHandler.SetWindow(Handle, ref r);
_mCurrentPreviewHandler.DoPreview();
return true;
}
/// <summary>
/// Unloads the preview handler hosted in this PreviewHandlerHost and closes the file stream.
/// </summary>
public void UnloadPreviewHandler()
{
try
{
_mCurrentPreviewHandler?.Unload();
}
catch (Exception)
{
// ignored
}
}
}
}

View File

@@ -1,12 +0,0 @@
<UserControl x:Class="QuickLook.Plugin.IPreviewHandlers.PreviewPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
x:Name="panel"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<WindowsFormsHost x:Name="presenter" />
</Grid>
</UserControl>

View File

@@ -1,69 +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.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.IPreviewHandlers
{
/// <summary>
/// Interaction logic for PreviewPanel.xaml
/// </summary>
public partial class PreviewPanel : UserControl, IDisposable
{
private PreviewHandlerHost _control;
public PreviewPanel()
{
InitializeComponent();
}
public void Dispose()
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
presenter.Child = null;
presenter?.Dispose();
_control?.Dispose();
_control = null;
}));
}
public void PreviewFile(string file, ContextObject context)
{
_control = new PreviewHandlerHost();
presenter.Child = _control;
_control.Open(file);
//SetForegroundWindow(new WindowInteropHelper(context.ViewerWindow).Handle);
//SetActiveWindow(presenter.Handle);
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetActiveWindow(IntPtr hWnd);
}
}

View File

@@ -1,68 +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.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("QuickLook.Plugin.IPreviewHandlers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("pooi.moe")]
[assembly: AssemblyProduct("QuickLook.Plugin.IPreviewHandlers")]
[assembly: AssemblyCopyright("Copyright © Paddy Xu 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E37675EA-D957-4495-8655-2609BF86756C}</ProjectGuid>
<OutputType>library</OutputType>
<RootNamespace>QuickLook.Plugin.IPreviewHandlers</RootNamespace>
<AssemblyName>QuickLook.Plugin.IPreviewHandlers</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="IInitializeWithFile.cs" />
<Compile Include="IPreviewHandler.cs" />
<Compile Include="Plugin.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="PreviewHandlerHost.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="PreviewPanel.xaml.cs">
<DependentUpon>PreviewPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\QuickLook.Common\QuickLook.Common.csproj">
<Project>{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}</Project>
<Name>QuickLook.Common</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="PreviewPanel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -43,7 +43,7 @@ namespace QuickLook.Plugin.ImageViewer
private ImagePanel _ip;
private NConvert _meta;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -31,7 +31,7 @@ namespace QuickLook.Plugin.MailViewer
private WebpagePanel _panel;
private string _tmpDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.MarkdownViewer
{
private WebpagePanel _panel;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.PDFViewer
private string _path;
private PdfViewerControl _pdfControl;
public int Priority => int.MaxValue;
public int Priority => 0;
public void Init()
{

View File

@@ -1,4 +1,4 @@
// Copyright © 2017 Paddy Xu
// Copyright © 2018 Paddy Xu
//
// This file is part of QuickLook program.
//
@@ -21,21 +21,10 @@ using System.Linq;
using System.Windows;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.IPreviewHandlers
namespace QuickLook.Plugin.PluginInstaller
{
public class Plugin : IViewer
{
private static readonly string[] Extensions =
{
".doc", ".docx", ".docm",
".xls", ".xlsx", ".xlsm", ".xlsb",
/*".vsd", ".vsdx",*/
".ppt", ".pptx",
".odt", ".ods", ".odp"
};
private PreviewPanel _panel;
public int Priority => int.MaxValue;
public void Init()
@@ -44,37 +33,30 @@ namespace QuickLook.Plugin.IPreviewHandlers
public bool CanHandle(string path)
{
if (Directory.Exists(path))
return false;
if (Extensions.Any(path.ToLower().EndsWith))
return PreviewHandlerHost.GetPreviewHandlerGUID(path) != Guid.Empty;
return false;
return !Directory.Exists(path) && path.ToLower().EndsWith(".qlviewer");
}
public void Prepare(string path, ContextObject context)
{
context.SetPreferredSizeFit(new Size {Width = 800, Height = 800}, 0.8);
context.PreferredSize = new Size { Width = 400, Height = 172 };
context.Title = "";
context.TitlebarOverlap = false;
context.TitlebarBlurVisibility = false;
context.TitlebarColourVisibility = false;
context.CanResize = false;
context.FullWindowDragging = true;
}
public void View(string path, ContextObject context)
{
_panel = new PreviewPanel();
context.ViewerContent = _panel;
context.Title = Path.GetFileName(path);
_panel.PreviewFile(path, context);
context.ViewerContent = new PluginInfoPanel(path);
context.IsBusy = false;
}
public void Cleanup()
{
GC.SuppressFinalize(this);
_panel?.Dispose();
_panel = null;
}
}
}

View File

@@ -0,0 +1,45 @@
<UserControl x:Class="QuickLook.Plugin.PluginInstaller.PluginInfoPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
FontSize="14"
mc:Ignorable="d" Width="400" Height="172" UseLayoutRounding="True">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="15" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="Auto" />
<RowDefinition Height="10" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<TextBlock x:Name="filename" Grid.Row="1" Grid.Column="1" FontSize="19" Padding="3"
TextWrapping="Wrap"
LineHeight="25" MaxHeight="60" TextTrimming="CharacterEllipsis" FontWeight="SemiBold">
QuickLook.Plugin.PluginInstaller
</TextBlock>
<TextBlock x:Name="description" Grid.Row="3" Grid.Column="1" Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}">
I am a potato.
</TextBlock>
<Button x:Name="btnInstall" Content="Click here to install this plugin." Grid.Column="1" Grid.Row="4"
FontWeight="SemiBold" Foreground="{DynamicResource WindowTextForegroundAlternative}"
Style="{StaticResource CaptionTextButtonStyle}" HorizontalAlignment="Right" Margin="0,0,20,0" />
</Grid>
</Grid>
</UserControl>

View File

@@ -0,0 +1,79 @@
// 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.Globalization;
using System.IO;
using System.IO.Compression;
using System.Windows.Controls;
using System.Xml;
namespace QuickLook.Plugin.PluginInstaller
{
public partial class PluginInfoPanel : UserControl
{
private readonly string _path;
public PluginInfoPanel(string path)
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
_path = path;
ReadInfo();
}
private void ReadInfo()
{
filename.Text = Path.GetFileNameWithoutExtension(_path);
var xml = LoadXml(GetFileFromZip(_path, "Metadata.config"));
}
private XmlDocument LoadXml(Stream data)
{
var doc = new XmlDocument();
try
{
doc.Load(data);
return doc;
}
catch (XmlException)
{
return null;
}
}
private Stream GetFileFromZip(string archive, string entry)
{
var ms = new MemoryStream();
using (var zip = ZipFile.Open(archive, ZipArchiveMode.Read))
{
using (var s = zip.GetEntry(entry)?.Open())
{
s?.CopyTo(ms);
}
}
return ms;
}
}
}

View File

@@ -21,12 +21,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("QuickLook.Plugin.ImageViewer")]
[assembly: AssemblyTitle("QuickLook.Plugin.PluginInstaller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("pooi.moe")]
[assembly: AssemblyProduct("QuickLook.Plugin.ImageViewer")]
[assembly: AssemblyCopyright("Copyright © Paddy Xu 2017")]
[assembly: AssemblyProduct("QuickLook.Plugin.PluginInstaller")]
[assembly: AssemblyCopyright("Copyright © Paddy Xu 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fe5a5111-9607-4721-a7be-422754002ed8")]
[assembly: Guid("042b5cb9-aaf0-4a61-b847-deb2e06f60ab")]
// Version information for an assembly consists of the following four values:
//

View File

@@ -7,8 +7,8 @@
<ProjectGuid>{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuickLook.Plugin.CameraRawViewer</RootNamespace>
<AssemblyName>QuickLook.Plugin.CameraRawViewer</AssemblyName>
<RootNamespace>QuickLook.Plugin.PluginInstaller</RootNamespace>
<AssemblyName>QuickLook.Plugin.PluginInstaller</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@@ -35,7 +35,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.CameraRawViewer\</OutputPath>
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.PluginInstaller\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -43,7 +43,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.CameraRawViewer\</OutputPath>
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.PluginInstaller\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
@@ -63,14 +63,19 @@
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="DCraw.cs" />
<Compile Include="PluginInfoPanel.xaml.cs">
<DependentUpon>PluginInfoPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@@ -80,19 +85,16 @@
<Name>QuickLook.Common</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\QuickLook.Plugin.ImageViewer\QuickLook.Plugin.ImageViewer.csproj">
<Project>{fe5a5111-9607-4721-a7be-422754002ed8}</Project>
<Name>QuickLook.Plugin.ImageViewer</Name>
<Private>False</Private>
<ProjectReference Include="..\..\QuickLook\QuickLook.csproj">
<Project>{8b4a9ce5-67b5-4a94-81cb-3771f688fdeb}</Project>
<Name>QuickLook</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="dcraw32.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dcraw64.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Page Include="PluginInfoPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -31,7 +31,7 @@ namespace QuickLook.Plugin.TextViewer
{
private TextViewerPanel _tvp;
public int Priority => 0;
public int Priority => -5;
public void Init()
{

View File

@@ -43,7 +43,7 @@ namespace QuickLook.Plugin.VideoViewer
private ViewerPanel _vp;
public int Priority => 0 - 10; // make it lower than TextViewer
public int Priority => -10; // make it lower than TextViewer
public void Init()
{

View File

@@ -48,13 +48,10 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "QuickLook.Installer", "Quic
{DE2E3BC5-6AB2-4420-A160-48C7A7506C1C} = {DE2E3BC5-6AB2-4420-A160-48C7A7506C1C}
{794E4DCF-F715-4836-9D30-ABD296586D23} = {794E4DCF-F715-4836-9D30-ABD296586D23}
{8B4A9CE5-67B5-4A94-81CB-3771F688FDEB} = {8B4A9CE5-67B5-4A94-81CB-3771F688FDEB}
{E37675EA-D957-4495-8655-2609BF86756C} = {E37675EA-D957-4495-8655-2609BF86756C}
{CE22A1F3-7F2C-4EC8-BFDE-B58D0EB625FC} = {CE22A1F3-7F2C-4EC8-BFDE-B58D0EB625FC}
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA} = {BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.IPreviewHandlers", "QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\QuickLook.Plugin.IPreviewHandlers.csproj", "{E37675EA-D957-4495-8655-2609BF86756C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QuickLook.Native64", "QuickLook.Native\QuickLook.Native64\QuickLook.Native64.vcxproj", "{794E4DCF-F715-4836-9D30-ABD296586D23}"
ProjectSection(ProjectDependencies) = postProject
{2C58F9B2-D8FA-4586-942B-5170CECE5963} = {2C58F9B2-D8FA-4586-942B-5170CECE5963}
@@ -73,10 +70,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.MailViewer
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Common", "QuickLook.Common\QuickLook.Common.csproj", "{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.CameraRawViewer", "QuickLook.Plugin\QuickLook.Plugin.CameraRawViewer\QuickLook.Plugin.CameraRawViewer.csproj", "{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.EpubViewer", "QuickLook.Plugin\QuickLook.Plugin.EpubViewer\QuickLook.Plugin.EpubViewer.csproj", "{260C9E70-0582-471F-BFB5-022CFE7984C8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.PluginInstaller", "QuickLook.Plugin\QuickLook.Plugin.PluginInstaller\QuickLook.Plugin.PluginInstaller.csproj", "{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -163,14 +160,6 @@ Global
{F0214FC2-EFBE-426C-842D-B42BC37D9525}.Release|Any CPU.Build.0 = Release|x86
{F0214FC2-EFBE-426C-842D-B42BC37D9525}.Release|x86.ActiveCfg = Release|x86
{F0214FC2-EFBE-426C-842D-B42BC37D9525}.Release|x86.Build.0 = Release|x86
{E37675EA-D957-4495-8655-2609BF86756C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E37675EA-D957-4495-8655-2609BF86756C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E37675EA-D957-4495-8655-2609BF86756C}.Debug|x86.ActiveCfg = Debug|x86
{E37675EA-D957-4495-8655-2609BF86756C}.Debug|x86.Build.0 = Debug|x86
{E37675EA-D957-4495-8655-2609BF86756C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E37675EA-D957-4495-8655-2609BF86756C}.Release|Any CPU.Build.0 = Release|Any CPU
{E37675EA-D957-4495-8655-2609BF86756C}.Release|x86.ActiveCfg = Release|x86
{E37675EA-D957-4495-8655-2609BF86756C}.Release|x86.Build.0 = Release|x86
{794E4DCF-F715-4836-9D30-ABD296586D23}.Debug|Any CPU.ActiveCfg = Debug|x64
{794E4DCF-F715-4836-9D30-ABD296586D23}.Debug|Any CPU.Build.0 = Debug|x64
{794E4DCF-F715-4836-9D30-ABD296586D23}.Debug|x86.ActiveCfg = Debug|x64
@@ -207,13 +196,6 @@ Global
{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|Any CPU.Build.0 = Release|Any CPU
{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|x86.ActiveCfg = Release|Any CPU
{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|x86.Build.0 = Release|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|x86.ActiveCfg = Debug|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|x86.Build.0 = Debug|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|x86.ActiveCfg = Release|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|x86.Build.0 = Release|x86
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -222,6 +204,14 @@ Global
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Release|Any CPU.Build.0 = Release|Any CPU
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Release|x86.ActiveCfg = Release|Any CPU
{260C9E70-0582-471F-BFB5-022CFE7984C8}.Release|x86.Build.0 = Release|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|x86.ActiveCfg = Debug|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Debug|x86.Build.0 = Debug|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|Any CPU.Build.0 = Release|Any CPU
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|x86.ActiveCfg = Release|x86
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -235,13 +225,12 @@ Global
{1B746D92-49A5-4A37-9D75-DCC490393290} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{CE22A1F3-7F2C-4EC8-BFDE-B58D0EB625FC} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{AB1270AF-7EB4-4B4F-9E09-6404F1A28EA0} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{E37675EA-D957-4495-8655-2609BF86756C} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{794E4DCF-F715-4836-9D30-ABD296586D23} = {D18A23FF-76BD-43BD-AC32-786D166EBAC9}
{2C58F9B2-D8FA-4586-942B-5170CECE5963} = {D18A23FF-76BD-43BD-AC32-786D166EBAC9}
{863ECAAC-18D9-4256-A27D-0F308089FB47} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{45E94893-3076-4A8E-8969-6955B6340739} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{260C9E70-0582-471F-BFB5-022CFE7984C8} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
{BD58F3FC-7601-47BA-AAA1-D8A9D54A33DA} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3761C32-8C5F-498A-892B-3B0882994B62}