Compare commits
279 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a20b4714ec | ||
![]() |
354bbfc1ca | ||
![]() |
4133d2148c | ||
![]() |
4e356f9e77 | ||
![]() |
39b93b11f1 | ||
![]() |
189e3a70d1 | ||
![]() |
b04fbabae6 | ||
![]() |
dada8bc6e7 | ||
![]() |
6f60f41d1c | ||
![]() |
6bc990bbf9 | ||
![]() |
197bfee1da | ||
![]() |
57f129bda3 | ||
![]() |
56af2311b9 | ||
![]() |
d50d757022 | ||
![]() |
fa0824bce9 | ||
![]() |
5b0da969af | ||
![]() |
d2fdcd240b | ||
![]() |
3f9794c2a4 | ||
![]() |
aa716dd04b | ||
![]() |
804876a987 | ||
![]() |
a63fd77a50 | ||
![]() |
914cc7c3a7 | ||
![]() |
bb7fb114f8 | ||
![]() |
3ff693ac37 | ||
![]() |
3c229a8526 | ||
![]() |
36484beb58 | ||
![]() |
2af22cde92 | ||
![]() |
a17b7f05d7 | ||
![]() |
c1bcf311bc | ||
![]() |
76dd2feb30 | ||
![]() |
4b9b6c7233 | ||
![]() |
6d78650b12 | ||
![]() |
e40bac0924 | ||
![]() |
5c0f88a961 | ||
![]() |
5667f98a01 | ||
![]() |
35c22db10c | ||
![]() |
5c02a8c9cf | ||
![]() |
2ba3fcdf6e | ||
![]() |
a969687b7b | ||
![]() |
c622ed748a | ||
![]() |
3be25ac28f | ||
![]() |
0914b264f4 | ||
![]() |
c791add587 | ||
![]() |
311d723bb3 | ||
![]() |
c78fbb009a | ||
![]() |
a502b2363a | ||
![]() |
b4198f61f2 | ||
![]() |
9369a94350 | ||
![]() |
1052d873e1 | ||
![]() |
97b749e64f | ||
![]() |
dedac98702 | ||
![]() |
3014b30358 | ||
![]() |
99d067ea2d | ||
![]() |
abc80e046d | ||
![]() |
fe39854b57 | ||
![]() |
1bcfd8db08 | ||
![]() |
f0990faa56 | ||
![]() |
b0e4f19491 | ||
![]() |
f321e243ba | ||
![]() |
6cd837b423 | ||
![]() |
82994b69bc | ||
![]() |
b1e5ce0172 | ||
![]() |
50d839a02f | ||
![]() |
18f3f57606 | ||
![]() |
1988cd3c09 | ||
![]() |
d481bcdceb | ||
![]() |
df0ba78298 | ||
![]() |
2fda049c26 | ||
![]() |
f8d24aa191 | ||
![]() |
057126a7a0 | ||
![]() |
1980ed1590 | ||
![]() |
93dae0a8ca | ||
![]() |
734b0e36e3 | ||
![]() |
0d07315253 | ||
![]() |
0320ce13b4 | ||
![]() |
03807a1afb | ||
![]() |
02f2cef5e3 | ||
![]() |
462891951b | ||
![]() |
5a83dce8ed | ||
![]() |
04b1180b26 | ||
![]() |
ba6efbe8ea | ||
![]() |
6b2a481cf2 | ||
![]() |
d6aa4d6959 | ||
![]() |
e56c33cbd8 | ||
![]() |
0e5809120d | ||
![]() |
42cbf9ecdf | ||
![]() |
a2660fc15c | ||
![]() |
31279b1015 | ||
![]() |
ff7d9c0aa9 | ||
![]() |
c643d9a4f5 | ||
![]() |
d34e1d379c | ||
![]() |
c9ca36085e | ||
![]() |
24fafc5746 | ||
![]() |
de7e09acc7 | ||
![]() |
edc073a0ea | ||
![]() |
49e9ccd0ca | ||
![]() |
775c63a301 | ||
![]() |
de07befb88 | ||
![]() |
59d957f06c | ||
![]() |
7ba410bb4e | ||
![]() |
5055669981 | ||
![]() |
8440bc6fc7 | ||
![]() |
fe5e8bf730 | ||
![]() |
9b2beb3d37 | ||
![]() |
1b1b74f39b | ||
![]() |
5db88cffe3 | ||
![]() |
c1406e6bfc | ||
![]() |
6bfd26bf0c | ||
![]() |
22fda2dbba | ||
![]() |
470eb93a3f | ||
![]() |
ea4c1cbb92 | ||
![]() |
c15f589a8f | ||
![]() |
778c578656 | ||
![]() |
b34c890d3e | ||
![]() |
63e7b3dd89 | ||
![]() |
db9111ff22 | ||
![]() |
c11bd9dc7b | ||
![]() |
61d4f7d2c2 | ||
![]() |
95995eab0e | ||
![]() |
1b2f5fabfa | ||
![]() |
3f262dfcd2 | ||
![]() |
6e5e7cb891 | ||
![]() |
66fdeefe84 | ||
![]() |
59c4216bca | ||
![]() |
d36278fd5e | ||
![]() |
4d564e29de | ||
![]() |
ebac276af7 | ||
![]() |
5a3df33890 | ||
![]() |
4f86e075e0 | ||
![]() |
333857ff81 | ||
![]() |
abd69a2acd | ||
![]() |
a6bf4fc2fc | ||
![]() |
2ca07cafd0 | ||
![]() |
f2e6244b4a | ||
![]() |
01d53fe29c | ||
![]() |
7c0380c25e | ||
![]() |
2a9777e3e7 | ||
![]() |
96efbbcc9f | ||
![]() |
4d07fc41f0 | ||
![]() |
a1320fe8da | ||
![]() |
b4ed9b4e7d | ||
![]() |
11ab3d7c42 | ||
![]() |
fcee5844cc | ||
![]() |
bff0dcfb7a | ||
![]() |
589693778a | ||
![]() |
dbbdfe876c | ||
![]() |
04b9f7b5c1 | ||
![]() |
1d7c95a822 | ||
![]() |
e4ab7d0a32 | ||
![]() |
6027a387b0 | ||
![]() |
3e2336a63d | ||
![]() |
1260afb2c4 | ||
![]() |
dbee403b59 | ||
![]() |
7676d5867b | ||
![]() |
6bae00361b | ||
![]() |
1c18890fbf | ||
![]() |
8e400e7ee5 | ||
![]() |
cd9b713c41 | ||
![]() |
9ce0776d53 | ||
![]() |
346ec59ea5 | ||
![]() |
bc533f3d18 | ||
![]() |
efaca311fc | ||
![]() |
2b3338cc43 | ||
![]() |
56cb31fd2a | ||
![]() |
5b97e7ef60 | ||
![]() |
3a20245304 | ||
![]() |
768425ad0f | ||
![]() |
60cd782c64 | ||
![]() |
8d59e7138c | ||
![]() |
e79de6c36d | ||
![]() |
810de851ff | ||
![]() |
15af258db0 | ||
![]() |
15d94d2c4b | ||
![]() |
dae2a3a512 | ||
![]() |
2575d4c909 | ||
![]() |
f15f65192d | ||
![]() |
dad0f0e962 | ||
![]() |
7d8a728925 | ||
![]() |
bf2f0f5ad7 | ||
![]() |
3994039864 | ||
![]() |
a5320b28ee | ||
![]() |
94a18707dd | ||
![]() |
67cc8aa480 | ||
![]() |
da66c27580 | ||
![]() |
4acac51a8d | ||
![]() |
94075595de | ||
![]() |
5ac88dbd1c | ||
![]() |
24c03163f6 | ||
![]() |
4ffe24f427 | ||
![]() |
2f12127cc9 | ||
![]() |
071a3b4f22 | ||
![]() |
6465ea9ed6 | ||
![]() |
c97f932bc3 | ||
![]() |
41aa42d897 | ||
![]() |
76dbdcdfa0 | ||
![]() |
76b6b648cc | ||
![]() |
694713ba17 | ||
![]() |
6c64aa7c3d | ||
![]() |
882078cd60 | ||
![]() |
19773884de | ||
![]() |
dad30d33bd | ||
![]() |
bf199478d7 | ||
![]() |
a5df20851d | ||
![]() |
227cc6eb49 | ||
![]() |
f03719af81 | ||
![]() |
73d131972a | ||
![]() |
fa2e34a065 | ||
![]() |
2204f27b01 | ||
![]() |
3fb18391df | ||
![]() |
2138c0e123 | ||
![]() |
3df710e1fc | ||
![]() |
f627011802 | ||
![]() |
2ef607ecb9 | ||
![]() |
2820b840e4 | ||
![]() |
78fe8d2558 | ||
![]() |
7b6fa41baf | ||
![]() |
44f52db289 | ||
![]() |
75bed46029 | ||
![]() |
fe5079a571 | ||
![]() |
fd1fdf1c73 | ||
![]() |
45b7361e79 | ||
![]() |
b0e8a29f85 | ||
![]() |
86dacf6e73 | ||
![]() |
e05ef2e969 | ||
![]() |
ea15722629 | ||
![]() |
a370b8a7e1 | ||
![]() |
83713412f2 | ||
![]() |
c50aa6c312 | ||
![]() |
5f6c5d0e07 | ||
![]() |
72d5f232d6 | ||
![]() |
4cc98c59fd | ||
![]() |
61fc320b8f | ||
![]() |
9ca358bd5a | ||
![]() |
61074fea2c | ||
![]() |
6453b74a96 | ||
![]() |
5240a8e75b | ||
![]() |
0c021217b1 | ||
![]() |
af9a5f3c92 | ||
![]() |
d98afaa4dc | ||
![]() |
95da093130 | ||
![]() |
36e732ea75 | ||
![]() |
8684e4ec62 | ||
![]() |
88f892bd05 | ||
![]() |
147065e023 | ||
![]() |
3f49a26502 | ||
![]() |
cbfd5bfa7e | ||
![]() |
584d56731f | ||
![]() |
4ab7a49d72 | ||
![]() |
77b973ef7b | ||
![]() |
751bd6e28e | ||
![]() |
d855e80bdc | ||
![]() |
031803a40e | ||
![]() |
396d34f230 | ||
![]() |
c5c478cc1c | ||
![]() |
97e8552e68 | ||
![]() |
847611648c | ||
![]() |
32df836f08 | ||
![]() |
a169cb0767 | ||
![]() |
5c081127c7 | ||
![]() |
3e9f9eeec9 | ||
![]() |
a1e3920569 | ||
![]() |
0cdaad32af | ||
![]() |
0a5ec182c9 | ||
![]() |
924d8dd49e | ||
![]() |
574ef7d8a3 | ||
![]() |
bb0c32c31d | ||
![]() |
74a4d853ca | ||
![]() |
072488d8de | ||
![]() |
d65a3a109e | ||
![]() |
57bf0e701a | ||
![]() |
889a9d38df | ||
![]() |
2e1b53965b | ||
![]() |
7e63636141 | ||
![]() |
a0712e4727 | ||
![]() |
8eff090e9f | ||
![]() |
b7c0e0d4f0 | ||
![]() |
35596ea641 | ||
![]() |
46ff725166 | ||
![]() |
f075f420fc |
@@ -6,33 +6,22 @@ cache:
|
||||
- packages -> **\packages.config
|
||||
- '%USERPROFILE%\.nuget\packages -> **\project.json'
|
||||
before_build:
|
||||
- cmd: nuget restore
|
||||
- ps: >-
|
||||
$env:GIT_TAG = git describe --always --tags
|
||||
|
||||
nuget restore
|
||||
build:
|
||||
verbosity: minimal
|
||||
after_build:
|
||||
- cmd: >-
|
||||
type GitVersion.cs
|
||||
- ps: >-
|
||||
Get-Content GitVersion.cs
|
||||
|
||||
cd Build
|
||||
Move-Item Build\QuickLook-$env:GIT_TAG.msi QuickLook-$env:GIT_TAG.msi
|
||||
|
||||
Move-Item Build\QuickLook-$env:GIT_TAG.zip QuickLook-$env:GIT_TAG.zip
|
||||
|
||||
move QuickLook.msi ..\QuickLook-%APPVEYOR_REPO_TAG_NAME%.msi
|
||||
|
||||
dir ..\QuickLook-%APPVEYOR_REPO_TAG_NAME%.msi
|
||||
|
||||
7z a ..\QuickLook-%APPVEYOR_REPO_TAG_NAME%.zip .\Package\* -r
|
||||
|
||||
7z l ..\QuickLook-%APPVEYOR_REPO_TAG_NAME%.zip
|
||||
artifacts:
|
||||
- path: QuickLook-$(APPVEYOR_REPO_TAG_NAME).zip
|
||||
name: QuickLook-$(APPVEYOR_REPO_TAG_NAME)
|
||||
- path: QuickLook-$(APPVEYOR_REPO_TAG_NAME).msi
|
||||
name: QuickLook-$(APPVEYOR_REPO_TAG_NAME)
|
||||
deploy:
|
||||
- provider: GitHub
|
||||
auth_token:
|
||||
secure: YwPL9DCYIWsHKBT7WMnx+IHTWph9fEOUBpnfZhZMTgz6VzWem01X+l/vZPlFxCG/
|
||||
artifact: QuickLook-$(APPVEYOR_REPO_TAG_NAME)
|
||||
draft: true
|
||||
on:
|
||||
branch: master
|
||||
APPVEYOR_REPO_TAG: true
|
||||
- path: QuickLook-%GIT_TAG%.zip
|
||||
name: QuickLook-%GIT_TAG%
|
||||
- path: QuickLook-%GIT_TAG%.msi
|
||||
name: QuickLook-%GIT_TAG%
|
||||
|
8
.gitignore
vendored
@@ -17,8 +17,6 @@
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
@@ -290,4 +288,8 @@ __pycache__/
|
||||
/QuickLook.Plugin.PDFViewer/MoonPdfLib
|
||||
/GitVersion.cs
|
||||
/QuickLook.Installer/C_QuickLookComponents.wxs
|
||||
/Build/
|
||||
/Build/*
|
||||
!/Build/Assets
|
||||
!/Build/AppxManifest.*
|
||||
!/Build/assetslayout.resfiles
|
||||
!/Build/priconfig.xml
|
||||
|
53
Build/AppxManifest.dev.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10">
|
||||
<Identity Name="21090PaddyXu.QuickLook" Version="0.0.0.0"
|
||||
Publisher='E=xupaddy@gmail.com, CN="Open Source Developer, Pengfei Xu", O=Open Source Developer, C=FI' />
|
||||
<Properties>
|
||||
<DisplayName>QuickLook</DisplayName>
|
||||
<PublisherDisplayName>Paddy Xu</PublisherDisplayName>
|
||||
<Description>Bring macOS “Quick Look” feature to Windows</Description>
|
||||
<Logo>Assets\storelogo.png</Logo>
|
||||
</Properties>
|
||||
<Resources>
|
||||
<Resource Language="en-us" />
|
||||
<Resource uap:Scale="100" />
|
||||
<Resource uap:Scale="125" />
|
||||
<Resource uap:Scale="150" />
|
||||
<Resource uap:Scale="200" />
|
||||
<Resource uap:Scale="400" />
|
||||
</Resources>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.15063.0" />
|
||||
</Dependencies>
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
<Applications>
|
||||
<Application Id="Main" Executable="Package\QuickLook.exe" EntryPoint="Windows.FullTrustApplication">
|
||||
<Extensions>
|
||||
<desktop:Extension Category="windows.startupTask" Executable="Package\QuickLook.exe"
|
||||
EntryPoint="Windows.FullTrustApplication">
|
||||
<desktop:StartupTask TaskId="QuickLookTask" Enabled="true" DisplayName="QuickLook" />
|
||||
</desktop:Extension>
|
||||
</Extensions>
|
||||
<uap:VisualElements DisplayName="QuickLook"
|
||||
Description="Bring macOS “Quick Look” feature to Windows"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"
|
||||
Square310x310Logo="Assets\LargeTile.png"
|
||||
Square71x71Logo="Assets\SmallTile.png">
|
||||
<uap:ShowNameOnTiles>
|
||||
<uap:ShowOn Tile="square150x150Logo" />
|
||||
<uap:ShowOn Tile="wide310x150Logo" />
|
||||
<uap:ShowOn Tile="square310x310Logo" />
|
||||
</uap:ShowNameOnTiles>
|
||||
</uap:DefaultTile>
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
</Package>
|
52
Build/AppxManifest.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10">
|
||||
<Identity Name="21090PaddyXu.QuickLook" Version="0.0.0.0" Publisher="CN=CE36AF3D-FF94-43EB-9908-7EC8FD1D29FB" />
|
||||
<Properties>
|
||||
<DisplayName>QuickLook</DisplayName>
|
||||
<PublisherDisplayName>Paddy Xu</PublisherDisplayName>
|
||||
<Description>Bring macOS “Quick Look” feature to Windows</Description>
|
||||
<Logo>Assets\storelogo.png</Logo>
|
||||
</Properties>
|
||||
<Resources>
|
||||
<Resource Language="en-us" />
|
||||
<Resource uap:Scale="100" />
|
||||
<Resource uap:Scale="125" />
|
||||
<Resource uap:Scale="150" />
|
||||
<Resource uap:Scale="200" />
|
||||
<Resource uap:Scale="400" />
|
||||
</Resources>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.15063.0" />
|
||||
</Dependencies>
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
<Applications>
|
||||
<Application Id="Main" Executable="Package\QuickLook.exe" EntryPoint="Windows.FullTrustApplication">
|
||||
<Extensions>
|
||||
<desktop:Extension Category="windows.startupTask" Executable="Package\QuickLook.exe"
|
||||
EntryPoint="Windows.FullTrustApplication">
|
||||
<desktop:StartupTask TaskId="QuickLookTask" Enabled="true" DisplayName="QuickLook" />
|
||||
</desktop:Extension>
|
||||
</Extensions>
|
||||
<uap:VisualElements DisplayName="QuickLook"
|
||||
Description="Bring macOS “Quick Look” feature to Windows"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"
|
||||
Square310x310Logo="Assets\LargeTile.png"
|
||||
Square71x71Logo="Assets\SmallTile.png">
|
||||
<uap:ShowNameOnTiles>
|
||||
<uap:ShowOn Tile="square150x150Logo" />
|
||||
<uap:ShowOn Tile="wide310x150Logo" />
|
||||
<uap:ShowOn Tile="square310x310Logo" />
|
||||
</uap:ShowNameOnTiles>
|
||||
</uap:DefaultTile>
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
</Package>
|
BIN
Build/Assets/LargeTile.scale-100.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
Build/Assets/LargeTile.scale-125.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
Build/Assets/LargeTile.scale-150.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
Build/Assets/LargeTile.scale-200.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
Build/Assets/LargeTile.scale-400.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
Build/Assets/SmallTile.scale-100.png
Normal file
After Width: | Height: | Size: 965 B |
BIN
Build/Assets/SmallTile.scale-125.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
Build/Assets/SmallTile.scale-150.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Build/Assets/SmallTile.scale-200.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Build/Assets/SmallTile.scale-400.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
Build/Assets/Square150x150Logo.scale-100.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Build/Assets/Square150x150Logo.scale-125.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Build/Assets/Square150x150Logo.scale-150.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
Build/Assets/Square150x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
Build/Assets/Square150x150Logo.scale-400.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
Build/Assets/Square44x44Logo.altform-unplated_targetsize-16.png
Normal file
After Width: | Height: | Size: 417 B |
BIN
Build/Assets/Square44x44Logo.altform-unplated_targetsize-24.png
Normal file
After Width: | Height: | Size: 568 B |
BIN
Build/Assets/Square44x44Logo.altform-unplated_targetsize-256.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
Build/Assets/Square44x44Logo.altform-unplated_targetsize-32.png
Normal file
After Width: | Height: | Size: 789 B |
BIN
Build/Assets/Square44x44Logo.altform-unplated_targetsize-48.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
Build/Assets/Square44x44Logo.scale-100.png
Normal file
After Width: | Height: | Size: 824 B |
BIN
Build/Assets/Square44x44Logo.scale-125.png
Normal file
After Width: | Height: | Size: 1007 B |
BIN
Build/Assets/Square44x44Logo.scale-150.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
Build/Assets/Square44x44Logo.scale-200.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
Build/Assets/Square44x44Logo.scale-400.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
Build/Assets/Square44x44Logo.targetsize-16.png
Normal file
After Width: | Height: | Size: 331 B |
BIN
Build/Assets/Square44x44Logo.targetsize-24.png
Normal file
After Width: | Height: | Size: 451 B |
BIN
Build/Assets/Square44x44Logo.targetsize-256.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
Build/Assets/Square44x44Logo.targetsize-32.png
Normal file
After Width: | Height: | Size: 599 B |
BIN
Build/Assets/Square44x44Logo.targetsize-48.png
Normal file
After Width: | Height: | Size: 864 B |
BIN
Build/Assets/Wide310x150Logo.scale-100.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
Build/Assets/Wide310x150Logo.scale-125.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
Build/Assets/Wide310x150Logo.scale-150.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
Build/Assets/Wide310x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
Build/Assets/Wide310x150Logo.scale-400.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
Build/Assets/storelogo.scale-100.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
Build/Assets/storelogo.scale-125.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Build/Assets/storelogo.scale-150.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
Build/Assets/storelogo.scale-200.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
Build/Assets/storelogo.scale-400.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
40
Build/assetslayout.resfiles
Normal file
@@ -0,0 +1,40 @@
|
||||
Assets\LargeTile.scale-100.png
|
||||
Assets\LargeTile.scale-125.png
|
||||
Assets\LargeTile.scale-150.png
|
||||
Assets\LargeTile.scale-200.png
|
||||
Assets\LargeTile.scale-400.png
|
||||
Assets\SmallTile.scale-100.png
|
||||
Assets\SmallTile.scale-125.png
|
||||
Assets\SmallTile.scale-150.png
|
||||
Assets\SmallTile.scale-200.png
|
||||
Assets\SmallTile.scale-400.png
|
||||
Assets\Square150x150Logo.scale-100.png
|
||||
Assets\Square150x150Logo.scale-125.png
|
||||
Assets\Square150x150Logo.scale-150.png
|
||||
Assets\Square150x150Logo.scale-200.png
|
||||
Assets\Square150x150Logo.scale-400.png
|
||||
Assets\Square44x44Logo.altform-unplated_targetsize-16.png
|
||||
Assets\Square44x44Logo.altform-unplated_targetsize-24.png
|
||||
Assets\Square44x44Logo.altform-unplated_targetsize-32.png
|
||||
Assets\Square44x44Logo.altform-unplated_targetsize-48.png
|
||||
Assets\Square44x44Logo.altform-unplated_targetsize-256.png
|
||||
Assets\Square44x44Logo.scale-100.png
|
||||
Assets\Square44x44Logo.scale-125.png
|
||||
Assets\Square44x44Logo.scale-150.png
|
||||
Assets\Square44x44Logo.scale-200.png
|
||||
Assets\Square44x44Logo.scale-400.png
|
||||
Assets\Square44x44Logo.targetsize-16.png
|
||||
Assets\Square44x44Logo.targetsize-24.png
|
||||
Assets\Square44x44Logo.targetsize-32.png
|
||||
Assets\Square44x44Logo.targetsize-48.png
|
||||
Assets\Square44x44Logo.targetsize-256.png
|
||||
Assets\storelogo.scale-100.png
|
||||
Assets\storelogo.scale-125.png
|
||||
Assets\storelogo.scale-150.png
|
||||
Assets\storelogo.scale-200.png
|
||||
Assets\storelogo.scale-400.png
|
||||
Assets\Wide310x150Logo.scale-100.png
|
||||
Assets\Wide310x150Logo.scale-125.png
|
||||
Assets\Wide310x150Logo.scale-150.png
|
||||
Assets\Wide310x150Logo.scale-200.png
|
||||
Assets\Wide310x150Logo.scale-400.png
|
18
Build/priconfig.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources targetOsVersion="10.0.0" majorVersion="1">
|
||||
<index root="\" startIndexAt="..\assetslayout.resfiles">
|
||||
<default>
|
||||
<qualifier name="Language" value="en-US" />
|
||||
<qualifier name="Contrast" value="standard" />
|
||||
<qualifier name="Scale" value="100" />
|
||||
<qualifier name="HomeRegion" value="001" />
|
||||
<qualifier name="TargetSize" value="256" />
|
||||
<qualifier name="LayoutDirection" value="LTR" />
|
||||
<qualifier name="Configuration" value="" />
|
||||
<qualifier name="AlternateForm" value="" />
|
||||
<qualifier name="DXFeatureLevel" value="DX9" />
|
||||
<qualifier name="Platform" value="UAP" />
|
||||
</default>
|
||||
<indexer-config type="RESFILES" qualifierDelimiter="." />
|
||||
</index>
|
||||
</resources>
|
152
QuickLook.Common/ExtensionMethods/BitmapExtensions.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using PixelFormat = System.Windows.Media.PixelFormat;
|
||||
|
||||
namespace QuickLook.Common.ExtensionMethods
|
||||
{
|
||||
public static class BitmapExtensions
|
||||
{
|
||||
public static BitmapSource ToBitmapSource(this Bitmap source)
|
||||
{
|
||||
var orgSource = source;
|
||||
BitmapSource bs = null;
|
||||
try
|
||||
{
|
||||
var data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
|
||||
ImageLockMode.ReadOnly, source.PixelFormat);
|
||||
|
||||
// BitmapSource.Create throws an exception when the image is scanned backward.
|
||||
// The Clone() will make it back scanning forward.
|
||||
if (data.Stride < 0)
|
||||
{
|
||||
source.UnlockBits(data);
|
||||
source = (Bitmap) source.Clone();
|
||||
data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
|
||||
ImageLockMode.ReadOnly, source.PixelFormat);
|
||||
}
|
||||
|
||||
bs = BitmapSource.Create(source.Width, source.Height, Math.Floor(source.HorizontalResolution),
|
||||
Math.Floor(source.VerticalResolution), ConvertPixelFormat(source.PixelFormat), null,
|
||||
data.Scan0, data.Stride * source.Height, data.Stride);
|
||||
|
||||
source.UnlockBits(data);
|
||||
|
||||
bs.Freeze();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (orgSource != source)
|
||||
source.Dispose();
|
||||
}
|
||||
|
||||
return bs;
|
||||
}
|
||||
|
||||
public static Bitmap ToBitmap(this BitmapSource source)
|
||||
{
|
||||
using (var outStream = new MemoryStream())
|
||||
{
|
||||
BitmapEncoder enc = new BmpBitmapEncoder();
|
||||
enc.Frames.Add(BitmapFrame.Create(source));
|
||||
enc.Save(outStream);
|
||||
var bitmap = new Bitmap(outStream);
|
||||
|
||||
return new Bitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
private static PixelFormat ConvertPixelFormat(
|
||||
System.Drawing.Imaging.PixelFormat sourceFormat)
|
||||
{
|
||||
switch (sourceFormat)
|
||||
{
|
||||
case System.Drawing.Imaging.PixelFormat.Format24bppRgb:
|
||||
return PixelFormats.Bgr24;
|
||||
|
||||
case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
|
||||
return PixelFormats.Bgra32;
|
||||
|
||||
case System.Drawing.Imaging.PixelFormat.Format32bppRgb:
|
||||
return PixelFormats.Bgr32;
|
||||
}
|
||||
|
||||
return new PixelFormat();
|
||||
}
|
||||
|
||||
public static bool IsDarkImage(this Bitmap image)
|
||||
{
|
||||
// convert to 24-bit RGB image
|
||||
image = image.Clone(new Rectangle(0, 0, image.Width, image.Height),
|
||||
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
|
||||
var sampleCount = (int) (0.2 * 400 * 400);
|
||||
const int pixelSize = 24 / 8;
|
||||
var data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
|
||||
ImageLockMode.ReadWrite, image.PixelFormat);
|
||||
|
||||
var darks = 0;
|
||||
unsafe
|
||||
{
|
||||
var pFirst = (byte*) data.Scan0;
|
||||
|
||||
Parallel.For(0, sampleCount, n =>
|
||||
{
|
||||
var rand = new Random(n);
|
||||
var row = rand.Next(0, data.Height);
|
||||
var col = rand.Next(0, data.Width);
|
||||
var pos = pFirst + row * data.Stride + col * pixelSize;
|
||||
|
||||
var b = pos[0];
|
||||
var g = pos[1];
|
||||
var r = pos[2];
|
||||
|
||||
var y = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
||||
|
||||
if (y < 0.5)
|
||||
darks++;
|
||||
});
|
||||
}
|
||||
|
||||
image.UnlockBits(data);
|
||||
image.Dispose();
|
||||
|
||||
return darks > 0.65 * sampleCount;
|
||||
}
|
||||
|
||||
public static BitmapImage LoadBitmapImage(this Uri source)
|
||||
{
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.UriSource = source;
|
||||
bitmap.EndInit();
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace QuickLook.ExtensionMethods
|
||||
namespace QuickLook.Common.ExtensionMethods
|
||||
{
|
||||
public static class DispatcherExtensions
|
||||
{
|
@@ -15,16 +15,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Windows.Media;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuickLook
|
||||
namespace QuickLook.Common.ExtensionMethods
|
||||
{
|
||||
internal class MainWindowNoTransparent : MainWindowTransparent
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public MainWindowNoTransparent()
|
||||
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
|
||||
{
|
||||
Background = new SolidColorBrush(Colors.White);
|
||||
AllowsTransparency = false;
|
||||
foreach (var item in enumeration)
|
||||
action(item);
|
||||
}
|
||||
}
|
||||
}
|
48
QuickLook.Common/ExtensionMethods/FileExtensions.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
namespace QuickLook.Common.ExtensionMethods
|
||||
{
|
||||
public static class FileExtensions
|
||||
{
|
||||
public static string ToPrettySize(this long value, int decimalPlaces = 0)
|
||||
{
|
||||
const long OneKb = 1024;
|
||||
const long OneMb = OneKb * 1024;
|
||||
const long OneGb = OneMb * 1024;
|
||||
const long OneTb = OneGb * 1024;
|
||||
|
||||
var asTb = Math.Round((double) value / OneTb, decimalPlaces);
|
||||
var asGb = Math.Round((double) value / OneGb, decimalPlaces);
|
||||
var asMb = Math.Round((double) value / OneMb, decimalPlaces);
|
||||
var asKb = Math.Round((double) value / OneKb, decimalPlaces);
|
||||
var chosenValue = asTb > 1
|
||||
? $"{asTb} TB"
|
||||
: asGb > 1
|
||||
? $"{asGb} GB"
|
||||
: asMb > 1
|
||||
? $"{asMb} MB"
|
||||
: asKb > 1
|
||||
? $"{asKb} KB"
|
||||
: $"{Math.Round((double) value, decimalPlaces)} bytes";
|
||||
|
||||
return chosenValue;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,9 +17,9 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace QuickLook.ExtensionMethods
|
||||
namespace QuickLook.Common.ExtensionMethods
|
||||
{
|
||||
internal static class TypeExtensions
|
||||
public static class TypeExtensions
|
||||
{
|
||||
public static T CreateInstance<T>(this Type t)
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -19,28 +19,25 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace QuickLook.Helpers
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
internal static class DpiHelper
|
||||
public static class DpiHelper
|
||||
{
|
||||
public const float DEFAULT_DPI = 96;
|
||||
public const float DefaultDpi = 96;
|
||||
|
||||
public static Dpi GetCurrentDpi()
|
||||
public static ScaleFactor GetCurrentScaleFactor()
|
||||
{
|
||||
var g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
var desktop = g.GetHdc();
|
||||
|
||||
var dpi = new Dpi
|
||||
{
|
||||
HorizontalDpi = GetDeviceCaps(desktop, (int) DeviceCap.LOGPIXELSX),
|
||||
VerticalDpi = GetDeviceCaps(desktop, (int) DeviceCap.LOGPIXELSY)
|
||||
};
|
||||
var horizontalDpi = GetDeviceCaps(desktop, (int) DeviceCap.LOGPIXELSX);
|
||||
var verticalDpi = GetDeviceCaps(desktop, (int) DeviceCap.LOGPIXELSY);
|
||||
|
||||
return dpi;
|
||||
return new ScaleFactor {Horizontal = horizontalDpi / DefaultDpi, Vertical = verticalDpi / DefaultDpi};
|
||||
}
|
||||
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern int GetDeviceCaps(IntPtr hDC, int nIndex);
|
||||
private static extern int GetDeviceCaps(IntPtr hDC, int nIndex);
|
||||
|
||||
private enum DeviceCap
|
||||
{
|
||||
@@ -54,10 +51,10 @@ namespace QuickLook.Helpers
|
||||
LOGPIXELSY = 90
|
||||
}
|
||||
|
||||
public struct Dpi
|
||||
public struct ScaleFactor
|
||||
{
|
||||
public float HorizontalDpi;
|
||||
public float VerticalDpi;
|
||||
public float Horizontal;
|
||||
public float Vertical;
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,40 +23,41 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace QuickLook.Helpers
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
internal class FileHelper
|
||||
public class FileHelper
|
||||
{
|
||||
public static bool? GetAssocApplication(string path, out string appFriendlyName)
|
||||
public static bool IsExecutable(string path, out string appFriendlyName)
|
||||
{
|
||||
appFriendlyName = string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return null;
|
||||
|
||||
if (Directory.Exists(path))
|
||||
return null;
|
||||
|
||||
if (!File.Exists(path))
|
||||
return null;
|
||||
|
||||
var ext = Path.GetExtension(path).ToLower();
|
||||
var isExe = new[] {".cmd", ".bat", ".pif", ".scf", ".exe", ".com", ".scr"}.Contains(ext.ToLower());
|
||||
|
||||
// no assoc. app. found
|
||||
if (!isExe)
|
||||
if (string.IsNullOrEmpty(GetAssocApplicationNative(ext, AssocStr.Command)))
|
||||
if (string.IsNullOrEmpty(GetAssocApplicationNative(ext, AssocStr.AppId))) // UWP
|
||||
return null;
|
||||
|
||||
appFriendlyName = isExe
|
||||
? FileVersionInfo.GetVersionInfo(path).FileDescription
|
||||
: GetAssocApplicationNative(ext, AssocStr.FriendlyAppName);
|
||||
return false;
|
||||
|
||||
appFriendlyName = FileVersionInfo.GetVersionInfo(path).FileDescription;
|
||||
if (string.IsNullOrEmpty(appFriendlyName))
|
||||
appFriendlyName = Path.GetFileName(path);
|
||||
|
||||
return isExe;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool GetAssocApplication(string path, out string appFriendlyName)
|
||||
{
|
||||
appFriendlyName = string.Empty;
|
||||
var ext = Path.GetExtension(path).ToLower();
|
||||
|
||||
// no assoc. app. found
|
||||
if (string.IsNullOrEmpty(GetAssocApplicationNative(ext, AssocStr.Command)))
|
||||
if (string.IsNullOrEmpty(GetAssocApplicationNative(ext, AssocStr.AppId))) // UWP
|
||||
return false;
|
||||
|
||||
appFriendlyName = GetAssocApplicationNative(ext, AssocStr.FriendlyAppName);
|
||||
if (string.IsNullOrEmpty(appFriendlyName))
|
||||
appFriendlyName = Path.GetFileName(path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[DllImport("shlwapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
79
QuickLook.Common/Helpers/ProcessHelper.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using QuickLook.Common.NativeMethods;
|
||||
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
public class ProcessHelper
|
||||
{
|
||||
private const int ErrorInsufficientBuffer = 0x7A;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void PerformAggressiveGC()
|
||||
{
|
||||
// delay some time to make sure that all windows are closed
|
||||
Task.Delay(2000).ContinueWith(t => GC.Collect(GC.MaxGeneration));
|
||||
}
|
||||
|
||||
public static bool IsRunningAsUWP()
|
||||
{
|
||||
try
|
||||
{
|
||||
uint len = 0;
|
||||
var r = Kernel32.GetCurrentPackageFullName(ref len, null);
|
||||
|
||||
return r == ErrorInsufficientBuffer;
|
||||
}
|
||||
catch (EntryPointNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool IsOnWindows10S()
|
||||
{
|
||||
const uint PRODUCT_CLOUD = 0x000000B2; // Windows 10 S
|
||||
const uint PRODUCT_CLOUDN = 0x000000B3; // Windows 10 S N
|
||||
|
||||
Kernel32.GetProductInfo(Environment.OSVersion.Version.Major,
|
||||
Environment.OSVersion.Version.Minor, 0, 0, out var osType);
|
||||
|
||||
return osType == PRODUCT_CLOUD || osType == PRODUCT_CLOUDN;
|
||||
}
|
||||
|
||||
public static void WriteLog(string msg)
|
||||
{
|
||||
var logFilePath = Path.Combine(SettingHelper.LocalDataPath, @"QuickLook.Exception.log");
|
||||
|
||||
using (var writer = new StreamWriter(new FileStream(logFilePath, FileMode.OpenOrCreate,
|
||||
FileAccess.ReadWrite, FileShare.Read)))
|
||||
{
|
||||
writer.BaseStream.Seek(0, SeekOrigin.End);
|
||||
|
||||
writer.WriteLine($"========{DateTime.Now}========");
|
||||
writer.WriteLine(msg);
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
140
QuickLook.Common/Helpers/SettingHelper.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
// Copyright © 2018 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
public class SettingHelper
|
||||
{
|
||||
public static readonly string LocalDataPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"pooi.moe\QuickLook\");
|
||||
|
||||
private static readonly Dictionary<string, XmlDocument> FileCache = new Dictionary<string, XmlDocument>();
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static T Get<T>(string id, T failsafe = default(T), Assembly calling = null)
|
||||
{
|
||||
if (!typeof(T).IsSerializable && !typeof(ISerializable).IsAssignableFrom(typeof(T)))
|
||||
throw new InvalidOperationException("A serializable Type is required");
|
||||
|
||||
var file = Path.Combine(LocalDataPath,
|
||||
(calling ?? Assembly.GetCallingAssembly()).GetName().Name + ".config");
|
||||
|
||||
var doc = GetConfigFile(file);
|
||||
|
||||
// try to get setting
|
||||
var s = GetSettingFromXml(doc, id, failsafe);
|
||||
|
||||
return s != null ? s : failsafe;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static void Set(string id, object value, Assembly calling = null)
|
||||
{
|
||||
if (!value.GetType().IsSerializable)
|
||||
throw new NotSupportedException("New value if not serializable.");
|
||||
|
||||
var file = Path.Combine(LocalDataPath,
|
||||
(calling ?? Assembly.GetCallingAssembly()).GetName().Name + ".config");
|
||||
|
||||
WriteSettingToXml(GetConfigFile(file), id, value);
|
||||
}
|
||||
|
||||
private static T GetSettingFromXml<T>(XmlDocument doc, string id, T failsafe)
|
||||
{
|
||||
var v = doc.SelectSingleNode($@"/Settings/{id}");
|
||||
|
||||
try
|
||||
{
|
||||
var result = v == null ? failsafe : (T) Convert.ChangeType(v.InnerText, typeof(T));
|
||||
return result;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return failsafe;
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteSettingToXml(XmlDocument doc, string id, object value)
|
||||
{
|
||||
var v = doc.SelectSingleNode($@"/Settings/{id}");
|
||||
|
||||
if (v != null)
|
||||
{
|
||||
v.InnerText = value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var node = doc.CreateNode(XmlNodeType.Element, id, doc.NamespaceURI);
|
||||
node.InnerText = value.ToString();
|
||||
doc.SelectSingleNode(@"/Settings")?.AppendChild(node);
|
||||
}
|
||||
|
||||
doc.Save(new Uri(doc.BaseURI).LocalPath);
|
||||
}
|
||||
|
||||
private static XmlDocument GetConfigFile(string file)
|
||||
{
|
||||
if (FileCache.ContainsKey(file))
|
||||
return FileCache[file];
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||||
if (!File.Exists(file))
|
||||
CreateNewConfig(file);
|
||||
|
||||
var doc = new XmlDocument();
|
||||
try
|
||||
{
|
||||
doc.Load(file);
|
||||
}
|
||||
catch (XmlException)
|
||||
{
|
||||
CreateNewConfig(file);
|
||||
doc.Load(file);
|
||||
}
|
||||
|
||||
if (doc.SelectSingleNode(@"/Settings") == null)
|
||||
{
|
||||
CreateNewConfig(file);
|
||||
doc.Load(file);
|
||||
}
|
||||
|
||||
FileCache.Add(file, doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
private static void CreateNewConfig(string file)
|
||||
{
|
||||
using (var writer = XmlWriter.Create(file))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("Settings");
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndDocument();
|
||||
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
86
QuickLook.Common/Helpers/TranslationHelper.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.XPath;
|
||||
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
public class TranslationHelper
|
||||
{
|
||||
private static readonly CultureInfo CurrentCultureInfo = CultureInfo.CurrentUICulture;
|
||||
//private static readonly CultureInfo CurrentCultureInfo = CultureInfo.GetCultureInfo("zh-CN");
|
||||
|
||||
private static readonly Dictionary<string, XPathNavigator> FileCache = new Dictionary<string, XPathNavigator>();
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string Get(string id, string file = null, CultureInfo locale = null, string failsafe = null,
|
||||
Assembly calling = null)
|
||||
{
|
||||
if (file == null)
|
||||
file = Path.Combine(Path.GetDirectoryName((calling ?? Assembly.GetCallingAssembly()).Location),
|
||||
"Translations.config");
|
||||
|
||||
if (!File.Exists(file))
|
||||
return failsafe ?? id;
|
||||
|
||||
if (locale == null)
|
||||
locale = CurrentCultureInfo;
|
||||
|
||||
var nav = GetLangFile(file);
|
||||
|
||||
// try to get string
|
||||
var s = GetStringFromXml(nav, id, locale);
|
||||
if (s != null)
|
||||
return s;
|
||||
|
||||
// try again for parent language
|
||||
if (locale.Parent.Name != string.Empty)
|
||||
s = GetStringFromXml(nav, id, locale.Parent);
|
||||
if (s != null)
|
||||
return s;
|
||||
|
||||
// use fallback language
|
||||
s = GetStringFromXml(nav, id, CultureInfo.GetCultureInfo("en"));
|
||||
if (s != null)
|
||||
return s;
|
||||
|
||||
return failsafe ?? id;
|
||||
}
|
||||
|
||||
private static string GetStringFromXml(XPathNavigator nav, string id, CultureInfo locale)
|
||||
{
|
||||
var result = nav.SelectSingleNode($@"/Translations/{locale.Name}/{id}");
|
||||
|
||||
return result?.Value;
|
||||
}
|
||||
|
||||
private static XPathNavigator GetLangFile(string file)
|
||||
{
|
||||
if (FileCache.ContainsKey(file))
|
||||
return FileCache[file];
|
||||
|
||||
var res = new XPathDocument(file).CreateNavigator();
|
||||
FileCache.Add(file, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,25 +17,29 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using QuickLook.NativeMethods;
|
||||
using QuickLook.Common.NativeMethods;
|
||||
|
||||
namespace QuickLook.Helpers
|
||||
namespace QuickLook.Common.Helpers
|
||||
{
|
||||
internal static class WindowHelper
|
||||
public static class WindowHelper
|
||||
{
|
||||
public enum WindowCompositionAttribute
|
||||
{
|
||||
WcaAccentPolicy = 19
|
||||
}
|
||||
|
||||
public static Rect GetCurrentWindowRect()
|
||||
{
|
||||
var screen = Screen.FromPoint(Cursor.Position).WorkingArea;
|
||||
var dpi = DpiHelper.GetCurrentDpi();
|
||||
var scaleX = dpi.HorizontalDpi / DpiHelper.DEFAULT_DPI;
|
||||
var scaleY = dpi.VerticalDpi / DpiHelper.DEFAULT_DPI;
|
||||
var scale = DpiHelper.GetCurrentScaleFactor();
|
||||
return new Rect(
|
||||
new Point(screen.X / scaleX, screen.Y / scaleY),
|
||||
new Size(screen.Width / scaleX, screen.Height / scaleY));
|
||||
new Point(screen.X / scale.Horizontal, screen.Y / scale.Vertical),
|
||||
new Size(screen.Width / scale.Horizontal, screen.Height / scale.Vertical));
|
||||
}
|
||||
|
||||
public static void BringToFront(this Window window)
|
||||
@@ -55,12 +59,11 @@ namespace QuickLook.Helpers
|
||||
{
|
||||
int pxLeft = 0, pxTop = 0;
|
||||
if (left != 0 || top != 0)
|
||||
window.TransformToPixels(left, top,
|
||||
TransformToPixels(window, left, top,
|
||||
out pxLeft, out pxTop);
|
||||
|
||||
int pxWidth, pxHeight;
|
||||
window.TransformToPixels(width, height,
|
||||
out pxWidth, out pxHeight);
|
||||
TransformToPixels(window, width, height,
|
||||
out var pxWidth, out var pxHeight);
|
||||
|
||||
User32.MoveWindow(new WindowInteropHelper(window).Handle, pxLeft, pxTop, pxWidth, pxHeight, true);
|
||||
}
|
||||
@@ -81,25 +84,74 @@ namespace QuickLook.Helpers
|
||||
matrix = src.CompositionTarget.TransformToDevice;
|
||||
}
|
||||
|
||||
pixelX = (int) (matrix.M11 * unitX);
|
||||
pixelY = (int) (matrix.M22 * unitY);
|
||||
pixelX = (int) Math.Round(matrix.M11 * unitX);
|
||||
pixelY = (int) Math.Round(matrix.M22 * unitY);
|
||||
}
|
||||
|
||||
internal static bool IsForegroundWindowBelongToSelf()
|
||||
public static bool IsForegroundWindowBelongToSelf()
|
||||
{
|
||||
var hwnd = User32.GetForegroundWindow();
|
||||
if (hwnd == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
User32.GetWindowThreadProcessId(hwnd, out uint procId);
|
||||
User32.GetWindowThreadProcessId(hwnd, out var procId);
|
||||
return procId == Process.GetCurrentProcess().Id;
|
||||
}
|
||||
|
||||
internal static void SetNoactivate(WindowInteropHelper window)
|
||||
public static void SetNoactivate(WindowInteropHelper window)
|
||||
{
|
||||
User32.SetWindowLong(window.Handle, User32.GWL_EXSTYLE,
|
||||
User32.GetWindowLong(window.Handle, User32.GWL_EXSTYLE) |
|
||||
User32.WS_EX_NOACTIVATE);
|
||||
}
|
||||
|
||||
public static void EnableBlur(Window window)
|
||||
{
|
||||
var accent = new AccentPolicy();
|
||||
var accentStructSize = Marshal.SizeOf(accent);
|
||||
accent.AccentState = AccentState.AccentEnableBlurbehind;
|
||||
accent.AccentFlags = 2;
|
||||
accent.GradientColor = 0x99FFFFFF;
|
||||
|
||||
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
|
||||
Marshal.StructureToPtr(accent, accentPtr, false);
|
||||
|
||||
var data = new WindowCompositionAttributeData
|
||||
{
|
||||
Attribute = WindowCompositionAttribute.WcaAccentPolicy,
|
||||
SizeOfData = accentStructSize,
|
||||
Data = accentPtr
|
||||
};
|
||||
|
||||
User32.SetWindowCompositionAttribute(new WindowInteropHelper(window).Handle, ref data);
|
||||
|
||||
Marshal.FreeHGlobal(accentPtr);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WindowCompositionAttributeData
|
||||
{
|
||||
public WindowCompositionAttribute Attribute;
|
||||
public IntPtr Data;
|
||||
public int SizeOfData;
|
||||
}
|
||||
|
||||
private enum AccentState
|
||||
{
|
||||
AccentDisabled = 0,
|
||||
AccentEnableGradient = 1,
|
||||
AccentEnableTransparentgradient = 2,
|
||||
AccentEnableBlurbehind = 3,
|
||||
AccentInvalidState = 4
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct AccentPolicy
|
||||
{
|
||||
public AccentState AccentState;
|
||||
public int AccentFlags;
|
||||
public uint GradientColor;
|
||||
public readonly int AnimationId;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,15 +17,24 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace QuickLook.NativeMethods
|
||||
namespace QuickLook.Common.NativeMethods
|
||||
{
|
||||
internal static class Kernel32
|
||||
public static class Kernel32
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
internal static extern IntPtr LoadLibrary(string lpFileName);
|
||||
public static extern IntPtr LoadLibrary(string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
internal static extern IntPtr GetCurrentThreadId();
|
||||
public static extern int GetCurrentPackageFullName(ref uint packageFullNameLength,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder packageFullName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr GetCurrentThreadId();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool GetProductInfo(int dwOSMajorVersion, int dwOSMinorVersion, int dwSpMajorVersion,
|
||||
int dwSpMinorVersion, out uint pdwReturnedProductType);
|
||||
}
|
||||
}
|
@@ -19,11 +19,14 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using QuickLook.Common.Helpers;
|
||||
|
||||
namespace QuickLook.NativeMethods
|
||||
namespace QuickLook.Common.NativeMethods
|
||||
{
|
||||
internal static class User32
|
||||
public static class User32
|
||||
{
|
||||
public delegate int KeyboardHookProc(int code, int wParam, ref KeyboardHookStruct lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight,
|
||||
[MarshalAs(UnmanagedType.Bool)] bool bRepaint);
|
||||
@@ -33,52 +36,54 @@ namespace QuickLook.NativeMethods
|
||||
uint uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr SetWindowsHookEx(int idHook, KeyboardHookProc callback, IntPtr hInstance,
|
||||
public static extern IntPtr SetWindowsHookEx(int idHook, KeyboardHookProc callback, IntPtr hInstance,
|
||||
uint threadId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern bool UnhookWindowsHookEx(IntPtr hInstance);
|
||||
public static extern bool UnhookWindowsHookEx(IntPtr hInstance);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref KeyboardHookStruct lParam);
|
||||
public static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref KeyboardHookStruct lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetForegroundWindow();
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr processId);
|
||||
public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr processId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
|
||||
public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, bool fAttach);
|
||||
public static extern IntPtr AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, bool fAttach);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetFocus();
|
||||
public static extern IntPtr GetFocus();
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetParent(IntPtr hWnd);
|
||||
public static extern IntPtr GetParent(IntPtr hWnd);
|
||||
|
||||
internal delegate int KeyboardHookProc(int code, int wParam, ref KeyboardHookStruct lParam);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SetWindowCompositionAttribute(IntPtr hwnd,
|
||||
ref WindowHelper.WindowCompositionAttributeData data);
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal struct KeyboardHookStruct
|
||||
public struct KeyboardHookStruct
|
||||
{
|
||||
internal int vkCode;
|
||||
internal int scanCode;
|
||||
internal int flags;
|
||||
internal int time;
|
||||
internal int dwExtraInfo;
|
||||
public int vkCode;
|
||||
public int scanCode;
|
||||
public int flags;
|
||||
public int time;
|
||||
public int dwExtraInfo;
|
||||
}
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
@@ -19,28 +19,27 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using QuickLook.Annotations;
|
||||
using QuickLook.Helpers;
|
||||
using QuickLook.Common.Annotations;
|
||||
using QuickLook.Common.Helpers;
|
||||
|
||||
namespace QuickLook.Plugin
|
||||
namespace QuickLook.Common.Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// A runtime object which allows interaction between this plugin and QuickLook.
|
||||
/// </summary>
|
||||
public class ContextObject : INotifyPropertyChanged
|
||||
{
|
||||
private bool _canFocus;
|
||||
private bool _canResize = true;
|
||||
|
||||
private bool _isBusy = true;
|
||||
private string _title = "";
|
||||
private bool _fullWindowDragging;
|
||||
private bool _isBusy;
|
||||
private string _title = string.Empty;
|
||||
private bool _titlebarAutoHide;
|
||||
private bool _titlebarBlurVisibility;
|
||||
private bool _titlebarColourVisibility = true;
|
||||
private bool _titlebarOverlap;
|
||||
private bool _useDarkTheme;
|
||||
private object _viewerContent;
|
||||
|
||||
/// <summary>
|
||||
/// Get the viewer window.
|
||||
/// </summary>
|
||||
public MainWindowTransparent ViewerWindow { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the title of Viewer window.
|
||||
/// </summary>
|
||||
@@ -99,14 +98,82 @@ namespace QuickLook.Plugin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether user are allowed to set focus at the viewer window.
|
||||
/// Set whether the full viewer window can be used for mouse dragging.
|
||||
/// </summary>
|
||||
public bool CanFocus
|
||||
public bool FullWindowDragging
|
||||
{
|
||||
get => _canFocus;
|
||||
get => _fullWindowDragging;
|
||||
set
|
||||
{
|
||||
_canFocus = value;
|
||||
_fullWindowDragging = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the viewer content is overlapped by the title bar
|
||||
/// </summary>
|
||||
public bool TitlebarOverlap
|
||||
{
|
||||
get => _titlebarOverlap;
|
||||
set
|
||||
{
|
||||
_titlebarOverlap = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the title bar shows a blurred background
|
||||
/// </summary>
|
||||
public bool TitlebarBlurVisibility
|
||||
{
|
||||
get => _titlebarBlurVisibility;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarBlurVisibility) return;
|
||||
_titlebarBlurVisibility = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the title bar shows a colour overlay
|
||||
/// </summary>
|
||||
public bool TitlebarColourVisibility
|
||||
{
|
||||
get => _titlebarColourVisibility;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarColourVisibility) return;
|
||||
_titlebarColourVisibility = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should the titlebar hides itself after a short period of inactivity?
|
||||
/// </summary>
|
||||
public bool TitlebarAutoHide
|
||||
{
|
||||
get => _titlebarAutoHide;
|
||||
set
|
||||
{
|
||||
if (value == _titlebarAutoHide) return;
|
||||
_titlebarAutoHide = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch to dark theme?
|
||||
/// </summary>
|
||||
public bool UseDarkTheme
|
||||
{
|
||||
get => _useDarkTheme;
|
||||
set
|
||||
{
|
||||
_useDarkTheme = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -114,18 +181,7 @@ namespace QuickLook.Plugin
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Show a notification balloon.
|
||||
/// </summary>
|
||||
/// <param name="title">Title of the notification.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="isError">Is this indicates a error?</param>
|
||||
public void ShowNotification(string title, string content, bool isError = false)
|
||||
{
|
||||
TrayIconManager.GetInstance().ShowNotification(title, content, isError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the size of viewer window and shrink to fit (to screen resolution).
|
||||
/// Set the size of viewer window, scale or shrink to fit (to screen resolution).
|
||||
/// The window can take maximum (maxRatio*resolution) space.
|
||||
/// </summary>
|
||||
/// <param name="size">The desired size.</param>
|
||||
@@ -135,7 +191,7 @@ namespace QuickLook.Plugin
|
||||
if (maxRatio > 1)
|
||||
maxRatio = 1;
|
||||
|
||||
var max = GetMaximumDisplayBound();
|
||||
var max = WindowHelper.GetCurrentWindowRect();
|
||||
|
||||
var widthRatio = max.Width * maxRatio / size.Width;
|
||||
var heightRatio = max.Height * maxRatio / size.Height;
|
||||
@@ -148,23 +204,22 @@ namespace QuickLook.Plugin
|
||||
return ratio;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the device-independent resolution.
|
||||
/// </summary>
|
||||
public Rect GetMaximumDisplayBound()
|
||||
public void Reset()
|
||||
{
|
||||
return WindowHelper.GetCurrentWindowRect();
|
||||
}
|
||||
|
||||
internal void Reset()
|
||||
{
|
||||
ViewerWindow = null;
|
||||
Title = "";
|
||||
ViewerContent = null;
|
||||
IsBusy = true;
|
||||
Title = string.Empty;
|
||||
// set to False to prevent showing loading icon
|
||||
IsBusy = false;
|
||||
PreferredSize = new Size();
|
||||
CanResize = true;
|
||||
CanFocus = false;
|
||||
FullWindowDragging = false;
|
||||
|
||||
UseDarkTheme = false;
|
||||
TitlebarOverlap = false;
|
||||
TitlebarAutoHide = false;
|
||||
TitlebarBlurVisibility = false;
|
||||
TitlebarColourVisibility = true;
|
||||
|
||||
ViewerContent = null;
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
@@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Plugin
|
||||
namespace QuickLook.Common.Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface implemented by every QuickLook.Plugin
|
||||
@@ -28,11 +28,6 @@ namespace QuickLook.Plugin
|
||||
/// </summary>
|
||||
int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the viewer window has blur effect.
|
||||
/// </summary>
|
||||
bool AllowsTransparency { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Do ont-time job when application starts. You may extract nessessary resource here.
|
||||
/// </summary>
|
@@ -25,7 +25,7 @@ using System;
|
||||
// ReSharper disable MemberCanBeProtected.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace QuickLook.Annotations
|
||||
namespace QuickLook.Common.Annotations
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the value of the marked element could be <c>null</c> sometimes,
|
||||
@@ -449,10 +449,10 @@ namespace QuickLook.Annotations
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
||||
public ImplicitUseKindFlags UseKindFlags { get; }
|
||||
|
||||
[UsedImplicitly]
|
||||
public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
||||
public ImplicitUseTargetFlags TargetFlags { get; }
|
||||
}
|
||||
|
||||
[Flags]
|
33
QuickLook.Common/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 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.Common")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("QuickLook.Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © Paddy Xu 2018")]
|
||||
[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)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95")]
|
||||
|
||||
// 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.*")]
|
69
QuickLook.Common/QuickLook.Common.csproj
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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>{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>QuickLook.Common</RootNamespace>
|
||||
<AssemblyName>QuickLook.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\Build\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\Build\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GitVersion.cs">
|
||||
<Link>Properties\GitVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Plugin\ContextObject.cs" />
|
||||
<Compile Include="Helpers\DpiHelper.cs" />
|
||||
<Compile Include="ExtensionMethods\BitmapExtensions.cs" />
|
||||
<Compile Include="ExtensionMethods\DispatcherExtensions.cs" />
|
||||
<Compile Include="ExtensionMethods\EnumerableExtensions.cs" />
|
||||
<Compile Include="ExtensionMethods\FileExtensions.cs" />
|
||||
<Compile Include="ExtensionMethods\TypeExtensions.cs" />
|
||||
<Compile Include="Helpers\FileHelper.cs" />
|
||||
<Compile Include="Plugin\IViewer.cs" />
|
||||
<Compile Include="NativeMethods\Kernel32.cs" />
|
||||
<Compile Include="Helpers\ProcessHelper.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\SettingHelper.cs" />
|
||||
<Compile Include="Helpers\TranslationHelper.cs" />
|
||||
<Compile Include="NativeMethods\User32.cs" />
|
||||
<Compile Include="Helpers\WindowHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@@ -71,7 +71,7 @@
|
||||
<UIRef Id="WixUI_InstallDir" />
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||
|
||||
<Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchApplication">1</Publish>
|
||||
<Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchApplication">NOT Installed</Publish>
|
||||
</UI>
|
||||
</Product>
|
||||
</Wix>
|
@@ -18,6 +18,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\Build\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants>PackageDir=$(SolutionDir)Build\Package\</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="C_QuickLookComponents.wxs" />
|
||||
@@ -32,25 +33,26 @@
|
||||
<ItemGroup>
|
||||
<Content Include="gpl.rtf" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\QuickLook\QuickLook.csproj">
|
||||
<Name>QuickLook</Name>
|
||||
<Project>{8b4a9ce5-67b5-4a94-81cb-3771f688fdeb}</Project>
|
||||
<Private>True</Private>
|
||||
<DoNotHarvest>True</DoNotHarvest>
|
||||
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
|
||||
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
|
||||
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
|
||||
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>robocopy "$(SolutionDir)Build\$(Configuration)" "$(SolutionDir)Build\Package" %2a.%2a /e /njh /njs /ndl /nfl /nc /ns /np /xf %2a.pdb /xf %2a.obj /xf %2a.ipdb /xf %2a.iobj /xf %2a.exp /xf %2a.lib /xf %2a.ilk /xf %2a.xml
|
||||
<PostBuildEvent>powershell -file "$(SolutionDir)Scripts\sign-msi.ps1"
|
||||
|
||||
"$(WIX)bin\heat" dir "$(SolutionDir)Build\Package" -dr INSTALLFOLDER -cg QuickLookComponents -gg -g1 -sf -srd -sreg -var "var.QuickLook.TargetDir" -out "$(ProjectDir)C_QuickLookComponents.wxs"</PreBuildEvent>
|
||||
powershell -file "$(SolutionDir)Scripts\rename-msi.ps1"
|
||||
|
||||
powershell -file "$(SolutionDir)Scripts\pack-zip.ps1"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>rmdir /S /Q "$(SolutionDir)Build\Package"
|
||||
|
||||
robocopy "$(SolutionDir)Build\$(Configuration)" "$(SolutionDir)Build\Package" %2a.%2a /e /njh /njs /ndl /nfl /nc /ns /np /xf %2a.pdb /xf %2a.obj /xf %2a.ipdb /xf %2a.iobj /xf %2a.exp /xf %2a.lib /xf %2a.ilk /xf %2a.xml
|
||||
|
||||
powershell -file "$(SolutionDir)Scripts\sign-package.ps1"
|
||||
|
||||
"$(WIX)bin\heat" dir "$(SolutionDir)Build\Package" -dr INSTALLFOLDER -cg QuickLookComponents -gg -g1 -sf -srd -sreg -var "var.PackageDir" -out "$(ProjectDir)C_QuickLookComponents.wxs"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -21,10 +21,10 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define DOPOUS_IPC_LP_INFO 0x00000015
|
||||
#define DOPOUS_IPC_LP_DATA L"listsel"
|
||||
#define DOPOUS_CLASS L"DOpus.ParentWindow"
|
||||
#define DOPOUS_NAME L"Directory Opus"
|
||||
#define DOPUS_IPC_LP_INFO 0x00000015
|
||||
#define DOPUS_IPC_LP_DATA L"listsel"
|
||||
#define DOPUS_CLASS L"DOpus.ParentWindow"
|
||||
#define DOPUS_NAME L"Directory Opus"
|
||||
#define MSGWINDOW_CLASS L"QuickLook.Native.DOpus.MsgWindow"
|
||||
|
||||
HWND hMsgWnd;
|
||||
@@ -59,13 +59,14 @@ void DOpus::GetSelected(PWCHAR buffer)
|
||||
if (hMsgWnd == nullptr)
|
||||
return;
|
||||
|
||||
PWCHAR data = DOPOUS_IPC_LP_DATA;
|
||||
PWCHAR data = DOPUS_IPC_LP_DATA;
|
||||
COPYDATASTRUCT cds;
|
||||
cds.dwData = DOPOUS_IPC_LP_INFO;
|
||||
cds.cbData = (wcslen(data) + 1) * sizeof WCHAR;
|
||||
cds.dwData = DOPUS_IPC_LP_INFO;
|
||||
cds.cbData = static_cast<DWORD>(wcslen(data) + 1) * sizeof WCHAR;
|
||||
cds.lpData = data;
|
||||
|
||||
auto ret = SendMessage(FindWindow(DOPOUS_CLASS, DOPOUS_NAME), WM_COPYDATA, (WPARAM)hMsgWnd, (LPARAM)&cds);
|
||||
auto ret = SendMessage(FindWindow(DOPUS_CLASS, DOPUS_NAME), WM_COPYDATA, reinterpret_cast<WPARAM>(hMsgWnd),
|
||||
reinterpret_cast<LPARAM>(&cds));
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
@@ -111,7 +112,7 @@ void DOpus::ParseXmlBuffer(PWCHAR buffer)
|
||||
|
||||
void DOpus::PrepareMessageWindow()
|
||||
{
|
||||
WNDCLASSEX wx = {'\0'};
|
||||
WNDCLASSEX wx = {sizeof wx};
|
||||
wx.cbSize = sizeof(WNDCLASSEX);
|
||||
wx.lpfnWndProc = msgWindowProc;
|
||||
wx.lpszClassName = MSGWINDOW_CLASS;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -34,6 +34,9 @@ static WCHAR filePathBuffer[MAX_PATH] = {'\0'};
|
||||
|
||||
void DialogHook::GetSelected(PWCHAR buffer)
|
||||
{
|
||||
if (HelperMethods::IsUWP())
|
||||
return;
|
||||
|
||||
auto hwndfg = GetForegroundWindow();
|
||||
DWORD pid = 0;
|
||||
auto tid = GetWindowThreadProcessId(hwndfg, &pid);
|
||||
@@ -96,7 +99,8 @@ void DialogHook::GetSelectedFromWoW64HookHelper(PWCHAR buffer)
|
||||
if (hHelperWnd == nullptr)
|
||||
return;
|
||||
|
||||
auto hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, MAX_PATH * sizeof WCHAR, SHARED_MEM_NAME);
|
||||
auto hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, MAX_PATH * sizeof WCHAR,
|
||||
SHARED_MEM_NAME);
|
||||
if (hMapFile == nullptr)
|
||||
return;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -42,7 +42,7 @@ void HelperMethods::GetSelectedInternal(CComQIPtr<IWebBrowserApp> pwba, PWCHAR b
|
||||
void HelperMethods::ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer)
|
||||
{
|
||||
FORMATETC formatetc;
|
||||
STGMEDIUM medium;
|
||||
STGMEDIUM medium = {sizeof medium};
|
||||
|
||||
formatetc.cfFormat = CF_HDROP;
|
||||
formatetc.ptd = nullptr;
|
||||
@@ -63,11 +63,48 @@ void HelperMethods::ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer)
|
||||
DragQueryFile(HDROP(medium.hGlobal), 0, buffer, MAX_PATH - 1);
|
||||
}
|
||||
|
||||
bool HelperMethods::IsListaryToolbarVisible()
|
||||
{
|
||||
auto CALLBACK findListaryWindowProc = [](__in HWND hwnd, __in LPARAM lParam)-> BOOL
|
||||
{
|
||||
WCHAR classBuffer[MAX_PATH] = {'\0'};
|
||||
if (FAILED(GetClassName(hwnd, classBuffer, MAX_PATH)))
|
||||
return TRUE;
|
||||
|
||||
if (wcsncmp(classBuffer, L"Listary_WidgetWin_", 18) == 0)
|
||||
{
|
||||
if (IsWindowVisible(hwnd))
|
||||
{
|
||||
*reinterpret_cast<bool*>(lParam) = true;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
auto found = false;
|
||||
EnumWindows(findListaryWindowProc, reinterpret_cast<LPARAM>(&found));
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
bool HelperMethods::IsCursorActivated(HWND hwnd)
|
||||
{
|
||||
auto tId = GetWindowThreadProcessId(hwnd, nullptr);
|
||||
|
||||
GUITHREADINFO gui = {sizeof gui};
|
||||
GetGUIThreadInfo(tId, &gui);
|
||||
return gui.flags || gui.hwndCaret;
|
||||
return gui.flags || gui.hwndCaret || IsListaryToolbarVisible();
|
||||
}
|
||||
|
||||
bool HelperMethods::IsUWP()
|
||||
{
|
||||
auto pGCPFN = decltype(&GetCurrentPackageFullName)(
|
||||
GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetCurrentPackageFullName"));
|
||||
|
||||
if (!pGCPFN)
|
||||
return false;
|
||||
|
||||
UINT32 pn = 0;
|
||||
return pGCPFN(&pn, nullptr) == ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -22,4 +22,8 @@ public:
|
||||
static void GetSelectedInternal(CComQIPtr<IWebBrowserApp> pWebBrowserApp, PWCHAR buffer);
|
||||
static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer);
|
||||
static bool IsCursorActivated(HWND hwndfg);
|
||||
static bool HelperMethods::IsUWP();
|
||||
|
||||
private:
|
||||
static bool IsListaryToolbarVisible();
|
||||
};
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<ProjectGuid>{D31EE321-C2B0-4984-B749-736F7DE509F1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>QuickLookNative32</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>QuickLook.Native32</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -106,12 +106,12 @@ void Shell32::getSelectedFromExplorer(PWCHAR buffer)
|
||||
for (auto i = 0; i < count; i++)
|
||||
{
|
||||
VARIANT vi;
|
||||
VariantInit(&vi);
|
||||
V_VT(&vi) = VT_I4;
|
||||
V_I4(&vi) = i;
|
||||
|
||||
CComPtr<IDispatch> pdisp;
|
||||
// ReSharper disable once CppSomeObjectMembersMightNotBeInitialized
|
||||
if (FAILED(psw->Item(vi, &pdisp)))
|
||||
if (S_OK != psw->Item(vi, &pdisp))
|
||||
continue;
|
||||
|
||||
CComQIPtr<IWebBrowserApp> pwba;
|
||||
@@ -139,9 +139,11 @@ void Shell32::getSelectedFromDesktop(PWCHAR buffer)
|
||||
if (FAILED(psw.CoCreateInstance(CLSID_ShellWindows)))
|
||||
return;
|
||||
|
||||
VARIANT pvarLoc = {VT_EMPTY};
|
||||
VARIANT pvarLoc;
|
||||
VariantInit(&pvarLoc);
|
||||
long phwnd;
|
||||
if (FAILED(psw->FindWindowSW(&pvarLoc, &pvarLoc, SWC_DESKTOP, &phwnd, SWFO_NEEDDISPATCH, reinterpret_cast<IDispatch**>(&pwba))))
|
||||
if (FAILED(psw->FindWindowSW(&pvarLoc, &pvarLoc, SWC_DESKTOP, &phwnd, SWFO_NEEDDISPATCH, reinterpret_cast<IDispatch**>(
|
||||
&pwba))))
|
||||
return;
|
||||
|
||||
if (HelperMethods::IsCursorActivated(reinterpret_cast<HWND>(LongToHandle(phwnd))))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "WoW64HookHelper.h"
|
||||
#include "HelperMethods.h"
|
||||
|
||||
#define HELPER_FILE L"\\QuickLook.WoW64HookHelper.exe"
|
||||
#define RUN_ARG L"033A853A-E4B2-4552-9A91-E88789761C48"
|
||||
@@ -37,6 +38,9 @@ bool WoW64HookHelper::Launch()
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (HelperMethods::IsUWP())
|
||||
return true;
|
||||
|
||||
if (CheckStatus())
|
||||
return true;
|
||||
|
||||
@@ -47,7 +51,7 @@ bool WoW64HookHelper::Launch()
|
||||
auto p = wcsrchr(fullPath, L'\\');
|
||||
memcpy(p, HELPER_FILE, wcslen(HELPER_FILE) * sizeof WCHAR);
|
||||
|
||||
STARTUPINFO si = {'\0'};
|
||||
STARTUPINFO si = {sizeof si};
|
||||
PROCESS_INFORMATION pi = {nullptr};
|
||||
si.cb = sizeof si;
|
||||
|
||||
@@ -66,10 +70,11 @@ void WoW64HookHelper::createJob()
|
||||
|
||||
hJob = CreateJobObject(nullptr, nullptr);
|
||||
|
||||
JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation = {'\0'};
|
||||
JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation = {sizeof BasicLimitInformation};
|
||||
BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION lpJobObjectInfo = {'\0'};
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION lpJobObjectInfo = {sizeof lpJobObjectInfo};
|
||||
lpJobObjectInfo.BasicLimitInformation = BasicLimitInformation;
|
||||
|
||||
SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &lpJobObjectInfo, sizeof JOBOBJECT_EXTENDED_LIMIT_INFORMATION);
|
||||
SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &lpJobObjectInfo,
|
||||
sizeof JOBOBJECT_EXTENDED_LIMIT_INFORMATION);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -32,3 +32,4 @@
|
||||
#include<Shlobj.h>
|
||||
#include<Shellapi.h>
|
||||
#include<Psapi.h>
|
||||
#include<AppModel.h>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -35,7 +35,7 @@
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{794E4DCF-F715-4836-9D30-ABD296586D23}</ProjectGuid>
|
||||
<RootNamespace>QuickLookNative64</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>QuickLook.Native64</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
@@ -88,6 +88,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -34,9 +34,9 @@ HWND hMsgWindow = nullptr;
|
||||
UINT WM_HOOK_NOTIFY = 0;
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
// do not run when double-clicking
|
||||
if (wcsstr(GetCommandLine(), RUN_ARG) == nullptr)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<ProjectGuid>{2C58F9B2-D8FA-4586-942B-5170CECE5963}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>QuickLookWoW64HookHelper</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>QuickLook.WoW64HookHelper</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
|
@@ -90,7 +90,7 @@
|
||||
|
||||
<TreeView BorderThickness="0" Focusable="False" Background="Transparent"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<TreeViewItem Focusable="False">
|
||||
<TreeViewItem Focusable="False" Visibility="Collapsed">
|
||||
<TreeViewItem.Header>
|
||||
<Grid ShowGridLines="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@@ -37,16 +37,11 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
IconManager.ClearCache();
|
||||
}
|
||||
|
||||
~ArchiveFileListView()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void SetDataContext(object context)
|
||||
{
|
||||
treeGrid.DataContext = context;
|
||||
|
||||
treeView.Loaded += (sender, e) =>
|
||||
treeView.LayoutUpdated += (sender, e) =>
|
||||
{
|
||||
// return when empty
|
||||
if (treeView.Items.Count == 0)
|
||||
|
@@ -7,21 +7,42 @@
|
||||
mc:Ignorable="d"
|
||||
x:Name="infoPanel"
|
||||
d:DesignHeight="600" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<local:Percent100ToVisibilityVisibleConverter x:Key="Percent100ToVisibilityVisibleConverter" />
|
||||
<local:Percent100ToVisibilityCollapsedConverter x:Key="Percent100ToVisibilityCollapsedConverter" />
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
<local:ArchiveFileListView Grid.Row="0" x:Name="fileListView" Focusable="False" />
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="archiveCount" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">9 folders and 10 files, solid, password-protected</Label>
|
||||
<Label x:Name="archiveSizeC" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">Compressed size 9999 bytes</Label>
|
||||
<Label x:Name="archiveSizeU" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center">Uncompressed size 99999 bytes</Label>
|
||||
<Grid ZIndex="9999"
|
||||
Visibility="{Binding ElementName=infoPanel, Path=LoadPercent, Mode=OneWay, Converter={StaticResource Percent100ToVisibilityCollapsedConverter}}">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Label FontSize="14" HorizontalAlignment="Center">Loading archive ...</Label>
|
||||
<ProgressBar Height="13" Width="150"
|
||||
Value="{Binding ElementName=infoPanel, Path=LoadPercent, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid
|
||||
Visibility="{Binding ElementName=infoPanel, Path=LoadPercent, Mode=OneWay, Converter={StaticResource Percent100ToVisibilityVisibleConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
<local:ArchiveFileListView Grid.Row="0" x:Name="fileListView" Focusable="False" />
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="archiveCount" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">0 folders and 0 files, solid, password-protected</Label>
|
||||
<Label x:Name="archiveSizeC" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">Compressed size 0 bytes</Label>
|
||||
<Label x:Name="archiveSizeU" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center">Uncompressed size 0 bytes</Label>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -17,9 +17,14 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using QuickLook.Common.Annotations;
|
||||
using QuickLook.Common.ExtensionMethods;
|
||||
using SharpCompress.Archives;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
@@ -29,9 +34,11 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
/// <summary>
|
||||
/// Interaction logic for ArchiveInfoPanel.xaml
|
||||
/// </summary>
|
||||
public partial class ArchiveInfoPanel : UserControl, IDisposable
|
||||
public partial class ArchiveInfoPanel : UserControl, IDisposable, INotifyPropertyChanged
|
||||
{
|
||||
private readonly Dictionary<string, ArchiveFileEntry> _fileEntries = new Dictionary<string, ArchiveFileEntry>();
|
||||
private bool _disposed;
|
||||
private double _loadPercent;
|
||||
private ulong _totalZippedSize;
|
||||
private string _type;
|
||||
|
||||
@@ -39,57 +46,83 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
LoadArchive(path);
|
||||
// design-time only
|
||||
Resources.MergedDictionaries.Clear();
|
||||
|
||||
fileListView.SetDataContext(_fileEntries[""].Children.Keys);
|
||||
BeginLoadArchive(path);
|
||||
}
|
||||
|
||||
public double LoadPercent
|
||||
{
|
||||
get => _loadPercent;
|
||||
private set
|
||||
{
|
||||
if (value == _loadPercent) return;
|
||||
_loadPercent = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_fileEntries.Clear();
|
||||
_disposed = true;
|
||||
|
||||
fileListView.Dispose();
|
||||
}
|
||||
|
||||
~ArchiveInfoPanel()
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void BeginLoadArchive(string path)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void LoadArchive(string path)
|
||||
{
|
||||
_totalZippedSize = (ulong) new FileInfo(path).Length;
|
||||
|
||||
LoadItemsFromArchive(path);
|
||||
|
||||
var folders = -1; // do not count root node
|
||||
var files = 0;
|
||||
ulong sizeU = 0L;
|
||||
_fileEntries.ForEach(e =>
|
||||
new Task(() =>
|
||||
{
|
||||
if (e.Value.IsFolder)
|
||||
folders++;
|
||||
_totalZippedSize = (ulong) new FileInfo(path).Length;
|
||||
|
||||
var root = new ArchiveFileEntry(Path.GetFileName(path), true);
|
||||
_fileEntries.Add("", root);
|
||||
|
||||
LoadItemsFromArchive(path);
|
||||
|
||||
var folders = -1; // do not count root node
|
||||
var files = 0;
|
||||
ulong sizeU = 0L;
|
||||
_fileEntries.ForEach(e =>
|
||||
{
|
||||
if (e.Value.IsFolder)
|
||||
folders++;
|
||||
else
|
||||
files++;
|
||||
|
||||
sizeU += e.Value.Size;
|
||||
});
|
||||
|
||||
string t;
|
||||
var d = folders != 0 ? $"{folders} folders" : string.Empty;
|
||||
var f = files != 0 ? $"{files} files" : string.Empty;
|
||||
if (!string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(f))
|
||||
t = $", {d} and {f}";
|
||||
else if (string.IsNullOrEmpty(d) && string.IsNullOrEmpty(f))
|
||||
t = string.Empty;
|
||||
else
|
||||
files++;
|
||||
t = $", {d}{f}";
|
||||
|
||||
sizeU += e.Value.Size;
|
||||
});
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
string t;
|
||||
var d = folders != 0 ? $"{folders} folders" : string.Empty;
|
||||
var f = files != 0 ? $"{files} files" : string.Empty;
|
||||
if (!string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(f))
|
||||
t = $", {d} and {f}";
|
||||
else if (string.IsNullOrEmpty(d) && string.IsNullOrEmpty(f))
|
||||
t = string.Empty;
|
||||
else
|
||||
t = $", {d}{f}";
|
||||
fileListView.SetDataContext(_fileEntries[""].Children.Keys);
|
||||
archiveCount.Content =
|
||||
$"{_type} archive{t}";
|
||||
archiveSizeC.Content =
|
||||
$"Compressed size {((long) _totalZippedSize).ToPrettySize(2)}";
|
||||
archiveSizeU.Content = $"Uncompressed size {((long) sizeU).ToPrettySize(2)}";
|
||||
});
|
||||
|
||||
archiveCount.Content =
|
||||
$"{_type} archive{t}";
|
||||
archiveSizeC.Content = $"Compressed size {_totalZippedSize.ToPrettySize(2)}";
|
||||
archiveSizeU.Content = $"Uncompressed size {sizeU.ToPrettySize(2)}";
|
||||
LoadPercent = 100d;
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private void LoadItemsFromArchive(string path)
|
||||
@@ -99,29 +132,33 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
// ReaderFactory is slow... so limit its usage
|
||||
string[] useReader = {".tar.gz", ".tgz", ".tar.bz2", ".tar.lz", ".tar.xz"};
|
||||
|
||||
if (useReader.Any(i => path.EndsWith(i)))
|
||||
if (useReader.Any(path.ToLower().EndsWith))
|
||||
{
|
||||
var reader = ReaderFactory.Open(stream);
|
||||
var reader = ReaderFactory.Open(stream, new ChardetReaderOptions());
|
||||
|
||||
_type = reader.ArchiveType.ToString();
|
||||
|
||||
var root = new ArchiveFileEntry(Path.GetFileName(path), true);
|
||||
_fileEntries.Add("", root);
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
LoadPercent = 100d * stream.Position / stream.Length;
|
||||
ProcessByLevel(reader.Entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var archive = ArchiveFactory.Open(stream);
|
||||
var archive = ArchiveFactory.Open(stream, new ChardetReaderOptions());
|
||||
|
||||
_type = archive.Type.ToString();
|
||||
|
||||
var root = new ArchiveFileEntry(Path.GetFileName(path), true);
|
||||
_fileEntries.Add("", root);
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
LoadPercent = 100d * stream.Position / stream.Length;
|
||||
ProcessByLevel(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,8 +175,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
if (_fileEntries.ContainsKey(f))
|
||||
return;
|
||||
|
||||
ArchiveFileEntry parent;
|
||||
_fileEntries.TryGetValue(GetDirectoryName(f), out parent);
|
||||
_fileEntries.TryGetValue(GetDirectoryName(f), out var parent);
|
||||
|
||||
var afe = new ArchiveFileEntry(Path.GetFileName(f), true, parent);
|
||||
|
||||
@@ -151,8 +187,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
{
|
||||
var file = pf.Last();
|
||||
|
||||
ArchiveFileEntry parent;
|
||||
_fileEntries.TryGetValue(GetDirectoryName(file), out parent);
|
||||
_fileEntries.TryGetValue(GetDirectoryName(file), out var parent);
|
||||
|
||||
_fileEntries.Add(file, new ArchiveFileEntry(Path.GetFileName(entry.Key), false, parent)
|
||||
{
|
||||
@@ -179,5 +214,11 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
|
||||
return frags.Select((s, i) => frags.Take(i + 1).Aggregate((a, b) => a + "\\" + b)).ToArray();
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,22 +16,32 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
using UtfUnknown;
|
||||
|
||||
namespace QuickLook.Helpers.BlurLibrary.PlatformsImpl
|
||||
namespace QuickLook.Plugin.ArchiveViewer
|
||||
{
|
||||
public class OsNotSupportedWindowBlurController : IWindowBlurController
|
||||
internal class ChardetReaderOptions : ReaderOptions
|
||||
{
|
||||
public void EnableBlur(IntPtr hwnd)
|
||||
public ChardetReaderOptions()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
ArchiveEncoding = new ArchiveEncoding
|
||||
{
|
||||
CustomDecoder = Chardet
|
||||
};
|
||||
}
|
||||
|
||||
public void DisableBlur(IntPtr hwnd)
|
||||
public string Chardet(byte[] bytes, int index, int count)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
var buffer = new byte[count];
|
||||
|
||||
public bool Enabled { get; } = false;
|
||||
public bool CanBeEnabled { get; } = false;
|
||||
Array.Copy(bytes, index, buffer, 0, count);
|
||||
|
||||
var encoding = CharsetDetector.DetectFromBytes(buffer).Detected?.Encoding ?? Encoding.Default;
|
||||
|
||||
return encoding.GetString(buffer);
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,9 +19,44 @@ using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using QuickLook.Common.ExtensionMethods;
|
||||
|
||||
namespace QuickLook.Plugin.ArchiveViewer
|
||||
{
|
||||
public class Percent100ToVisibilityVisibleConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
value = 0;
|
||||
|
||||
var percent = (double) value;
|
||||
return Math.Abs(percent - 100) < 0.00001 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class Percent100ToVisibilityCollapsedConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
value = 0;
|
||||
|
||||
var percent = (double) value;
|
||||
return Math.Abs(percent - 100) < 0.00001 ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class LevelToIndentConverter : DependencyObject, IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
@@ -77,7 +112,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
var size = (ulong) values[0];
|
||||
var isFolder = (bool) values[1];
|
||||
|
||||
return isFolder ? "" : size.ToPrettySize(2);
|
||||
return isFolder ? "" : ((long) size).ToPrettySize(2);
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
|
@@ -47,31 +47,8 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
if (foundElement != null)
|
||||
break;
|
||||
}
|
||||
|
||||
return foundElement;
|
||||
}
|
||||
|
||||
public static string ToPrettySize(this ulong value, int decimalPlaces = 0)
|
||||
{
|
||||
const long OneKb = 1024;
|
||||
const long OneMb = OneKb * 1024;
|
||||
const long OneGb = OneMb * 1024;
|
||||
const long OneTb = OneGb * 1024;
|
||||
|
||||
var asTb = Math.Round((double) value / OneTb, decimalPlaces);
|
||||
var asGb = Math.Round((double) value / OneGb, decimalPlaces);
|
||||
var asMb = Math.Round((double) value / OneMb, decimalPlaces);
|
||||
var asKb = Math.Round((double) value / OneKb, decimalPlaces);
|
||||
var chosenValue = asTb > 1
|
||||
? $"{asTb} TB"
|
||||
: asGb > 1
|
||||
? $"{asGb} GB"
|
||||
: asMb > 1
|
||||
? $"{asMb} MB"
|
||||
: asKb > 1
|
||||
? $"{asKb} KB"
|
||||
: $"{Math.Round((double) value, decimalPlaces)} bytes";
|
||||
|
||||
return chosenValue;
|
||||
}
|
||||
}
|
||||
}
|
@@ -211,8 +211,10 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
public readonly IntPtr hIcon;
|
||||
private readonly int iIcon;
|
||||
private readonly uint dwAttributes;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] private readonly string szDisplayName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Namesize)] private readonly string szTypeName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)]
|
||||
private readonly string szDisplayName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Namesize)]
|
||||
private readonly string szTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
|