步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.9 KiB

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
{
/// <summary>
/// SealBoxPolicyDetailsWindow.xaml 的交互逻辑
/// </summary>
public partial class SealBoxPolicyDetailsWindow : BWindow
{
public SealBoxPolicyDetailsWindow(List<WareSealBoxSku> 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();
}
/// <summary>
/// 封箱sku列表
/// </summary>
public List<WareSealBoxSku> 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();
}
}
}