public void Draw()
{
this.plot.PlotBackColor = Color.White;
this.plot.BackColor = Color.White;
ArrayList xs1 = new ArrayList();
ArrayList times = new ArrayList();
int split = 1;
long lap = 0;
float max = 0;
float min = 32767 * 32767;
long nlaps = 0;
long totaltime = 0;
this.plot.Clear();
if (((long[])splits[winner]).Length < nsplits)
return;
for (int i = nsplits; i < ((long[])splits[winner]).Length; ++i)
{
lap += ((long[])splits[winner])[i];
if (i != 0) lap -= ((long[])splits[winner])[i - 1];
if (split == nsplits)
{
//times.Add(" " + timetostr(lap));
string time = " " + timetostr(lap, true) + " : ";
for (int s = nsplits - 1; s >= 0; --s)
{
if (i == nsplits && s == nsplits)
time += timetostr(((long[])splits[winner])[i - s], false);
else
time += timetostr(((long[])splits[winner])[i - s] - ((long[])splits[winner])[i - 1 - s], false);
if (s != 0)
time += " , ";
}
time += " ";
times.Add(time);
totaltime += lap;
++nlaps;
if (max < lap) max = lap;
if (min > lap) min = lap;
xs1.Add((double)lap);
split = 1;
lap = 0;
}
else split++;
}
if (nlaps != 0)
this.winner_avgtime = totaltime / nlaps;
if (nlaps == 0)
return;
Grid mygrid = new Grid();
mygrid.VerticalGridType = Grid.GridType.Coarse;
mygrid.HorizontalGridType = Grid.GridType.Coarse;
mygrid.MajorGridPen = new Pen(Color.LightGray, 1f);
this.plot.Add(mygrid);
for (int i = 0; i < xs1.Count; ++i)
{
double[] abscissa = { 0 };
double[] ordinate = { 0 };
if ((double)xs1[i] < winner_avgtime)
{
abscissa[0] = (i);
ordinate[0] = ((double)xs1[i]) / 10000.0;
HistogramPlot hp = new HistogramPlot();
hp.OrdinateData = ordinate;
hp.AbscissaData = abscissa;
hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(106, 205, 84), Color.FromArgb(235, 255, 213));
hp.Pen.Color = Color.FromArgb(0, 150, 0);
hp.Filled = true;
hp.ShowInLegend = false;
this.plot.Add(hp);
}
if ((double)xs1[i] >= winner_avgtime)
{
abscissa[0] = i;
if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier))
ordinate[0] = (winner_avgtime + (winner_avgtime - min) * Settings.LimitMultiplier) / 10000.0;
else
ordinate[0] = ((double)xs1[i]) / 10000.0;
HistogramPlot hp = new HistogramPlot();
hp.OrdinateData = ordinate;
hp.AbscissaData = abscissa;
if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier))
{
hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(190, 39, 92), Color.FromArgb(235, 124, 177));
}
else
{
hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(235, 84, 137), Color.FromArgb(255, 230, 210));
}
hp.Pen.Color = Color.FromArgb(150, 0, 0);
hp.Filled = true;
hp.ShowInLegend = false;
this.plot.Add(hp);
}
}
//int xmax = ((long[])splits[winner]).Length / nsplits;
LabelAxis la = new LabelAxis(this.plot.XAxis1);
la.TicksBetweenText = false;
la.TicksCrossAxis = false;
la.LargeTickSize = 0;
la.TickTextFont = Settings.lapTimesFont;
for (int i = 0; i < times.Count; ++i)
la.AddLabel((string)times[i], i);
la.TicksLabelAngle = -90.0f;
this.plot.XAxis1 = la;
la = new LabelAxis((LabelAxis)la.Clone());
la.TicksBetweenText = false;
la.TicksCrossAxis = true;
la.LargeTickSize = 2;
la.TicksLabelAngle = -90.0f;
la.TickTextNextToAxis = false;
la.TickTextFont = Settings.commonFont;
for (int i = 0; i < times.Count; ++i)
{
la.AddLabel(System.Convert.ToString(i + 2), i);
}
la.LabelFont = Settings.commonFont;
this.plot.XAxis2 = la;
this.plot.YAxis1.TicksCrossAxis = true;
this.plot.YAxis1.Label = ((string)this.players[this.player]);
this.plot.YAxis1.LabelFont = Settings.titleFont;
this.plot.YAxis1.LabelOffset = 20;
this.plot.YAxis1.NumberFormat = "";
this.plot.YAxis1.TicksCrossAxis = false;
if (Settings.LimitToGlobalBestLap) this.plot.YAxis1.WorldMin = (double)this.bestlap / 10000.0;
((LinearAxis)this.plot.YAxis1).NumberOfSmallTicks = 4;
((LinearAxis)this.plot.YAxis1).LargeTickStep = 1;
((LinearAxis)this.plot.YAxis1).TicksLabelAngle = -90f;
HorizontalLine hl = new HorizontalLine((float)winner_avgtime / 10000, Color.Gray);
hl.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
this.plot.Add(hl);
this.laps = (int)nlaps;
// this.plot.YAxis1.WorldMax += 1;
if (this.plot.YAxis1.WorldMax - this.plot.YAxis1.WorldMin <= 0.1)
this.plot.YAxis1.WorldMax += 1;
this.plot.Refresh();
// System.Console.WriteLine(System.Convert.ToString(this.plot.YAxis1.WorldMin) + " " + System.Convert.ToString(this.plot.YAxis1.WorldMax));
}