public int CompareTo(object obj) { if (obj is ArbiterUserPartition) { ArbiterUserPartition aup = (ArbiterUserPartition)obj; if (this.InitialGeneric is ArbiterWaypoint) { return(-1); } else if (aup.InitialGeneric is ArbiterWaypoint) { return(1); } else { ArbiterUserWaypoint auw1 = (ArbiterUserWaypoint)this.InitialGeneric; ArbiterUserWaypoint auw2 = (ArbiterUserWaypoint)aup.InitialGeneric; return(auw1.WaypointId.Number.CompareTo(auw2.WaypointId.Number)); } } else { return(-1); } }
public override bool Equals(object obj) { if (obj is ArbiterUserWaypoint) { ArbiterUserWaypoint other = (ArbiterUserWaypoint)obj; return(this.WaypointId.Equals(other.WaypointId)); } else { return(false); } }
public void InsertUserWaypoint(Coordinates c) { if (this.Partition is ArbiterLanePartition) { ArbiterLanePartition alp = (ArbiterLanePartition)this.Partition; ArbiterUserWaypoint final = null; if (this.InitialGeneric is ArbiterUserWaypoint) { ArbiterUserWaypoint auw = (ArbiterUserWaypoint)this.InitialGeneric; ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(auw.WaypointId.Number + 1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } else { ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } foreach (ArbiterUserWaypoint aup in alp.UserWaypoints) { if (aup.WaypointId.Number >= final.WaypointId.Number) aup.WaypointId.Number++; } ArbiterUserPartition aup1 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, this.InitialGeneric.GenericId, final.WaypointId), this.Partition, this.InitialGeneric, final); aup1.FinalGeneric = final; aup1.InitialGeneric = this.InitialGeneric; final.Previous = aup1; if (aup1.InitialGeneric is ArbiterUserWaypoint) ((ArbiterUserWaypoint)aup1.InitialGeneric).Next = aup1; ArbiterUserPartition aup2 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, final.WaypointId, this.FinalGeneric.GenericId), this.Partition, final, this.FinalGeneric); aup2.InitialGeneric = final; aup2.FinalGeneric = this.FinalGeneric; final.Next = aup2; if (aup2.FinalGeneric is ArbiterUserWaypoint) ((ArbiterUserWaypoint)aup2.FinalGeneric).Previous = aup2; alp.UserPartitions.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(final); alp.UserWaypoints.Add(final); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup1); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup2); alp.UserPartitions.Add(aup1); alp.UserPartitions.Add(aup2); alp.UserPartitions.Sort(); alp.Lane.ReformPath(); } }
public void InsertUserWaypoint(Coordinates c) { if (this.Partition is ArbiterLanePartition) { ArbiterLanePartition alp = (ArbiterLanePartition)this.Partition; ArbiterUserWaypoint final = null; if (this.InitialGeneric is ArbiterUserWaypoint) { ArbiterUserWaypoint auw = (ArbiterUserWaypoint)this.InitialGeneric; ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(auw.WaypointId.Number + 1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } else { ArbiterUserWaypointId auwi = new ArbiterUserWaypointId(1, this.Partition.ConnectionId); final = new ArbiterUserWaypoint(c, auwi, this.Partition); } foreach (ArbiterUserWaypoint aup in alp.UserWaypoints) { if (aup.WaypointId.Number >= final.WaypointId.Number) { aup.WaypointId.Number++; } } ArbiterUserPartition aup1 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, this.InitialGeneric.GenericId, final.WaypointId), this.Partition, this.InitialGeneric, final); aup1.FinalGeneric = final; aup1.InitialGeneric = this.InitialGeneric; final.Previous = aup1; if (aup1.InitialGeneric is ArbiterUserWaypoint) { ((ArbiterUserWaypoint)aup1.InitialGeneric).Next = aup1; } ArbiterUserPartition aup2 = new ArbiterUserPartition( new ArbiterUserPartitionId(this.Partition.ConnectionId, final.WaypointId, this.FinalGeneric.GenericId), this.Partition, final, this.FinalGeneric); aup2.InitialGeneric = final; aup2.FinalGeneric = this.FinalGeneric; final.Next = aup2; if (aup2.FinalGeneric is ArbiterUserWaypoint) { ((ArbiterUserWaypoint)aup2.FinalGeneric).Previous = aup2; } alp.UserPartitions.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Remove(this); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(final); alp.UserWaypoints.Add(final); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup1); alp.Lane.Way.Segment.RoadNetwork.DisplayObjects.Add(aup2); alp.UserPartitions.Add(aup1); alp.UserPartitions.Add(aup2); alp.UserPartitions.Sort(); alp.Lane.ReformPath(); } }