/// <summary> /// Shows the print preview dialog with the specified <paramref name="parent"/> /// </summary> /// <param name="parent">Parent window</param> /// <returns>The dialog resultP</returns> public override DialogResult ShowDialog(Window parent) { Document.OnBeforePrint(); PrintSettings = Document.PrintSettings; PrintSettings.MaximumPageRange = new Range <int>(1, Document.PageCount); Handler.Document = Document; var result = base.ShowDialog(parent); Document.OnAfterPrint(); return(result); }
Control ShowPrintDialog() { var control = new Button { Text = "Show Print Dialog" }; control.Click += delegate { var print = CreatePrintDialog(); var ret = print.ShowDialog(ParentWindow); if (ret == DialogResult.Ok) { DataContext = settings = print.PrintSettings; } }; return control; }
Control PrintFromGraphicsWithDialog() { var control = new Button { Text = "Print From Graphics With Dialog" }; control.Click += delegate { var document = GetPrintDocument(); var dialog = CreatePrintDialog(); dialog.ShowDialog(this, document); DataContext = settings = document.PrintSettings; }; return control; }