步步为盈
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.

121 lines
3.6 KiB

2 years ago
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Client.Models.FallWare;
using BBWY.Controls;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing.Printing;
using System.IO;
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.FallWare
{
/// <summary>
/// PrintBoxWindow.xaml 的交互逻辑
/// </summary>
public partial class PrintBoxWindow : BWindow
{
public PrintBoxWindow(JDWareBoxModel model, WareType WareType)
{
JDWareBoxModel =model ; this.WareType = WareType;
InitializeComponent();
this.DataContext = this;
InitPrintList();
}
public void InitPrintList()
{
//TaskImage = MyPrintHelper.GetBarcodeImage(TaskId.ToString(), 300, 60);
//BarcodeImage = MyPrintHelper.GetBarcodeImage(SkuId, 300, 60);
PrintList = new ObservableCollection<string>();
var printingNames = PrinterSettings.InstalledPrinters;//获取本机的打印机数据
int index = -1;
int selectIndex = 0;
foreach (string name in printingNames)
{
if (name == "Microsoft XPS Document Writer" || name == "Microsoft Print to PDF" || name == "Fax")
{
continue;
}
index++;
if (name.Contains("Deli"))
{
selectIndex = index;
}
PrintList.Add(name);
}
try
{
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string printNames = System.IO.Path.Combine(applicationPath, "printName.init");
if (File.Exists(printNames))
{
PrintName = File.ReadAllText(printNames);
}
else
{
if (PrintList.Count > 0)
{
PrintName = PrintList[0].ToString();
}
}
}
catch (Exception)
{
}
}
public string PrintName { get; set; }
public int PrintCount { get; set; } = 1;
public JDWareBoxModel JDWareBoxModel { get; set; }
/// <summary>
/// 箱唛类型
/// </summary>
public WareType WareType { get; set; }
/// <summary>
/// 打印机列表
/// </summary>
public ObservableCollection<string> PrintList { get; set; }
private void BButton_Click(object sender, RoutedEventArgs e)
{
if (WareType== WareType.)
{
SetJDWareBoxWindow jdWindow = new SetJDWareBoxWindow(JDWareBoxModel);
jdWindow.Show();
//jdWindow.WindowState = WindowState.Maximized;
jdWindow.PrintBox(PrintName);
}
if (WareType== WareType.|| WareType== WareType.)
{
SetCloudWareBoxWindow cloudWareWindow = new SetCloudWareBoxWindow(JDWareBoxModel, WareType);
cloudWareWindow.Visibility = Visibility.Hidden;
cloudWareWindow.Show();
cloudWareWindow.PrintBox(PrintName);
}
}
}
}