Add project files.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using Custom.CuCustomWndAPI;
|
||||
using HandyControl.Data;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace SafeBagDE70.Services
|
||||
{
|
||||
public class PrinterManager
|
||||
{
|
||||
CuCustomWndDevice? dev = null;
|
||||
CuCustomWndAPIWrap? customWndAPIWrap =null;
|
||||
PrinterStatus? status = null;
|
||||
public PrinterManager()
|
||||
{
|
||||
try
|
||||
{
|
||||
customWndAPIWrap = new CuCustomWndAPIWrap(CuCustomWndAPIWrap.CcwLogVerbosity.CCW_LOG_FATAL, null);
|
||||
customWndAPIWrap.InitLibrary();
|
||||
USBDevice[] usbArray = customWndAPIWrap.EnumUSBDevices();
|
||||
dev = customWndAPIWrap.OpenPrinterUSB(usbArray[0]);
|
||||
Log.Information("[PRINTER] Init Printer Successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// System.Windows.MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public PrinterStatus? GetStatus()
|
||||
{
|
||||
var status = dev.GetPrinterFullStatus();
|
||||
return status;
|
||||
}
|
||||
public bool IsNearPaperOut()
|
||||
{
|
||||
try
|
||||
{
|
||||
var status = dev.GetPrinterFullStatus();
|
||||
return status.StsNEARENDPAP;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsPaperOut()
|
||||
{
|
||||
try
|
||||
{
|
||||
var status = dev.GetPrinterFullStatus();
|
||||
return status.StsNOPAPER;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
if (dev != null)
|
||||
dev.Terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user