/// <summary> /// Render loop /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CompositionTarget_Rendering(object sender, EventArgs e) { TimeSpan timeSinceLastRender = DateTime.Now.TimeOfDay - LastRenderTime; if (timeSinceLastRender.TotalSeconds < (1.0 / FrameLimiter)) { return; } LastRenderTime = DateTime.Now.TimeOfDay; // Stop animation if there is no more points if (!Points.Any()) { CompositionTarget.Rendering -= CompositionTarget_Rendering; IsBusy = false; IsPlaying = false; Demo.PositionPoints.Clear(); Points.Clear(); CommandManager.InvalidateRequerySuggested(); return; } // Draw points for each player foreach (List <PositionPoint> positionPoints in Points) { if (positionPoints.Any()) { // get the first point of the list PositionPoint positionPoint = positionPoints.First(); // If there is an event at this point, draw it if (positionPoint.Event != null) { if (!string.IsNullOrWhiteSpace(positionPoint.Event.Message)) { _events.Add(positionPoint.Event); } _drawService.DrawEvent(positionPoint); } else { // Draw it _drawService.DrawPixel(positionPoint); _drawService.DrawPlayerMarker(positionPoint); } // Remove this point positionPoints.Remove(positionPoint); // If there is no more points remove the list from all the lists if (!positionPoints.Any()) { Points.Remove(positionPoints); break; } } } }