mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-14 01:25:45 -05:00
************* CHG Removed version text from NuGet files. CHG Replaced Tuple usage from SystemInfo by Point, which is also supported by .NET 3.5. CHG Changelog and credits update.
39 lines
905 B
C#
39 lines
905 B
C#
using System.Windows.Interop;
|
|
|
|
namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|
{
|
|
public static class SystemInfo
|
|
{
|
|
private static System.Windows.Point? dpiFactors;
|
|
|
|
private static System.Windows.Point? DpiFactors
|
|
{
|
|
get
|
|
{
|
|
if (dpiFactors == null)
|
|
using (var source = new HwndSource(new HwndSourceParameters()))
|
|
dpiFactors = new System.Windows.Point(source.CompositionTarget.TransformToDevice.M11, source.CompositionTarget.TransformToDevice.M22);
|
|
return dpiFactors;
|
|
}
|
|
}
|
|
|
|
public static double DpiXFactor
|
|
{
|
|
get
|
|
{
|
|
var factors = DpiFactors;
|
|
return factors.HasValue ? factors.Value.X : 1;
|
|
}
|
|
}
|
|
|
|
public static double DpiYFactor
|
|
{
|
|
get
|
|
{
|
|
var factors = DpiFactors;
|
|
return factors.HasValue ? factors.Value.Y : 1;
|
|
}
|
|
}
|
|
}
|
|
}
|