Skip to content

Commit

Permalink
Address more review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausLoeffelmann committed Aug 6, 2024
1 parent c61d0d3 commit 3191e93
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' <summary>
''' Gets or sets the VisualStylesMode for the Application.
''' </summary>
''' <returns>
''' The <see cref="VisualStylesMode"/> that the application is running in.
''' </returns>
<Experimental(DiagnosticIDs.ExperimentalVisualStyles)>
<EditorBrowsable(EditorBrowsableState.Never)>
Protected Property VisualStylesMode As VisualStylesMode
Expand All @@ -846,6 +849,9 @@ Namespace Microsoft.VisualBasic.ApplicationServices
''' <summary>
''' Gets or sets the ColorMode for the Application.
''' </summary>
''' <returns>
''' The <see cref="SystemColorMode"/> that the application is running in.
''' </returns>
<Experimental(DiagnosticIDs.ExperimentalDarkMode)>
<EditorBrowsable(EditorBrowsableState.Never)>
Protected Property ColorMode As SystemColorMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@
<data name="AddDesignerSerializationVisibilityCodeFixTitle" xml:space="preserve">
<value>Add DesignerSerializationVisibilityAttribute to property</value>
</data>
</root>
</root>
3 changes: 3 additions & 0 deletions src/System.Windows.Forms/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7015,4 +7015,7 @@ Stack trace where the illegal operation occurred was:
<data name="FormCaptionTextColorDescr" xml:space="preserve">
<value>The color of the Form's text caption (title bar text).</value>
</data>
<data name="ControlVisualStylesModeChangedDescr" xml:space="preserve">
<value>Event raised whenever the VisualStylesMode property changes.</value>
</data>
</root>
5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf

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

5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf

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

15 changes: 8 additions & 7 deletions src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public sealed partial class Application

private const string DarkModeKeyPath = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
private const string DarkModeKey = "AppsUseLightTheme";
private const int DarkModeNotAvailable = -1;

/// <summary>
/// Events the user can hook into
Expand Down Expand Up @@ -250,7 +251,7 @@ internal static bool CustomThreadExceptionHandlerAttached
/// Gets the default dark mode for the application. This is the SystemColorMode which either has been set
/// by <see cref="SetColorMode(SystemColorMode)"/> or its default value <see cref="SystemColorMode.Classic"/>.
/// </summary>
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = "https://aka.ms/WfoExperimental/{0}")]
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = "https://aka.ms/winforms-experimental/{0}")]
public static SystemColorMode ColorMode =>
!s_systemColorMode.HasValue
? SystemColorMode.Classic
Expand All @@ -262,7 +263,7 @@ internal static bool CustomThreadExceptionHandlerAttached
/// Sets the default dark mode for the application.
/// </summary>
/// <param name="systemColorMode">The default dark mode to set.</param>
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = "https://aka.ms/WfoExperimental/{0}")]
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = "https://aka.ms/winforms-experimental/{0}")]
public static void SetColorMode(SystemColorMode systemColorMode)
{
try
Expand Down Expand Up @@ -308,7 +309,7 @@ public static void SetColorMode(SystemColorMode systemColorMode)
/// is essential.
/// </para>
/// </remarks>
[Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat = "https://aka.ms/WfoExperimental/{0}")]
[Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat = "https://aka.ms/winforms-experimental/{0}")]
public static VisualStylesMode DefaultVisualStylesMode { get; private set; }

/// <summary>
Expand All @@ -318,7 +319,7 @@ public static void SetColorMode(SystemColorMode systemColorMode)
/// as not setting using <see cref="EnableVisualStyles"/>.
/// </summary>
/// <param name="styleSetting">The version of visual styles to set.</param>
[Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat = "https://aka.ms/WfoExperimental/{0}")]
[Experimental(DiagnosticIDs.ExperimentalVisualStyles, UrlFormat = "https://aka.ms/winforms-experimental/{0}")]
public static void SetDefaultVisualStylesMode(VisualStylesMode styleSetting)
{
if (styleSetting != DefaultVisualStylesMode)
Expand Down Expand Up @@ -363,10 +364,10 @@ private static int GetSystemColorModeInternal()
{
if (SystemInformation.HighContrast)
{
return -1;
return DarkModeNotAvailable;
}

int systemColorMode = -1;
int systemColorMode = DarkModeNotAvailable;

// Dark mode is supported when we are >= W11/22000
// Technically, we could go earlier, but then the APIs we're using weren't officially public.
Expand All @@ -377,7 +378,7 @@ private static int GetSystemColorModeInternal()
systemColorMode = (Registry.GetValue(
keyName: DarkModeKeyPath,
valueName: DarkModeKey,
defaultValue: -1) as int?) ?? systemColorMode;
defaultValue: DarkModeNotAvailable) as int?) ?? systemColorMode;
}
catch (Exception ex) when (!ex.IsCriticalException())
{
Expand Down
Loading

0 comments on commit 3191e93

Please sign in to comment.