protected void DangerOfProximityEvent(object sender, FlightInProximityEventArgs e) //FlightInProximity event { var renderStr = $"Danger! Proximity of {e.proximityTracks.Item1.Tag} and {e.proximityTracks.Item2.Tag}"; _view.AddToRenderWithColor(renderStr, ConsoleColor.Red); _logger.DataLog(renderStr); var timer = new StringEventTimer(5000, renderStr); timer.Elapsed += StopShowingAirspaceEvent; }
private void UpdateFlightTracks(object sender, FlightRecordEventArgs e) { var flightUpdate = e.FlightRecord; if (_monitoredAirspace.HasPositionWithinBoundaries(flightUpdate.Position)) { IFlightTrack updatedTrack; var existingTrack = _tracks.Any(t => t.Tag == flightUpdate.Tag); if (existingTrack) // already in list { updatedTrack = _tracks.SortRecordByTag(flightUpdate); _view.AddToRenderWithColor(updatedTrack.ToString(), ConsoleColor.Yellow); } else { updatedTrack = _tracks.SortRecordByTag(flightUpdate); var args = new FlightTrackEventArgs(updatedTrack); EnteredAirspace?.Invoke(this, args); } _handler.DetectCollision(_tracks); _handler.DetectCollision(_tracks); } else { var leftAirspaceTrack = _tracks.FirstOrDefault(t => t.Tag == flightUpdate.Tag); var leftairspacetrue = _tracks.Any(t => t.Tag == flightUpdate.Tag); if (leftairspacetrue) // in list { var args = new FlightTrackEventArgs(leftAirspaceTrack); LeftAirspace?.Invoke(this, args); _tracks.Remove(leftAirspaceTrack); } } }