public Boolean AddPit(String lapNumber, String driver, String team, int driverid, String tyres, String fuel, String mistake, String total) { try { Pits p = new Pits(lapNumber, driver, team, driverid, tyres, fuel, mistake, total); pits.Add(p); return true; } catch { return false; } }
public Boolean AddPit(String lapNumber, String driver, String team, int driverid, String tyres, String fuel, String mistake, String total) { try { Pits p = new Pits(lapNumber, driver, team, driverid, tyres, fuel, mistake, total); pits.Add(p); return(true); } catch { return(false); } }
protected override void OnPaint(PaintEventArgs e) { if (pits.Count > 0) { Graphics g = PitPanel.CreateGraphics(); // draw the pattern try { g.Clear(Color.White); Decimal yMax = (Decimal)(y - pH * 2); DrawText(g, "Tyres", 0f, 0f, false, Color.Green); DrawText(g, "Fuel", 0f, 10f, false, Color.Red); DrawText(g, "Mistake", 0f, 20f, false, Color.Blue); DrawText(g, "Pit Entry", 0f, 30f, false, Color.Orange); for (int i = 0; i < pits.Count; i++) { Pits p = pits[i]; int x1 = (i + 1) * x / (pits.Count + 1) - pW; Decimal y1 = yMax * p.Tyres / p.Total; Decimal y2 = yMax * p.Fuel / p.Total; Decimal y3 = yMax * p.Mistake / p.Total; int yc = pH; g.FillRectangle(Brushes.Yellow, x1, yc, pW * 2, (int)yMax); ///In lap if (y1 > 0) { g.FillRectangle(Brushes.Green, x1, yc, pW * 2, (int)y1); ///Tyre yc += (int)(y1); DrawText(g, p.Tyres.ToString() + "s", (float)(x1), (float)(yc - y1 / 2), false, Color.Black); } if (y2 > 0) { g.FillRectangle(Brushes.Red, x1, yc, pW * 2, (int)y2); ///Fuel yc += (int)y2; DrawText(g, p.Fuel.ToString() + "s", (float)(x1), (float)(yc - y2 / 2), false, Color.Black); } if (y3 > 0) { g.FillRectangle(Brushes.Blue, x1, yc, pW * 2, (int)y3); ///Mistake yc += (int)y3; DrawText(g, p.Mistake.ToString() + "s", (float)(x1), (float)(yc - y3 / 2), false, Color.Black); } //DrawText(g, p.Total.ToString() + "s", (float)(x1), (float)yMax, false); DrawText(g, "Lap " + p.LapNumber.ToString(), (float)(x1), (float)0, false, Color.Black); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } finally { g.Dispose(); } } base.OnPaint(e); }