I have to print to specified printer (price-label printer) some data. Data looks like ean13 barcode, price, item's title, etc
I have a few settings what to print in each case. What I want:
- create usercontrol (WPF) with 2 columns. left column for print preview, and right column for settings (checkboxes, textboxes).
- is user changes settings, print preview updates.
What approach should I use, to do it most right way? Now printing routine looks like:
private void DrawOnGraphics(Graphics graphics)
{
using (var shF = new Font("Arial", 10, FontStyle.Bold))
{
graphics.DrawImage(_barcode, new Point(0, 0));
// etc...
}
I think it's not very good code but it works here:
var pDoc = new PrintDocument();
pDoc.PrintPage += (a, e) =>
{
DrawOnGraphics(e.Graphics);
e.HasMorePages = false;
};
pDoc.Print();
Can I create one 'rendering routine' for both actions: print and printpreview? Thanks. How can it be done? Should I use in XAML for print preview
<Image Source="{Binding Path=PrintPreviewImage}" />
or? :)
Main question is: how to draw own things (text, images, etc) for print and printpreview in WPF.