Files
SabreTools/SabreTools.DatItems/Display.cs

232 lines
7.0 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-03 13:20:56 -07:00
2020-12-08 13:23:59 -08:00
using SabreTools.Core;
2020-09-03 13:20:56 -07:00
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2020-09-02 21:36:14 -07:00
2020-12-08 15:15:41 -08:00
namespace SabreTools.DatItems
2020-09-02 21:36:14 -07:00
{
/// <summary>
/// Represents one machine display
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("display"), XmlRoot("display")]
2020-09-02 21:36:14 -07:00
public class Display : DatItem
{
#region Fields
/// <summary>
/// Display tag
/// </summary>
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("tag")]
2020-09-02 21:36:14 -07:00
public string Tag { get; set; }
/// <summary>
/// Display type
/// </summary>
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("type")]
public DisplayType DisplayType { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool DisplayTypeSpecified { get { return DisplayType != DisplayType.NULL; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display rotation
/// </summary>
[JsonProperty("rotate", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("rotate")]
2020-09-04 10:28:25 -07:00
public long? Rotate { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool RotateSpecified { get { return Rotate != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Determines if display is flipped in the X-coordinates
/// </summary>
[JsonProperty("flipx", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("flipx")]
2020-09-02 21:36:14 -07:00
public bool? FlipX { get; set; }
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool FlipXSpecified { get { return FlipX != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display width
/// </summary>
[JsonProperty("width", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("width")]
2020-09-04 10:39:37 -07:00
public long? Width { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool WidthSpecified { get { return Width != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display height
/// </summary>
[JsonProperty("height", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("height")]
2020-09-04 10:39:37 -07:00
public long? Height { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HeightSpecified { get { return Height != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Refresh rate
/// </summary>
[JsonProperty("refresh", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("refresh")]
2020-09-04 11:04:58 -07:00
public double? Refresh { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool RefreshSpecified { get { return Refresh != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Pixel clock timer
/// </summary>
[JsonProperty("pixclock", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("pixclock")]
2020-09-04 10:50:08 -07:00
public long? PixClock { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool PixClockSpecified { get { return PixClock != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Total horizontal lines
/// </summary>
[JsonProperty("htotal", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("htotal")]
2020-09-04 10:57:30 -07:00
public long? HTotal { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HTotalSpecified { get { return HTotal != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Horizontal blank end
/// </summary>
[JsonProperty("hbend", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("hbend")]
2020-09-04 10:57:30 -07:00
public long? HBEnd { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HBEndSpecified { get { return HBEnd != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Horizontal blank start
/// </summary>
[JsonProperty("hbstart", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("hbstart")]
2020-09-04 10:57:30 -07:00
public long? HBStart { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HBStartSpecified { get { return HBStart != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Total vertical lines
/// </summary>
[JsonProperty("vtotal", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("vtotal")]
2020-09-04 10:57:30 -07:00
public long? VTotal { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VTotalSpecified { get { return VTotal != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Vertical blank end
/// </summary>
[JsonProperty("vbend", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("vbend")]
2020-09-04 10:57:30 -07:00
public long? VBEnd { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VBEndSpecified { get { return VBEnd != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Vertical blank start
/// </summary>
[JsonProperty("vbstart", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("vbstart")]
2020-09-04 10:57:30 -07:00
public long? VBStart { get; set; }
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VBStartSpecified { get { return VBStart != null; } }
2020-09-02 21:36:14 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Display object
/// </summary>
public Display()
{
ItemType = ItemType.Display;
}
#endregion
#region Cloning Methods
public override object Clone()
{
return new Display()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Tag = this.Tag,
DisplayType = this.DisplayType,
Rotate = this.Rotate,
FlipX = this.FlipX,
Width = this.Width,
Height = this.Height,
Refresh = this.Refresh,
PixClock = this.PixClock,
HTotal = this.HTotal,
HBEnd = this.HBEnd,
HBStart = this.HBStart,
VTotal = this.VTotal,
VBEnd = this.VBEnd,
VBStart = this.VBStart,
};
}
#endregion
#region Comparision Methods
public override bool Equals(DatItem other)
{
// If we don't have a Display, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Display
Display newOther = other as Display;
// If the Display information matches
return (Tag == newOther.Tag
&& DisplayType == newOther.DisplayType
&& Rotate == newOther.Rotate
&& FlipX == newOther.FlipX
&& Width == newOther.Width
&& Height == newOther.Height
&& Refresh == newOther.Refresh
&& PixClock == newOther.PixClock
&& HTotal == newOther.HTotal
&& HBEnd == newOther.HBEnd
&& HBStart == newOther.HBStart
&& VTotal == newOther.VTotal
&& VBEnd == newOther.VBEnd
&& VBStart == newOther.VBStart);
}
#endregion
}
}