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(); } /// /// 该接口用于设置打印时的对齐方式 /// n=0 左对齐;n=1 居中;n=2 右对齐 /// /// /// public static int SetAlign(int n) { return YkPosSDK.SetAlign(n); } /// /// 该接口用于使能或禁用加重打印模式 /// n=1 使能, n=0 禁用 /// /// /// public static int SetEmphasized(int n) { return YkPosSDK.SetEmphasized(n); } /// /// 该接口用于设置打印的左边距 /// 左边距 =(nL + nH x 256) x 0.125 毫米 /// /// /// /// public static int SetLeftMargin(int nL, int nH) { return YkPosSDK.SetLeftMargin(nL, nH); } /// /// 该接口用于设置字符放大倍数 /// hsize ,vsize 值与倍数对应关系 /// hsize 水平放大倍数 vsize 垂直放在倍数 ,取值范围 0~7 /// 0-----1 倍(原大小) /// 7-----8 倍 /// /// /// /// public static int SetCharSize(int hsize, int vsize) { return YkPosSDK.SetCharSize(hsize, vsize); } /// /// 纸尽 /// /// public static bool IsPaperExhaust() { var nRet4 = YkPosSDK.GetStatus(4); return (nRet4 & 0x60) > 0; } /// /// 纸将尽 /// /// public static bool IsPaperWillExhaust() { var nRet4 = YkPosSDK.GetStatus(4); return (nRet4 & 0x0c) > 0; } } }