本文整理汇总了C#中System.Windows.Forms.PrintPreviewDialog类的典型用法代码示例。如果您正苦于以下问题:C# PrintPreviewDialog类的具体用法?C# PrintPreviewDialog怎么用?C# PrintPreviewDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrintPreviewDialog类属于System.Windows.Forms命名空间,在下文中一共展示了PrintPreviewDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintClass
/// <summary>
/// 打印信息的初始化
/// </summary>
/// <param datagrid="DataGridView">打印数据</param>
/// <param PageS="int">纸张大小</param>
/// <param lendscape="bool">是否横向打印</param>
public PrintClass(DataGridView datagrid, int PageS, bool lendscape)
{
this.datagrid = datagrid;//获取打印数据
this.PageSheet = PageS;//纸张大小
printdocument = new PrintDocument();//实例化PrintDocument类
pagesetupdialog = new PageSetupDialog();//实例化PageSetupDialog类
pagesetupdialog.Document = printdocument;//获取当前页的设置
printpreviewdialog = new PrintPreviewDialog();//实例化PrintPreviewDialog类
printpreviewdialog.Document = printdocument;//获取预览文档的信息
printpreviewdialog.FormBorderStyle = FormBorderStyle.Fixed3D;//设置窗体的边框样式
//横向打印的设置
if (PageSheet >= 0)
{
if (lendscape == true)
{
printdocument.DefaultPageSettings.Landscape = lendscape;//横向打印
}
else
{
printdocument.DefaultPageSettings.Landscape = lendscape;//纵向打印
}
}
pagesetupdialog.Document = printdocument;
printdocument.PrintPage += new PrintPageEventHandler(this.printdocument_printpage);//事件的重载
}
示例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: 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();
}
示例5: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
gcOptions.Visible = false;
using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
{
printDocument.PrintPage += printDocument_PrintPage;
printDocument.DefaultPageSettings.Landscape = true;
printDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("FalseX", 500, 1000);
//Resize
Size = new Size(974, 507);
CaptureScreen();
try
{
//printDocument.Print();
PrintPreviewDialog PPdlg = new PrintPreviewDialog() { Document = printDocument };
PPdlg.Show();
}
catch (Exception ex)
{
Program.ShowMsg(ex.Message, true, this);
Program.Logger.LogThis(null, Text, FXFW.Logger.OpType.fail, ex, null, this);
}
}
Size = new Size(974, 589);
gcOptions.Visible = true;
}
示例6: MapOutPut
public MapOutPut(AxPageLayoutControl pagecontrol)
{
axPageLayoutControl1 = pagecontrol;
printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
InitializePageSetupDialog(); //intitialize the page setup dialog
comboBox1.Items.Add("esriPageMappingTile");
comboBox1.Items.Add("esriPageMappingCrop");
comboBox1.Items.Add("esriPageMappingScale");
comboBox1.SelectedIndex = 0;
// create a new PrintPreviewDialog using constructor
printPreviewDialog1 = new PrintPreviewDialog();
//set the size, location, name and the minimum size the dialog can be resized to
printPreviewDialog1.ClientSize = new System.Drawing.Size(800, 600);
printPreviewDialog1.Location = new System.Drawing.Point(29, 29);
printPreviewDialog1.Name = "PrintPreviewDialog1";
printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
//set UseAntiAlias to true to allow the operating system to smooth fonts
printPreviewDialog1.UseAntiAlias = true;
//associate the event-handling method with the document's PrintPage event
this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
}
示例7: filePrintPreviewMenuItem_Click
private void filePrintPreviewMenuItem_Click(Object sender ,
EventArgs e)
{
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = printDoc;
dlg.ShowDialog();
}
示例8: 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("打印已经取消");
}
}
示例9: 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)
{
}
}
示例10: InitializeComponent
private void InitializeComponent()
{
this.printDocument1 = new System.Drawing.Printing.PrintDocument();
//
//Main DataSet Initialization
//
this.printPreviewDialog1 = new PrintPreviewDialog();
this.maindataset = new SupremeTransport.maindataset();
//
//Table Adapter Initialization
//
this.mainbillTableAdapter = new SupremeTransport.maindatasetTableAdapters.mainbillTableAdapter();
this.billTableAdapter = new SupremeTransport.maindatasetTableAdapters.billTableAdapter();
//
// printDocument1
//
this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
//
// printPreviewDialog1
//
this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
this.printPreviewDialog1.Enabled = true;
this.printPreviewDialog1.Name = "printPreviewDialog1";
this.printPreviewDialog1.Visible = false;
}
示例11: bPay_Click
private void bPay_Click(object sender, EventArgs e)
{
DB.Instance.Insert("order", new Parameter("customer_id", cid), new Parameter("dt", DateTime.Now), new Parameter("status", OrderStatus.New));
uint oid = 0;
using (MySqlDataReader reader = DB.Instance.SelectReader("select max(id) from order"))
{
if(reader != null && reader.Read()){
oid = reader.GetUInt32(0);
}
}
foreach (var item in Role.Instance.ShopCart)
{
DB.Instance.Insert("order_inventory", new Parameter("order_id", oid), new Parameter("inventory_id", item.ID), new Parameter("amount", item.Qty));
}
var dr = MessageBox.Show("Order Placed. Would you like to pay now?", "Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
new Payment().ShowDialog();
}
else if(dr == DialogResult.No)
{
var ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
ppd.Document = pd;
pd.PrintPage += Pd_PrintPage;
ppd.ShowDialog();
}
}
示例12: PrintPreviewTree
/// <summary>
/// Shows a PrintPreview dialog displaying the Tree control passed in.
/// </summary>
/// <param name="tree">TreeView to print preview</param>
/// <param name="reportTitle"></param>
public void PrintPreviewTree(TreeView tree, string reportTitle)
{
this.title = reportTitle;
this.PrepareTreeImage(tree);
var pp = new PrintPreviewDialog { Document = this.printDoc };
pp.Show();
}
示例13: 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();
}
}
示例14: ShowPrintPreviewDialog
/// <summary>
/// Shows the print preview dialog</summary>
public void ShowPrintPreviewDialog()
{
PrintPreviewDialog dialog = new PrintPreviewDialog();
PrintDocument printDocument = GetPrintDocument();
dialog.Document = printDocument;
dialog.ShowDialog();
}
示例15: 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();
}