Fixed portability warnings for .NET 6.0 build

This commit is contained in:
cygon 2024-11-06 20:41:41 +01:00
parent 7a0ae3b3c7
commit a1e8b42706
2 changed files with 17 additions and 2 deletions

View File

@ -74,7 +74,19 @@ namespace Nuclex.Windows.Forms {
base.View = View.Details; base.View = View.Details;
this.columnHeaderHeight = Font.Height; #if NET6_0_OR_GREATER
if(OperatingSystem.IsWindows()) {
#else
if(Environment.OSVersion.Platform == PlatformID.Win32NT) {
#endif
this.columnHeaderHeight = Font.Height;
} else {
// Font sizes *should* be in one 72ths of an inch. And screens *might*
// be set to 96 DPI. So this is the best we can do, cross-platform,
// due to Microsoft's shortsighted design. Sorry high DPI users.
//this.columnHeaderHeight = (int)(Font.Size * 96 / 72);
this.columnHeaderHeight = 16;
}
} }
/// <summary>Controls being embedded in the ListView</summary> /// <summary>Controls being embedded in the ListView</summary>
@ -98,7 +110,7 @@ namespace Nuclex.Windows.Forms {
bool intersectsColumnHeader = bool intersectsColumnHeader =
(base.HeaderStyle != ColumnHeaderStyle.None) && (base.HeaderStyle != ColumnHeaderStyle.None) &&
(cellBounds.Top < base.Font.Height); (cellBounds.Top < this.columnHeaderHeight);
embeddedControl.Control.Visible = !intersectsColumnHeader; embeddedControl.Control.Visible = !intersectsColumnHeader;
embeddedControl.Control.Bounds = cellBounds; embeddedControl.Control.Bounds = cellBounds;

View File

@ -22,6 +22,9 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms.Controls { namespace Nuclex.Windows.Forms.Controls {