本文整理汇总了C#中System.Windows.Controls.PrintDialog类的典型用法代码示例。如果您正苦于以下问题:C# PrintDialog类的具体用法?C# PrintDialog怎么用?C# PrintDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrintDialog类属于System.Windows.Controls命名空间,在下文中一共展示了PrintDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: cmdPrint_Click
private void cmdPrint_Click(object sender, RoutedEventArgs e)
{
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog().GetValueOrDefault())
{
PrintTicket ticket = pd.PrintTicket;
if (cmboOrientation.SelectedIndex == 0)
{
ticket.PageOrientation = PageOrientation.Landscape;
}
else
{
ticket.PageOrientation = PageOrientation.Portrait;
}
pd.PrintTicket = ticket;
mDoc.PageHeight = pd.PrintableAreaHeight;
mDoc.PageWidth = pd.PrintableAreaWidth;
mDoc.PagePadding = new Thickness(50);
mDoc.ColumnGap = 0;
mDoc.ColumnWidth = pd.PrintableAreaWidth;
IDocumentPaginatorSource dps = mDoc;
pd.PrintDocument(dps.DocumentPaginator, title);
}
}
开发者ID:phillipCouto,项目名称:Clear-Choice,代码行数:28,代码来源:DocumentPreviewer.xaml.cs
示例2: print_btn_Click
private void print_btn_Click(object sender, RoutedEventArgs e)
{
try
{
report.report_cr_dr p = new BMS.report.report_cr_dr();
p.lst_balance.ItemsSource = dr;
p.r_date.Content = DateTime.Now.Date.ToShortDateString();
p.r_name.Content = "Top Debitors";
PrintDialog pd = new PrintDialog();
FixedDocument document = new FixedDocument();
document.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
FixedPage page1 = new FixedPage();
page1.Width = document.DocumentPaginator.PageSize.Width;
page1.Height = document.DocumentPaginator.PageSize.Height;
Canvas can = p.layout;
page1.Children.Add(can);
PageContent page1Content = new PageContent();
((IAddChild)page1Content).AddChild(page1);
document.Pages.Add(page1Content);
pd.PrintDocument(document.DocumentPaginator, "My first document");
}
catch (Exception ex)
{
MessageBox.Show("Sorry some system error has occour please try again");
}
}
开发者ID:sumit10,项目名称:BMS,代码行数:26,代码来源:home.xaml.cs
示例3: PrintPreview_Click
private void PrintPreview_Click(object sender, RoutedEventArgs e)
{
var printdialog = new PrintDialog();
if (printdialog.ShowDialog() != true) { return; }
var doc = new FixedDocument();
doc.DocumentPaginator.PageSize = new Size(printdialog.PrintableAreaWidth, printdialog.PrintableAreaHeight);
var queue = printdialog.PrintQueue;
var caps = queue.GetPrintCapabilities();
var area = caps.PageImageableArea;
var marginwidth = (printdialog.PrintableAreaWidth - caps.PageImageableArea.ExtentWidth) / 2.0;
var marginheight = (printdialog.PrintableAreaHeight - caps.PageImageableArea.ExtentHeight) / 2.0;
double gutter;
if (!Double.TryParse(GutterWidthTextbox.Text, out gutter)) { gutter = 0.25; }
// Translate inches to device independent pixels
gutter *= 96.0;
var opts = new PrintOptions
{
PrintableWidth = area.ExtentWidth,
PrintableHeight = area.ExtentHeight,
MarginWidth = marginwidth,
MarginHeight = marginheight,
Gutter = gutter
};
var category = (CardCategory)DataContext;
category.AddPagesToDocument(doc, opts, category.SelectedCards);
var preview = new PrintPreview();
preview.Document = doc;
preview.ShowDialog();
}
开发者ID:dyselon,项目名称:cscribe,代码行数:33,代码来源:PrintSelectedOptions.xaml.cs
示例4: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
{
document.FontFamily = new System.Windows.Media.FontFamily(LocalSettings.PrintFontFamily);
document.Typography.EastAsianWidths = FontEastAsianWidths.Half;
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
开发者ID:BOBAHbI4,项目名称:SambaPOS-3,代码行数:31,代码来源:WindowsPrinterJob.cs
示例5: Print
/// <summary>
/// Prints this instance.
/// </summary>
public bool Print()
{
try
{
PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
bool? results = printDlg.ShowDialog();
if (results == null || results == false) return false;
//get selected printer capabilities
System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);
//get the size of the printer page
System.Windows.Size printSize = new System.Windows.Size(
capabilities.PageImageableArea.ExtentHeight, capabilities.PageImageableArea.ExtentWidth);
// Build print view
this.Height = printSize.Height;
this.Width = printSize.Width;
Measure(printSize);
Arrange(new System.Windows.Rect(printSize));
XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(printDlg.PrintQueue);
printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;
xpsdw.WriteAsync(this);
}
catch (Exception ex)
{
MessageBox.Show(ex.GetBaseException().Message, "Printing Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
return true;
}
开发者ID:bradsjm,项目名称:LaJustPowerMeter,代码行数:35,代码来源:GameImpactPrintView.xaml.cs
示例6: PrintCommand
public void PrintCommand()
{
PrintDialog printDlg = new PrintDialog();
FlowDocument doc = new FlowDocument(new Paragraph(new Run(WebAddress))) {Name = "Directions"};
IDocumentPaginatorSource idpSource = doc;
printDlg.PrintDocument(idpSource.DocumentPaginator, "Directions Printing.");
}
开发者ID:brucedog,项目名称:Morning-Commuter,代码行数:7,代码来源:TravelDirectionsViewModel.cs
示例7: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var fm = document.FontFamily;
var bg = document.Background;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (q != null || pd.PrintQueue.FullName == Printer.ShareName || Printer.ShareName.ToLower() == "default" || Printer.ShareName.Contains("/") || pd.ShowDialog().GetValueOrDefault(false))
{
document.Background = Brushes.Transparent;
document.FontFamily = new FontFamily(LocalSettings.PrintFontFamily);
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.Background = bg;
document.FontFamily = fm;
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:35,代码来源:WindowsPrinterJob.cs
示例8: btnPrint_Click
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
//Show a Print Dialog
PrintDialog dialog = new PrintDialog();
dialog.MaxPage = this.pdfViewer1.PageCount > 0 ? (uint)this.pdfViewer1.PageCount : 1;
dialog.MinPage = 1;
dialog.UserPageRangeEnabled = true;
bool? result = dialog.ShowDialog();
if (result.Value)
{
try
{
//Set print parnameters.
this.pdfViewer1.PrintDialog = dialog;
//Get the PrintDocument.
dialog.PrintDocument(pdfViewer1.PrintDocument.DocumentPaginator, "Print Document");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
开发者ID:e-iceblue,项目名称:Spire.Office-for-.NET,代码行数:26,代码来源:MainWindow.xaml.cs
示例9: Print
public static void Print(FlowDocument printedPage)
{
PrintDialog dialog = new PrintDialog();
dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
dialog.PrintTicket.PageOrientation = PageOrientation.Portrait;
dialog.PrintTicket.OutputQuality = OutputQuality.High;
dialog.PrintTicket.PageBorderless = PageBorderless.None;
dialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
if (dialog.ShowDialog() == true)
{
double pageHeight = printedPage.PageHeight;
double pageWidth = printedPage.PageWidth;
Thickness pagePadding = printedPage.PagePadding;
double columnGap = printedPage.ColumnGap;
double columnWidth = printedPage.ColumnWidth;
printedPage.PageHeight = dialog.PrintableAreaHeight;
printedPage.PageWidth = dialog.PrintableAreaWidth;
printedPage.PagePadding = new Thickness(50);
dialog.PrintDocument(((IDocumentPaginatorSource)printedPage).DocumentPaginator, "");
printedPage.PagePadding = pagePadding;
printedPage.PageHeight = pageHeight;
printedPage.PageWidth = pageWidth;
printedPage.ColumnWidth = columnWidth;
printedPage.ColumnGap = columnGap;
}
}
开发者ID:Ashna,项目名称:ShayanDent,代码行数:32,代码来源:Common.cs
示例10: OnPrintCommand
protected override void OnPrintCommand()
{
PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;
printDialog.PrintTicket.PageOrientation = PageOrientation;
if (printDialog.ShowDialog() == true)
{
// Code assumes this.Document will either by a FixedDocument or a FixedDocumentSequence
FixedDocument fixedDocument = this.Document as FixedDocument;
FixedDocumentSequence fixedDocumentSequence = this.Document as FixedDocumentSequence;
if (fixedDocument != null)
fixedDocument.PrintTicket = printDialog.PrintTicket;
if (fixedDocumentSequence != null)
fixedDocumentSequence.PrintTicket = printDialog.PrintTicket;
XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
if (fixedDocument != null)
writer.WriteAsync(fixedDocument, printDialog.PrintTicket);
if (fixedDocumentSequence != null)
writer.WriteAsync(fixedDocumentSequence, printDialog.PrintTicket);
}
}
开发者ID:alexiej,项目名称:YATE,代码行数:29,代码来源:PrintPreview.cs
示例11: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
{
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
开发者ID:Spanky81,项目名称:SambaPOS-3,代码行数:29,代码来源:WindowsPrinterJob.cs
示例12: UserControl_Loaded
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
var dialog = new PrintDialog();
document.DocumentPaginator.PageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
fixedPage = new FixedPage
{
Height = document.DocumentPaginator.PageSize.Height,
Width = document.DocumentPaginator.PageSize.Width
};
grid = new Grid();
grid.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
fixedPage.Children.Add(grid);
pageContent = new PageContent { Child = fixedPage };
pageContent.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
fixedPage.Margin = new Thickness(20, 44, 20, 44);
for (int i = 0; i < totalRows; i++)
{
grid.RowDefinitions.Add(new RowDefinition());
}
for (int j = 0; j < totalColumns; j++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
}
document.Pages.Add(pageContent);
}
开发者ID:sergiosorias,项目名称:terminalzero,代码行数:27,代码来源:BarcodePrintView.xaml.cs
示例13: printOrder
public static void printOrder( Order o )
{
PrintDialog printDlg = new PrintDialog();
String textToPrint = "";
textToPrint += "\t\t Τραπέζι "+o.Table_id+"\n\n";
textToPrint += "Παραγγελία : \n";
String orderName = "";
foreach (Items i in DBController.LoadItems())
{
if (i.Id == o.Items_id)
orderName = i.Name;
}
orderName += o.CharacteristicsInfo;
textToPrint += "\t1 "+orderName+"\n";
textToPrint += "\n\n";
String waiterName = "";
foreach (User u in DBController.LoadUsers())
{
if (u.User_id == o.User_id)
waiterName = u.Name;
}
textToPrint += "Σερβιτόρος : "+waiterName+"\n";
textToPrint += "Ώρα : " + DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt");
FlowDocument doc = new FlowDocument(new Paragraph(new Run(textToPrint)));
doc.Name = "FlowDoc";
IDocumentPaginatorSource idpSource = doc;
printDlg.PrintDocument(idpSource.DocumentPaginator, "smart order");
}
开发者ID:MeTaXaS4,项目名称:smartOrderPC,代码行数:35,代码来源:Printer.cs
示例14: Print_Click
private void Print_Click(object sender, RoutedEventArgs e)
{
//If you reduce the size of the view area of the window, so the text does not all fit into one page, it will print separate pages
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument).DocumentPaginator, "This is a Flow Document");
}
开发者ID:nanomouse,项目名称:stratasys,代码行数:7,代码来源:Window2.xaml.cs
示例15: cmdPrintCustom_Click
private void cmdPrintCustom_Click(object sender, RoutedEventArgs e)
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
FlowDocument doc = docReader.Document;
// Save all the existing settings.
double pageHeight = doc.PageHeight;
double pageWidth = doc.PageWidth;
Thickness pagePadding = doc.PagePadding;
double columnGap = doc.ColumnGap;
double columnWidth = doc.ColumnWidth;
// Make the FlowDocument page match the printed page.
doc.PageHeight = printDialog.PrintableAreaHeight;
doc.PageWidth = printDialog.PrintableAreaWidth;
doc.PagePadding = new Thickness(50);
// Use two columns.
doc.ColumnGap = 25;
doc.ColumnWidth = (doc.PageWidth - doc.ColumnGap
- doc.PagePadding.Left - doc.PagePadding.Right) / 2;
printDialog.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, "A Flow Document");
// Reapply the old settings.
doc.PageHeight = pageHeight;
doc.PageWidth = pageWidth;
doc.PagePadding = pagePadding;
doc.ColumnGap = columnGap;
doc.ColumnWidth = columnWidth;
}
}
开发者ID:ittray,项目名称:LocalDemo,代码行数:34,代码来源:PrintFlowDocument.xaml.cs
示例16: ButtonOk_Click
private void ButtonOk_Click(object sender, RoutedEventArgs e)
{
this.TextBoxRealReportNumber.Text = this.TextBoxRealReportNumber.Text.ToUpper();
this.TextBoxDummyReportNumber.Text = this.TextBoxDummyReportNumber.Text.ToUpper();
if (this.TextBoxRealReportNumber.Text.Length < 4)
{
MessageBox.Show("The real report number does not appear to be a valid number.\n\nPlease check it and try again.", "Invalid report number", MessageBoxButton.OK);
return;
}
string lastName = this.GetPatientLastName();
if (lastName.Length == 0)
{
MessageBox.Show("The report number does not appear to be a valid number.\n\nPlease check it and try again.", "Case not found", MessageBoxButton.OK);
return;
}
YellowstonePathology.UI.Login.CytologySlideLabelDocument cyologySlideLabelDocument = new CytologySlideLabelDocument(this.TextBoxDummyReportNumber.Text, lastName, false);
System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
System.Printing.PrintQueue printQueue = YellowstonePathology.UI.PrintQueueFactory.GetSlideLabelPrintQueue(YellowstonePathology.Properties.Settings.Default.CytologySlideLabelPrinterName);
printDialog.PrintQueue = printQueue;
printDialog.PrintDocument(cyologySlideLabelDocument.DocumentPaginator, "Slide Labels");
Close();
}
开发者ID:ericramses,项目名称:YPILIS,代码行数:27,代码来源:CytologyDummySlideLabel.xaml.cs
示例17: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
Common.Print(printedPage);
PrintDialog printDlg = new PrintDialog();
printDlg.PrintVisual(mygrid, "Grid Printing.");
}
开发者ID:Ashna,项目名称:ShayanDent,代码行数:7,代码来源:PrintScriiption.xaml.cs
示例18: OnPrintCommand
protected override void OnPrintCommand()
{
// get a print dialog, defaulted to default printer and default printer's preferences.
var printDialog = new PrintDialog();
printDialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;
string s = Document.GetType().ToString();
// get a reference to the FixedDocumentSequence for the viewer.
//FixedDocumentSequence docSeq = this.Document as FixedDocumentSequence;
var docSeq = (FixedDocument) Document;
// set the default page orientation based on the desired output.
printDialog.PrintTicket = (PrintTicket) docSeq.PrintTicket;
if (printDialog.ShowDialog() == true)
{
// set the print ticket for the document sequence and write it to the printer.
docSeq.PrintTicket = printDialog.PrintTicket;
var writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
writer.WriteAsync(docSeq, printDialog.PrintTicket);
}
}
开发者ID:schakko,项目名称:bootstrap-net,代码行数:25,代码来源:PrintDocumentViewer.cs
示例19: PrintOnClick
void PrintOnClick(object sender, RoutedEventArgs args)
{
PrintDialog dlg = new PrintDialog();
if (dlg.ShowDialog().GetValueOrDefault())
{
// Make sure orientation is Portrait.
PrintTicket prntkt = dlg.PrintTicket;
prntkt.PageOrientation = PageOrientation.Portrait;
dlg.PrintTicket = prntkt;
// Create new BannerDocumentPaginator object.
BannerDocumentPaginator paginator = new BannerDocumentPaginator();
// Set Text property from TextBox.
paginator.Text = txtbox.Text;
// Give it a PageSize property based on the paper dimensions.
paginator.PageSize = new Size(dlg.PrintableAreaWidth,
dlg.PrintableAreaHeight);
// Call PrintDocument to print the document.
dlg.PrintDocument(paginator, "Banner: " + txtbox.Text);
}
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:25,代码来源:PrintBanner.cs
示例20: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
//REFACTOR ME
dtgParentReport.Update();
System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
Nullable<bool> print = printDialog.ShowDialog();
if (print == true)
{
try
{
XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
}
catch (UnauthorizedAccessException e1)
{
const string message =
"Unauthoried to access that printer.";
const string caption = "Unauthoried Access";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
catch (PrintDialogException e2)
{
const string message =
"Unknow error occurred.";
const string caption = "Error Printing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
开发者ID:jeffBunce,项目名称:Math-Monkeys-3.0,代码行数:34,代码来源:frmParentReport.cs
注:本文中的System.Windows.Controls.PrintDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论