mirror of
https://github.com/jkocon/g-helper.git
synced 2026-06-24 14:41:04 +02:00
Gamma Init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
internal enum DisplayConfigDeviceInfoType
|
||||
{
|
||||
SetSourceDPIScale = -4,
|
||||
GetSourceDPIScale = -3,
|
||||
GetSourceName = 1,
|
||||
GetTargetName = 2,
|
||||
GetTargetPreferredMode = 3,
|
||||
GetAdapterName = 4,
|
||||
SetTargetPersistence = 5,
|
||||
GetTargetBaseType = 6,
|
||||
GetSupportVirtualResolution = 7,
|
||||
SetSupportVirtualResolution = 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possbile types of modes
|
||||
/// </summary>
|
||||
public enum DisplayConfigModeInfoType : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid value for mode type
|
||||
/// </summary>
|
||||
Invalid = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Source mode type
|
||||
/// </summary>
|
||||
Source = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Target mode type
|
||||
/// </summary>
|
||||
Target = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Display image type
|
||||
/// </summary>
|
||||
DesktopImage = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
[Flags]
|
||||
internal enum DisplayConfigPathInfoFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
Active = 1,
|
||||
SupportVirtualMode = 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
[Flags]
|
||||
internal enum DisplayConfigPathSourceInfoFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
InUse = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
[Flags]
|
||||
internal enum DisplayConfigPathTargetInfoFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
InUse = 1,
|
||||
Forcible = 2,
|
||||
AvailabilityBoot = 3,
|
||||
AvailabilityPath = 4,
|
||||
AvailabilitySystem = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible pixel formats
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553963(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum DisplayConfigPixelFormat : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Pixel format is not specified
|
||||
/// </summary>
|
||||
NotSpecified = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates 8 bits per pixel format.
|
||||
/// </summary>
|
||||
PixelFormat8Bpp = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates 16 bits per pixel format.
|
||||
/// </summary>
|
||||
PixelFormat16Bpp = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates 24 bits per pixel format.
|
||||
/// </summary>
|
||||
PixelFormat24Bpp = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates 32 bits per pixel format.
|
||||
/// </summary>
|
||||
PixelFormat32Bpp = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the current display is not an 8, 16, 24, or 32 bits per pixel GDI desktop mode.
|
||||
/// </summary>
|
||||
PixelFormatNonGDI = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotation modes
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553970(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum DisplayConfigRotation : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotation mode is not specified
|
||||
/// </summary>
|
||||
NotSpecified = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that rotation is 0 degrees—landscape mode.
|
||||
/// </summary>
|
||||
Identity = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that rotation is 90 degrees clockwise—portrait mode.
|
||||
/// </summary>
|
||||
Rotate90 = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that rotation is 180 degrees clockwise—inverted landscape mode.
|
||||
/// </summary>
|
||||
Rotate180 = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that rotation is 270 degrees clockwise—inverted portrait mode.
|
||||
/// </summary>
|
||||
Rotate270 = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Scaling modes
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553974(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum DisplayConfigScaling : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Scaling mode is not specified
|
||||
/// </summary>
|
||||
NotSpecified = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the identity transformation; the source content is presented with no change. This transformation is
|
||||
/// available only if the path's source mode has the same spatial resolution as the path's target mode.
|
||||
/// </summary>
|
||||
Identity = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the centering transformation; the source content is presented unscaled, centered with respect to the
|
||||
/// spatial resolution of the target mode.
|
||||
/// </summary>
|
||||
Centered = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the content is scaled to fit the path's target.
|
||||
/// </summary>
|
||||
Stretched = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the aspect-ratio centering transformation.
|
||||
/// </summary>
|
||||
AspectRatioCenteredMax = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the caller requests a custom scaling that the caller cannot describe with any of the other values.
|
||||
/// Only a hardware vendor's value-add application should use this value, because the value-add application might
|
||||
/// require a private interface to the driver. The application can then use this value to indicate additional context
|
||||
/// for the driver for the custom value on the specified path.
|
||||
/// </summary>
|
||||
Custom = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the caller does not have any preference for the scaling.
|
||||
/// </summary>
|
||||
Preferred = 128
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible values for display scan line ordering
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553977(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum DisplayConfigScanLineOrdering : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that scan-line ordering of the output is unspecified.
|
||||
/// </summary>
|
||||
NotSpecified = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the output is a progressive image.
|
||||
/// </summary>
|
||||
Progressive = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the output is an interlaced image that is created beginning with the upper field.
|
||||
/// </summary>
|
||||
InterlacedWithUpperFieldFirst = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the output is an interlaced image that is created beginning with the lower field.
|
||||
/// </summary>
|
||||
InterlacedWithLowerFieldFirst = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
public enum DisplayConfigSourceDPIScale : uint
|
||||
{
|
||||
Identity = 100,
|
||||
Scale125Percent = 125,
|
||||
Scale150Percent = 150,
|
||||
Scale175Percent = 175,
|
||||
Scale200Percent = 200,
|
||||
Scale225Percent = 225,
|
||||
Scale250Percent = 250,
|
||||
Scale300Percent = 300,
|
||||
Scale350Percent = 350,
|
||||
Scale400Percent = 400,
|
||||
Scale450Percent = 450,
|
||||
Scale500Percent = 500
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
[Flags]
|
||||
internal enum DisplayConfigTargetDeviceNameFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
FriendlyNameFromEDID = 1,
|
||||
FriendlyNameForced = 2,
|
||||
EDIDIdsValid = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible topology identifications
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554001(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DisplayConfigTopologyId : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid topology identification
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the display topology is an internal configuration.
|
||||
/// </summary>
|
||||
Internal = 0x00000001,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the display topology is clone-view configuration.
|
||||
/// </summary>
|
||||
Clone = 0x00000002,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the display topology is an extended configuration.
|
||||
/// </summary>
|
||||
Extend = 0x00000004,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the display topology is an external configuration.
|
||||
/// </summary>
|
||||
External = 0x00000008
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible target's connector types
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554003(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum DisplayConfigVideoOutputTechnology : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates a connector that is not one of the types that is indicated by the following enumerators in this
|
||||
/// enumeration.
|
||||
/// </summary>
|
||||
Other = 0xFFFFFFFF,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an HD15 (VGA) connector.
|
||||
/// </summary>
|
||||
HD15 = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an S-video connector.
|
||||
/// </summary>
|
||||
SVideo = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a composite video connector group.
|
||||
/// </summary>
|
||||
CompositeVideo = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a component video connector group.
|
||||
/// </summary>
|
||||
ComponentVideo = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a Digital Video Interface (DVI) connector.
|
||||
/// </summary>
|
||||
DVI = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a High-Definition Multimedia Interface (HDMI) connector.
|
||||
/// </summary>
|
||||
HDMI = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a Low Voltage Differential Swing (LVDS) connector.
|
||||
/// </summary>
|
||||
LVDS = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a Japanese D connector.
|
||||
/// </summary>
|
||||
DJPN = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an SDI connector.
|
||||
/// </summary>
|
||||
SDI = 9,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an external display port, which is a display port that connects externally to a display device.
|
||||
/// </summary>
|
||||
DisplayPortExternal = 10,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an embedded display port that connects internally to a display device.
|
||||
/// </summary>
|
||||
DisplayPortEmbedded = 11,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an external Unified Display Interface (UDI), which is a UDI that connects externally to a display device.
|
||||
/// </summary>
|
||||
UDIExternal = 12,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates an embedded UDI that connects internally to a display device.
|
||||
/// </summary>
|
||||
UDIEmbedded = 13,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a dongle cable that supports standard definition television (SDTV).
|
||||
/// </summary>
|
||||
SDTVDongle = 14,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the VidPN target is a Miracast wireless display device.
|
||||
/// </summary>
|
||||
Miracast = 15,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the video output device connects internally to a display device (for example, the internal
|
||||
/// connection in a laptop computer).
|
||||
/// </summary>
|
||||
Internal = 0x80000000
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible values for QueryDisplayConfig() flags property
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff569215(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum QueryDeviceConfigFlags : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// All the possible path combinations of sources to targets.
|
||||
/// </summary>
|
||||
AllPaths = 0x00000001,
|
||||
|
||||
/// <summary>
|
||||
/// Currently active paths only.
|
||||
/// </summary>
|
||||
OnlyActivePaths = 0x00000002,
|
||||
|
||||
/// <summary>
|
||||
/// Active path as defined in the CCD database for the currently connected displays.
|
||||
/// </summary>
|
||||
DatabaseCurrent = 0x00000004,
|
||||
|
||||
/// <summary>
|
||||
/// Virtual Mode Aware
|
||||
/// </summary>
|
||||
VirtualModeAware = 0x0000010
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
[Flags]
|
||||
internal enum SetDisplayConfigFlags : uint
|
||||
{
|
||||
TopologyInternal = 0x00000001,
|
||||
TopologyClone = 0x00000002,
|
||||
TopologyExtend = 0x00000004,
|
||||
TopologyExternal = 0x00000008,
|
||||
UseDatabaseCurrent = TopologyInternal | TopologyClone | TopologyExtend | TopologyExternal,
|
||||
TopologySupplied = 0x00000010,
|
||||
UseSuppliedDisplayConfig = 0x00000020,
|
||||
Validate = 0x00000040,
|
||||
Apply = 0x00000080,
|
||||
NoOptimization = 0x00000100,
|
||||
SaveToDatabase = 0x00000200,
|
||||
AllowChanges = 0x00000400,
|
||||
PathPersistIfRequired = 0x00000800,
|
||||
ForceModeEnumeration = 0x00001000,
|
||||
AllowPathOrderChanges = 0x00002000,
|
||||
VirtualModeAware = 0x00008000
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553913(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfig2DRegion : IEquatable<DisplayConfig2DRegion>
|
||||
{
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Width;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Height;
|
||||
|
||||
public DisplayConfig2DRegion(uint width, uint height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfig2DRegion other)
|
||||
{
|
||||
return Width == other.Width && Height == other.Height;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfig2DRegion region && Equals(region);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((int) Width * 397) ^ (int) Height;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfig2DRegion left, DisplayConfig2DRegion right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfig2DRegion left, DisplayConfig2DRegion right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/ff553915(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct DisplayConfigAdapterName
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public readonly string AdapterDevicePath;
|
||||
|
||||
public DisplayConfigAdapterName(LUID adapter) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/mt622102(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigDesktopImageInfo : IEquatable<DisplayConfigDesktopImageInfo>
|
||||
{
|
||||
public const ushort InvalidDesktopImageModeIndex = 0xffff;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly PointL PathSourceSize;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly RectangleL DesktopImageRegion;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly RectangleL DesktopImageClip;
|
||||
|
||||
public DisplayConfigDesktopImageInfo(
|
||||
PointL pathSourceSize,
|
||||
RectangleL desktopImageRegion,
|
||||
RectangleL desktopImageClip)
|
||||
{
|
||||
PathSourceSize = pathSourceSize;
|
||||
DesktopImageRegion = desktopImageRegion;
|
||||
DesktopImageClip = desktopImageClip;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigDesktopImageInfo other)
|
||||
{
|
||||
return PathSourceSize == other.PathSourceSize &&
|
||||
DesktopImageRegion == other.DesktopImageRegion &&
|
||||
DesktopImageClip == other.DesktopImageClip;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigDesktopImageInfo info && Equals(info);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = PathSourceSize.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ DesktopImageRegion.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ DesktopImageClip.GetHashCode();
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigDesktopImageInfo left, DisplayConfigDesktopImageInfo right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigDesktopImageInfo left, DisplayConfigDesktopImageInfo right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553920(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigDeviceInfoHeader
|
||||
{
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigDeviceInfoType Type;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Size;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly LUID AdapterId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Id;
|
||||
|
||||
public DisplayConfigDeviceInfoHeader(LUID adapterId, Type requestType) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
Size = (uint) Marshal.SizeOf(requestType);
|
||||
|
||||
if (requestType == typeof(DisplayConfigSourceDeviceName))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetSourceName;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigTargetDeviceName))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetTargetName;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigTargetPreferredMode))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetTargetPreferredMode;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigAdapterName))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetAdapterName;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigSetTargetPersistence))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.SetTargetPersistence;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigTargetBaseType))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetTargetBaseType;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigGetSourceDPIScale))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.GetSourceDPIScale;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigSetSourceDPIScale))
|
||||
{
|
||||
Type = DisplayConfigDeviceInfoType.SetSourceDPIScale;
|
||||
}
|
||||
else if (requestType == typeof(DisplayConfigSupportVirtualResolution))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// throw exception?
|
||||
}
|
||||
|
||||
public DisplayConfigDeviceInfoHeader(LUID adapterId, uint id, Type requestType) : this(adapterId, requestType)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public DisplayConfigDeviceInfoHeader(
|
||||
LUID adapterId,
|
||||
uint id,
|
||||
Type requestType,
|
||||
DisplayConfigDeviceInfoType request)
|
||||
: this(adapterId, id, requestType)
|
||||
{
|
||||
Type = request;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// Internal undocumented structure
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigGetSourceDPIScale
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
|
||||
[field: MarshalAs(UnmanagedType.U4)]
|
||||
public int MinimumScaleSteps { get; }
|
||||
|
||||
[field: MarshalAs(UnmanagedType.U4)]
|
||||
public int CurrentScaleSteps { get; }
|
||||
|
||||
[field: MarshalAs(UnmanagedType.U4)]
|
||||
public int MaximumScaleSteps { get; }
|
||||
|
||||
public DisplayConfigGetSourceDPIScale(LUID adapter, uint sourceId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, sourceId, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553933(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Explicit)] // Size = 64
|
||||
internal struct DisplayConfigModeInfo : IEquatable<DisplayConfigModeInfo>
|
||||
{
|
||||
public const uint InvalidModeIndex = 0xffffffff;
|
||||
|
||||
[MarshalAs(UnmanagedType.U4)] [FieldOffset(0)]
|
||||
public readonly DisplayConfigModeInfoType InfoType;
|
||||
|
||||
[MarshalAs(UnmanagedType.U4)] [FieldOffset(4)]
|
||||
public readonly uint Id;
|
||||
|
||||
[MarshalAs(UnmanagedType.Struct)] [FieldOffset(8)]
|
||||
public readonly LUID AdapterId;
|
||||
|
||||
[MarshalAs(UnmanagedType.Struct)] [FieldOffset(16)]
|
||||
public readonly DisplayConfigTargetMode TargetMode;
|
||||
|
||||
[MarshalAs(UnmanagedType.Struct)] [FieldOffset(16)]
|
||||
public readonly DisplayConfigSourceMode SourceMode;
|
||||
|
||||
[MarshalAs(UnmanagedType.Struct)] [FieldOffset(16)]
|
||||
public readonly DisplayConfigDesktopImageInfo
|
||||
DesktopImageInfo;
|
||||
|
||||
public DisplayConfigModeInfo(LUID adapterId, uint id, DisplayConfigTargetMode targetMode) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
Id = id;
|
||||
TargetMode = targetMode;
|
||||
InfoType = DisplayConfigModeInfoType.Target;
|
||||
}
|
||||
|
||||
public DisplayConfigModeInfo(LUID adapterId, uint id, DisplayConfigSourceMode sourceMode) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
Id = id;
|
||||
SourceMode = sourceMode;
|
||||
InfoType = DisplayConfigModeInfoType.Source;
|
||||
}
|
||||
|
||||
public DisplayConfigModeInfo(LUID adapterId, uint id, DisplayConfigDesktopImageInfo desktopImageInfo) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
Id = id;
|
||||
DesktopImageInfo = desktopImageInfo;
|
||||
InfoType = DisplayConfigModeInfoType.DesktopImage;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigModeInfo other)
|
||||
{
|
||||
return InfoType == other.InfoType &&
|
||||
Id == other.Id &&
|
||||
AdapterId == other.AdapterId &&
|
||||
(InfoType == DisplayConfigModeInfoType.Source && SourceMode == other.SourceMode ||
|
||||
InfoType == DisplayConfigModeInfoType.Target && TargetMode == other.TargetMode ||
|
||||
InfoType == DisplayConfigModeInfoType.DesktopImage &&
|
||||
DesktopImageInfo == other.DesktopImageInfo);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigModeInfo info && Equals(info);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = (int) InfoType;
|
||||
hashCode = (hashCode * 397) ^ (int) Id;
|
||||
hashCode = (hashCode * 397) ^ AdapterId.GetHashCode();
|
||||
|
||||
switch (InfoType)
|
||||
{
|
||||
case DisplayConfigModeInfoType.Source:
|
||||
hashCode = (hashCode * 397) ^ SourceMode.GetHashCode();
|
||||
|
||||
break;
|
||||
case DisplayConfigModeInfoType.Target:
|
||||
hashCode = (hashCode * 397) ^ TargetMode.GetHashCode();
|
||||
|
||||
break;
|
||||
case DisplayConfigModeInfoType.DesktopImage:
|
||||
hashCode = (hashCode * 397) ^ DesktopImageInfo.GetHashCode();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigModeInfo left, DisplayConfigModeInfo right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigModeInfo left, DisplayConfigModeInfo right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553945(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigPathInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigPathSourceInfo SourceInfo;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigPathTargetInfo TargetInfo;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigPathInfoFlags Flags;
|
||||
|
||||
public DisplayConfigPathInfo(
|
||||
DisplayConfigPathSourceInfo sourceInfo,
|
||||
DisplayConfigPathTargetInfo targetInfo,
|
||||
DisplayConfigPathInfoFlags flags)
|
||||
{
|
||||
SourceInfo = sourceInfo;
|
||||
TargetInfo = targetInfo;
|
||||
Flags = flags;
|
||||
}
|
||||
|
||||
public DisplayConfigPathInfo(DisplayConfigPathSourceInfo sourceInfo, DisplayConfigPathInfoFlags flags)
|
||||
{
|
||||
SourceInfo = sourceInfo;
|
||||
Flags = flags;
|
||||
TargetInfo = new DisplayConfigPathTargetInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553951(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigPathSourceInfo
|
||||
{
|
||||
public const ushort InvalidCloneGroupId = 0xffff;
|
||||
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly LUID AdapterId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint SourceId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint ModeInfoIndex;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigPathSourceInfoFlags StatusFlags;
|
||||
|
||||
public ushort SourceModeInfoIndex
|
||||
{
|
||||
get => (ushort) ((ModeInfoIndex << 16) >> 16);
|
||||
}
|
||||
|
||||
public ushort CloneGroupId
|
||||
{
|
||||
get => (ushort) (ModeInfoIndex >> 16);
|
||||
}
|
||||
|
||||
public DisplayConfigPathSourceInfo(LUID adapterId, uint sourceId, uint modeInfoIndex) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
SourceId = sourceId;
|
||||
ModeInfoIndex = modeInfoIndex;
|
||||
}
|
||||
|
||||
public DisplayConfigPathSourceInfo(
|
||||
LUID adapterId,
|
||||
uint sourceId,
|
||||
ushort sourceModeInfoIndex,
|
||||
ushort cloneGroupId) : this(adapterId, sourceId, 0)
|
||||
{
|
||||
ModeInfoIndex = (uint) (sourceModeInfoIndex + (cloneGroupId << 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553954(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigPathTargetInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly LUID AdapterId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint TargetId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint ModeInfoIndex;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigVideoOutputTechnology OutputTechnology;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigRotation Rotation;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigScaling Scaling;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigRational RefreshRate;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigScanLineOrdering ScanLineOrdering;
|
||||
[MarshalAs(UnmanagedType.Bool)] public readonly bool TargetAvailable;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigPathTargetInfoFlags StatusFlags;
|
||||
|
||||
public ushort TargetModeInfoIndex
|
||||
{
|
||||
get => (ushort) ((ModeInfoIndex << 16) >> 16);
|
||||
}
|
||||
|
||||
public ushort DesktopModeInfoIndex
|
||||
{
|
||||
get => (ushort) (ModeInfoIndex >> 16);
|
||||
}
|
||||
|
||||
public DisplayConfigPathTargetInfo(
|
||||
LUID adapterId,
|
||||
uint targetId,
|
||||
uint modeInfoIndex,
|
||||
DisplayConfigVideoOutputTechnology outputTechnology,
|
||||
DisplayConfigRotation rotation,
|
||||
DisplayConfigScaling scaling,
|
||||
DisplayConfigRational refreshRate,
|
||||
DisplayConfigScanLineOrdering scanLineOrdering,
|
||||
bool targetAvailable) : this()
|
||||
{
|
||||
AdapterId = adapterId;
|
||||
TargetId = targetId;
|
||||
ModeInfoIndex = modeInfoIndex;
|
||||
OutputTechnology = outputTechnology;
|
||||
Rotation = rotation;
|
||||
Scaling = scaling;
|
||||
RefreshRate = refreshRate;
|
||||
ScanLineOrdering = scanLineOrdering;
|
||||
TargetAvailable = targetAvailable;
|
||||
}
|
||||
|
||||
public DisplayConfigPathTargetInfo(
|
||||
LUID adapterId,
|
||||
uint targetId,
|
||||
ushort targetModeInfoIndex,
|
||||
ushort desktopModeInfoIndex,
|
||||
DisplayConfigVideoOutputTechnology outputTechnology,
|
||||
DisplayConfigRotation rotation,
|
||||
DisplayConfigScaling scaling,
|
||||
DisplayConfigRational refreshRate,
|
||||
DisplayConfigScanLineOrdering scanLineOrdering,
|
||||
bool targetAvailable)
|
||||
: this(
|
||||
adapterId, targetId, 0, outputTechnology, rotation, scaling, refreshRate, scanLineOrdering,
|
||||
targetAvailable)
|
||||
{
|
||||
ModeInfoIndex = (uint) (targetModeInfoIndex + (desktopModeInfoIndex << 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553968(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigRational : IEquatable<DisplayConfigRational>
|
||||
{
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Numerator;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Denominator;
|
||||
|
||||
public DisplayConfigRational(uint numerator, uint denominator, bool simplify)
|
||||
: this((ulong) numerator, denominator, simplify)
|
||||
{
|
||||
}
|
||||
|
||||
public DisplayConfigRational(ulong numerator, ulong denominator, bool simplify)
|
||||
{
|
||||
var gcm = simplify & (numerator != 0) ? Euclidean(numerator, denominator) : 1;
|
||||
Numerator = (uint) (numerator / gcm);
|
||||
Denominator = (uint) (denominator / gcm);
|
||||
}
|
||||
|
||||
private static ulong Euclidean(ulong a, ulong b)
|
||||
{
|
||||
while (a != 0 && b != 0)
|
||||
{
|
||||
if (a > b)
|
||||
{
|
||||
a %= b;
|
||||
}
|
||||
else
|
||||
{
|
||||
b %= a;
|
||||
}
|
||||
}
|
||||
|
||||
return a == 0 ? b : a;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public ulong ToValue(ulong multiplier = 1)
|
||||
{
|
||||
if (Numerator == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Numerator * multiplier / Denominator;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigRational other)
|
||||
{
|
||||
if (Numerator == other.Numerator && Denominator == other.Denominator)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var left = Numerator / (double) Denominator;
|
||||
var right = other.Numerator / (double) other.Denominator;
|
||||
|
||||
return Math.Abs(left - right) <= Math.Max(Math.Abs(left), Math.Abs(right)) * 1E-15;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigRational rational && Equals(rational);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((int) Numerator * 397) ^ (int) Denominator;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigRational left, DisplayConfigRational right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigRational left, DisplayConfigRational right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// Internal undocumented structure
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigSetSourceDPIScale
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
|
||||
[field: MarshalAs(UnmanagedType.U4)]
|
||||
public int ScaleSteps { get; }
|
||||
|
||||
public DisplayConfigSetSourceDPIScale(LUID adapter, uint sourceId, int scaleSteps) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, sourceId, GetType());
|
||||
ScaleSteps = scaleSteps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/ff553981(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigSetTargetPersistence
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
[MarshalAs(UnmanagedType.U4)] private readonly uint _BootPersistenceOn;
|
||||
|
||||
public bool BootPersistence
|
||||
{
|
||||
get => _BootPersistenceOn > 0;
|
||||
}
|
||||
|
||||
public DisplayConfigSetTargetPersistence(LUID adapter, uint targetId, bool bootPersistence) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType());
|
||||
_BootPersistenceOn = bootPersistence ? 1u : 0u;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/ff553983(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct DisplayConfigSourceDeviceName
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public readonly string DeviceName;
|
||||
|
||||
public DisplayConfigSourceDeviceName(LUID adapter, uint sourceId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, sourceId, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553986(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigSourceMode : IEquatable<DisplayConfigSourceMode>
|
||||
{
|
||||
public const ushort InvalidSourceModeIndex = 0xffff;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Width;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Height;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigPixelFormat PixelFormat;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly PointL Position;
|
||||
|
||||
public DisplayConfigSourceMode(uint width, uint height, DisplayConfigPixelFormat pixelFormat, PointL position)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
PixelFormat = pixelFormat;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigSourceMode other)
|
||||
{
|
||||
return Width == other.Width &&
|
||||
Height == other.Height &&
|
||||
PixelFormat == other.PixelFormat &&
|
||||
Position == other.Position;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigSourceMode mode && Equals(mode);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = (int) Width;
|
||||
hashCode = (hashCode * 397) ^ (int) Height;
|
||||
hashCode = (hashCode * 397) ^ (int) PixelFormat;
|
||||
hashCode = (hashCode * 397) ^ Position.GetHashCode();
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigSourceMode left, DisplayConfigSourceMode right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigSourceMode left, DisplayConfigSourceMode right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/mt622103(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct DisplayConfigSupportVirtualResolution
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
[MarshalAs(UnmanagedType.U4)] private readonly int _DisableMonitorVirtualResolution;
|
||||
|
||||
public bool DisableMonitorVirtualResolution
|
||||
{
|
||||
get => _DisableMonitorVirtualResolution > 0;
|
||||
}
|
||||
|
||||
public DisplayConfigSupportVirtualResolution(LUID adapter, uint targetId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType(),
|
||||
DisplayConfigDeviceInfoType.GetSupportVirtualResolution);
|
||||
}
|
||||
|
||||
public DisplayConfigSupportVirtualResolution(LUID adapter, uint targetId, bool disableMonitorVirtualResolution)
|
||||
: this()
|
||||
{
|
||||
_DisableMonitorVirtualResolution = disableMonitorVirtualResolution ? 1 : 0;
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType(),
|
||||
DisplayConfigDeviceInfoType.SetSupportVirtualResolution);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/dn362043(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigTargetBaseType
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigVideoOutputTechnology BaseOutputTechnology;
|
||||
|
||||
public DisplayConfigTargetBaseType(LUID adapter, uint targetId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/ff553989(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct DisplayConfigTargetDeviceName
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigTargetDeviceNameFlags Flags;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigVideoOutputTechnology OutputTechnology;
|
||||
[MarshalAs(UnmanagedType.U2)] public readonly ushort EDIDManufactureId;
|
||||
[MarshalAs(UnmanagedType.U2)] public readonly ushort EDIDProductCodeId;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint ConnectorInstance;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||
public readonly string MonitorFriendlyDeviceName;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public readonly string MonitorDevicePath;
|
||||
|
||||
|
||||
public DisplayConfigTargetDeviceName(LUID adapter, uint targetId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553993(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigTargetMode : IEquatable<DisplayConfigTargetMode>
|
||||
{
|
||||
public const ushort InvalidTargetModeIndex = 0xffff;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigVideoSignalInfo TargetVideoSignalInfo;
|
||||
|
||||
public DisplayConfigTargetMode(DisplayConfigVideoSignalInfo targetVideoSignalInfo)
|
||||
{
|
||||
TargetVideoSignalInfo = targetVideoSignalInfo;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigTargetMode other)
|
||||
{
|
||||
return TargetVideoSignalInfo == other.TargetVideoSignalInfo;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigTargetMode mode && Equals(mode);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return TargetVideoSignalInfo.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigTargetMode left, DisplayConfigTargetMode right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigTargetMode left, DisplayConfigTargetMode right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsDisplayAPI.Native.Structures;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/vs/alm/ff553996(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigTargetPreferredMode
|
||||
{
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
[MarshalAs(UnmanagedType.Struct)] private readonly DisplayConfigDeviceInfoHeader _Header;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Width;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly uint Height;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigTargetMode TargetMode;
|
||||
|
||||
public DisplayConfigTargetPreferredMode(LUID adapter, uint targetId) : this()
|
||||
{
|
||||
_Header = new DisplayConfigDeviceInfoHeader(adapter, targetId, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig.Structures
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554007(v=vs.85).aspx
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct DisplayConfigVideoSignalInfo : IEquatable<DisplayConfigVideoSignalInfo>
|
||||
{
|
||||
[MarshalAs(UnmanagedType.U8)] public readonly ulong PixelRate;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigRational HorizontalSyncFrequency;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfigRational VerticalSyncFrequency;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfig2DRegion ActiveSize;
|
||||
[MarshalAs(UnmanagedType.Struct)] public readonly DisplayConfig2DRegion TotalSize;
|
||||
[MarshalAs(UnmanagedType.U2)] public readonly VideoSignalStandard VideoStandard;
|
||||
[MarshalAs(UnmanagedType.U2)] public readonly ushort VerticalSyncFrequencyDivider;
|
||||
[MarshalAs(UnmanagedType.U4)] public readonly DisplayConfigScanLineOrdering ScanLineOrdering;
|
||||
|
||||
public DisplayConfigVideoSignalInfo(
|
||||
ulong pixelRate,
|
||||
DisplayConfigRational horizontalSyncFrequency,
|
||||
DisplayConfigRational verticalSyncFrequency,
|
||||
DisplayConfig2DRegion activeSize,
|
||||
DisplayConfig2DRegion totalSize,
|
||||
VideoSignalStandard videoStandard,
|
||||
ushort verticalSyncFrequencyDivider,
|
||||
DisplayConfigScanLineOrdering scanLineOrdering)
|
||||
{
|
||||
PixelRate = pixelRate;
|
||||
HorizontalSyncFrequency = horizontalSyncFrequency;
|
||||
VerticalSyncFrequency = verticalSyncFrequency;
|
||||
ActiveSize = activeSize;
|
||||
TotalSize = totalSize;
|
||||
VideoStandard = videoStandard;
|
||||
VerticalSyncFrequencyDivider = verticalSyncFrequencyDivider;
|
||||
ScanLineOrdering = scanLineOrdering;
|
||||
}
|
||||
|
||||
public bool Equals(DisplayConfigVideoSignalInfo other)
|
||||
{
|
||||
return PixelRate == other.PixelRate &&
|
||||
HorizontalSyncFrequency == other.HorizontalSyncFrequency &&
|
||||
VerticalSyncFrequency == other.VerticalSyncFrequency &&
|
||||
ActiveSize == other.ActiveSize &&
|
||||
TotalSize == other.TotalSize &&
|
||||
VideoStandard == other.VideoStandard &&
|
||||
VerticalSyncFrequencyDivider == other.VerticalSyncFrequencyDivider &&
|
||||
ScanLineOrdering == other.ScanLineOrdering;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj is DisplayConfigVideoSignalInfo info && Equals(info);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = PixelRate.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ HorizontalSyncFrequency.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ VerticalSyncFrequency.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ ActiveSize.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ TotalSize.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ (int) VideoStandard;
|
||||
hashCode = (hashCode * 397) ^ VerticalSyncFrequencyDivider.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ (int) ScanLineOrdering;
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(DisplayConfigVideoSignalInfo left, DisplayConfigVideoSignalInfo right)
|
||||
{
|
||||
return Equals(left, right) || left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(DisplayConfigVideoSignalInfo left, DisplayConfigVideoSignalInfo right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
namespace WindowsDisplayAPI.Native.DisplayConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible video signal standards
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff546632(v=vs.85).aspx
|
||||
/// </summary>
|
||||
public enum VideoSignalStandard : ushort
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the variable has not yet been assigned a meaningful value.
|
||||
/// </summary>
|
||||
Uninitialized = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Video Electronics Standards Association (VESA) Display Monitor Timing (DMT) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
VESA_DMT = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the VESA Generalized Timing Formula (GTF) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
VESA_GTF = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the VESA Coordinated Video Timing (CVT) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
VESA_CVT = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the IBM standard.
|
||||
/// </summary>
|
||||
IBM = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Apple standard.
|
||||
/// </summary>
|
||||
Apple = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the National Television Standards Committee (NTSC) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
NTSC_M = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the NTSC japanese standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
NTSC_J = 7,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the NTSC standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
NTSC_443 = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Phase Alteration Line (PAL) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_B = 9,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_B1 = 10,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_G = 11,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_H = 12,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_I = 13,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_D = 14,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_N = 15,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_NC = 16,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Systeme Electronic Pour Couleur Avec Memoire (SECAM) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_B = 17,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_D = 18,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_G = 19,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_H = 20,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_K = 21,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_K1 = 22,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_L = 23,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the SECAM standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
SECAM_L1 = 24,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Electronics Industries Association (EIA) standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
EIA_861 = 25,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the EIA standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
EIA_861A = 26,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the EIA standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
EIA_861B = 27,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_K = 28,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_K1 = 29,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_L = 30,
|
||||
|
||||
/// <summary>
|
||||
/// Represents the PAL standard.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
PAL_M = 31,
|
||||
|
||||
/// <summary>
|
||||
/// Represents any video standard other than those represented by the previous constants in this enumeration.
|
||||
/// </summary>
|
||||
Other = 255
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user