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.
107 lines
3.7 KiB
107 lines
3.7 KiB
using BBWY.Client.Helpers;
|
|
using BBWY.Client.Models;
|
|
using BBWY.Client.ViewModels.PackTask;
|
|
using BBWY.Controls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Printing;
|
|
using System.Reflection;
|
|
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.PackTask
|
|
{
|
|
/// <summary>
|
|
/// PackDetailWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class PackDetailWindow : BWindow
|
|
{
|
|
public PackDetailWindow(PackTaskModel model, Action reflashWindow)
|
|
{
|
|
InitializeComponent();
|
|
|
|
var serviceViewModel = this.DataContext as PackDetailViewModel;
|
|
//加载数据
|
|
|
|
if (model.BarCodeModel != null)
|
|
{
|
|
model.BarCodeModel.ShopName = model.ShopName;
|
|
}
|
|
|
|
serviceViewModel.PackTaskModel = model;
|
|
serviceViewModel.PackTaskList = new System.Collections.ObjectModel.ObservableCollection<PackTaskModel> { model};
|
|
serviceViewModel.FloorDragNumber = model.FloorDragNumber;
|
|
serviceViewModel.TaskCount = model.SkuCount;
|
|
serviceViewModel.TaskId = model.TaskId;
|
|
serviceViewModel.OrderId = model.OrderId;
|
|
serviceViewModel.SkuId = model.SkuId;
|
|
serviceViewModel.PackUserName = model.PackUser?.Replace("\r\n", ",")?.Replace("\n", ",")?.Replace("\r", ",");
|
|
serviceViewModel.LoadPackDatas();
|
|
if (reflashWindow != null)
|
|
serviceViewModel.ReflashWindow = reflashWindow;
|
|
}
|
|
private void BButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
//return;//禁用打印
|
|
var localPrintServer = new LocalPrintServer();
|
|
string printName = cbPrintName.Text.Trim();
|
|
if (string.IsNullOrEmpty(printName))
|
|
{
|
|
System.Windows.MessageBox.Show("选择打印机");
|
|
return;
|
|
}
|
|
|
|
var printQueue = localPrintServer.GetPrintQueue(printName);
|
|
if (printQueue.IsInError)
|
|
{
|
|
System.Windows.MessageBox.Show("打印机处于错误状态");
|
|
return;
|
|
}
|
|
|
|
MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机
|
|
|
|
|
|
System.Windows.Controls.PrintDialog printDialog = new PrintDialog();
|
|
printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;//设置为横向打印 PageOrientation.Landscape Portrait为纵向
|
|
//设置纸张大小
|
|
|
|
|
|
var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth);
|
|
var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight);
|
|
printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight);
|
|
//printArea.Height = pageHeight;//833
|
|
//printArea.Width = pageWidth;//1123
|
|
this.printArea.Arrange(new Rect(new Point(0, 0), new Size(printArea.ActualWidth, printArea.ActualHeight)));
|
|
|
|
printDialog.PrintVisual(this.printArea, "打印任务");
|
|
|
|
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
string printNames = System.IO.Path.Combine(applicationPath, "printName.init");
|
|
try
|
|
{
|
|
if (File.Exists(printNames))
|
|
{
|
|
File.Delete(printNames);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
|
|
}
|
|
|
|
File.WriteAllText(printNames, cbPrintName.Text);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|