2025-04-24 20:56:44 +08:00
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
using ShrlAlgoToolkit.RevitAddins.RvIndependent.MetroGauges.LandXMLData.Interfaces;
|
2025-02-10 20:53:40 +08:00
|
|
|
|
|
2025-04-24 20:56:44 +08:00
|
|
|
|
namespace ShrlAlgoToolkit.RevitAddins.RvIndependent.MetroGauges.LandXMLData;
|
2025-02-10 20:53:40 +08:00
|
|
|
|
|
|
|
|
|
|
[XmlType("Range")]
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class Range : GenerationRangeInstance, IComparableStructure<Range>
|
|
|
|
|
|
{
|
|
|
|
|
|
public Range()
|
|
|
|
|
|
{
|
|
|
|
|
|
StartStation = 0.0;
|
|
|
|
|
|
EndStation = 0.0;
|
|
|
|
|
|
Part = 0;
|
|
|
|
|
|
Import = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected bool _import;
|
|
|
|
|
|
|
|
|
|
|
|
protected Part _parent;
|
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
|
public string NameSideSegment => Parent == null ? string.Empty : Parent.NameSideSegment;
|
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
|
public string NameSideSegmentPart => Parent == null ? PartName : NameSideSegment + PartName;
|
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
|
public Part Parent
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _parent;
|
|
|
|
|
|
internal set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_parent != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_parent = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
|
public string PartName => Part == 0 ? string.Empty : " p" + Part;
|
|
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
|
public IEnumerable<DesignShape> Shapes => Parent == null ? null : Parent.Shapes;
|
|
|
|
|
|
|
|
|
|
|
|
[XmlAttribute]
|
|
|
|
|
|
public bool Import
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _import;
|
|
|
|
|
|
set => _import = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[XmlAttribute("p")]
|
|
|
|
|
|
public int Part { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public bool DifferentDescendants(Range range)
|
|
|
|
|
|
{
|
|
|
|
|
|
IEnumerable<DesignShape> shapes = Shapes;
|
|
|
|
|
|
IEnumerable<DesignShape> shapes2 = range.Shapes;
|
|
|
|
|
|
if (shapes == null || shapes2 == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return shapes != shapes2;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DesignShape[] array = shapes.ToArray();
|
|
|
|
|
|
DesignShape[] array2 = shapes2.ToArray();
|
|
|
|
|
|
if (array.Length == array2.Length)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!array[i].Equals(array2[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool DifferentItem(Range range)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Import != range.Import
|
|
|
|
|
|
|| StartStation != range.StartStation
|
|
|
|
|
|
|| EndStation != range.EndStation
|
|
|
|
|
|
|| GenerationStartStation != range.GenerationStartStation
|
|
|
|
|
|
|| GenerationEndStation != range.GenerationEndStation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(Range range)
|
|
|
|
|
|
{
|
|
|
|
|
|
return range is not null && !DifferentItem(range) && !DifferentDescendants(range);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Equals(obj as Range);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetParent(Part part)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_parent != part)
|
|
|
|
|
|
{
|
|
|
|
|
|
_parent?.Ranges.Remove(this);
|
|
|
|
|
|
|
|
|
|
|
|
_parent = part;
|
|
|
|
|
|
_parent?.AddRange(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|