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.

136 lines
2.8 KiB

3 years ago
using System.Text;
namespace EC.AutoWeightServer.IfManager.YkPos
{
internal class YkPosManager
{
private static bool openFlag = false;
public static int OpenDevice()
{
int i;
i = YkPosSDK.OpenDevice();
openFlag = i == 0;
return i;
}
public static int CloseDevice()
{
return YkPosSDK.CloseDevice();
}
public static int InitPrinter()
{
return YkPosSDK.InitPrinter();
}
public static int PrintStr(StringBuilder pstr)
{
return YkPosSDK.PrintStr(pstr);
}
public static bool IsConnected()
{
return openFlag && YkPosSDK.IsConnected() == 1;
}
public static int FeedPaper()
{
return YkPosSDK.FeedPaper();
}
public static int GetStatus(byte n)
{
return YkPosSDK.GetStatus(n);
}
public static int GetPrinterStatus(byte n)
{
return YkPosSDK.GetPrinterStatus(n);
}
public static int PrintRasterBmp(StringBuilder pBmpFile)
{
return YkPosSDK.PrintRasterBmp(pBmpFile);
}
public static int PrintBitmap(StringBuilder pBmpFile)
{
return YkPosSDK.PrintBitmap(pBmpFile);
}
public static int CutPaper()
{
return YkPosSDK.CutPaper();
}
/// <summary>
/// 该接口用于设置打印时的对齐方式
/// n=0 左对齐;n=1 居中;n=2 右对齐
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int SetAlign(int n)
{
return YkPosSDK.SetAlign(n);
}
/// <summary>
/// 该接口用于使能或禁用加重打印模式
/// n=1 使能, n=0 禁用
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int SetEmphasized(int n)
{
return YkPosSDK.SetEmphasized(n);
}
/// <summary>
/// 该接口用于设置打印的左边距
/// 左边距 =(nL + nH x 256) x 0.125 毫米
/// </summary>
/// <param name="nL"></param>
/// <param name="nH"></param>
/// <returns></returns>
public static int SetLeftMargin(int nL, int nH)
{
return YkPosSDK.SetLeftMargin(nL, nH);
}
/// <summary>
/// 该接口用于设置字符放大倍数
/// hsize ,vsize 值与倍数对应关系
/// hsize 水平放大倍数 vsize 垂直放在倍数 ,取值范围 0~7
/// 0-----1 倍(原大小)
/// 7-----8 倍
/// </summary>
/// <param name="hsize"></param>
/// <param name="vsize"></param>
/// <returns></returns>
public static int SetCharSize(int hsize, int vsize)
{
return YkPosSDK.SetCharSize(hsize, vsize);
}
/// <summary>
/// 纸尽
/// </summary>
/// <returns></returns>
public static bool IsPaperExhaust()
{
var nRet4 = YkPosSDK.GetStatus(4);
return (nRet4 & 0x60) > 0;
}
/// <summary>
/// 纸将尽
/// </summary>
/// <returns></returns>
public static bool IsPaperWillExhaust()
{
var nRet4 = YkPosSDK.GetStatus(4);
return (nRet4 & 0x0c) > 0;
}
}
}