using System;
using NvAPIWrapper.Display;
using NvAPIWrapper.Native.Display;
using NvAPIWrapper.Native.Interfaces.Mosaic;
using NvAPIWrapper.Native.Mosaic;
using NvAPIWrapper.Native.Mosaic.Structures;
namespace NvAPIWrapper.Mosaic
{
///
/// Represents a display in a mosaic grid topology
///
public class GridTopologyDisplay : IEquatable
{
///
/// Creates a mew GridTopologyDisplay
///
/// Corresponding display identification
/// The overlap values
/// The display rotation
/// The display clone group
/// The display pixel shift type
public GridTopologyDisplay(
uint displayId,
Overlap overlap = default(Overlap),
Rotate rotation = Rotate.Degree0,
uint cloneGroup = 0,
PixelShiftType pixelShiftType = PixelShiftType.NoPixelShift)
: this(new DisplayDevice(displayId), overlap, rotation, cloneGroup, pixelShiftType)
{
}
///
/// Creates a mew GridTopologyDisplay
///
/// Corresponding display device
/// The overlap values
/// The display rotation
/// The display clone group
/// The display pixel shift type
public GridTopologyDisplay(
DisplayDevice display,
Overlap overlap = default(Overlap),
Rotate rotation = Rotate.Degree0,
uint cloneGroup = 0,
PixelShiftType pixelShiftType = PixelShiftType.NoPixelShift)
{
DisplayDevice = display;
Overlap = overlap;
Rotation = rotation;
CloneGroup = cloneGroup;
PixelShiftType = pixelShiftType;
}
///
/// Creates a mew GridTopologyDisplay
///
/// IGridTopologyDisplay implamented object
public GridTopologyDisplay(IGridTopologyDisplay gridTopologyDisplay)
: this(
new DisplayDevice(gridTopologyDisplay.DisplayId),
new Overlap(gridTopologyDisplay.OverlapX, gridTopologyDisplay.OverlapY),
gridTopologyDisplay.Rotation, gridTopologyDisplay.CloneGroup, gridTopologyDisplay.PixelShiftType)
{
}
///
/// Gets the clone group identification; Reserved, must be 0
///
public uint CloneGroup { get; set; }
///
/// Gets the corresponding DisplayDevice
///
public DisplayDevice DisplayDevice { get; }
///
/// Gets the overlap values
///
public Overlap Overlap { get; set; }
///
/// Gets the type of display pixel shift
///
public PixelShiftType PixelShiftType { get; set; }
///
/// Gets the rotation of the display
///
public Rotate Rotation { get; set; }
///
public bool Equals(GridTopologyDisplay other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return DisplayDevice.Equals(other.DisplayDevice) &&
Overlap.Equals(other.Overlap) &&
Rotation == other.Rotation &&
CloneGroup == other.CloneGroup &&
PixelShiftType == other.PixelShiftType;
}
///
/// Checks for equality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are equal, otherwise false
public static bool operator ==(GridTopologyDisplay left, GridTopologyDisplay right)
{
return right?.Equals(left) ?? ReferenceEquals(left, null);
}
///
/// Checks for inequality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are not equal, otherwise false
public static bool operator !=(GridTopologyDisplay left, GridTopologyDisplay right)
{
return !(left == right);
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GridTopologyDisplay) obj);
}
///
public override int GetHashCode()
{
unchecked
{
var hashCode = DisplayDevice?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ Overlap.GetHashCode();
hashCode = (hashCode * 397) ^ (int) Rotation;
hashCode = (hashCode * 397) ^ (int) CloneGroup;
hashCode = (hashCode * 397) ^ (int) PixelShiftType;
return hashCode;
}
}
///
/// Creates and fills a GridTopologyDisplayV1 object
///
/// The newly created GridTopologyDisplayV1 object
public GridTopologyDisplayV1 GetGridTopologyDisplayV1()
{
return new GridTopologyDisplayV1(DisplayDevice.DisplayId, Overlap.HorizontalOverlap,
Overlap.VerticalOverlap,
Rotation, CloneGroup);
}
///
/// Creates and fills a GridTopologyDisplayV2 object
///
/// The newly created GridTopologyDisplayV2 object
public GridTopologyDisplayV2 GetGridTopologyDisplayV2()
{
return new GridTopologyDisplayV2(DisplayDevice.DisplayId, Overlap.HorizontalOverlap,
Overlap.VerticalOverlap,
Rotation, CloneGroup, PixelShiftType);
}
}
}