diff --git a/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs b/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs index 77376950..bb27a400 100644 --- a/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs +++ b/PInvoke/Shared/WinGdi/WinGdi.LOGFONT.cs @@ -276,8 +276,8 @@ namespace Vanara.PInvoke } /// The LOGFONT structure defines the attributes of a font. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [PInvokeData("Wingdi.h", MSDNShortId = "dd145037")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct LOGFONT { /// @@ -387,7 +387,8 @@ namespace Vanara.PInvoke /// The font family. public FontFamily FontFamily { - get => (FontFamily)(lfPitchAndFamily & 0xF0); set => lfPitchAndFamily = (byte)((lfPitchAndFamily & 0x0F) | (byte)value); + get => (FontFamily)(lfPitchAndFamily & 0xF0); + set => lfPitchAndFamily = (byte)((lfPitchAndFamily & 0x0F) | (byte)value); } /// @@ -398,12 +399,8 @@ namespace Vanara.PInvoke /// The face name of the font. public string lfFaceName { - get => _lfFaceName; set - { - if (value?.Length > 31) - throw new ArgumentException(@"The face name may not have more than 31 characters.", nameof(lfFaceName)); - _lfFaceName = value; - } + get => _lfFaceName; + set => _lfFaceName = value?.Length <= 31 ? value : throw new ArgumentException(@"The face name may not have more than 31 characters.", nameof(lfFaceName)); } /// @@ -412,19 +409,16 @@ namespace Vanara.PInvoke /// public short lfWeight { - get => (short)_lfWeight; set - { - if (value < 0 || value > 1000) - throw new ArgumentOutOfRangeException(nameof(lfWeight), @"Font weight must be a value in the range 0 through 1000."); - _lfWeight = value; - } + get => (short)_lfWeight; + set => _lfWeight = value >= 0 && value <= 1000 ? value : throw new ArgumentOutOfRangeException(nameof(lfWeight), @"Font weight must be a value in the range 0 through 1000."); } /// Gets or sets the font pitch. /// The pitch. public FontPitch Pitch { - get => (FontPitch)(lfPitchAndFamily & 0x0F); set => lfPitchAndFamily = (byte)((lfPitchAndFamily & 0xF0) | (byte)value); + get => (FontPitch)(lfPitchAndFamily & 0x0F); + set => lfPitchAndFamily = (byte)((lfPitchAndFamily & 0xF0) | (byte)value); } /// Returns a that represents this instance.