Exemplo n.º 1
0
 /// <summary>
 /// Gets the <see cref="PedestrianLight"/> with the given <paramref name="id"/>
 /// for the given <paramref name="intersection"/>.
 /// </summary>
 /// <param name="id">The ID of the pedestrian light.</param>
 /// <param name="intersection">The intersection to which the traffic light belongs to.</param>
 /// <returns>A <see cref="TrafficLight"/> if it exists. Otherwise, it returns null.</returns>
 public PedestrianLight GetPedestrianLight(int id, PedestrianIntersection intersection)
     => this.Intersections.Where(i => i is PedestrianIntersection && (PedestrianIntersection) i == intersection)
         .SelectMany(i => intersection.PedestrianTrafficLights)
         .FirstOrDefault(pl => pl.ID == id);
Exemplo n.º 2
0
        private bool CreateIntersection(Point loc)
        {
            if (trafficMonitor.Intersections.Any(inter => inter.HitBox.Contains(loc)))
            {
                return false;
            }
            var id = this.GetIdForIntersection(loc);
            BaseIntersection intersection = null;
            if (this.intersectionType == 1)
            {
                intersection = new NormalIntersection(Properties.Resources.newjunction1, loc, id);
            }
            else if (this.intersectionType == 2)
            {
                intersection = new PedestrianIntersection(Properties.Resources.newjunction2_NoSensors, loc, id);
            }
            else if (this.intersectionType == 3)
            {
                intersection = new PedestrianIntersectionType2(Properties.Resources.newjunction3_NoSensors, loc, id);
            }

            bool added = trafficMonitor.AddIntersection(intersection);
            InvalidateEvent.InvalidatePanel();
            intersectionType = 0;

            if (added)
            {
                selectedIntersection = intersection;
            }
            toolTip.SetToolTip(panel3, "Double click on an intersection to change its properties");
            return added;

        }