private void btnExportPdf_Click(object sender, EventArgs e)
 {
     if (PreviewPlan != null && dlgSavePdf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         RenderPdf render = new RenderPdf();
         render.LoadedPlan = PreviewPlan;
         PdfDocument pdf = new PdfDocument();
         page = pdf.AddPage();
         XGraphics gfx = XGraphics.FromPdfPage(page);
         render.Render(gfx);
         page.Width = new XUnit(render.Width);
         pdf.Save(dlgSavePdf.FileName);
     }
     else if(PreviewPlan == null)
         RadMessageBox.Show("Wczytaj plan", "WiadomoϾ");
 }
 private void btnShowPreview_Click(object sender, EventArgs e)
 {
     new PlansLoad(false, true).ShowDialog();
     if (PreviewPlan != null)
     {
         RenderPdf render = new RenderPdf();
         render.LoadedPlan = PreviewPlan;
         pagePreview1.SetRenderEvent(render.Render);
         PdfDocument pdf = new PdfDocument();
         page = pdf.AddPage();
         page.Orientation = PdfSharp.PageOrientation.Landscape;
         XGraphics gfx = XGraphics.FromPdfPage(page);
         render.Render(gfx);
         page.Width = new XUnit(render.Width);
         pagePreview1.PageSize = new XSize(render.Width, pagePreview1.PageSize.Height);
     }
 }