using BBWY.Client.Helpers; using BBWY.Client.Models.APIModel; using BBWY.Client.Models.FallWare; using BBWY.Controls; using System; using System.Collections.Generic; using System.Printing; using System.Reflection; using System.Text; using System.Threading; 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.SealBox { /// /// SealBoxPolicyDetailsWindow.xaml 的交互逻辑 /// public partial class SealBoxPolicyDetailsWindow : BWindow { public SealBoxPolicyDetailsWindow(List sealBoxSkus, string shopName, string wareName, long sealBoxId,string acceptUserName) { InitializeComponent(); this.DataContext = this; SealBoxSkus = sealBoxSkus; ShopName = shopName; WareName = wareName; AcceptUserName = acceptUserName; SealBoxId = sealBoxId; NowDateTime = DateTime.Now; this.UpdateLayout(); } /// /// 封箱sku列表 /// public List SealBoxSkus { get; set; } public string ShopName { get; set; } public string WareName { get; set; } public string AcceptUserName { get; set; } public DateTime? NowDateTime { get; set; } public long SealBoxId { get; set; } public void PrintBox(string printName) { var localPrintServer = new LocalPrintServer(); if (string.IsNullOrEmpty(printName)) { return; } var printQueue = localPrintServer.GetPrintQueue(printName); if (printQueue.IsInError) { System.Windows.MessageBox.Show("打印机处于错误状态"); return; } NowDateTime = DateTime.Now; this.UpdateLayout(); MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机 PrintDialog printDialog = new PrintDialog(); printDialog.PrintTicket.PageOrientation = PageOrientation.Portrait;//设置为横向打印 PageOrientation.Landscape Portrait为纵向 var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth); var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight); printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight); this.Height = pageHeight; this.Width = pageWidth; // this.FontSize = 30; this.print_sealbox.Arrange(new Rect(new Point(0, 0), new Size(pageWidth, pageHeight))); this.UpdateLayout(); printDialog.PrintVisual(this.print_sealbox, "打印任务"); this.Close(); } } }