From a1e8b427061af2ccd74fbbce6e88e9046fd6d3da Mon Sep 17 00:00:00 2001 From: cygon Date: Wed, 6 Nov 2024 20:41:41 +0100 Subject: [PATCH] Fixed portability warnings for .NET 6.0 build --- Source/ContainerListView/ContainerListView.cs | 16 ++++++++++++++-- Source/Controls/ProgressSpinner.cs | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/ContainerListView/ContainerListView.cs b/Source/ContainerListView/ContainerListView.cs index 0f8ea89..a2a7edd 100644 --- a/Source/ContainerListView/ContainerListView.cs +++ b/Source/ContainerListView/ContainerListView.cs @@ -74,7 +74,19 @@ namespace Nuclex.Windows.Forms { 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; + } } /// Controls being embedded in the ListView @@ -98,7 +110,7 @@ namespace Nuclex.Windows.Forms { bool intersectsColumnHeader = (base.HeaderStyle != ColumnHeaderStyle.None) && - (cellBounds.Top < base.Font.Height); + (cellBounds.Top < this.columnHeaderHeight); embeddedControl.Control.Visible = !intersectsColumnHeader; embeddedControl.Control.Bounds = cellBounds; diff --git a/Source/Controls/ProgressSpinner.cs b/Source/Controls/ProgressSpinner.cs index 025fe25..125a328 100644 --- a/Source/Controls/ProgressSpinner.cs +++ b/Source/Controls/ProgressSpinner.cs @@ -22,6 +22,9 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif namespace Nuclex.Windows.Forms.Controls {