2018-10-20 00:19:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using WindowsDisplayAPI.Native.DisplayConfig;
|
|
|
|
|
using NvAPIWrapper.Native.Mosaic;
|
2017-02-26 19:23:31 +00:00
|
|
|
|
|
|
|
|
|
namespace HeliosDisplayManagement.Shared.Topology
|
|
|
|
|
{
|
|
|
|
|
internal static class PathHelper
|
|
|
|
|
{
|
|
|
|
|
public static DisplayConfigRotation ToDisplayConfigRotation(this Rotation rotation)
|
|
|
|
|
{
|
|
|
|
|
switch (rotation)
|
|
|
|
|
{
|
|
|
|
|
case Rotation.Identity:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return DisplayConfigRotation.Identity;
|
|
|
|
|
case Rotation.Rotate90:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return DisplayConfigRotation.Rotate90;
|
|
|
|
|
case Rotation.Rotate180:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return DisplayConfigRotation.Rotate180;
|
|
|
|
|
case Rotation.Rotate270:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return DisplayConfigRotation.Rotate270;
|
|
|
|
|
default:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return DisplayConfigRotation.NotSpecified;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
|
|
|
|
public static DisplayConfigScaling ToDisplayConfigScaling(this Scaling scaling)
|
|
|
|
|
{
|
|
|
|
|
switch (scaling)
|
|
|
|
|
{
|
|
|
|
|
case Scaling.Identity:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.Identity;
|
|
|
|
|
case Scaling.Centered:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.Centered;
|
|
|
|
|
case Scaling.Stretched:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.Stretched;
|
|
|
|
|
case Scaling.AspectRatioCenteredMax:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.AspectRatioCenteredMax;
|
|
|
|
|
case Scaling.Custom:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.Custom;
|
|
|
|
|
case Scaling.Preferred:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.Preferred;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScaling.NotSpecified;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DisplayConfigScanLineOrdering ToDisplayConfigScanLineOrdering(
|
|
|
|
|
this ScanLineOrdering scanLineOrdering)
|
|
|
|
|
{
|
|
|
|
|
switch (scanLineOrdering)
|
|
|
|
|
{
|
|
|
|
|
case ScanLineOrdering.Progressive:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScanLineOrdering.Progressive;
|
|
|
|
|
case ScanLineOrdering.InterlacedWithUpperFieldFirst:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScanLineOrdering.InterlacedWithUpperFieldFirst;
|
|
|
|
|
case ScanLineOrdering.InterlacedWithLowerFieldFirst:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScanLineOrdering.InterlacedWithLowerFieldFirst;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
return DisplayConfigScanLineOrdering.NotSpecified;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
public static Rotation ToRotation(this DisplayConfigRotation rotation)
|
|
|
|
|
{
|
|
|
|
|
switch (rotation)
|
|
|
|
|
{
|
|
|
|
|
case DisplayConfigRotation.Identity:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return Rotation.Identity;
|
|
|
|
|
case DisplayConfigRotation.Rotate90:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return Rotation.Rotate90;
|
|
|
|
|
case DisplayConfigRotation.Rotate180:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return Rotation.Rotate180;
|
|
|
|
|
case DisplayConfigRotation.Rotate270:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return Rotation.Rotate270;
|
|
|
|
|
default:
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
2017-02-26 19:23:31 +00:00
|
|
|
|
return Rotation.Unknown;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-20 00:19:30 +00:00
|
|
|
|
|
|
|
|
|
public static Scaling ToScaling(this DisplayConfigScaling scaling)
|
|
|
|
|
{
|
|
|
|
|
switch (scaling)
|
|
|
|
|
{
|
|
|
|
|
case DisplayConfigScaling.Identity:
|
|
|
|
|
|
|
|
|
|
return Scaling.Identity;
|
|
|
|
|
case DisplayConfigScaling.Centered:
|
|
|
|
|
|
|
|
|
|
return Scaling.Centered;
|
|
|
|
|
case DisplayConfigScaling.Stretched:
|
|
|
|
|
|
|
|
|
|
return Scaling.Stretched;
|
|
|
|
|
case DisplayConfigScaling.AspectRatioCenteredMax:
|
|
|
|
|
|
|
|
|
|
return Scaling.AspectRatioCenteredMax;
|
|
|
|
|
case DisplayConfigScaling.Custom:
|
|
|
|
|
|
|
|
|
|
return Scaling.Custom;
|
|
|
|
|
case DisplayConfigScaling.Preferred:
|
|
|
|
|
|
|
|
|
|
return Scaling.Preferred;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
return Scaling.NotSpecified;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ScanLineOrdering ToScanLineOrdering(this DisplayConfigScanLineOrdering scanLineOrdering)
|
|
|
|
|
{
|
|
|
|
|
switch (scanLineOrdering)
|
|
|
|
|
{
|
|
|
|
|
case DisplayConfigScanLineOrdering.Progressive:
|
|
|
|
|
|
|
|
|
|
return ScanLineOrdering.Progressive;
|
|
|
|
|
case DisplayConfigScanLineOrdering.InterlacedWithUpperFieldFirst:
|
|
|
|
|
|
|
|
|
|
return ScanLineOrdering.InterlacedWithUpperFieldFirst;
|
|
|
|
|
case DisplayConfigScanLineOrdering.InterlacedWithLowerFieldFirst:
|
|
|
|
|
|
|
|
|
|
return ScanLineOrdering.InterlacedWithLowerFieldFirst;
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
return ScanLineOrdering.NotSpecified;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-26 19:23:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|