private void LoadLayout_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filter = Strings.LayoutFilter; dlg.DefaultExt = Strings.LayoutDefaultExt;; dlg.CheckFileExists = true; dlg.Multiselect = false; if (dlg.ShowDialog(this) == DialogResult.OK) { try { BinaryFormatter formatter = new BinaryFormatter(); using (var file = dlg.OpenFile()) { m_DocumentLayout = (AllocationDocumentLayout)formatter.Deserialize(file); m_PrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Custom", m_DocumentLayout.PaperSize.Width, m_DocumentLayout.PaperSize.Height); this.BackgroundImage = this.BackgroundImage.DisposeSf(); this.BackgroundImage = m_DocumentLayout.DocumentImage; } Invalidate(); } catch (Exception ex) { ex.ShowDialog(this); } } } }
public VoucherPrintEngine(AllocationDocumentLayout layout) { DocumentLayout = layout; }