diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index 0719a290..4bf23797 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -363,12 +363,6 @@ namespace SabreTools.Library.DatFiles DisplayType = reader.GetAttribute("type").AsDisplayType(), FlipX = reader.GetAttribute("flipx").AsYesNo(), Refresh = reader.GetAttribute("refresh"), - HTotal = reader.GetAttribute("htotal"), - HBEnd = reader.GetAttribute("hbend"), - HBStart = reader.GetAttribute("hbstart"), - VTotal = reader.GetAttribute("vtotal"), - VBEnd = reader.GetAttribute("vbend"), - VBStart = reader.GetAttribute("vbstart"), Source = new Source { @@ -405,6 +399,48 @@ namespace SabreTools.Library.DatFiles display.PixClock = pixclock; } + // Set the htotal + if (reader.GetAttribute("htotal") != null) + { + if (Int64.TryParse(reader.GetAttribute("htotal"), out long htotal)) + display.HTotal = htotal; + } + + // Set the hbend + if (reader.GetAttribute("hbend") != null) + { + if (Int64.TryParse(reader.GetAttribute("hbend"), out long hbend)) + display.HBEnd = hbend; + } + + // Set the hbstart + if (reader.GetAttribute("hbstart") != null) + { + if (Int64.TryParse(reader.GetAttribute("hbstart"), out long hbstart)) + display.HBStart = hbstart; + } + + // Set the vtotal + if (reader.GetAttribute("vtotal") != null) + { + if (Int64.TryParse(reader.GetAttribute("vtotal"), out long vtotal)) + display.VTotal = vtotal; + } + + // Set the vbend + if (reader.GetAttribute("vbend") != null) + { + if (Int64.TryParse(reader.GetAttribute("vbend"), out long vbend)) + display.VBEnd = vbend; + } + + // Set the vbstart + if (reader.GetAttribute("vbstart") != null) + { + if (Int64.TryParse(reader.GetAttribute("vbstart"), out long vbstart)) + display.VBStart = vbstart; + } + datItems.Add(display); reader.Read(); @@ -1563,12 +1599,12 @@ namespace SabreTools.Library.DatFiles xtw.WriteOptionalAttributeString("height", display.Height?.ToString()); xtw.WriteOptionalAttributeString("refresh", display.Refresh); xtw.WriteOptionalAttributeString("pixclock", display.PixClock?.ToString()); - xtw.WriteOptionalAttributeString("htotal", display.HTotal); - xtw.WriteOptionalAttributeString("hbend", display.HBEnd); - xtw.WriteOptionalAttributeString("hstart", display.HBStart); - xtw.WriteOptionalAttributeString("vtotal", display.VTotal); - xtw.WriteOptionalAttributeString("vbend", display.VBEnd); - xtw.WriteOptionalAttributeString("vbstart", display.VBStart); + xtw.WriteOptionalAttributeString("htotal", display.HTotal?.ToString()); + xtw.WriteOptionalAttributeString("hbend", display.HBEnd?.ToString()); + xtw.WriteOptionalAttributeString("hstart", display.HBStart?.ToString()); + xtw.WriteOptionalAttributeString("vtotal", display.VTotal?.ToString()); + xtw.WriteOptionalAttributeString("vbend", display.VBEnd?.ToString()); + xtw.WriteOptionalAttributeString("vbstart", display.VBStart?.ToString()); xtw.WriteEndElement(); break; diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs index 09d6d1fa..b727991a 100644 --- a/SabreTools.Library/DatFiles/SabreDat.cs +++ b/SabreTools.Library/DatFiles/SabreDat.cs @@ -1443,12 +1443,12 @@ namespace SabreTools.Library.DatFiles xtw.WriteOptionalAttributeString("height", display.Height?.ToString()); xtw.WriteOptionalAttributeString("refresh", display.Refresh); xtw.WriteOptionalAttributeString("pixclock", display.PixClock?.ToString()); - xtw.WriteOptionalAttributeString("htotal", display.HTotal); - xtw.WriteOptionalAttributeString("hbend", display.HBEnd); - xtw.WriteOptionalAttributeString("hstart", display.HBStart); - xtw.WriteOptionalAttributeString("vtotal", display.VTotal); - xtw.WriteOptionalAttributeString("vbend", display.VBEnd); - xtw.WriteOptionalAttributeString("vbstart", display.VBStart); + xtw.WriteOptionalAttributeString("htotal", display.HTotal?.ToString()); + xtw.WriteOptionalAttributeString("hbend", display.HBEnd?.ToString()); + xtw.WriteOptionalAttributeString("hstart", display.HBStart?.ToString()); + xtw.WriteOptionalAttributeString("vtotal", display.VTotal?.ToString()); + xtw.WriteOptionalAttributeString("vbend", display.VBEnd?.ToString()); + xtw.WriteOptionalAttributeString("vbstart", display.VBStart?.ToString()); xtw.WriteEndElement(); break; diff --git a/SabreTools.Library/DatItems/Display.cs b/SabreTools.Library/DatItems/Display.cs index 42705bcf..c7dbed57 100644 --- a/SabreTools.Library/DatItems/Display.cs +++ b/SabreTools.Library/DatItems/Display.cs @@ -70,37 +70,37 @@ namespace SabreTools.Library.DatItems /// Total horizontal lines /// [JsonProperty("htotal", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string HTotal { get; set; } // TODO: Int32? Float? + public long? HTotal { get; set; } /// /// Horizontal blank end /// [JsonProperty("hbend", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string HBEnd { get; set; } // TODO: Int32? Float? + public long? HBEnd { get; set; } /// /// Horizontal blank start /// [JsonProperty("hbstart", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string HBStart { get; set; } // TODO: Int32? Float? + public long? HBStart { get; set; } /// /// Total vertical lines /// [JsonProperty("vtotal", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string VTotal { get; set; } // TODO: Int32? Float? + public long? VTotal { get; set; } /// /// Vertical blank end /// [JsonProperty("vbend", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string VBEnd { get; set; } // TODO: Int32? Float? + public long? VBEnd { get; set; } /// /// Vertical blank start /// [JsonProperty("vbstart", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string VBStart { get; set; } // TODO: Int32? Float? + public long? VBStart { get; set; } #endregion @@ -153,22 +153,40 @@ namespace SabreTools.Library.DatItems } if (mappings.Keys.Contains(Field.DatItem_HTotal)) - HTotal = mappings[Field.DatItem_HTotal]; + { + if (Int64.TryParse(mappings[Field.DatItem_HTotal], out long hTotal)) + HTotal = hTotal; + } if (mappings.Keys.Contains(Field.DatItem_HBEnd)) - HBEnd = mappings[Field.DatItem_HBEnd]; + { + if (Int64.TryParse(mappings[Field.DatItem_HBEnd], out long hbEnd)) + HBEnd = hbEnd; + } if (mappings.Keys.Contains(Field.DatItem_HBStart)) - HBStart = mappings[Field.DatItem_HBStart]; + { + if (Int64.TryParse(mappings[Field.DatItem_HBStart], out long hbStart)) + HBStart = hbStart; + } if (mappings.Keys.Contains(Field.DatItem_VTotal)) - VTotal = mappings[Field.DatItem_VTotal]; + { + if (Int64.TryParse(mappings[Field.DatItem_VTotal], out long vTotal)) + VTotal = vTotal; + } if (mappings.Keys.Contains(Field.DatItem_VBEnd)) - VBEnd = mappings[Field.DatItem_VBEnd]; + { + if (Int64.TryParse(mappings[Field.DatItem_VBEnd], out long vbEnd)) + VBEnd = vbEnd; + } if (mappings.Keys.Contains(Field.DatItem_VBStart)) - VBStart = mappings[Field.DatItem_VBStart]; + { + if (Int64.TryParse(mappings[Field.DatItem_VBStart], out long vbStart)) + VBStart = vbStart; + } } #endregion @@ -307,39 +325,39 @@ namespace SabreTools.Library.DatItems return false; // Filter on htotal - if (filter.DatItem_HTotal.MatchesPositiveSet(HTotal) == false) + if (filter.DatItem_HTotal.MatchesPositive(null, HTotal) == false) return false; - if (filter.DatItem_HTotal.MatchesNegativeSet(HTotal) == true) + if (filter.DatItem_HTotal.MatchesNegative(null, HTotal) == true) return false; // Filter on hbend - if (filter.DatItem_HBEnd.MatchesPositiveSet(HBEnd) == false) + if (filter.DatItem_HBEnd.MatchesPositive(null, HBEnd) == false) return false; - if (filter.DatItem_HBEnd.MatchesNegativeSet(HBEnd) == true) + if (filter.DatItem_HBEnd.MatchesNegative(null, HBEnd) == true) return false; // Filter on hbstart - if (filter.DatItem_HBStart.MatchesPositiveSet(HBStart) == false) + if (filter.DatItem_HBStart.MatchesPositive(null, HBStart) == false) return false; - if (filter.DatItem_HBStart.MatchesNegativeSet(HBStart) == true) + if (filter.DatItem_HBStart.MatchesNegative(null, HBStart) == true) return false; // Filter on vtotal - if (filter.DatItem_VTotal.MatchesPositiveSet(VTotal) == false) + if (filter.DatItem_VTotal.MatchesPositive(null, VTotal) == false) return false; - if (filter.DatItem_VTotal.MatchesNegativeSet(VTotal) == true) + if (filter.DatItem_VTotal.MatchesNegative(null, VTotal) == true) return false; // Filter on vbend - if (filter.DatItem_VBEnd.MatchesPositiveSet(VBEnd) == false) + if (filter.DatItem_VBEnd.MatchesPositive(null, VBEnd) == false) return false; - if (filter.DatItem_VBEnd.MatchesNegativeSet(VBEnd) == true) + if (filter.DatItem_VBEnd.MatchesNegative(null, VBEnd) == true) return false; // Filter on vbstart - if (filter.DatItem_VBStart.MatchesPositiveSet(VBStart) == false) + if (filter.DatItem_VBStart.MatchesPositive(null, VBStart) == false) return false; - if (filter.DatItem_VBStart.MatchesNegativeSet(VBStart) == true) + if (filter.DatItem_VBStart.MatchesNegative(null, VBStart) == true) return false; return true; diff --git a/SabreTools.Library/Filtering/Filter.cs b/SabreTools.Library/Filtering/Filter.cs index d7ad8959..161bf09a 100644 --- a/SabreTools.Library/Filtering/Filter.cs +++ b/SabreTools.Library/Filtering/Filter.cs @@ -203,12 +203,12 @@ namespace SabreTools.Library.Filtering public FilterItem DatItem_Height { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; public FilterItem DatItem_Refresh { get; private set; } = new FilterItem(); public FilterItem DatItem_PixClock { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; - public FilterItem DatItem_HTotal { get; private set; } = new FilterItem(); - public FilterItem DatItem_HBEnd { get; private set; } = new FilterItem(); - public FilterItem DatItem_HBStart { get; private set; } = new FilterItem(); - public FilterItem DatItem_VTotal { get; private set; } = new FilterItem(); - public FilterItem DatItem_VBEnd { get; private set; } = new FilterItem(); - public FilterItem DatItem_VBStart { get; private set; } = new FilterItem(); + public FilterItem DatItem_HTotal { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; + public FilterItem DatItem_HBEnd { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; + public FilterItem DatItem_HBStart { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; + public FilterItem DatItem_VTotal { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; + public FilterItem DatItem_VBEnd { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; + public FilterItem DatItem_VBStart { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; // Driver public FilterItem DatItem_SupportStatus { get; private set; } = new FilterItem() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL }; @@ -863,27 +863,27 @@ namespace SabreTools.Library.Filtering break; case Field.DatItem_HTotal: - SetStringFilter(DatItem_HTotal, value, negate); + SetOptionalLongFilter(DatItem_HTotal, value, negate); break; case Field.DatItem_HBEnd: - SetStringFilter(DatItem_HBEnd, value, negate); + SetOptionalLongFilter(DatItem_HBEnd, value, negate); break; case Field.DatItem_HBStart: - SetStringFilter(DatItem_HBStart, value, negate); + SetOptionalLongFilter(DatItem_HBStart, value, negate); break; case Field.DatItem_VTotal: - SetStringFilter(DatItem_VTotal, value, negate); + SetOptionalLongFilter(DatItem_VTotal, value, negate); break; case Field.DatItem_VBEnd: - SetStringFilter(DatItem_VBEnd, value, negate); + SetOptionalLongFilter(DatItem_VBEnd, value, negate); break; case Field.DatItem_VBStart: - SetStringFilter(DatItem_VBStart, value, negate); + SetOptionalLongFilter(DatItem_VBStart, value, negate); break; // Driver