mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-22 03:00:14 +08:00
..
This commit is contained in:
@@ -15,9 +15,16 @@ namespace QuickLook.Plugin.ArchiveViewer
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
IconManager.ClearCache();
|
IconManager.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ArchiveFileListView()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetDataContext(object context)
|
public void SetDataContext(object context)
|
||||||
{
|
{
|
||||||
treeGrid.DataContext = context;
|
treeGrid.DataContext = context;
|
||||||
|
|||||||
@@ -28,9 +28,16 @@ namespace QuickLook.Plugin.ArchiveViewer
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
fileListView.Dispose();
|
fileListView.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ArchiveInfoPanel()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadArchive(string path)
|
private void LoadArchive(string path)
|
||||||
{
|
{
|
||||||
LoadItemsFromArchive(path);
|
LoadItemsFromArchive(path);
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ namespace QuickLook.Plugin.ArchiveViewer
|
|||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SevenZipExtractor archive = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (archive = new SevenZipExtractor(path))
|
using (var archive = new SevenZipExtractor(path))
|
||||||
{
|
{
|
||||||
// dummy access to the data. If it throws exception, return false
|
// dummy access to the data. If it throws exception, return false
|
||||||
if (archive.ArchiveFileData == null)
|
if (archive.ArchiveFileData == null)
|
||||||
@@ -42,10 +41,6 @@ namespace QuickLook.Plugin.ArchiveViewer
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
archive?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -63,9 +58,16 @@ namespace QuickLook.Plugin.ArchiveViewer
|
|||||||
container.Title = $"{Path.GetFileName(path)}";
|
container.Title = $"{Path.GetFileName(path)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_panel.Dispose();
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
_panel?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
~Plugin()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="SevenZipSharp">
|
<Reference Include="SevenZipSharp">
|
||||||
<HintPath>References\SevenZipSharp.dll</HintPath>
|
<HintPath>References\SevenZipSharp.dll</HintPath>
|
||||||
|
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace QuickLook.Plugin.ImageViewer
|
|||||||
container.Title = $"{Path.GetFileName(path)} ({_imageSize.Width} × {_imageSize.Height})";
|
container.Title = $"{Path.GetFileName(path)} ({_imageSize.Width} × {_imageSize.Height})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
<Reference Include="WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\WpfAnimatedGif.1.4.14\lib\net\WpfAnimatedGif.dll</HintPath>
|
<HintPath>..\..\packages\WpfAnimatedGif.1.4.14\lib\net\WpfAnimatedGif.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using Microsoft.Office.Interop.PowerPoint;
|
||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using Application = Microsoft.Office.Interop.Excel.Application;
|
||||||
|
using Task = System.Threading.Tasks.Task;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.OfficeViewer
|
||||||
|
{
|
||||||
|
internal class OfficeInteropWrapper : IDisposable
|
||||||
|
{
|
||||||
|
public enum FileTypeEnum
|
||||||
|
{
|
||||||
|
Word,
|
||||||
|
Excel,
|
||||||
|
PowerPoint
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly string _path;
|
||||||
|
private readonly string _tempPdf = Path.GetTempFileName();
|
||||||
|
|
||||||
|
private Application _excelApp;
|
||||||
|
private Microsoft.Office.Interop.PowerPoint.Application _powerpointApp;
|
||||||
|
private Microsoft.Office.Interop.Word.Application _wordApp;
|
||||||
|
|
||||||
|
public OfficeInteropWrapper(string path)
|
||||||
|
{
|
||||||
|
_path = path;
|
||||||
|
|
||||||
|
switch (Path.GetExtension(path).ToLower())
|
||||||
|
{
|
||||||
|
case ".doc":
|
||||||
|
case ".docx":
|
||||||
|
FileType = FileTypeEnum.Word;
|
||||||
|
break;
|
||||||
|
case ".xls":
|
||||||
|
case ".xlsx":
|
||||||
|
FileType = FileTypeEnum.Excel;
|
||||||
|
break;
|
||||||
|
case ".ppt":
|
||||||
|
case ".pptx":
|
||||||
|
FileType = FileTypeEnum.PowerPoint;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException($"{path} is not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileTypeEnum FileType { get; }
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
// communicate with COM in a separate thread
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//_wordApp?.Documents.Close(false);
|
||||||
|
_wordApp?.Quit(false);
|
||||||
|
_wordApp = null;
|
||||||
|
|
||||||
|
_excelApp?.Workbooks.Close();
|
||||||
|
_excelApp?.Quit();
|
||||||
|
_excelApp = null;
|
||||||
|
|
||||||
|
_powerpointApp?.Quit();
|
||||||
|
_powerpointApp = null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e.Message);
|
||||||
|
Debug.WriteLine(e.StackTrace);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SaveAsPdf()
|
||||||
|
{
|
||||||
|
if (_wordApp == null && _excelApp == null && _powerpointApp == null)
|
||||||
|
throw new Exception("Office application launch failed.");
|
||||||
|
|
||||||
|
var succeeded = false;
|
||||||
|
|
||||||
|
// communicate with COM in a separate thread
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (FileType)
|
||||||
|
{
|
||||||
|
case FileTypeEnum.Word:
|
||||||
|
_wordApp.ActiveDocument.ExportAsFixedFormat(_tempPdf,
|
||||||
|
WdExportFormat.wdExportFormatPDF);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
case FileTypeEnum.Excel:
|
||||||
|
_excelApp.ActiveWorkbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF,
|
||||||
|
_tempPdf);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
case FileTypeEnum.PowerPoint:
|
||||||
|
_powerpointApp.ActivePresentation.ExportAsFixedFormat(_tempPdf,
|
||||||
|
PpFixedFormatType.ppFixedFormatTypePDF);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException($"{_path} is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e.Message);
|
||||||
|
Debug.WriteLine(e.StackTrace);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Wait();
|
||||||
|
|
||||||
|
if (succeeded)
|
||||||
|
return FileType == FileTypeEnum.Excel
|
||||||
|
? _tempPdf + ".pdf"
|
||||||
|
: _tempPdf; // Excel will add ".pdf" to our filename
|
||||||
|
|
||||||
|
Dispose();
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadApplication()
|
||||||
|
{
|
||||||
|
var succeeded = false;
|
||||||
|
|
||||||
|
// communicate with COM in a separate thread
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (FileType)
|
||||||
|
{
|
||||||
|
case FileTypeEnum.Word:
|
||||||
|
_wordApp = new Microsoft.Office.Interop.Word.Application();
|
||||||
|
_wordApp.Documents.Add(_path);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
case FileTypeEnum.Excel:
|
||||||
|
_excelApp = new Application();
|
||||||
|
_excelApp.Workbooks.Add(_path);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
case FileTypeEnum.PowerPoint:
|
||||||
|
_powerpointApp = new Microsoft.Office.Interop.PowerPoint.Application();
|
||||||
|
_powerpointApp.Presentations.Open(_path);
|
||||||
|
succeeded = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException($"{_path} is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e.Message);
|
||||||
|
Debug.WriteLine(e.StackTrace);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Wait();
|
||||||
|
|
||||||
|
if (!succeeded)
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
~OfficeInteropWrapper()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
|
using QuickLook.Plugin.PDFViewer;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.OfficeViewer
|
||||||
|
{
|
||||||
|
public class PluginInterface : IViewer
|
||||||
|
{
|
||||||
|
private string _pdfPath = "";
|
||||||
|
private PdfViewerControl _pdfViewer;
|
||||||
|
|
||||||
|
public int Priority => int.MaxValue;
|
||||||
|
|
||||||
|
public bool CanHandle(string path)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (Path.GetExtension(path).ToLower())
|
||||||
|
{
|
||||||
|
case ".doc":
|
||||||
|
case ".docx":
|
||||||
|
case ".xls":
|
||||||
|
case ".xlsx":
|
||||||
|
case ".ppt":
|
||||||
|
case ".pptx":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Prepare(string path, ViewContentContainer container)
|
||||||
|
{
|
||||||
|
container.SetPreferedSizeFit(new Size {Width = 800, Height = 600}, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void View(string path, ViewContentContainer container)
|
||||||
|
{
|
||||||
|
using (var officeApp = new OfficeInteropWrapper(path))
|
||||||
|
{
|
||||||
|
_pdfPath = officeApp.SaveAsPdf();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_pdfPath))
|
||||||
|
throw new Exception("COM failed.");
|
||||||
|
|
||||||
|
_pdfViewer = new PdfViewerControl();
|
||||||
|
|
||||||
|
_pdfViewer.Loaded += (sender, e) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_pdfViewer.LoadPdf(_pdfPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.Title = $"{Path.GetFileName(path)} (1 / {_pdfViewer.TotalPages})";
|
||||||
|
};
|
||||||
|
_pdfViewer.CurrentPageChanged += (sender, e) => container.Title =
|
||||||
|
$"{Path.GetFileName(path)} ({_pdfViewer.CurrectPage + 1} / {_pdfViewer.TotalPages})";
|
||||||
|
|
||||||
|
container.SetContent(_pdfViewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
// release the Pdf file first
|
||||||
|
_pdfViewer?.Dispose();
|
||||||
|
_pdfViewer = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(_pdfPath);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~PluginInterface()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
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.OfficeViewer")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("QuickLook.Plugin.OfficeViewer")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 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.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
62
QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Properties/Resources.Designer.cs
generated
Normal file
62
QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.OfficeViewer.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if ((resourceMan == null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("QuickLook.Plugin.OfficeViewer.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
26
QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Properties/Settings.Designer.cs
generated
Normal file
26
QuickLook.Plugin/QuickLook.Plugin.OfficeViewer/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.OfficeViewer.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
|
||||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
<?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.OfficeViewer</RootNamespace>
|
||||||
|
<AssemblyName>QuickLook.Plugin.OfficeViewer</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\Build\Debug\Plugins\QuickLook.Plugin.OfficeViewer\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>..\..\Build\Debug\Plugins\QuickLook.Plugin.OfficeViewer\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Interop.PowerPoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Office.Interop.PowerPoint.15.0.4420.1017\lib\net20\Microsoft.Office.Interop.PowerPoint.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
<HintPath>..\..\packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xaml">
|
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="OfficeInteropWrapper.cs" />
|
||||||
|
<Compile Include="PluginInterface.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\QuickLook\QuickLook.csproj">
|
||||||
|
<Project>{8b4a9ce5-67b5-4a94-81cb-3771f688fdeb}</Project>
|
||||||
|
<Name>QuickLook</Name>
|
||||||
|
<Private>False</Private>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\QuickLook.Plugin.PDFViewer\QuickLook.Plugin.PdfViewer.csproj">
|
||||||
|
<Project>{a82ac69c-edf5-4f0d-8cbd-8e5e3c06e64d}</Project>
|
||||||
|
<Name>QuickLook.Plugin.PdfViewer</Name>
|
||||||
|
<Private>False</Private>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.Office.Interop.PowerPoint" version="15.0.4420.1017" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" targetFramework="net452" />
|
||||||
|
</packages>
|
||||||
@@ -23,11 +23,18 @@ namespace QuickLook.Plugin.PDFViewer
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
LibMuPdf.NativeMethods.CloseDocument(_doc);
|
LibMuPdf.NativeMethods.CloseDocument(_doc);
|
||||||
LibMuPdf.NativeMethods.CloseStream(_stm);
|
LibMuPdf.NativeMethods.CloseStream(_stm);
|
||||||
LibMuPdf.NativeMethods.FreeContext(_ctx);
|
LibMuPdf.NativeMethods.FreeContext(_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~PdfFile()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsLastPage(int pageId)
|
public bool IsLastPage(int pageId)
|
||||||
{
|
{
|
||||||
return pageId >= TotalPages;
|
return pageId >= TotalPages;
|
||||||
|
|||||||
@@ -55,13 +55,20 @@ namespace QuickLook.Plugin.PDFViewer
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_whellMonitor.Dispose();
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
_whellMonitor?.Dispose();
|
||||||
PdfHandleForThumbnails?.Dispose();
|
PdfHandleForThumbnails?.Dispose();
|
||||||
PdfHandle?.Dispose();
|
PdfHandle?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
~PdfViewerControl()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public event EventHandler CurrentPageChanged;
|
public event EventHandler CurrentPageChanged;
|
||||||
|
|
||||||
private void NavigatePage(object sender, MouseWheelEventArgs e)
|
private void NavigatePage(object sender, MouseWheelEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace QuickLook.Plugin.PDFViewer
|
namespace QuickLook.Plugin.PDFViewer
|
||||||
@@ -45,10 +46,17 @@ namespace QuickLook.Plugin.PDFViewer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_pdfControl.Dispose();
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
_pdfControl?.Dispose();
|
||||||
_pdfControl = null;
|
_pdfControl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Plugin()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace QuickLook.Plugin.TextViewer
|
|||||||
container.Title = $"{Path.GetFileName(path)}";
|
container.Title = $"{Path.GetFileName(path)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.PdfViewer"
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.TextViewer", "QuickLook.Plugin\QuickLook.Plugin.TextViewer\QuickLook.Plugin.TextViewer.csproj", "{AE041682-E3A1-44F6-8BB4-916A98D89FBE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.TextViewer", "QuickLook.Plugin\QuickLook.Plugin.TextViewer\QuickLook.Plugin.TextViewer.csproj", "{AE041682-E3A1-44F6-8BB4-916A98D89FBE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.OfficeViewer", "QuickLook.Plugin\QuickLook.Plugin.OfficeViewer\QuickLook.Plugin.OfficeViewer.csproj", "{E37675EA-D957-4495-8655-2609BF86756C}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -74,6 +76,14 @@ Global
|
|||||||
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|x86.ActiveCfg = Release|Any CPU
|
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|x86.Build.0 = Release|Any CPU
|
{AE041682-E3A1-44F6-8BB4-916A98D89FBE}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{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|Any CPU
|
||||||
|
{E37675EA-D957-4495-8655-2609BF86756C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{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|Any CPU
|
||||||
|
{E37675EA-D957-4495-8655-2609BF86756C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -83,5 +93,6 @@ Global
|
|||||||
{FE5A5111-9607-4721-A7BE-422754002ED8} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
{FE5A5111-9607-4721-A7BE-422754002ED8} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||||
{A82AC69C-EDF5-4F0D-8CBD-8E5E3C06E64D} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
{A82AC69C-EDF5-4F0D-8CBD-8E5E3C06E64D} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||||
{AE041682-E3A1-44F6-8BB4-916A98D89FBE} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
{AE041682-E3A1-44F6-8BB4-916A98D89FBE} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||||
|
{E37675EA-D957-4495-8655-2609BF86756C} = {06EFDBE0-6408-4B37-BCF2-0CF9EBEA2E93}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using QuickLook.Utilities;
|
|
||||||
|
|
||||||
namespace QuickLook
|
namespace QuickLook
|
||||||
{
|
{
|
||||||
|
|||||||
12
QuickLook/ExtensionMethods/TypeExtensions.cs
Normal file
12
QuickLook/ExtensionMethods/TypeExtensions.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace QuickLook.ExtensionMethods
|
||||||
|
{
|
||||||
|
internal static class TypeExtensions
|
||||||
|
{
|
||||||
|
public static T CreateInstance<T>(this Type t)
|
||||||
|
{
|
||||||
|
return (T) Activator.CreateInstance(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using QuickLook.NativeMethods;
|
using QuickLook.NativeMethods;
|
||||||
|
|
||||||
namespace QuickLook.Utilities
|
namespace QuickLook
|
||||||
{
|
{
|
||||||
internal class GlobalKeyboardHook
|
internal class GlobalKeyboardHook : IDisposable
|
||||||
{
|
{
|
||||||
private static GlobalKeyboardHook _instance;
|
private static GlobalKeyboardHook _instance;
|
||||||
|
|
||||||
@@ -18,12 +18,19 @@ namespace QuickLook.Utilities
|
|||||||
Hook();
|
Hook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
Unhook();
|
||||||
|
}
|
||||||
|
|
||||||
internal event KeyEventHandler KeyDown;
|
internal event KeyEventHandler KeyDown;
|
||||||
internal event KeyEventHandler KeyUp;
|
internal event KeyEventHandler KeyUp;
|
||||||
|
|
||||||
~GlobalKeyboardHook()
|
~GlobalKeyboardHook()
|
||||||
{
|
{
|
||||||
Unhook();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static GlobalKeyboardHook GetInstance()
|
internal static GlobalKeyboardHook GetInstance()
|
||||||
@@ -16,7 +16,7 @@ namespace QuickLook
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for MainWindow.xaml
|
/// Interaction logic for MainWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class MainWindow : Window, INotifyPropertyChanged
|
internal partial class MainWindow : Window, INotifyPropertyChanged, IDisposable
|
||||||
{
|
{
|
||||||
internal MainWindow()
|
internal MainWindow()
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,6 @@ namespace QuickLook
|
|||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
|
||||||
ContentRendered += (sender, e) => AeroGlass.EnableBlur(this);
|
ContentRendered += (sender, e) => AeroGlass.EnableBlur(this);
|
||||||
Closed += MainWindow_Closed;
|
|
||||||
|
|
||||||
buttonCloseWindow.MouseLeftButtonUp += CloseCurrentWindow;
|
buttonCloseWindow.MouseLeftButtonUp += CloseCurrentWindow;
|
||||||
titlebarTitleArea.MouseLeftButtonDown += (sender, e) => DragMove();
|
titlebarTitleArea.MouseLeftButtonDown += (sender, e) => DragMove();
|
||||||
@@ -33,14 +32,6 @@ namespace QuickLook
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
private void MainWindow_Closed(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
viewContentContainer.ViewerPlugin.Close();
|
|
||||||
viewContentContainer.ViewerPlugin = null;
|
|
||||||
|
|
||||||
GC.Collect();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal new void Show()
|
internal new void Show()
|
||||||
{
|
{
|
||||||
loadingIconLayer.Opacity = 1;
|
loadingIconLayer.Opacity = 1;
|
||||||
@@ -108,5 +99,17 @@ namespace QuickLook
|
|||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
viewContentContainer?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
~MainWindow()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,6 @@
|
|||||||
bool CanHandle(string path);
|
bool CanHandle(string path);
|
||||||
void Prepare(string path, ViewContentContainer container);
|
void Prepare(string path, ViewContentContainer container);
|
||||||
void View(string path, ViewContentContainer container);
|
void View(string path, ViewContentContainer container);
|
||||||
void Close();
|
void Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
using System.Windows;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace QuickLook.Plugin.InfoPanel
|
namespace QuickLook.Plugin.InfoPanel
|
||||||
{
|
{
|
||||||
public class PluginInterface : IViewer
|
public class PluginInterface : IViewer, IDisposable
|
||||||
{
|
{
|
||||||
private InfoPanel _ip;
|
private InfoPanel _ip;
|
||||||
|
|
||||||
@@ -28,9 +29,14 @@ namespace QuickLook.Plugin.InfoPanel
|
|||||||
container.SetContent(_ip);
|
container.SetContent(_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_ip.Stop = true;
|
_ip.Stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~PluginInterface()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ namespace QuickLook.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ViewContentContainer.xaml
|
/// Interaction logic for ViewContentContainer.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ViewContentContainer : UserControl, INotifyPropertyChanged
|
public partial class ViewContentContainer : UserControl, INotifyPropertyChanged, IDisposable
|
||||||
{
|
{
|
||||||
private string _title = string.Empty;
|
private string _title = string.Empty;
|
||||||
|
|
||||||
@@ -35,6 +35,13 @@ namespace QuickLook.Plugin
|
|||||||
|
|
||||||
public bool CanResize { get; set; } = true;
|
public bool CanResize { get; set; } = true;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
|
ViewerPlugin?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
public void SetContent(object content)
|
public void SetContent(object content)
|
||||||
@@ -71,5 +78,10 @@ namespace QuickLook.Plugin
|
|||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ViewContentContainer()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using QuickLook.ExtensionMethods;
|
||||||
using QuickLook.Plugin;
|
using QuickLook.Plugin;
|
||||||
using QuickLook.Plugin.InfoPanel;
|
using QuickLook.Plugin.InfoPanel;
|
||||||
|
|
||||||
@@ -17,9 +18,9 @@ namespace QuickLook
|
|||||||
LoadPlugins();
|
LoadPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IViewer DefaultPlugin { get; set; } = new PluginInterface();
|
internal Type DefaultPlugin { get; } = typeof(PluginInterface);
|
||||||
|
|
||||||
internal List<IViewer> LoadedPlugins { get; private set; } = new List<IViewer>();
|
internal List<Type> LoadedPlugins { get; private set; } = new List<Type>();
|
||||||
|
|
||||||
internal static PluginManager GetInstance()
|
internal static PluginManager GetInstance()
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,10 @@ namespace QuickLook
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var matched = GetInstance()
|
var matched = GetInstance()
|
||||||
.LoadedPlugins.FirstOrDefault(plugin => plugin.CanHandle(path));
|
.LoadedPlugins.FirstOrDefault(plugin => plugin.CreateInstance<IViewer>().CanHandle(path))
|
||||||
|
?.CreateInstance<IViewer>();
|
||||||
|
|
||||||
return matched ?? DefaultPlugin;
|
return matched ?? DefaultPlugin.CreateInstance<IViewer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPlugins()
|
private void LoadPlugins()
|
||||||
@@ -49,10 +51,10 @@ namespace QuickLook
|
|||||||
where !t.IsInterface && !t.IsAbstract
|
where !t.IsInterface && !t.IsAbstract
|
||||||
where typeof(IViewer).IsAssignableFrom(t)
|
where typeof(IViewer).IsAssignableFrom(t)
|
||||||
select t).ToList()
|
select t).ToList()
|
||||||
.ForEach(type => LoadedPlugins.Add((IViewer) Activator.CreateInstance(type)));
|
.ForEach(type => LoadedPlugins.Add(type));
|
||||||
});
|
});
|
||||||
|
|
||||||
LoadedPlugins = LoadedPlugins.OrderByDescending(i => i.Priority).ToList();
|
LoadedPlugins = LoadedPlugins.OrderByDescending(i => i.CreateInstance<IViewer>().Priority).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
|
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
|
<HintPath>..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
|
||||||
|
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
@@ -74,6 +75,7 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="ExtensionMethods\TypeExtensions.cs" />
|
||||||
<Compile Include="PluginManager.cs" />
|
<Compile Include="PluginManager.cs" />
|
||||||
<Compile Include="Plugin\InfoPanel\Extensions.cs" />
|
<Compile Include="Plugin\InfoPanel\Extensions.cs" />
|
||||||
<Compile Include="Plugin\InfoPanel\FileHelper.cs" />
|
<Compile Include="Plugin\InfoPanel\FileHelper.cs" />
|
||||||
@@ -110,7 +112,7 @@
|
|||||||
<Compile Include="NativeMethods\User32.cs" />
|
<Compile Include="NativeMethods\User32.cs" />
|
||||||
<Compile Include="Properties\Annotations.cs" />
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Utilities\AeroGlass.cs" />
|
<Compile Include="Utilities\AeroGlass.cs" />
|
||||||
<Compile Include="Utilities\GlobalKeyboardHook.cs" />
|
<Compile Include="GlobalKeyboardHook.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using QuickLook.ExtensionMethods;
|
||||||
using QuickLook.Plugin;
|
using QuickLook.Plugin;
|
||||||
using QuickLook.Utilities;
|
using QuickLook.Utilities;
|
||||||
|
|
||||||
@@ -33,16 +35,24 @@ namespace QuickLook
|
|||||||
private void BeginShowNewWindow(IViewer matchedPlugin, string path)
|
private void BeginShowNewWindow(IViewer matchedPlugin, string path)
|
||||||
{
|
{
|
||||||
_viewWindow = new MainWindow();
|
_viewWindow = new MainWindow();
|
||||||
_viewWindow.Closed += (sender2, e2) => { _viewWindow = null; };
|
_viewWindow.Closed += (sender2, e2) =>
|
||||||
|
{
|
||||||
|
_viewWindow.Dispose();
|
||||||
|
_viewWindow = null;
|
||||||
|
GC.Collect();
|
||||||
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_viewWindow.BeginShow(matchedPlugin, path);
|
_viewWindow.BeginShow(matchedPlugin, path);
|
||||||
}
|
}
|
||||||
catch (Exception) // if current plugin failed, switch to default one
|
catch (Exception e) // if current plugin failed, switch to default one
|
||||||
{
|
{
|
||||||
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin.GetType())
|
Debug.WriteLine(e.ToString());
|
||||||
_viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin, path);
|
Debug.WriteLine(e.StackTrace);
|
||||||
|
|
||||||
|
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
|
||||||
|
_viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>(), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +61,6 @@ namespace QuickLook
|
|||||||
if (_viewWindow != null)
|
if (_viewWindow != null)
|
||||||
{
|
{
|
||||||
_viewWindow.Close();
|
_viewWindow.Close();
|
||||||
_viewWindow = null;
|
|
||||||
|
|
||||||
GC.Collect();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user