1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Class BMSformulaire
{
PrintDocument myDocument;
Graphics monGr;
Font myFont;
Brush printColor;
Pen monStylo;
StringFormat sf;
string sNumDocument;
public BMSformulaire(string sNumFormulaire)
{
myDocument = new PrintDocument();
myDocument.DefaultPageSettings.Landscape = false;
myDocument.PrintPage += new PrintPageEventHandler(myDocument_PrintPage);
myDocument.Print();
}
private void myDocument_PrintPage(object sender, PrintPageEventArgs e)
{
//En-tête du formulaire
monGr = e.Graphics;
myFont = new Font("Arial", 10);
printColor = Brushes.Black;
sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sIntitulé = "Nom de la Société";
RectangleF rIntitulé = new RectangleF(0, 25, 800, 20);
monGr.DrawString(sIntitulé, myFont, printColor, rIntitulé, sf);
//Rectangle Titre formulaire Accusé de réception
myFont = new Font("Arial", 10, FontStyle.Bold);
monStylo = new Pen(Color.Black, 1);
monGr.DrawRectangle(monStylo, 544, 104, 168, 48);
RectangleF rFormulaire1 = new RectangleF(545, 108, 167, 20);
monGr.DrawString("FACTURE PRO FORMA", myFont, printColor, rFormulaire1, sf);
myFont = new Font("Arial", 8);
RectangleF rfNumFormulaire = new RectangleF(545, 130, 167, 20);
inscrireDonnées();
//Enregistrer le fichier
try
{
//Code pour l'enregistrement sous forme de fichier
}
catch (IOException ex)
{
}
printColor.Dispose();
monStylo.Dispose();
myFont.Dispose();
monGr.Dispose();
}
private void inscrireDonnées()
{
myFont = new Font("Arial", 10);
printColor = Brushes.Red;
sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
string sNumDocument = "FA0001-07";
monGr.DrawString(sLocalité, myFont, printColor, rfNumFormulaire, sf);
}
} |