更新
This commit is contained in:
31
AntdWpf/Utils/UIElementUtil.cs
Normal file
31
AntdWpf/Utils/UIElementUtil.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace AntdWpf.Utils
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class UIElementUtil
|
||||
{
|
||||
public static double RoundLayoutValue(double value, double dpiScale)
|
||||
{
|
||||
double newValue;
|
||||
|
||||
// If DPI == 1, don't use DPI-aware rounding.
|
||||
if (!DoubleUtil.AreClose(dpiScale, 1.0))
|
||||
{
|
||||
newValue = Math.Round(value * dpiScale) / dpiScale;
|
||||
// If rounding produces a value unacceptable to layout (NaN, Infinity or MaxValue), use the original value.
|
||||
if (double.IsNaN(newValue) ||
|
||||
double.IsInfinity(newValue) ||
|
||||
DoubleUtil.AreClose(newValue, double.MaxValue))
|
||||
{
|
||||
newValue = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue = Math.Round(value);
|
||||
}
|
||||
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user