public void DrawOutroBody(Graphics graphics, GraphicRect r, int page) { var rsession = OverlayData.SessionData.SessionInfo.Sessions.Race(); var results = rsession.ResultsPositions ?? new SessionData._SessionInfo._Sessions._ResultsPositions[0]; var offset = 5; var pen = new Pen(Styles.Black, 2); graphics.InRectangle(FlashCardLeft, r.Rectangle.Top, FlashCardWidth, 10) .WithPen(pen) .DrawLine(FlashCardLeft, r.Rectangle.Top - offset, FlashCardLeft + FlashCardWidth, r.Rectangle.Top - offset); var LeaderTime = TimeSpan.FromSeconds(results[0].Time); foreach (var racer in results.Skip(DriversPerPage * page).Take(DriversPerPage)) { var driver = OverlayData.SessionData.DriverInfo.CompetingDrivers[racer.CarIdx]; var Gap = TimeSpan.FromSeconds(racer.Time) - LeaderTime; // Gap calculation if (Gap == TimeSpan.Zero) //For the leader we want to display the race duration Gap = LeaderTime; r.WithBrush(Settings.Default.PreferredDriverNames.Contains(driver.UserName) ? Styles.RedBrush : Styles.BlackBrush); r .Center(cg => cg .DrawText(racer.Position.ToString()) .AfterText(racer.Position.ToString()) .MoveRight(1) .WithFont(fontName, 16, FontStyle.Bold) .DrawText(racer.Position.Ordinal()) ) .ToRight(width: 190, left: 30) .DrawText(Gap.ToString("hh\\:mm\\:ss\\.fff")) .ToRight(width: 80, left: 20) .DrawText(driver.CarNumber) .ToRight(width: 350) .DrawText(driver.UserName); r = r.ToBelow(); graphics.InRectangle(FlashCardLeft, r.Rectangle.Top, FlashCardWidth, 10) .WithPen(pen) .DrawLine(FlashCardLeft, r.Rectangle.Top - offset, FlashCardLeft + FlashCardWidth, r.Rectangle.Top - offset); } }
private void DrawIntroBody(Graphics graphics, GraphicRect r, int page) { var totalWidth = FlashCardWidth; var left = FlashCardLeft; var qsession = OverlayData.SessionData.SessionInfo.Sessions.Qualifying(); var results = qsession.ResultsPositions ?? new SessionData._SessionInfo._Sessions._ResultsPositions[0]; var offset = 5; var pen = new Pen(Styles.Black, 2); graphics.InRectangle(left, r.Rectangle.Top, totalWidth, 10) .WithPen(pen) .DrawLine(left, r.Rectangle.Top - offset, left + totalWidth, r.Rectangle.Top - offset); foreach (var qualifier in results.Skip(page * DriversPerPage).Take(DriversPerPage)) { var driver = OverlayData.SessionData.DriverInfo.CompetingDrivers[qualifier.CarIdx]; r .Center(cg => cg .DrawText(qualifier.Position.ToString()) .AfterText(qualifier.Position.ToString()) .MoveRight(1) .WithFont(fontName, 16, FontStyle.Bold) .DrawText(qualifier.Position.Ordinal()) ) .ToRight(width: 120, left: 30) .DrawText(TimeSpan.FromSeconds(qualifier.FastestTime).ToString("mm\\:ss\\.ff")) .ToRight(width: 60) .DrawText(driver.CarNumber) .ToRight(width: 300) .DrawText(driver.UserName); r = r.ToBelow(); graphics.InRectangle(left, r.Rectangle.Top, totalWidth, 10) .WithPen(pen) .DrawLine(left, r.Rectangle.Top - offset, left + totalWidth, r.Rectangle.Top - offset); } }
public GraphicRect Center(Func<GraphicRect, GraphicRect> operation) { var newG = new CenterGraphicRect(g, r, b, p, f, sf); var calculateCenter = (CenterGraphicRect)operation(newG); var width = calculateCenter.Width; var currentCenterPoint = r.Left + r.Width / 2; var newRect = new Rectangle(currentCenterPoint - width/2, r.Top, width, r.Height); var centeredGr = new GraphicRect(g, newRect, b, p, f, sf ); operation(centeredGr).ToBelow(); return this; }