Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,6 @@ public static string ExecutablePath
public static HighDpiMode HighDpiMode
=> DpiHelper.GetWinformsApplicationDpiAwareness();

/// <summary>
/// Sets the <see cref="HighDpiMode"/> mode for process.
/// </summary>
/// <param name="highDpiMode">One of the enumeration values that specifies the high DPI mode to set.</param>
/// <returns><see langword="true" /> if the high DPI mode was set; otherwise, <see langword="false" />.</returns>
public static bool SetHighDpiMode(HighDpiMode highDpiMode)
=> !DpiHelper.FirstParkingWindowCreated && DpiHelper.SetWinformsApplicationDpiAwareness(highDpiMode);

/// <summary>
/// Gets the path for the application data specific to a local, non-roaming user.
/// </summary>
Expand Down Expand Up @@ -1241,6 +1233,18 @@ public static void SetCompatibleTextRenderingDefault(bool defaultValue)
Control.UseCompatibleTextRenderingDefault = defaultValue;
}

/// <summary>
/// Sets the <see cref="HighDpiMode"/> mode for process.
/// </summary>
/// <param name="highDpiMode">One of the enumeration values that specifies the high DPI mode to set.</param>
/// <returns><see langword="true" /> if the high DPI mode was set; otherwise, <see langword="false" />.</returns>
public static bool SetHighDpiMode(HighDpiMode highDpiMode)
{
SourceGenerated.EnumValidator.Validate(highDpiMode, nameof(highDpiMode));

return !DpiHelper.FirstParkingWindowCreated && DpiHelper.SetWinformsApplicationDpiAwareness(highDpiMode);
}

/// <summary>
/// Sets the suspend/hibernate state of the machine.
/// Returns true if the call succeeded, else false.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Threading;
Expand Down Expand Up @@ -150,6 +151,13 @@ public void Application_EnableVisualStyles_ManifestResourceExists()
Assert.NotNull(stream);
}

[WinFormsTheory]
[CommonMemberData(nameof(CommonTestHelper.GetEnumTypeTheoryDataInvalid), typeof(HighDpiMode))]
public void Application_SetHighDpiMode_SetInvalidValue_ThrowsInvalidEnumArgumentException(HighDpiMode value)
{
Assert.Throws<InvalidEnumArgumentException>("highDpiMode", () => Application.SetHighDpiMode(value));
}

private class CustomLCIDCultureInfo : CultureInfo
{
private readonly int _lcid;
Expand Down