Skip to content

Commit

Permalink
Use black icon when OS is in Light Mode; upgrade SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed May 26, 2019
1 parent 68248ce commit cdf3b26
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
<ProjectGuid>{D31EE321-C2B0-4984-B749-736F7DE509F1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>QuickLookNative32</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>QuickLook.Native32</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{794E4DCF-F715-4836-9D30-ABD296586D23}</ProjectGuid>
<RootNamespace>QuickLookNative64</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>QuickLook.Native64</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
<ProjectGuid>{2C58F9B2-D8FA-4586-942B-5170CECE5963}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>QuickLookWoW64HookHelper</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>QuickLook.WoW64HookHelper</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
41 changes: 41 additions & 0 deletions QuickLook/Helpers/OSThemeHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright © 2019 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 <https://www.gnu.org/licenses/>.

using Microsoft.Win32;

namespace QuickLook.Helpers
{
internal class OSThemeHelper
{
public static bool AppsUseDarkTheme()
{
var value = Registry.GetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
"AppsUseLightTheme", 1);

return value != null && (int)value == 0;
}
public static bool SystemUsesDarkTheme()
{
var value = Registry.GetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
"SystemUsesLightTheme", 0);

return value == null || (int)value == 0;
}
}
}
32 changes: 31 additions & 1 deletion QuickLook/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions QuickLook/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@
<data name="app_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app_16.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="app_black" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app_black.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="app_black_16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app_black_16.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="app_black_png" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app_black.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="app_png" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\app.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
12 changes: 8 additions & 4 deletions QuickLook/QuickLook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
<HintPath>$(SystemRoot)\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -103,13 +103,13 @@
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="windows">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0\Facade\windows.winmd</HintPath>
<HintPath>$(SystemRoot)\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\Facade\windows.winmd</HintPath>
</Reference>
<Reference Include="Windows.Foundation.FoundationContract">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\References\10.0.17134.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd</HintPath>
<HintPath>$(SystemRoot)\..\Program Files (x86)\Windows Kits\10\References\10.0.17763.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd</HintPath>
</Reference>
<Reference Include="Windows.Foundation.UniversalApiContract">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\References\10.0.17134.0\Windows.Foundation.UniversalApiContract\6.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
<HintPath>$(SystemRoot)\..\Program Files (x86)\Windows Kits\10\References\10.0.17763.0\Windows.Foundation.UniversalApiContract\7.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
Expand Down Expand Up @@ -142,6 +142,7 @@
<Compile Include="Controls\BusyDecorator\BackgroundVisualHost.cs" />
<Compile Include="Controls\BusyDecorator\BusyDecorator.cs" />
<Compile Include="Controls\BusyDecorator\VisualTargetPresentationSource.cs" />
<Compile Include="Helpers\OSThemeHelper.cs" />
<Compile Include="Helpers\ShareHelper.cs" />
<Compile Include="NativeMethods\ShellLink.cs" />
<Compile Include="PipeServerManager.cs" />
Expand Down Expand Up @@ -196,6 +197,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Resource Include="Resources\app_black.ico" />
<Resource Include="Resources\app_black.png" />
<Resource Include="Resources\app_black_16.ico" />
<Resource Include="Resources\app.png" />
<Resource Include="Resources\app_white.png" />
<None Include="packages.config" />
Expand Down
Binary file added QuickLook/Resources/app_black.ico
Binary file not shown.
Binary file added QuickLook/Resources/app_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added QuickLook/Resources/app_black_16.ico
Binary file not shown.
9 changes: 6 additions & 3 deletions QuickLook/TrayIconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ private Icon GetTrayIconByDPI()
{
var scale = DpiHelper.GetCurrentScaleFactor().Vertical;

if (App.IsWin10)
return scale > 1 ? Resources.app_white : Resources.app_white_16;
return scale > 1 ? Resources.app : Resources.app_16;
if (!App.IsWin10)
return scale > 1 ? Resources.app : Resources.app_16;

return OSThemeHelper.SystemUsesDarkTheme()
? (scale > 1 ? Resources.app_white : Resources.app_white_16)
: (scale > 1 ? Resources.app_black : Resources.app_black_16);
}

public static void ShowNotification(string title, string content, bool isError = false, int timeout = 5000,
Expand Down
7 changes: 2 additions & 5 deletions QuickLook/ViewerWindow.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using Microsoft.Win32;
using QuickLook.Common.Annotations;
using QuickLook.Common.Plugin;
using QuickLook.Helpers;

namespace QuickLook
{
Expand Down Expand Up @@ -73,10 +73,7 @@ public void SwitchTheme(Themes theme)
switch (theme)
{
case Themes.None:
var t = Registry.GetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
"AppsUseLightTheme", 1);
isDark = t != null && (int) t == 0;
isDark = OSThemeHelper.AppsUseDarkTheme();
break;
case Themes.Dark:
case Themes.Light:
Expand Down
4 changes: 2 additions & 2 deletions Scripts/pack-appx-dev.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ if(-not (Test-Path env:CI))
Update-Version("..\Build\Appx\AppxManifest.xml")

# generate resources
$priExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\makepri.exe'
$priExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\makepri.exe'
.$priExe new /pr ..\Build\Appx /cf ..\Build\priconfig.xml /of ..\Build\Appx\resources.pri

# packing
$packExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\makeappx.exe'
$packExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\makeappx.exe'
$folder = '..\Build\Appx\'

.$packExe pack /l /o /d ..\Build\Appx /p ..\Build\QuickLook-$version.appx
Expand Down
4 changes: 2 additions & 2 deletions Scripts/pack-appx.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ if(-not (Test-Path env:CI))
Update-Version("..\Build\Appx\AppxManifest.xml")

# generate resources
$priExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\makepri.exe'
$priExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\makepri.exe'
.$priExe new /pr ..\Build\Appx /cf ..\Build\priconfig.xml /of ..\Build\Appx\resources.pri

# packing
$packExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\makeappx.exe'
$packExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\makeappx.exe'
$folder = '..\Build\Appx\'

.$packExe pack /l /o /d ..\Build\Appx /p ..\Build\QuickLook-$version.appx
Expand Down
2 changes: 1 addition & 1 deletion Scripts/sign-appx.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$signExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86\signtool.exe'
$signExe = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool.exe'
$files = gci '..\Build\QuickLook-*.appx' | %{('"{0}"' -f $_.FullName)}
$timestampUrl = 'https://time.certum.pl/'

Expand Down

0 comments on commit cdf3b26

Please sign in to comment.