mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2025-07-25 12:53:07 +00:00
All Enums mirrored on the Shared assembly
This commit is contained in:
@ -56,14 +56,17 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ScanLineOrdering.cs" />
|
||||
<Compile Include="Helios.cs" />
|
||||
<Compile Include="NVIDIA\SurroundHelper.cs" />
|
||||
<Compile Include="NVIDIA\SurroundTopologyDisplay.cs" />
|
||||
<Compile Include="PixelShift.cs" />
|
||||
<Compile Include="Profile.cs" />
|
||||
<Compile Include="NVIDIA\SurroundTopology.cs" />
|
||||
<Compile Include="HeliosStartupAction.cs" />
|
||||
<Compile Include="ProfileIcon.cs" />
|
||||
<Compile Include="Rotation.cs" />
|
||||
<Compile Include="Scaling.cs" />
|
||||
<Compile Include="Topology\Path.cs" />
|
||||
<Compile Include="Topology\PathHelper.cs" />
|
||||
<Compile Include="Topology\PathTarget.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NvAPIWrapper.Native.Display;
|
||||
using NvAPIWrapper.Native.Mosaic;
|
||||
|
||||
namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
{
|
||||
@ -38,5 +39,31 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
return Rotation.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public static PixelShiftType ToPixelShiftType(this PixelShift pixelShift)
|
||||
{
|
||||
switch (pixelShift)
|
||||
{
|
||||
case PixelShift.TopLeft2X2Pixels:
|
||||
return PixelShiftType.TopLeft2X2Pixels;
|
||||
case PixelShift.BottomRight2X2Pixels:
|
||||
return PixelShiftType.BottomRight2X2Pixels;
|
||||
default:
|
||||
return PixelShiftType.NoPixelShift;
|
||||
}
|
||||
}
|
||||
|
||||
public static PixelShift ToPixelShift(this PixelShiftType pixelShift)
|
||||
{
|
||||
switch (pixelShift)
|
||||
{
|
||||
case PixelShiftType.TopLeft2X2Pixels:
|
||||
return PixelShift.TopLeft2X2Pixels;
|
||||
case PixelShiftType.BottomRight2X2Pixels:
|
||||
return PixelShift.BottomRight2X2Pixels;
|
||||
default:
|
||||
return PixelShift.NoPixelShift;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ using System.Linq;
|
||||
using EDIDParser;
|
||||
using EDIDParser.Descriptors;
|
||||
using EDIDParser.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using NvAPIWrapper.Mosaic;
|
||||
using NvAPIWrapper.Native.Mosaic;
|
||||
|
||||
@ -16,7 +18,7 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
DisplayId = display.DisplayDevice.DisplayId;
|
||||
Rotation = display.Rotation.ToRotation();
|
||||
Overlap = new Point(display.Overlap.HorizontalOverlap, display.Overlap.VerticalOverlap);
|
||||
PixelShiftType = display.PixelShiftType;
|
||||
PixelShift = display.PixelShiftType.ToPixelShift();
|
||||
try
|
||||
{
|
||||
var bytes = display.DisplayDevice.PhysicalGPU.ReadEDIDData(display.DisplayDevice.Output);
|
||||
@ -40,7 +42,11 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public Point Overlap { get; set; }
|
||||
public PixelShiftType PixelShiftType { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public PixelShift PixelShift { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Rotation Rotation { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -49,7 +55,7 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return (DisplayId == other.DisplayId) && Overlap.Equals(other.Overlap) &&
|
||||
(PixelShiftType == other.PixelShiftType) && (Rotation == other.Rotation);
|
||||
(PixelShift == other.PixelShift) && (Rotation == other.Rotation);
|
||||
}
|
||||
|
||||
public static bool operator ==(SurroundTopologyDisplay left, SurroundTopologyDisplay right)
|
||||
@ -78,7 +84,7 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
{
|
||||
var hashCode = (int) DisplayId;
|
||||
hashCode = (hashCode*397) ^ Overlap.GetHashCode();
|
||||
hashCode = (hashCode*397) ^ (int) PixelShiftType;
|
||||
hashCode = (hashCode*397) ^ (int) PixelShift;
|
||||
hashCode = (hashCode*397) ^ (int) Rotation;
|
||||
return hashCode;
|
||||
}
|
||||
@ -93,7 +99,7 @@ namespace HeliosDisplayManagement.Shared.NVIDIA
|
||||
public GridTopologyDisplay ToGridTopologyDisplay()
|
||||
{
|
||||
return new GridTopologyDisplay(DisplayId, new Overlap(Overlap.X, Overlap.Y), Rotation.ToRotate(), 0,
|
||||
PixelShiftType);
|
||||
PixelShift.ToPixelShiftType());
|
||||
}
|
||||
}
|
||||
}
|
9
HeliosDisplayManagement.Shared/PixelShift.cs
Normal file
9
HeliosDisplayManagement.Shared/PixelShift.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace HeliosDisplayManagement.Shared
|
||||
{
|
||||
public enum PixelShift
|
||||
{
|
||||
NoPixelShift,
|
||||
TopLeft2X2Pixels,
|
||||
BottomRight2X2Pixels,
|
||||
}
|
||||
}
|
13
HeliosDisplayManagement.Shared/Scaling.cs
Normal file
13
HeliosDisplayManagement.Shared/Scaling.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace HeliosDisplayManagement.Shared
|
||||
{
|
||||
public enum Scaling
|
||||
{
|
||||
NotSpecified,
|
||||
Identity,
|
||||
Centered,
|
||||
Stretched,
|
||||
AspectRatioCenteredMax,
|
||||
Custom,
|
||||
Preferred,
|
||||
}
|
||||
}
|
10
HeliosDisplayManagement.Shared/ScanLineOrdering.cs
Normal file
10
HeliosDisplayManagement.Shared/ScanLineOrdering.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace HeliosDisplayManagement.Shared
|
||||
{
|
||||
public enum ScanLineOrdering
|
||||
{
|
||||
NotSpecified,
|
||||
Progressive,
|
||||
InterlacedWithUpperFieldFirst,
|
||||
InterlacedWithLowerFieldFirst,
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using WindowsDisplayAPI.DisplayConfig;
|
||||
using WindowsDisplayAPI.Native.DisplayConfig;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace HeliosDisplayManagement.Shared.Topology
|
||||
{
|
||||
@ -21,11 +23,13 @@ namespace HeliosDisplayManagement.Shared.Topology
|
||||
{
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public DisplayConfigPixelFormat PixelFormat { get; set; }
|
||||
|
||||
public Point Position { get; set; }
|
||||
|
||||
public Size Resolution { get; set; }
|
||||
|
||||
public uint SourceId { get; set; }
|
||||
|
||||
public PathTarget[] Targets { get; set; }
|
||||
|
@ -1,4 +1,6 @@
|
||||
using WindowsDisplayAPI.Native.DisplayConfig;
|
||||
using System;
|
||||
using WindowsDisplayAPI.Native.DisplayConfig;
|
||||
using NvAPIWrapper.Native.Mosaic;
|
||||
|
||||
namespace HeliosDisplayManagement.Shared.Topology
|
||||
{
|
||||
@ -9,33 +11,139 @@ namespace HeliosDisplayManagement.Shared.Topology
|
||||
switch (rotation)
|
||||
{
|
||||
case Rotation.Identity:
|
||||
|
||||
return DisplayConfigRotation.Identity;
|
||||
case Rotation.Rotate90:
|
||||
|
||||
return DisplayConfigRotation.Rotate90;
|
||||
case Rotation.Rotate180:
|
||||
|
||||
return DisplayConfigRotation.Rotate180;
|
||||
case Rotation.Rotate270:
|
||||
|
||||
return DisplayConfigRotation.Rotate270;
|
||||
default:
|
||||
|
||||
return DisplayConfigRotation.NotSpecified;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rotation ToRotation(this DisplayConfigRotation rotation)
|
||||
{
|
||||
switch (rotation)
|
||||
{
|
||||
case DisplayConfigRotation.Identity:
|
||||
|
||||
return Rotation.Identity;
|
||||
case DisplayConfigRotation.Rotate90:
|
||||
|
||||
return Rotation.Rotate90;
|
||||
case DisplayConfigRotation.Rotate180:
|
||||
|
||||
return Rotation.Rotate180;
|
||||
case DisplayConfigRotation.Rotate270:
|
||||
|
||||
return Rotation.Rotate270;
|
||||
default:
|
||||
|
||||
return Rotation.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ using System.Linq;
|
||||
using WindowsDisplayAPI.DisplayConfig;
|
||||
using WindowsDisplayAPI.Native.DisplayConfig;
|
||||
using HeliosDisplayManagement.Shared.NVIDIA;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace HeliosDisplayManagement.Shared.Topology
|
||||
{
|
||||
@ -17,8 +19,8 @@ namespace HeliosDisplayManagement.Shared.Topology
|
||||
|
||||
FrequencyInMillihertz = targetInfo.FrequencyInMillihertz;
|
||||
Rotation = targetInfo.Rotation.ToRotation();
|
||||
Scaling = targetInfo.Scaling;
|
||||
ScanLineOrdering = targetInfo.ScanLineOrdering;
|
||||
Scaling = targetInfo.Scaling.ToScaling();
|
||||
ScanLineOrdering = targetInfo.ScanLineOrdering.ToScanLineOrdering();
|
||||
try
|
||||
{
|
||||
DisplayName = targetInfo.DisplayTarget.FriendlyName;
|
||||
@ -38,10 +40,17 @@ namespace HeliosDisplayManagement.Shared.Topology
|
||||
public string DevicePath { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public ulong FrequencyInMillihertz { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Rotation Rotation { get; set; }
|
||||
public DisplayConfigScaling Scaling { get; set; }
|
||||
public DisplayConfigScanLineOrdering ScanLineOrdering { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public Scaling Scaling { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ScanLineOrdering ScanLineOrdering { get; set; }
|
||||
|
||||
public SurroundTopology SurroundTopology { get; set; }
|
||||
|
||||
@ -106,7 +115,7 @@ namespace HeliosDisplayManagement.Shared.Topology
|
||||
if (targetDevice == null)
|
||||
return null;
|
||||
return new PathTargetInfo(new PathDisplayTarget(targetDevice.Adapter, targetDevice.TargetId),
|
||||
FrequencyInMillihertz, ScanLineOrdering, Rotation.ToDisplayConfigRotation(), Scaling);
|
||||
FrequencyInMillihertz, ScanLineOrdering.ToDisplayConfigScanLineOrdering(), Rotation.ToDisplayConfigRotation(), Scaling.ToDisplayConfigScaling());
|
||||
}
|
||||
}
|
||||
}
|
@ -193,20 +193,20 @@ namespace HeliosDisplayManagement.UIForms
|
||||
}
|
||||
|
||||
|
||||
private ColorDepth PixelFormatToColorDepth(DisplayConfigPixelFormat format)
|
||||
private WindowsDisplayAPI.ColorDepth PixelFormatToColorDepth(DisplayConfigPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case DisplayConfigPixelFormat.PixelFormat8Bpp:
|
||||
return ColorDepth.Depth8Bit;
|
||||
return WindowsDisplayAPI.ColorDepth.Depth8Bit;
|
||||
case DisplayConfigPixelFormat.PixelFormat16Bpp:
|
||||
return ColorDepth.Depth16Bit;
|
||||
return WindowsDisplayAPI.ColorDepth.Depth16Bit;
|
||||
case DisplayConfigPixelFormat.PixelFormat24Bpp:
|
||||
return ColorDepth.Depth24Bit;
|
||||
return WindowsDisplayAPI.ColorDepth.Depth24Bit;
|
||||
case DisplayConfigPixelFormat.PixelFormat32Bpp:
|
||||
return ColorDepth.Depth32Bit;
|
||||
return WindowsDisplayAPI.ColorDepth.Depth32Bit;
|
||||
default:
|
||||
return ColorDepth.Depth4Bit;
|
||||
return WindowsDisplayAPI.ColorDepth.Depth4Bit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ namespace HeliosDisplayManagement.UIForms
|
||||
.Distinct())
|
||||
{
|
||||
cb_colordepth.Items.Add(colorDepth);
|
||||
if ((ColorDepth) cb_colordepth.Items[cb_colordepth.Items.Count - 1] ==
|
||||
if ((WindowsDisplayAPI.ColorDepth) cb_colordepth.Items[cb_colordepth.Items.Count - 1] ==
|
||||
PixelFormatToColorDepth(pathSource.PixelFormat))
|
||||
cb_colordepth.SelectedIndex = cb_colordepth.Items.Count - 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user