Finish animation and PDF viewer, still need refinement

This commit is contained in:
Paddy Xu
2017-04-12 23:28:12 +03:00
parent 7e2001bc4d
commit 7388c3874a
27 changed files with 252 additions and 170 deletions

View File

@@ -1,52 +1,40 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using MoonPdfLib;
using QuickLook.ExtensionMethods;
namespace QuickLook.Plugin.PDFViewer
{
public class Class1:IViewer
public class Class1 : IViewer
{
public bool CanView(string path, byte[] sample)
public PluginType Type => PluginType.ByExtension | PluginType.ByContent;
public string[] SupportExtensions => new[] {".pdf"};
public bool CheckSupportByContent(byte[] sample)
{
if (String.IsNullOrEmpty(path))
return false;
if (Path.GetExtension(path).ToLower() == ".pdf")
return true;
if (Encoding.ASCII.GetString(sample.Take(4).ToArray()) == "%PDF")
return true;
return false;
return Encoding.ASCII.GetString(sample.Take(4).ToArray()) == "%PDF";
}
public void View(string path, ViewContentContainer container)
{
MoonPdfPanel pdfPanel = new MoonPdfPanel
var pdfPanel = new MoonPdfPanel
{
ViewType = ViewType.SinglePage,
PageRowDisplay = PageRowDisplayType.ContinuousPageRows,
PageMargin = new System.Windows.Thickness(0, 2, 4, 2),
PageMargin = new Thickness(0, 2, 4, 2),
Background = new SolidColorBrush(Colors.LightGray)
};
container.SetContent(pdfPanel);
Task.Delay(200).ContinueWith(t => container.Dispatcher.Invoke(() => pdfPanel.OpenFile(path)));
Task.Delay(400).ContinueWith(t => container.Dispatcher.Invoke(() => pdfPanel.ZoomToWidth()));
container.Dispatcher.Delay(100, o => pdfPanel.OpenFile(path));
//container.Dispatcher.Delay(200, o => pdfPanel.ZoomToWidth());
}
public void Close()
{
return;
}
}
}
}

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MoonPdfLib-x86" version="0.3.0" targetFramework="net452" />
</packages>