public frmPrintPreview() { InitializeComponent(); Model model = diagram1.Model; diagram1.Model.SetSize(new Size(1000, 1000)); Shape shape = new Shape(); shape.Location = new PointF(300, 50); model.Shapes.Add("a1", shape); shape = new Shape(); shape.Location = new PointF(200, 200); model.Shapes.Add("b1", shape); shape = new Shape(); shape.Location = new PointF(400, 200); model.Shapes.Add("b2", shape); shape = new Shape(); shape.Location = new PointF(100, 300); model.Shapes.Add("c1", shape); shape = new Shape(); shape.Location = new PointF(200, 300); model.Shapes.Add("c2", shape); shape = new Shape(); shape.Location = new PointF(300, 300); model.Shapes.Add("c3", shape); shape = new Shape(); shape.Location = new PointF(400, 300); model.Shapes.Add("c4", shape); shape = new Shape(); shape.Location = new PointF(500, 300); model.Shapes.Add("c5", shape); model.ApplyTheme(Themes.Orange); foreach (Shape item in model.Shapes.Values) { item.Width = 60; } Crainiate.Diagramming.Printing.PrintDocument MyDocument = new Crainiate.Diagramming.Printing.PrintDocument(diagram1); MyDocument.View = diagram1; MyDocument.PrintPreview(); }
//Perform file and print actions private void DoFileAction(object sender) { frmDiagram active = (frmDiagram)this.ActiveMdiChild; //Open if (sender == mnuFileOpen || sender == btnOpen) { active.Open(""); } //Save if (sender == mnuFileSave || sender == btnSave) { active.Save(active.Path); } //Save as if (sender == mnuFileSaveAs) { active.Save(""); } //Print preview if (sender == mnuFilePrintPreview) { Crainiate.Diagramming.Printing.PrintDocument print = new Crainiate.Diagramming.Printing.PrintDocument(active.Model); print.PrintPreview(new Point(100, 100), new Size(800, 600)); return; } //Print with settings if (sender == mnuFilePrint || sender == btnPrint) { Crainiate.Diagramming.Printing.PrintDocument print = new Crainiate.Diagramming.Printing.PrintDocument(active.Model); System.Windows.Forms.PrintDialog printDialogue = new System.Windows.Forms.PrintDialog(); printDialogue.Document = print; if (printDialogue.ShowDialog() == DialogResult.OK) { print.Print(); } return; } if (sender == mnuFileExit) { this.Close(); } }