Done HtmlViewer

This commit is contained in:
Paddy Xu
2017-05-14 02:21:24 +03:00
parent 3f82070deb
commit f18aa022f7
27 changed files with 24660 additions and 13 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,9 @@ namespace QuickLook.Plugin.HtmlViewer
public void Prepare(string path, ContextObject context)
{
context.PreferredSize = new Size(600, 800);
context.PreferredSize = new Size(800, 800);
context.Focusable = true;
}
public void View(string path, ContextObject context)
@@ -42,6 +44,9 @@ namespace QuickLook.Plugin.HtmlViewer
public void Dispose()
{
GC.SuppressFinalize(this);
_panel?.Dispose();
}
~Plugin()

View File

@@ -34,8 +34,17 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="AirspaceFixer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\AirspaceFixer.1.0.2\lib\AirspaceFixer.dll</HintPath>
<Reference Include="CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\CefSharp.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Core, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Wpf, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\CefSharp.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@@ -81,7 +90,38 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<ContentWithTargetPath Include="CefSharp\cef.pak">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>cef.pak</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\cef_100_percent.pak">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>cef_100_percent.pak</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\cef_200_percent.pak">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>cef_200_percent.pak</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\cef_extensions.pak">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>cef_extensions.pak</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\icudtl.dat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>icudtl.dat</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\locales\en-US.pak">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>locales\en-US.pak</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\natives_blob.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>natives_blob.bin</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\snapshot_blob.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>snapshot_blob.bin</TargetPath>
</ContentWithTargetPath>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -94,5 +134,39 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="CefSharp\CefSharp.BrowserSubprocess.Core.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>CefSharp.BrowserSubprocess.Core.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\CefSharp.BrowserSubprocess.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>CefSharp.BrowserSubprocess.exe</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\chrome_elf.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>chrome_elf.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\d3dcompiler_47.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>d3dcompiler_47.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\libcef.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>libcef.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\libEGL.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>libEGL.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\libGLESv2.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>libGLESv2.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="CefSharp\widevinecdmadapter.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>widevinecdmadapter.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,9 +4,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:QuickLook.Plugin.HtmlViewer"
xmlns:cef="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Background="Aqua">
<WebBrowser x:Name="browser" />
<Grid>
<cef:ChromiumWebBrowser x:Name="browser" />
</Grid>
</UserControl>

View File

@@ -1,27 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using CefSharp;
namespace QuickLook.Plugin.HtmlViewer
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class WebkitPanel : UserControl
public partial class WebkitPanel : UserControl,IDisposable
{
private string _cefPath =
Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
public WebkitPanel()
{
var libraryLoader = new CefLibraryHandle(Path.Combine(_cefPath, "libcef.dll"));
if (!Cef.IsInitialized)
Cef.Initialize(new CefSettings
{
BrowserSubprocessPath = Path.Combine(_cefPath, "CefSharp.BrowserSubprocess.exe"),
LocalesDirPath = Path.Combine(_cefPath, "locales"),
ResourcesDirPath = _cefPath,
LogSeverity = LogSeverity.Disable,
CefCommandLineArgs = {new KeyValuePair<string, string>("disable-gpu", "1")},
});
InitializeComponent();
Application.Current.Exit += (sender, e) => Cef.Shutdown();
}
public void Navigate(string path)
{
//path = "http://pooi.moe/QuickLook";
if (Path.IsPathRooted(path))
path = FilePathToFileUrl(path);
browser.Loaded += (sender, e) => browser.Navigate(path);
browser.IsBrowserInitializedChanged += (sender, e) => browser.Load(path);
}
private static string FilePathToFileUrl(string filePath)
@@ -50,5 +70,10 @@ namespace QuickLook.Plugin.HtmlViewer
uri.Insert(0, "file:///");
return uri.ToString();
}
public void Dispose()
{
browser?.Dispose();
}
}
}

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AirspaceFixer" version="1.0.2" targetFramework="net452" />
</packages>