コミットメタ情報

リビジョン61566523cb35a802b21743524116bce7e61a25bc (tree)
日時2019-10-30 22:52:32
作者yyagi <yyagi.dtxmania@gmai...>
コミッターyyagi

ログメッセージ

#xxxxx FDKのコミット漏れ対応(CWindowsTheme.cs) 。ダークテーマ対応のための下回りだが不完全。
#xxxxx COS.cs: Windows10のビルド情報を補足。また、OSのビルド番号の確認機能をpublic化。
#xxxxx NVorbisのビルド時警告を抑制。csprojの<NoWarn>は最初の<PropertyGroup>に置かないと機能しないらしい。

変更サマリ

差分

--- a/FDK/コード/00.共通/COS.cs
+++ b/FDK/コード/00.共通/COS.cs
@@ -124,18 +124,18 @@ namespace FDK
124124 }
125125 public enum WIN10BUILD : int
126126 {
127- TH1 = 10240,
128- TH2 = 10586,
129- RS1 = 14393,
130- RS2 = 15063,
131- RS3 = 16299,
132- RS4 = 17134,
133- RS5 = 17763,
134- _19H1 = 18362,
127+ TH1 = 10240, // 1507:
128+ TH2 = 10586, // 1511: November Update
129+ RS1 = 14393, // 1607: Anniversary Update
130+ RS2 = 15063, // 1703: Creators Update
131+ RS3 = 16299, // 1709: Fall Creators Update
132+ RS4 = 17134, // 1803: April 2018 Update
133+ RS5 = 17763, // 1809: October 2018 Update
134+ _19H1 = 18362, // 1903: May 2019 Update
135135 UNKNOWN = -1,
136136 NOTWIN10 = 0
137137 }
138- private static WIN10BUILD GetWin10BuildNumber()
138+ public static WIN10BUILD GetWin10BuildNumber()
139139 {
140140 WIN10BUILD ret = WIN10BUILD.UNKNOWN;
141141
--- /dev/null
+++ b/FDK/コード/00.共通/CWindowsTheme.cs
@@ -0,0 +1,153 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using System.Runtime.InteropServices;
7+using System.Diagnostics;
8+using System.Drawing;
9+using Microsoft.Win32;
10+
11+namespace FDK
12+{
13+ /// <summary>
14+ /// Dark theme suuport class
15+ /// </summary>
16+ /// <remarks>
17+ /// http://grabacr.net/archives/6671
18+ /// </remarks>
19+ public class CWindowsTheme
20+ {
21+ protected internal static class SafeNativeMethod
22+ {
23+ [DllImport("Dwmapi.dll")]
24+ public static extern void DwmGetColorizationColor([Out] out int pcrColorization, [Out] out bool pfOpaqueBlend);
25+ }
26+
27+ /// <summary>
28+ /// Get Current Accent Color
29+ /// </summary>
30+ /// <returns>Accent Color (ARGB)</returns>
31+ public Color AccentColor
32+ {
33+ get
34+ {
35+ SafeNativeMethod.DwmGetColorizationColor(out int pcrColorization, out bool pfOpaqueBlend);
36+ Trace.TraceInformation($"AccentColor: Color={pcrColorization.ToString("X4")}, Opaque={pfOpaqueBlend}");
37+ return GetColorFromInt(pcrColorization);
38+ }
39+ }
40+ public Color GetColorFromInt(int color)
41+ {
42+ return Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color);
43+ }
44+
45+
46+ /// <summary>
47+ /// Get Current Fontcolor.
48+ /// </summary>
49+ /// <remarks>
50+ /// It should be depends on the AccentColor. Need Improvement.
51+ /// </remarks>
52+ public Color FontColor
53+ {
54+ get
55+ {
56+ // it should be depends on the AccentColor. Need Improvement.
57+ if (AppMode == EAppMode.Dark)
58+ {
59+ return Color.White;
60+ }
61+ else
62+ {
63+ return Color.Black;
64+ }
65+ }
66+ }
67+ /// <summary>
68+ /// Get Current Backgroundcolor.
69+ /// </summary>
70+ /// <remarks>
71+ /// It should be depends on the AccentColor. Need Improvement.
72+ /// </remarks>
73+ public Color BackgroundColor
74+ {
75+ get
76+ {
77+ // it should be depends on the AccentColor. Need Improvement.
78+ if (AppMode == EAppMode.Dark)
79+ {
80+ return Color.Black;
81+ }
82+ else
83+ {
84+ return Color.White;
85+ }
86+ }
87+ }
88+
89+ public enum EAppMode:int
90+ {
91+ NotSupported = -1,
92+ Dark = 0,
93+ Light = 1
94+ }
95+
96+ /// <summary>
97+ /// Get Current App Theme (Dark/Light) from registry
98+ /// </summary>
99+ public EAppMode AppMode
100+ {
101+ get
102+ {
103+ #region [If OS doesn't support Dark Theme, return "Not Supported"]
104+ if (!COS.bIsWin10OrLater())
105+ {
106+ return EAppMode.NotSupported;
107+ }
108+ if (COS.GetWin10BuildNumber() < COS.WIN10BUILD.RS1)
109+ {
110+ return EAppMode.NotSupported;
111+ }
112+ #endregion
113+
114+ #region [Get app theme value from registry]
115+ string rKeyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
116+ string rGetValueName = "AppsUseLightTheme";
117+ int AppsUseLightTheme = (int)EAppMode.Light;
118+ try
119+ {
120+ RegistryKey rKey = Registry.CurrentUser.OpenSubKey(rKeyName);
121+ AppsUseLightTheme = (int)rKey.GetValue(rGetValueName);
122+ rKey.Close();
123+
124+ Trace.TraceInformation($"Current App Theme = {AppsUseLightTheme}");
125+ }
126+ catch (NullReferenceException)
127+ {
128+ Trace.TraceWarning($"Warning: No registry key {rKeyName} in {rGetValueName}. Light Theme is assumed.");
129+ // AppsUseLightTheme = (int)EAppMode.Light;
130+ }
131+ #endregion
132+
133+ return (EAppMode)AppsUseLightTheme;
134+ }
135+ //HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize
136+ //AppsUseLightTheme
137+ }
138+#if false
139+if (msg == (int)WindowsMessages.WM_SETTINGCHANGE)
140+{
141+ var systemParmeter = Marshal.PtrToStringAuto(lParam);
142+ if (systemParmeter == "ImmersiveColorSet")
143+ {
144+ // 再度レジストリから Dark/Light をとってくるとか
145+
146+ handled = true;
147+ }
148+}
149+#endif
150+
151+ }
152+
153+}
--- a/NVorbis/NVorbis.csproj
+++ b/NVorbis/NVorbis.csproj
@@ -1,4 +1,4 @@
1-<Project Sdk="Microsoft.NET.Sdk">
1+<Project Sdk="Microsoft.NET.Sdk">
22
33 <PropertyGroup>
44 <TargetFrameworks>netstandard2.0;net35</TargetFrameworks>
@@ -21,6 +21,10 @@
2121 <RepositoryType>git</RepositoryType>
2222 <GenerateDocumentationFile>true</GenerateDocumentationFile>
2323 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
24+ <NoWarn>1701,1702,1591</NoWarn>
25+ </PropertyGroup>
26+
27+ <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
2428 </PropertyGroup>
2529
2630 </Project>
旧リポジトリブラウザで表示