Up!
i give you the main part of my project, just to know if there s somethink i didn t do right.
Code:
while (!docCreated)
{
if (tempCount > samples) break; //même distance parcourue pour les mesures d'une même tournée
PdfPage pdfPage = pdfDoc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(pdfPage);
pdfPage.Size = PageSize.A3;
pdfPage.Orientation = PageOrientation.Landscape;
//////////Structure de la page pdf//////////
int minGraph_X = maxPage_X - 60;
int minGraph_Y = Convert.ToInt32((decimal)(maxPage_Y - 20) / (decimal)Piv_Datas.Count()); // hauteur d'un graphique
//////////Structure de la page pdf//////////
for(int indexPivot = 0;indexPivot<Piv_Datas.Length;indexPivot++)
{
double minValue = Piv_Datas[indexPivot].Select(piv => piv.Y).Min();
double maxValue = Piv_Datas[indexPivot].Select(piv => piv.Y).Max();
double pasMesure_H = Convert.ToDouble((decimal)minGraph_X / (decimal)pointsToSee);
double pasMesure_V = Convert.ToDouble((decimal)minGraph_Y / (decimal)(maxValue - minValue));
double origineGraph = 10 + (minGraph_Y) * (1 + indexPivot) - (Math.Abs(minValue) * pasMesure_V); // plusieurs origines en fonction du nombre de graphiques
//Background
XLinearGradientBrush brush = new XLinearGradientBrush(new XRect(maxGraph_X, maxGraph_Y + minGraph_Y * indexPivot, minGraph_X, minGraph_Y), XColors.AliceBlue, XColors.LightBlue, XLinearGradientMode.Vertical);
gfx.DrawRectangle(new XPen(XColors.Black, 0.1), brush, new XRect(maxGraph_X, maxGraph_Y + minGraph_Y * indexPivot, minGraph_X, minGraph_Y));
//Recouvrement Background
XLinearGradientBrush redGradientBrush = new XLinearGradientBrush(new XRect(maxGraph_X, maxGraph_Y + minGraph_Y * indexPivot, minGraph_X, minGraph_Y), XColors.Beige, XColors.LightPink, XLinearGradientMode.Vertical);
gfx.DrawRectangle(redGradientBrush, new XRect(maxGraph_X + 1, maxGraph_Y + 1 + minGraph_Y * indexPivot, pointsInRecouvrZone * pasMesure_H - 1, minGraph_Y - 2));
gfx.DrawRectangle(redGradientBrush, new XRect(maxPage_X - 11 - pointsInRecouvrZone * pasMesure_H, maxGraph_Y + 1 + minGraph_Y * indexPivot, maxPage_X - (maxPage_X - pointsInRecouvrZone * pasMesure_H), minGraph_Y - 2));
// repères valeurs
gfx.DrawString(maxValue.ToString("0.00"), new XFont("Verdana", 8, XFontStyle.BoldItalic), XBrushes.Gray, new XPoint(10, maxGraph_Y + 10 + minGraph_Y * indexPivot));
gfx.DrawString("0", new XFont("Verdana", 10, XFontStyle.BoldItalic), XBrushes.Gray, new XPoint(40, origineGraph));
gfx.DrawString(minValue.ToString("0.00"), new XFont("Verdana", 8, XFontStyle.BoldItalic), XBrushes.Gray, new XPoint(10, minGraph_Y * (indexPivot + 1)));
XPen pen = new XPen(XColors.Black, 0.01);
int countMax = 0;
if (globalTempCount + pointsToSee > samples) // cas en fin de constitution de courbe (dernière page pdf)
{
countMax = Convert.ToInt32(samples);
docCreated = true;
}
else
{
if (indexPivot != 0)
{
tempCount = globalTempCount;
countMax = tempCount + pointsToSee;
}
else
countMax = tempCount + pointsToSee;
}
int xTranslation = 0;
for (int indexMeasure = tempCount; indexMeasure < countMax; indexMeasure++)
{
try
{
// affichage des points de mesure
gfx.DrawLine(pen, xTranslation * pasMesure_H + maxGraph_X,
-Piv_Datas[indexPivot][indexMeasure].Y * pasMesure_V + origineGraph,
(xTranslation + 1) * pasMesure_H + maxGraph_X,
-Piv_Datas[indexPivot][indexMeasure + 1].Y * pasMesure_V + origineGraph);
if (indexMeasure != 0 && indexMeasure % repereVerticaux_MeterToPt == 0 && indexPivot == Piv_Datas.Length - 1)
{
gfx.DrawString(((decimal)indexMeasure / (decimal)4000).ToString("0.000"), new XFont("Verdana", 8, XFontStyle.BoldItalic), XBrushes.Gray, new XPoint(xTranslation * pasMesure_H + 20, maxGraph_Y + 10));
gfx.DrawString(((decimal)indexMeasure / (decimal)4000).ToString("0.000"), new XFont("Verdana", 8, XFontStyle.BoldItalic), XBrushes.Gray, new XPoint(xTranslation * pasMesure_H + 20, maxPage_Y - 15));
}
// affichage des points de dépassement de seuils
if (Ds_Datas[indexPivot] != null && Ds_Datas[indexPivot].Contains(Piv_Datas[indexPivot][indexMeasure].X))
{
gfx.DrawEllipse(XBrushes.Red, xTranslation * pasMesure_H + maxGraph_X - 0.5, -Piv_Datas[indexPivot][indexMeasure].Y * pasMesure_V + origineGraph - 0.5, 1, 1);
gfx.DrawString(Math.Round(Convert.ToDecimal(Piv_Datas[indexPivot][indexMeasure].Y), 3).ToString(), new XFont("Verdana", 3, XFontStyle.BoldItalic), XBrushes.Red, new XPoint(xTranslation * pasMesure_H + maxGraph_X + 7, -Piv_Datas[indexPivot][indexMeasure].Y * pasMesure_V + origineGraph));
}
xTranslation++;
}
catch(OutOfMemoryException oomEx)
{
MessageBox.Show(oomEx.Message, "Interruption de l'export", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
if(!docCreated)
tempCount = countMax + 1 - Convert.ToInt32(pointsInRecouvrZone); //Affichage section suivante avec recouvrement précédant
ShowOnGraph(ref pen, ref gfx, origineGraph, maxValue, minValue, pasMesure_V, pasMesure_H, repereVerticaux_MeterToPt, pointsToSee);
}
globalTempCount = tempCount;
gfx.Dispose();
pdfPage.Close();
}
string path = SaveDocument_Pdf(pdfDoc);
if (File.Exists(path))
ShowDocument_Pdf(path);
Thanks in advance.
PS : i don t know if i m in the good sexion so sorry for my mistake in this case.