Allow plugin initialization when application starts

This commit is contained in:
Paddy Xu
2017-06-03 13:07:48 +03:00
parent 5886ee5c12
commit fb394288dd
12 changed files with 59 additions and 2 deletions

View File

@@ -11,6 +11,10 @@ namespace QuickLook.Plugin.ArchiveViewer
public int Priority => 0;
public bool AllowsTransparency => true;
public void Init()
{
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -12,6 +12,11 @@ namespace QuickLook.Plugin.HtmlViewer
public int Priority => int.MaxValue;
public bool AllowsTransparency => false;
public void Init()
{
Helper.SetBrowserFeatureControl();
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -14,8 +14,6 @@ namespace QuickLook.Plugin.HtmlViewer
public WebpagePanel()
{
InitializeComponent();
Helper.SetBrowserFeatureControl();
}
public void Dispose()

View File

@@ -11,6 +11,10 @@ namespace QuickLook.Plugin.IPreviewHandlers
public int Priority => int.MaxValue;
public bool AllowsTransparency => false;
public void Init()
{
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -2,6 +2,7 @@
using System.Linq;
using System.Reflection;
using System.Windows;
using ImageMagick;
namespace QuickLook.Plugin.ImageViewer
{
@@ -23,6 +24,11 @@ namespace QuickLook.Plugin.ImageViewer
public int Priority => int.MaxValue;
public bool AllowsTransparency => true;
public void Init()
{
new MagickImage().Dispose();
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -13,6 +13,10 @@ namespace QuickLook.Plugin.MarkdownViewer
public int Priority => int.MaxValue;
public bool AllowsTransparency => false;
public void Init()
{
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -12,6 +12,10 @@ namespace QuickLook.Plugin.PDFViewer
public int Priority => int.MaxValue;
public bool AllowsTransparency => true;
public void Init()
{
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -11,6 +11,10 @@ namespace QuickLook.Plugin.TextViewer
public int Priority => 0;
public bool AllowsTransparency => true;
public void Init()
{
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -13,6 +13,11 @@ namespace QuickLook.Plugin.VideoViewer
public int Priority => int.MaxValue;
public bool AllowsTransparency => true;
public void Init()
{
MediaElement.FFmpegPaths.RegisterFFmpeg();
}
public bool CanHandle(string path)
{
if (Directory.Exists(path))

View File

@@ -16,6 +16,11 @@
/// </summary>
bool AllowsTransparency { get; }
/// <summary>
/// Do ont-time job when application starts. You may extract nessessary resource here.
/// </summary>
void Init();
/// <summary>
/// Determine whether this plugin can open this file. Please also check the file header, if applicable.
/// </summary>

View File

@@ -9,6 +9,10 @@ namespace QuickLook.Plugin.InfoPanel
public int Priority => int.MinValue;
public bool AllowsTransparency => true;
public void Init()
{
}
public bool CanHandle(string sample)
{
return true;

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using QuickLook.ExtensionMethods;
using QuickLook.Plugin;
using QuickLook.Plugin.InfoPanel;
@@ -66,6 +68,18 @@ namespace QuickLook
});
LoadedPlugins = LoadedPlugins.OrderByDescending(i => i.Priority).ToList();
LoadedPlugins.ForEach(i =>
{
try
{
i.Init();
}
catch (Exception e)
{
Debug.WriteLine(e);
}
});
}
}
}