using BBWY.Client.Helpers; using BBWY.Client.Models; using BBWY.Controls; using System; using System.Collections.Generic; using System.Printing; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace BBWY.Client.Views.SomeArrival { /// /// SomeArrivalWindow.xaml 的交互逻辑 /// public partial class SomeArrivalWindow : BWindow { public SomeArrivalWindow(PackTaskModel model) { InitializeComponent(); this.DataContext = this; Model = model; } private PackTaskModel model; public PackTaskModel Model { get => model; set { Set(ref model, value); } } public string taskIdRemark; public string TaskIdRemark { get => taskIdRemark; set { Set(ref taskIdRemark, value); } } public string remarkMsg; public string RemarkMsg { get => remarkMsg; set { Set(ref remarkMsg, value); } } public string exceptType; public string ExceptType { get => exceptType; set { Set(ref exceptType, value); } } public void Print(string printName) { MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机 PrintDialog printDialog = new PrintDialog(); //Height="492" Width="272" 567 388 printDialog.PrintTicket.PageOrientation = PageOrientation.ReversePortrait;//设置为横向打印 PageOrientation.Landscape Portrait为纵向 //设置纸张大小 var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight); print_box.Height = pageHeight; print_box.Width = pageWidth; this.print_box.Arrange(new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(pageWidth, pageHeight))); this.UpdateLayout(); //刷新界面 printDialog.PrintVisual(this.print_box, "打印任务"); this.Close(); } } }