using System;
using System.Drawing;
using System.Drawing.Printing;
namespace GMW_data
{
///
/// Classe che si occupa di stampare etichette barcode via printer remota
///
public class bCodePrinter
{
///
/// funzione di stampa...
///
public void Print(string printerName, PaperSize pSize, string testo, string bCode, float EmSize )
{
text2print = testo;
bCode2print = bCode;
baseEmSize = EmSize;
PrintDocument label = new PrintDocument();
label.DefaultPageSettings.PaperSize = pSize;
label.PrinterSettings.PrinterName = printerName;
label.PrinterSettings.DefaultPageSettings.PaperSize = pSize;
label.PrintPage += new PrintPageEventHandler(PrintPage);
label.Print();
}
public string text2print { get; set; }
public string bCode2print { get; set; }
public float baseEmSize { get; set; }
private void PrintPage(object sender, PrintPageEventArgs e)
{
SolidBrush brush = new SolidBrush(Color.Black);
Font arial = new Font("Arial", baseEmSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
Font threeOfNine = new Font("Free 3 of 9 Extended", baseEmSize* 3, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
e.Graphics.DrawString(text2print, arial, brush, 0, 5);
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize));
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize * 2));
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize * 3));
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize * 4));
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize * 5));
e.Graphics.DrawString("*" + bCode2print + "*", threeOfNine, brush, 0, Convert.ToInt32(10 + baseEmSize * 6));
}
///
/// oggetto protected
///
///
protected bCodePrinter()
{
}
///
/// singleton pubblico
///
public static bCodePrinter man = new bCodePrinter();
}
}