Compare commits

...

49 Commits

Author SHA1 Message Date
Paddy Xu
c6c727d2cc try fix SDK 2022-11-23 21:17:20 +01:00
Paddy Xu
dea3d05660 Merge branch 'master' of github.com:QL-Win/QuickLook 2022-11-23 20:38:56 +01:00
Paddy Xu
7b5b01a7b4 Fix textviewer highlighting 2022-11-23 20:38:53 +01:00
Alexander Eder
0ee6e3621b Experimental support for gimp (.xcf extension) 2022-11-17 13:13:52 +01:00
Samuel Carreira
437d47ed05 TSV file extension support (#1185)
if there are more file extensions to support maybe makes sense to readapt the code to iterate over a regex.
2022-11-08 19:58:20 +01:00
Paddy Xu
b80c264cdf Fix for Tabbed File Explorer in Windows 11 22H2 2022-11-05 17:58:23 +01:00
Alexander Raab
bd9b32ff91 Minor tweak to renew appveyor 2022-08-02 23:05:04 +02:00
Paddy
7c8655aff3 Fix #1147: DWM blur in Windows 10 and 11 2022-06-14 22:13:08 +02:00
marciozomb13
df4f642b51 Brazilian Portuguese fixes and improvements. (#1101)
Brazilian Portuguese fixes and improvements.
2022-03-11 17:52:06 +01:00
Piteriuz
95492fdd80 Update Polish translation (#1097) 2022-03-07 09:53:54 +01:00
SomeDeveloping
e8524dced5 Update French translation (#1083)
Update French strings
2022-03-03 17:16:11 +01:00
Paddy Xu
698e780988 Partial revert "move theme helper ref"
This reverts commit c93be2cb51.
2022-02-20 19:31:17 +01:00
Paddy
660dc88001 #1080: dark theme support for the text viewer 2022-02-20 18:55:28 +01:00
Paddy
c93be2cb51 move theme helper ref 2022-02-20 18:54:51 +01:00
Paddy Xu
fc14b58fa5 Fix #1033 again 2022-02-14 10:17:31 +01:00
Paddy Xu
1ed5f5ba2a Update .appveyor.yml 2022-02-13 15:12:58 +01:00
Paddy
22c08f62fa Fix #329: respect monitor ICC 2022-02-13 15:01:32 +01:00
Paddy
b39a58f1b9 rename 2022-02-13 12:21:06 +01:00
Paddy
d3217a0983 restore transparency in Win11 2022-02-13 10:51:11 +01:00
Paddy
e8125c51c5 refresh SDK 2022-02-13 10:50:47 +01:00
Paddy Xu
ef51c459ab Fix #1055: do not apply white background in ImageMagick 2021-12-02 18:04:28 +01:00
Paddy Xu
f726841d99 update deps 2021-11-15 23:52:02 +01:00
Paddy Xu
e640a8b98a Fix #1007: strcpy requires the number of chars not bytes 2021-10-18 21:22:24 +02:00
Paddy Xu
fe6dae67ce Disable transparency in Win11 2021-09-18 19:08:19 +02:00
Habib Mahdi
eaa918079c Add Arabic translation (#972)
* Add Arabic translation

* Add Arabic translation

* Add Arabic translation
2021-09-18 19:07:57 +02:00
Paddy Xu
69d6aa0f0a Update README.md 2021-09-07 10:03:52 +02:00
Paddy Xu
51ddd18c34 #955: Provide workaround for Windows 11 transparency issue 2021-07-31 23:35:11 +02:00
Paddy Xu
c10773249f hold Space to preview 2021-07-08 21:32:38 +02:00
Paddy Xu
cbaf636173 set syntax highlighting limit to 512KB 2021-07-06 21:19:52 +02:00
Paddy Xu
4a476aff4b refresh packages 2021-07-06 21:11:11 +02:00
Paddy Xu
28b9552dcd fix font bug 2021-07-06 21:10:57 +02:00
Paddy Xu
971285fc95 Fix #948: disable syntax highlighing when file is too big 2021-07-06 21:10:41 +02:00
Paddy Xu
1ad78c9f4b Disable image detection from file contents (partially revert 3ef980bb17) 2021-06-27 11:34:50 +02:00
Paddy Xu
237b99b305 Fix #941: caller assembly is incorrect in RELEASE mode 2021-06-27 11:22:02 +02:00
Alexander Raab
2b8b0e5c6d Provide name of product in changelog (#945)
* Provide name of product in changelog

fixes #944

* Change of headline-string
2021-06-27 11:02:33 +02:00
albertopasqualetto
49bb96e92d Updated Italian translation (#918) 2021-06-21 11:16:55 +02:00
Frank Becker
1e5de83f62 Simple RTF support via RichTextBox. (#933)
* Simple RTF support via RichTextBox.

* Minor tweaks to file extension checks.

Co-authored-by: Frank Becker <frank.becker@thoughtexchange.com>
2021-06-17 18:27:57 +02:00
Paddy Xu
df66c425e3 Revert "Add support for Windows 10 SDK versions 10.0.18362.0 and 10.0.19041.0 (#904)" (#911)
This reverts commit f32536f51e.
2021-05-15 16:08:55 +02:00
Cédric Luthi
f32536f51e Add support for Windows 10 SDK versions 10.0.18362.0 and 10.0.19041.0 (#904) 2021-05-15 16:04:09 +02:00
Frank Becker
3ef980bb17 Replace supported image extension list with image detection via MagickImageInfo. (#818)
* Replace supported image extension list with image detection via MagickImageInfo.

* Change ImageViewer priority to -4.
Change VideoViewer priority to -3 and detect audio/video via MediaInfo instead of file extensions.

* Make mediaInfo a class static and initialize once.
Add some notes about MediaInfo Open and Close.

* Remove try/catch from Prepare and let it be handled in caller.
If there was an exception due to MediaInfo it would have already occurred in CanHandle.

* Upgrade ImageMagick to latest

* Only check extension for well known image and animated image types.
For other image formats, let ImageMagick try to detect by file content.
Upgrade to latest Magick.NET

Co-authored-by: Frank Becker <frank.becker@thoughtexchange.com>
2021-05-14 19:07:32 +02:00
Elaborendum
885b3ed53f Update spanish localization (#899)
* Update spanish translation

* Update spanish translation

* Update Translations.config

Co-authored-by: Paddy Xu <xupaddy@gmail.com>
2021-05-14 19:06:24 +02:00
Natan FOURIÉ
8c8ade0bf9 Adding french translation (#900)
* Adding french translation

* Adding missing french translation

* Update Translations.config

* Updating french localization
2021-05-14 19:03:08 +02:00
Cédric Luthi
9478f9d4d7 Add support for NuGet package files (.nupkg) which are just zip files (#903) 2021-05-14 19:02:38 +02:00
Hyeongmin Kim
0dd8e919ca Added Korean localization (#891)
* Added korean language

* Update Translations.config
2021-04-06 13:16:58 +02:00
Tomáš Hvozdovič
a5763e460e Fix slovak translation (#872) 2021-03-16 13:45:47 +01:00
Alexander Raab
dc0d275015 Minor tweak for german language 2021-03-10 18:29:27 +01:00
Alexander Raab
9fc90ae479 Merge pull request #866 from vkrol/patch-1
Fix typo in README.md
2021-03-09 13:17:49 +01:00
Veniamin Krol
b6dc1cafcb Fix typo in README.md 2021-03-09 14:36:52 +03:00
Paddy Xu
b683ce0fd1 Fix config domain mismatch due to CLR optimisation 2021-03-07 19:48:40 +01:00
149 changed files with 581 additions and 347 deletions

View File

@@ -3,7 +3,7 @@ branches:
only:
- master
skip_branch_with_pr: true
image: Visual Studio 2019
image: Visual Studio 2022
configuration: Release
platform: Any CPU
clone_script:

View File

@@ -103,7 +103,7 @@ void DOpus::ParseXmlBuffer(PWCHAR buffer)
auto b = new WCHAR[size];
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, -1, b, size);
wcscpy_s(buffer, MAX_PATH_EX, b); // DOpus supports Long Path
wcscpy_s(buffer, wcslen(b) + 1, b); // DOpus supports Long Path
delete[] b;
return; // we now cares only the first result

View File

@@ -18,16 +18,8 @@
#include "stdafx.h"
#include "HelperMethods.h"
void HelperMethods::GetSelectedInternal(CComQIPtr<IWebBrowserApp> pwba, PWCHAR buffer)
void HelperMethods::GetSelectedInternal(CComPtr<IShellBrowser> psb, PWCHAR buffer)
{
CComQIPtr<IServiceProvider> psp;
if (FAILED(pwba->QueryInterface(IID_IServiceProvider, reinterpret_cast<void**>(&psp))))
return;
CComPtr<IShellBrowser> psb;
if (FAILED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, reinterpret_cast<LPVOID*>(&psb))))
return;
CComPtr<IShellView> psv;
if (FAILED(psb->QueryActiveShellView(&psv)))
return;

View File

@@ -19,7 +19,7 @@
class HelperMethods
{
public:
static void GetSelectedInternal(CComQIPtr<IWebBrowserApp> pWebBrowserApp, PWCHAR buffer);
static void GetSelectedInternal(CComPtr<IShellBrowser> psb, PWCHAR buffer);
static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer);
static bool IsCursorActivated(HWND hwndfg);
static bool IsExplorerSearchBoxFocused();

View File

@@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@@ -104,7 +104,8 @@ void Shell32::getSelectedFromExplorer(PWCHAR buffer)
if (FAILED(psw.CoCreateInstance(CLSID_ShellWindows)))
return;
auto hwndfg = GetForegroundWindow();
auto hwndfgw = GetForegroundWindow();
auto hwndfgt = FindWindowEx(hwndfgw, nullptr, L"ShellTabWindowClass", nullptr);
auto count = 0L;
psw->get_Count(&count);
@@ -120,18 +121,26 @@ void Shell32::getSelectedFromExplorer(PWCHAR buffer)
if (S_OK != psw->Item(vi, &pdisp))
continue;
CComQIPtr<IWebBrowserApp> pwba;
if (FAILED(pdisp->QueryInterface(IID_IWebBrowserApp, reinterpret_cast<void**>(&pwba))))
CComPtr<IServiceProvider> psp;
if (FAILED(pdisp->QueryInterface(IID_IServiceProvider, reinterpret_cast<void**>(&psp))))
continue;
HWND hwndwba;
if (FAILED(pwba->get_HWND(reinterpret_cast<LONG_PTR*>(&hwndwba))))
CComPtr<IShellBrowser> psb;
if (FAILED(psp->QueryService(IID_IShellBrowser, IID_IShellBrowser, reinterpret_cast<LPVOID*>(&psb))))
continue;
if (hwndwba != hwndfg || HelperMethods::IsCursorActivated(hwndwba))
HWND phwnd;
if (FAILED(psb->GetWindow(&phwnd)))
continue;
HelperMethods::GetSelectedInternal(pwba, buffer);
if (hwndfgw != phwnd && (hwndfgt != nullptr && hwndfgt != phwnd))
continue;
if (HelperMethods::IsCursorActivated(0))
continue;
HelperMethods::GetSelectedInternal(psb, buffer);
return;
}
}
@@ -140,7 +149,7 @@ void Shell32::getSelectedFromDesktop(PWCHAR buffer)
CoInitialize(nullptr);
CComPtr<IShellWindows> psw;
CComQIPtr<IWebBrowserApp> pwba;
CComPtr<IWebBrowserApp> pwba;
if (FAILED(psw.CoCreateInstance(CLSID_ShellWindows)))
return;
@@ -155,5 +164,13 @@ void Shell32::getSelectedFromDesktop(PWCHAR buffer)
if (HelperMethods::IsCursorActivated(reinterpret_cast<HWND>(LongToHandle(phwnd))))
return;
HelperMethods::GetSelectedInternal(pwba, buffer);
CComPtr<IServiceProvider> psp;
if (FAILED(pwba->QueryInterface(IID_IServiceProvider, reinterpret_cast<void**>(&psp))))
return;
CComPtr<IShellBrowser> psb;
if (FAILED(psp->QueryService(IID_IShellBrowser, IID_IShellBrowser, reinterpret_cast<LPVOID*>(&psb))))
return;
HelperMethods::GetSelectedInternal(psb, buffer);
}

View File

@@ -42,13 +42,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@@ -90,14 +90,14 @@ void GetCurrentSelection()
if (hMapFile == nullptr)
return;
auto buffer = static_cast<PWCHAR>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH * sizeof WCHAR));
auto buffer = static_cast<PWCHAR>(MapViewOfFile(hMapFile, FILE_MAP_WRITE, 0, 0, 0));
if (buffer == nullptr)
{
CloseHandle(hMapFile);
return;
}
wcscpy_s(buffer, MAX_PATH_EX, dllBuffer);
wcscpy_s(buffer, wcslen(dllBuffer) + 1, dllBuffer);
UnmapViewOfFile(buffer);
CloseHandle(hMapFile);

View File

@@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@@ -26,7 +26,7 @@ namespace QuickLook.Plugin.ArchiveViewer
public class Plugin : IViewer
{
private static readonly string[] Extensions =
{".rar", ".zip", ".tar", ".tgz", ".gz", ".bz2", ".lz", ".xz", ".7z", ".jar", ".crx"};
{".rar", ".zip", ".tar", ".tgz", ".gz", ".bz2", ".lz", ".xz", ".7z", ".jar", ".crx", ".nupkg"};
private ArchiveInfoPanel _panel;

View File

@@ -59,8 +59,8 @@
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="SharpCompress, Version=0.25.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpCompress.0.25.1\lib\net46\SharpCompress.dll</HintPath>
<Reference Include="SharpCompress, Version=0.26.0.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\..\packages\SharpCompress.0.26.0\lib\net46\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
@@ -78,9 +78,12 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="UtfUnknown, Version=2.0.0.0, Culture=neutral, PublicKeyToken=90217ce7a23260d4, processorArchitecture=MSIL">
<HintPath>..\..\packages\UTF.Unknown.2.3.0\lib\net40\UtfUnknown.dll</HintPath>
<HintPath>..\..\packages\UTF.Unknown.2.5.0\lib\net40\UtfUnknown.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>

View File

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpCompress" version="0.25.1" targetFramework="net462" />
<package id="SharpCompress" version="0.26.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net462" />
<package id="UTF.Unknown" version="2.3.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="4.5.1" targetFramework="net462" />
<package id="UTF.Unknown" version="2.5.0" targetFramework="net462" />
</packages>

View File

@@ -48,14 +48,14 @@ namespace QuickLook.Plugin.CsvViewer
using (var sr = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
var conf = new Configuration {MissingFieldFound = null, BadDataFound = null};
var conf = new CsvConfiguration(CultureInfo.CurrentUICulture) {MissingFieldFound = null, BadDataFound = null, DetectDelimiter = true};
using (var parser = new CsvParser(sr, conf))
{
var i = 0;
while (true)
while (parser.Read())
{
var row = parser.Read();
var row = parser.Record;
if (row == null)
break;
row = Concat(new[] {$"{i++ + 1}".PadLeft(6)}, row);

View File

@@ -34,7 +34,7 @@ namespace QuickLook.Plugin.CsvViewer
public bool CanHandle(string path)
{
return !Directory.Exists(path) && path.ToLower().EndsWith(".csv");
return !Directory.Exists(path) && (path.ToLower().EndsWith(".csv") || path.ToLower().EndsWith(".tsv"));
}
public void Prepare(string path, ContextObject context)
@@ -60,4 +60,4 @@ namespace QuickLook.Plugin.CsvViewer
_panel = null;
}
}
}
}

View File

@@ -56,13 +56,23 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\..\packages\CsvHelper.12.3.2\lib\net45\CsvHelper.dll</HintPath>
<Reference Include="CsvHelper, Version=27.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
<HintPath>..\..\packages\CsvHelper.27.1.1\lib\net45\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>

View File

@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CsvHelper" version="12.3.2" targetFramework="net462" />
<package id="Microsoft.CSharp" version="4.5.0" targetFramework="net462" />
<package id="CsvHelper" version="27.1.1" targetFramework="net462" />
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>

View File

@@ -61,14 +61,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.664.37, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.664.37\lib\net462\Microsoft.Web.WebView2.Core.dll</HintPath>
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\lib\net45\Microsoft.Web.WebView2.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.664.37, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.664.37\lib\net462\Microsoft.Web.WebView2.WinForms.dll</HintPath>
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\lib\net45\Microsoft.Web.WebView2.WinForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.664.37, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.664.37\lib\net462\Microsoft.Web.WebView2.Wpf.dll</HintPath>
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.1020.30, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\lib\net45\Microsoft.Web.WebView2.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -124,11 +124,11 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\build\Microsoft.Web.WebView2.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.664.37\build\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Web.WebView2.1.0.1020.30\build\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>

View File

@@ -7,9 +7,15 @@
<de>
<WEBVIEW2_NOT_AVAILABLE>Für das Anzeigen dieses Dateityps wird MS Edge WebView2 benötigt.&#10;Hier klicken zum Downloaden.</WEBVIEW2_NOT_AVAILABLE>
</de>
<fr>
<WEBVIEW2_NOT_AVAILABLE>Microsoft Edge WebView2 est requis pour afficher ce type de fichier.&#10;Cliquez ici pour le télécharger.</WEBVIEW2_NOT_AVAILABLE>
</fr>
<ja>
<WEBVIEW2_NOT_AVAILABLE>このファイルを閲覧するには、Microsoft Edge WebView2 がインストールされている必要があります。&#10;ここをクリックしてダウンロードを開始する。</WEBVIEW2_NOT_AVAILABLE>
</ja>
<ko-KR>
<WEBVIEW2_NOT_AVAILABLE>이 파일을 표시하려면 Microsoft Edge WebView2가 필요합니다.&#10;여기를 클릭해서 다운로드 하세요.</WEBVIEW2_NOT_AVAILABLE>
</ko-KR>
<zh-CN>
<WEBVIEW2_NOT_AVAILABLE>查看此文件需要安装 Microsoft Edge WebView2。&#10;点击这里开始下载。</WEBVIEW2_NOT_AVAILABLE>
</zh-CN>
@@ -19,4 +25,13 @@
<es>
<WEBVIEW2_NOT_AVAILABLE>Es necesario tener instalado Microsoft Edge WebView2 para ver este fichero.&#10;Haga clic aquí para descargarlo.</WEBVIEW2_NOT_AVAILABLE>
</es>
<it>
<WEBVIEW2_NOT_AVAILABLE>Visualizzare questo file richiede che Microsoft Edge WebView2 sia installato.&#10;Clicca qui per scaricarlo.</WEBVIEW2_NOT_AVAILABLE>
</it>
<ar>
<WEBVIEW2_NOT_AVAILABLE>مطلوب لعرض هذا الملف. انقر هنا لتحميله Microsoft Edge WebView2</WEBVIEW2_NOT_AVAILABLE>
</ar>
<pl>
<WEBVIEW2_NOT_AVAILABLE>Wyświetlenie tego pliku wymaga zainstalowania Microsoft Edge WebView2.&#10;Kliknij tutaj, aby go pobrać.</WEBVIEW2_NOT_AVAILABLE>
</pl>
</Translations>

View File

@@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Web.WebView2.Core;
@@ -92,7 +93,8 @@ namespace QuickLook.Plugin.HtmlViewer
{
var button = new Button
{
Content = TranslationHelper.Get("WEBVIEW2_NOT_AVAILABLE"),
Content = TranslationHelper.Get("WEBVIEW2_NOT_AVAILABLE",
domain: Assembly.GetExecutingAssembly().GetName().Name),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Padding = new Thickness(20, 6, 20, 6)

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.664.37" targetFramework="net462" />
<package id="Microsoft.Web.WebView2" version="1.0.1020.30" targetFramework="net462" />
</packages>

View File

@@ -48,12 +48,12 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
public event EventHandler ImageLoaded;
public event EventHandler DoZoomToFit;
private static AnimationProvider InitAnimationProvider(Uri path, MetaProvider meta)
private static AnimationProvider InitAnimationProvider(Uri path, MetaProvider meta, ContextObject contextObject)
{
var ext = Path.GetExtension(path.LocalPath).ToLower();
var type = Providers.First(p => p.Key.Contains(ext) || p.Key.Contains("*")).Value;
var provider = type.CreateInstance<AnimationProvider>(path, meta);
var provider = type.CreateInstance<AnimationProvider>(path, meta, contextObject);
return provider;
}
@@ -106,7 +106,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
//var thumbnail = instance.Meta?.GetThumbnail(true);
//instance.Source = thumbnail;
instance._animation = InitAnimationProvider((Uri) ev.NewValue, instance.Meta);
instance._animation = InitAnimationProvider((Uri) ev.NewValue, instance.Meta, instance.ContextObject);
ShowThumbnailAndStartAnimation(instance);
}

View File

@@ -20,21 +20,25 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage
{
internal abstract class AnimationProvider : IDisposable
{
protected AnimationProvider(Uri path, MetaProvider meta)
protected AnimationProvider(Uri path, MetaProvider meta, ContextObject contextObject)
{
Path = path;
Meta = meta;
ContextObject = contextObject;
}
public Uri Path { get; }
public MetaProvider Meta { get; }
public ContextObject ContextObject { get; }
public Int32AnimationUsingKeyFrames Animator { get; protected set; }
public abstract void Dispose();

View File

@@ -26,6 +26,7 @@ using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using LibAPNG;
using QuickLook.Common.ExtensionMethods;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
@@ -37,11 +38,11 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
private int _lastEffectivePreviousPreviousFrameIndex;
private NativeProvider _nativeImageProvider;
public APngProvider(Uri path, MetaProvider meta) : base(path, meta)
public APngProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject)
{
if (!IsAnimatedPng(path.LocalPath))
{
_nativeImageProvider = new NativeProvider(path, meta);
_nativeImageProvider = new NativeProvider(path, meta, contextObject);
Animator = _nativeImageProvider.Animator;
return;
}

View File

@@ -16,12 +16,13 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
internal class DcrawProvider : NativeProvider
{
public DcrawProvider(Uri path, MetaProvider meta) : base(path, meta)
public DcrawProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject)
{
throw new NotImplementedException();
}

View File

@@ -22,6 +22,7 @@ using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using QuickLook.Common.ExtensionMethods;
using QuickLook.Common.Helpers;
using QuickLook.Common.Plugin;
using Size = System.Windows.Size;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
@@ -33,18 +34,18 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
private bool _isPlaying;
private NativeProvider _nativeProvider;
public GifProvider(Uri path, MetaProvider meta) : base(path, meta)
public GifProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject)
{
if (!ImageAnimator.CanAnimate(Image.FromFile(path.LocalPath)))
{
_nativeProvider = new NativeProvider(path, meta);
_nativeProvider = new NativeProvider(path, meta, contextObject);
return;
}
_fileHandle = (Bitmap) Image.FromFile(path.LocalPath);
_fileHandle.SetResolution(DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Horizontal,
DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Vertical);
_fileHandle.SetResolution(DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Horizontal,
DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Vertical);
Animator = new Int32AnimationUsingKeyFrames {RepeatBehavior = RepeatBehavior.Forever};
Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));

View File

@@ -23,14 +23,15 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using ImageMagick;
using ImageMagick.Formats.Dng;
using ImageMagick.Formats;
using QuickLook.Common.Helpers;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
internal class ImageMagickProvider : AnimationProvider
{
public ImageMagickProvider(Uri path, MetaProvider meta) : base(path, meta)
public ImageMagickProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject)
{
Animator = new Int32AnimationUsingKeyFrames();
Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0,
@@ -80,6 +81,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
var settings = new MagickReadSettings
{
BackgroundColor = MagickColors.None,
Defines = new DngReadDefines
{
OutputColor = DngOutputColor.SRGB,
@@ -92,19 +94,23 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
using (var mi = new MagickImage(Path.LocalPath, settings))
{
var profile = mi.GetColorProfile();
if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB ||
mi.ColorSpace == ColorSpace.scRGB)
if (profile?.Description != null && !profile.Description.Contains("sRGB"))
if (SettingHelper.Get("UseColorProfile", false, "QuickLook.Plugin.ImageViewer"))
{
if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB || mi.ColorSpace == ColorSpace.scRGB)
{
mi.SetProfile(ColorProfile.SRGB);
if (ContextObject.ColorProfileName != null)
mi.SetProfile(new ColorProfile(ContextObject.ColorProfileName)); // map to monitor color
}
}
mi.AutoOrient();
if (mi.Width != (int) fullSize.Width || mi.Height != (int) fullSize.Height)
mi.Resize((int) fullSize.Width, (int) fullSize.Height);
mi.Density = new Density(DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Horizontal,
DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Vertical);
mi.Density = new Density(DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Horizontal,
DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Vertical);
var img = mi.ToBitmapSourceWithDensity();

View File

@@ -22,12 +22,13 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using QuickLook.Common.Helpers;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers
{
internal class NativeProvider : AnimationProvider
{
public NativeProvider(Uri path, MetaProvider meta) : base(path, meta)
public NativeProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject)
{
Animator = new Int32AnimationUsingKeyFrames();
Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0,

View File

@@ -30,8 +30,8 @@ namespace QuickLook.Plugin.ImageViewer
{
// a dirty hack... but is the fastest
var newDpiX = (double) DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Horizontal;
var newDpiY = (double) DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Vertical;
var newDpiX = (double) DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Horizontal;
var newDpiY = (double) DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Vertical;
var dpiX = img.GetType().GetField("_dpiX",
BindingFlags.NonPublic | BindingFlags.Instance);

View File

@@ -278,7 +278,7 @@ namespace QuickLook.Plugin.ImageViewer
{
Theme = Theme == Themes.Dark ? Themes.Light : Themes.Dark;
SettingHelper.Set("LastTheme", (int) Theme);
SettingHelper.Set("LastTheme", (int) Theme, "QuickLook.Plugin.ImageViewer");
}
private void ShowMeta()

View File

@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using ImageMagick;
using QuickLook.Common.Helpers;
using QuickLook.Common.Plugin;
using QuickLook.Plugin.ImageViewer.AnimatedImage.Providers;
@@ -27,13 +28,28 @@ namespace QuickLook.Plugin.ImageViewer
{
public class Plugin : IViewer
{
private static readonly HashSet<string> Formats = new HashSet<string>(new[]
private static readonly HashSet<string> WellKnownImageExtensions = new HashSet<string>(new[]
{
".apng", ".ari", ".arw", ".avif", ".bay", ".bmp", ".cap", ".cr2", ".cr3", ".crw", ".dcr", ".dcs", ".dng",
".drf", ".eip", ".emf", ".erf", ".exr", ".fff", ".gif", ".hdr", ".heic", ".heif", ".ico", ".icon", ".iiq",
".jfif", ".jpeg", ".jpg", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf",
".pbm", ".pef", ".pgm", ".png", ".pnm", ".ppm", ".psd", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rw2",
".rwl", ".rwz", ".sr2", ".srf", ".srw", ".svg", ".tga", ".tif", ".tiff", ".wdp", ".webp", ".wmf", ".x3f"
".apng", ".ari", ".arw", ".avif",
".bay", ".bmp",
".cap", ".cr2", ".cr3", ".crw",
".dcr", ".dcs", ".dng", ".drf",
".eip", ".emf", ".erf", ".exr",
".fff",
".gif",
".hdr", ".heic", ".heif",
".ico", ".icon", ".iiq",
".jfif", ".jp2", ".jpeg", ".jpg", ".jxl",
".k25", ".kdc",
".mdc", ".mef", ".mos", ".mrw",
".nef", ".nrw",
".obm", ".orf",
".pbm", ".pef", ".pgm", ".png", ".pnm", ".ppm", ".psd", ".ptx", ".pxn",
".r3d", ".raf", ".raw", ".rw2", ".rwl", ".rwz",
".sr2", ".srf", ".srw", ".svg",
".tga", ".tif", ".tiff",
".wdp", ".webp", ".wmf",
".x3f", ".xcf"
});
private ImagePanel _ip;
@@ -43,23 +59,47 @@ namespace QuickLook.Plugin.ImageViewer
public void Init()
{
var useColorProfile = SettingHelper.Get("UseColorProfile", false, "QuickLook.Plugin.ImageViewer");
AnimatedImage.AnimatedImage.Providers.Add(
new KeyValuePair<string[], Type>(new[] {".apng", ".png"},
new KeyValuePair<string[], Type>(
useColorProfile ? new[] { ".apng" } : new[] { ".apng", ".png" },
typeof(APngProvider)));
AnimatedImage.AnimatedImage.Providers.Add(
new KeyValuePair<string[], Type>(new[] {".gif"},
typeof(GifProvider)));
AnimatedImage.AnimatedImage.Providers.Add(
new KeyValuePair<string[], Type>(new[] {".bmp", ".jpg", ".jpeg", ".jfif", ".tif", ".tiff"},
new KeyValuePair<string[], Type>(
useColorProfile ? new string[0] : new[] { ".bmp", ".jpg", ".jpeg", ".jfif", ".tif", ".tiff" },
typeof(NativeProvider)));
AnimatedImage.AnimatedImage.Providers.Add(
new KeyValuePair<string[], Type>(new[] {"*"},
typeof(ImageMagickProvider)));
}
private bool IsWellKnownImageExtension(string path)
{
return WellKnownImageExtensions.Contains(Path.GetExtension(path.ToLower()));
}
private bool IsImageMagickSupported(string path)
{
try
{
return new MagickImageInfo(path).Format != MagickFormat.Unknown;
}
catch
{
return false;
}
}
public bool CanHandle(string path)
{
return !Directory.Exists(path) && Formats.Contains(Path.GetExtension(path.ToLower()));
// Disabled due mishandling text file types e.g., "*.config".
// Only check extension for well known image and animated image types.
// For other image formats, let ImageMagick try to detect by file content.
return !Directory.Exists(path) && (IsWellKnownImageExtension(path)); // || IsImageMagickSupported(path));
}
public void Prepare(string path, ContextObject context)
@@ -73,7 +113,7 @@ namespace QuickLook.Plugin.ImageViewer
else
context.PreferredSize = new Size(800, 600);
context.Theme = (Themes) SettingHelper.Get("LastTheme", 1);
context.Theme = (Themes) SettingHelper.Get("LastTheme", 1, "QuickLook.Plugin.ImageViewer");
}
public void View(string path, ContextObject context)

View File

@@ -62,14 +62,14 @@
<Reference Include="LibAPNG">
<HintPath>.\LibAPNG.dll</HintPath>
</Reference>
<Reference Include="Magick.NET-Q8-AnyCPU, Version=7.20.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET-Q8-AnyCPU.7.20.0.1\lib\net40\Magick.NET-Q8-AnyCPU.dll</HintPath>
<Reference Include="Magick.NET-Q8-AnyCPU, Version=8.4.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET-Q8-AnyCPU.8.4.0\lib\net20\Magick.NET-Q8-AnyCPU.dll</HintPath>
</Reference>
<Reference Include="Magick.NET.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET.Core.3.0.0\lib\net40\Magick.NET.Core.dll</HintPath>
<Reference Include="Magick.NET.Core, Version=8.4.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET.Core.8.4.0\lib\net20\Magick.NET.Core.dll</HintPath>
</Reference>
<Reference Include="Magick.NET.SystemWindowsMedia, Version=1.0.2.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET.SystemWindowsMedia.1.0.2\lib\net40\Magick.NET.SystemWindowsMedia.dll</HintPath>
<Reference Include="Magick.NET.SystemWindowsMedia, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\..\packages\Magick.NET.SystemWindowsMedia.4.0.9\lib\net40\Magick.NET.SystemWindowsMedia.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Magick.NET.Core" version="3.0.0" targetFramework="net462" />
<package id="Magick.NET.SystemWindowsMedia" version="1.0.2" targetFramework="net462" />
<package id="Magick.NET-Q8-AnyCPU" version="7.20.0.1" targetFramework="net462" />
<package id="Magick.NET.Core" version="8.4.0" targetFramework="net462" />
<package id="Magick.NET.SystemWindowsMedia" version="4.0.9" targetFramework="net462" />
<package id="Magick.NET-Q8-AnyCPU" version="8.4.0" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>

View File

@@ -63,7 +63,7 @@
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="UtfUnknown, Version=2.0.0.0, Culture=neutral, PublicKeyToken=90217ce7a23260d4, processorArchitecture=MSIL">
<HintPath>..\..\packages\UTF.Unknown.2.3.0\lib\net40\UtfUnknown.dll</HintPath>
<HintPath>..\..\packages\UTF.Unknown.2.5.0\lib\net40\UtfUnknown.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="UTF.Unknown" version="2.3.0" targetFramework="net462" />
<package id="UTF.Unknown" version="2.5.0" targetFramework="net462" />
</packages>

View File

@@ -49,9 +49,9 @@ namespace QuickLook.Plugin.PDFViewer
public static BitmapSource Render(this PdfDocumentWrapper doc, int page, double factor, bool fixDpi = true)
{
var scale = DpiHelper.GetCurrentScaleFactor();
var dpiX = fixDpi ? scale.Horizontal * DpiHelper.DefaultDpi : 96;
var dpiY = fixDpi ? scale.Vertical * DpiHelper.DefaultDpi : 96;
var scale = DisplayDeviceHelper.GetCurrentScaleFactor();
var dpiX = fixDpi ? scale.Horizontal * DisplayDeviceHelper.DefaultDpi : 96;
var dpiY = fixDpi ? scale.Vertical * DisplayDeviceHelper.DefaultDpi : 96;
Bitmap bitmap;

View File

@@ -65,8 +65,8 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="PdfiumViewer, Version=2.14.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\PdfiumViewer.Updated.2.14.0\lib\net45\PdfiumViewer.dll</HintPath>
<Reference Include="PdfiumViewer, Version=2.14.2.0, Culture=neutral, PublicKeyToken=97c6f28bf5a3df6e, processorArchitecture=MSIL">
<HintPath>..\..\packages\PdfiumViewer.Updated.2.14.2\lib\net45\PdfiumViewer.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />

View File

@@ -2,5 +2,5 @@
<packages>
<package id="PDFium.x64.v8-xfa" version="4194.0.0" targetFramework="net462" />
<package id="PDFium.x86.v8-xfa" version="4194.0.0" targetFramework="net462" />
<package id="PdfiumViewer.Updated" version="2.14.0" targetFramework="net462" />
<package id="PdfiumViewer.Updated" version="2.14.2" targetFramework="net462" />
</packages>

View File

@@ -16,14 +16,17 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using QuickLook.Common.Helpers;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.TextViewer
@@ -32,33 +35,18 @@ namespace QuickLook.Plugin.TextViewer
{
private TextViewerPanel _tvp;
private static HighlightingManager _hlmLight;
private static HighlightingManager _hlmDark;
public int Priority => -5;
public void Init()
{
var hlm = HighlightingManager.Instance;
var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (string.IsNullOrEmpty(assemblyPath)) return;
var syntaxPath = Path.Combine(assemblyPath, "Syntax");
if (!Directory.Exists(syntaxPath)) return;
foreach (var file in Directory.EnumerateFiles(syntaxPath, "*.xshd"))
{
var ext = Path.GetFileNameWithoutExtension(file);
using (Stream s = File.OpenRead(Path.GetFullPath(file)))
using (var reader = new XmlTextReader(s))
{
var xshd = HighlightingLoader.LoadXshd(reader);
var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
if (xshd.Extensions.Count > 0)
hlm.RegisterHighlighting(ext, xshd.Extensions.ToArray(), highlightingDefinition);
}
}
// pre-load
var _ = new TextEditor();
_hlmLight = getHighlightingManager(Themes.Light, "Light");
_hlmDark = getHighlightingManager(Themes.Dark, "Dark");
}
public bool CanHandle(string path)
@@ -66,7 +54,7 @@ namespace QuickLook.Plugin.TextViewer
if (Directory.Exists(path))
return false;
if (path.ToLower().EndsWith(".txt"))
if (new[] { ".txt", ".rtf" }.Any(path.ToLower().EndsWith))
return true;
// if there is a matched highlighting scheme (by file extension), treat it as a plain text file
@@ -86,16 +74,30 @@ namespace QuickLook.Plugin.TextViewer
public void Prepare(string path, ContextObject context)
{
//context.Theme = Themes.Light;
context.PreferredSize = new Size {Width = 800, Height = 600};
}
public void View(string path, ContextObject context)
{
_tvp = new TextViewerPanel(path, context);
if (path.ToLower().EndsWith(".rtf"))
{
var rtfBox = new RichTextBox();
FileStream fs = File.OpenRead(path);
rtfBox.Selection.Load(fs, DataFormats.Rtf);
rtfBox.IsReadOnly = true;
rtfBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
rtfBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
context.ViewerContent = _tvp;
context.ViewerContent = rtfBox;
context.IsBusy = false;
}
else
{
_tvp = new TextViewerPanel(path, context);
AssignHighlightingManager(_tvp, context);
context.ViewerContent = _tvp;
}
context.Title = $"{Path.GetFileName(path)}";
}
@@ -113,5 +115,40 @@ namespace QuickLook.Plugin.TextViewer
return true;
}
private HighlightingManager getHighlightingManager(Themes theme, string dirName)
{
var hlm = new HighlightingManager();
var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (string.IsNullOrEmpty(assemblyPath))
return hlm;
var syntaxPath = Path.Combine(assemblyPath, "Syntax", dirName);
if (!Directory.Exists(syntaxPath))
return hlm;
foreach (var file in Directory.EnumerateFiles(syntaxPath, "*.xshd").OrderBy(f => f))
{
Debug.WriteLine(file);
var ext = Path.GetFileNameWithoutExtension(file);
using (Stream s = File.OpenRead(Path.GetFullPath(file)))
using (var reader = new XmlTextReader(s))
{
var xshd = HighlightingLoader.LoadXshd(reader);
var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
if (xshd.Extensions.Count > 0)
hlm.RegisterHighlighting(ext, xshd.Extensions.ToArray(), highlightingDefinition);
}
}
return hlm;
}
private void AssignHighlightingManager(TextViewerPanel tvp, ContextObject context)
{
var darkThemeAllowed = SettingHelper.Get("AllowDarkTheme", false, "QuickLook.Plugin.TextViewer");
var isDark = darkThemeAllowed && OSThemeHelper.AppsUseDarkTheme();
tvp.HighlightingManager = isDark ? _hlmDark : _hlmLight;
}
}
}

View File

@@ -57,8 +57,8 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.AvalonEdit, Version=6.0.1.278, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
<HintPath>..\..\packages\AvalonEdit.6.0.1\lib\net45\ICSharpCode.AvalonEdit.dll</HintPath>
<Reference Include="ICSharpCode.AvalonEdit, Version=6.1.3.50, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
<HintPath>..\..\packages\AvalonEdit.6.1.3.50\lib\net45\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
@@ -68,7 +68,7 @@
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="UtfUnknown, Version=2.0.0.0, Culture=neutral, PublicKeyToken=90217ce7a23260d4, processorArchitecture=MSIL">
<HintPath>..\..\packages\UTF.Unknown.2.3.0\lib\net40\UtfUnknown.dll</HintPath>
<HintPath>..\..\packages\UTF.Unknown.2.5.0\lib\net40\UtfUnknown.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
@@ -91,6 +91,7 @@
<Content Include="Syntax\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Translations.config">
<SubType>Designer</SubType>

Some files were not shown because too many files have changed in this diff Show More