本文整理汇总了C#中System.Windows.Forms.PrintPreviewDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# PrintPreviewDialog.ShowDialog方法的具体用法?C# PrintPreviewDialog.ShowDialog怎么用?C# PrintPreviewDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.PrintPreviewDialog
的用法示例。
在下文中一共展示了PrintPreviewDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InializePrinting
public static void InializePrinting(List<BarCode> barCodeList, string printType)
{
_barCodeList = barCodeList;
_printType = printType;
var printPreviewDialog =
new PrintPreviewDialog
{
WindowState = FormWindowState.Maximized,
FormBorderStyle = FormBorderStyle.None,
UseAntiAlias = true,
Document = PrintDocument
};
if (AppContext.Counter != null)
PrintDocument.PrinterSettings.PrinterName = AppContext.Counter.BarCodePrinter;
PrintDocument.BeginPrint += PrintDocBeginPrint;
if (Resources.ConstBarCodeTemplate5.Equals(_printType))
{
PrintDocument.PrintPage += BarcodeSample5_PrintPage;
printPreviewDialog.ShowDialog();
PrintDocument.PrintPage -= BarcodeSample5_PrintPage;
}
else if (Resources.ConstBarCodeTemplate4.Equals(_printType))
{
PrintDocument.PrintPage += BarcodeSample4_PrintPage;
printPreviewDialog.ShowDialog();
PrintDocument.PrintPage -= BarcodeSample4_PrintPage;
}
else if (Resources.ConstBarCodeTemplate3.Equals(_printType))
{
PrintDocument.PrintPage += BarcodeSample3_PrintPage;
printPreviewDialog.ShowDialog();
PrintDocument.PrintPage -= BarcodeSample3_PrintPage;
}
else if (Resources.ConstBarCodeTemplate2.Equals(_printType))
{
PrintDocument.PrintPage += BarcodeSample2_PrintPage;
printPreviewDialog.ShowDialog();
PrintDocument.PrintPage -= BarcodeSample2_PrintPage;
}
else if (Resources.ConstBarCodeTemplate1.Equals(_printType))
{
PrintDocument.PrintPage += BarcodeSample1_PrintPage;
printPreviewDialog.ShowDialog();
PrintDocument.PrintPage -= BarcodeSample1_PrintPage;
}
PrintDocument.BeginPrint -= PrintDocBeginPrint;
}
示例2: print
public void print()
{
PrintDialog pd = new PrintDialog();
PrintDocument pdoc = new PrintDocument();
PrinterSettings ps = new PrinterSettings();
Font font =new Font("Arial",12);
PaperSize psize = new PaperSize("Custome", 100, 200);
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.DefaultPageSettings.PaperSize.Height = 320;
pdoc.DefaultPageSettings.PaperSize.Width = 200;
pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = pdoc;
result = ppd.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
示例3: print
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 300, 100);
ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.DefaultPageSettings.PaperSize = psize;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
示例4: printPreview
public void printPreview(PrinteModel model)
{
if (model != null)
{
printModel = model;
}
else
{
return;
}
try
{
init();
PrintPreviewDialog previewDialog = new PrintPreviewDialog();
previewDialog.Document = docToPrint;
var result = previewDialog.ShowDialog();
if (result == DialogResult.OK)
{
docToPrint.Print();
}
}
catch (Exception ex)
{
}
}
示例5: filePrintPreviewMenuItem_Click
private void filePrintPreviewMenuItem_Click(Object sender ,
EventArgs e)
{
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = printDoc;
dlg.ShowDialog();
}
示例6: buttonPrintImage_Click
private void buttonPrintImage_Click(object sender, EventArgs e)
{
try
{
PrintDialog printDialog = new PrintDialog();
printDialog.Document = this.printDocument1;
if (printDialog.ShowDialog() != DialogResult.OK)
{
throw new Exception();
}
/*
PageSetupDialog pageSetupDialog = new PageSetupDialog();
pageSetupDialog.Document = printDocument1;
if (pageSetupDialog.ShowDialog() != DialogResult.OK)
{
throw new Exception();
}
*/
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = this.printDocument1;
printPreviewDialog.ShowDialog();
}
catch (Exception)
{
MessageBox.Show("打印已经取消");
}
}
示例7: Execute
/// <summary>
/// A utility method to print preview and print an Aspose.Words document.
/// </summary>
internal static void Execute(Document document)
{
// This operation can take some time (for the first page) so we set the Cursor to WaitCursor.
Cursor cursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
PrintPreviewDialog previewDlg = new PrintPreviewDialog();
// Initialize the Print Dialog with the number of pages in the document.
PrintDialog printDlg = new PrintDialog();
printDlg.AllowSomePages = true;
printDlg.PrinterSettings = new PrinterSettings();
printDlg.PrinterSettings.MinimumPage = 1;
printDlg.PrinterSettings.MaximumPage = document.PageCount;
printDlg.PrinterSettings.FromPage = 1;
printDlg.PrinterSettings.ToPage = document.PageCount;
// Restore cursor.
Cursor.Current = cursor;
// Interesting, but PrintDialog will not show and will always return cancel
// if you run this application in 64-bit mode.
if (!printDlg.ShowDialog().Equals(DialogResult.OK))
return;
// Create the Aspose.Words' implementation of the .NET print document
// and pass the printer settings from the dialog to the print document.
AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document);
awPrintDoc.PrinterSettings = printDlg.PrinterSettings;
// Pass the Aspose.Words' print document to the .NET Print Preview dialog.
previewDlg.Document = awPrintDoc;
previewDlg.ShowDialog();
}
示例8: Execute
public override void Execute()
{
printDocument = new PrintDocument();
printDocument.OriginAtMargins = true;
printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";
// Sizes must be given in inch * 100 (sigh).
int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
PaperSize paperSize = new PaperSize("Ignored anyway", paperWidth, paperHeight);
if ((bool)paperSettings["marginsSet"])
printDocument.DefaultPageSettings.Margins =
new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
(int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);
System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog();
preview.Document = printDocument;
preview.UseAntiAlias = true;
preview.ShowDialog();
}
示例9: Print_DataGridView
public static void Print_DataGridView(DataGridView dgv1, string printTitle, bool printAllRows, bool fitToPageWidth)
{
PrintPreviewDialog ppvw;
try
{
// Getting DataGridView object to print
dgv = dgv1;
// Getting all Coulmns Names in the DataGridView
AvailableColumns.Clear();
foreach (DataGridViewColumn c in dgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
// Showing the PrintOption Form
//PrintOptions dlg = new PrintOptions(AvailableColumns);
//if (dlg.ShowDialog() != DialogResult.OK) return;
PrintTitle = printTitle;
PrintAllRows = printAllRows;
FitToPageWidth = fitToPageWidth;
SelectedColumns = AvailableColumns;
RowsPerPage = 0;
ppvw = new PrintPreviewDialog();
PageSetupDialog psd = new PageSetupDialog();
psd.Document = printDoc;
psd.ShowDialog();
printDoc.DefaultPageSettings = psd.PageSettings;
ppvw.Document = printDoc;
// Showing the Print Preview Page
printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
//printDoc.QueryPageSettings += new System.Drawing.Printing.QueryPageSettingsEventHandler(printDoc_QueryPageSettings);
if (ppvw.ShowDialog() != DialogResult.OK)
{
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
return;
}
// Printing the Documnet
printDoc.Print();
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
}
}
示例10: GetPrinters_Click
private void GetPrinters_Click(object sender, EventArgs e)
{
//PrintDocument pd = new PrintDocument();
//pd.DefaultPageSettings.Bounds = new
//pd.Print();
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
//设置边距
Margins margin = new Margins(200, 20, 20, 0);
pd.DefaultPageSettings.Margins = margin;
//纸张设置默认
PaperSize pageSize = new PaperSize("First custom size", getYc(58), 100);
pd.DefaultPageSettings.PaperSize = pageSize;
//打印事件设置
pd.PrintPage += pd_PrintPage;
ppd.Document = pd;
ppd.ShowDialog();
//try
//{
// pd.Print();
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
// pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
//}
}
示例11: ShowPrintPreviewDialog
/// <summary>
/// Shows the print preview dialog</summary>
public void ShowPrintPreviewDialog()
{
PrintPreviewDialog dialog = new PrintPreviewDialog();
PrintDocument printDocument = GetPrintDocument();
dialog.Document = printDocument;
dialog.ShowDialog();
}
示例12: PrintTokens
public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview)
{
_tokensToPrint = tokens;
_pageCounter = 0;
//bool showPrintPreview = true;
PrintDocument pd = new PrintDocument();
PrintDocument pd1 = new PrintDocument();
pd.DefaultPageSettings.PaperSize = paperSize;
pd.PrintPage += printDoc_PrintPage;
pd.PrinterSettings.PrinterName = PrinterName;
//ToDo: can remove preview in the actual production.
if (showPrintPreview)
{
var ppDlg = new PrintPreviewDialog();
ppDlg.SetBounds(30, 30, 1024, 500);
ppDlg.PrintPreviewControl.AutoZoom = true;
ppDlg.PrintPreviewControl.Zoom = 0.75;
ppDlg.Document = pd;
var dr = ppDlg.ShowDialog(parentDialog);
}
else
{
pd.Print();
}
}
示例13: Print_DataGridView
private static int TotalWidth; // Summation of Columns widths
#endregion Fields
#region Methods
public static void Print_DataGridView(DataGridView dgv1)
{
PrintPreviewDialog ppvw;
try
{
// Getting DataGridView object to print
dgv = dgv1;
// Getting all Coulmns Names in the DataGridView
AvailableColumns.Clear();
foreach (DataGridViewColumn c in dgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
// Showing the PrintOption Form
PrintOptions dlg = new PrintOptions(AvailableColumns);
if (dlg.ShowDialog() != DialogResult.OK) return;
PrintAllRows = dlg.PrintAllRows;
FitToPageWidth = dlg.FitToPageWidth;
SelectedColumns = dlg.GetSelectedColumns();
RowsPerPage = 0;
ppvw = new PrintPreviewDialog();
ppvw.Document = printDoc;
// Showing the Print Preview Page
printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
printDoc.DefaultPageSettings.Landscape = true;
PaperSize paperSize = new PaperSize("Letter", 850, 1100);
paperSize.RawKind = (int)PaperKind.Custom;
printDoc.DefaultPageSettings.PaperSize = paperSize;
if (ppvw.ShowDialog() != DialogResult.OK)
{
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
return;
}
// Printing the Documnet
printDoc.DefaultPageSettings.Landscape = true;
printDoc.DefaultPageSettings.PaperSize = paperSize;
printDoc.Print();
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
}
}
示例14: PrintPreview
public DialogResult PrintPreview()
{
var ppd = new PrintPreviewDialog();
ppd.WindowState = FormWindowState.Maximized;
ppd.Icon = ((Form)window).Icon;
ppd.Document = PrintDocument;
return ppd.ShowDialog(window);
}
示例15: Preview
// The Print Preview Button
public void Preview(string title)
{
if (Setup(title))
{
var myPrintPreviewDialog = new PrintPreviewDialog {Document = printDocument};
myPrintPreviewDialog.ShowDialog();
}
}