spc-kiosk-pb/Agent/KPS/OPOSPrint.cs

334 lines
13 KiB
C#
Raw Permalink Normal View History

2019-06-16 05:12:09 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cosmos.KPS
{
class OPOSPrint
{
#region
public enum Position
{
Top,
Buttom,
TopAndButtom
}
public enum Alignment
{
Center,
Left,
Right
}
#endregion
#region Character size/Filter
/// <summary>
/// Character size horizontal [넓이 배율 1~8]
/// </summary>
public enum CharactersizeH
{
H_1,
H_2,
H_3,
H_4,
H_5,
H_6,
H_7,
H_8
}
/// <summary>
/// Character size vertical [높이 배율 1~8]
/// </summary>
public enum CharactersizeV
{
V_1,
V_2,
V_3,
V_4,
V_5,
V_6,
V_7,
V_8
}
/// <summary>
/// Bold 체 여부
/// </summary>
public enum TextBold
{
Nomal,
Bold
}
/// <summary>
/// 밑줄(UnderLine)
/// </summary>
public enum TextUnderLine
{
Nomal,
UnderLine
}
/// <summary>
/// 반전 Text 효과
/// </summary>
public enum TextReverseMode
{
Nomal,
ReverseMode
}
#endregion
#region OposPrint
/// <summary>
/// Text Print
/// 문자열을 출력 합니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="eVerticalSize">세로확대(1배~8배)</param>
/// <param name="eHorizontalSize">가로확대(1배~8배)</param>
/// <param name="bBold">굵은글씨(BOLD)</param>
/// <param name="bUnderLine">밑줄(UnderLine)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, TextBold eBold, TextUnderLine eTextUnderLine, TextReverseMode eTextReverseMode, bool bLineFeed)
{
bool bRet = false;
string sCmdctrlTmp = "";
string ESC = String.Format("{0}", (char)27);
string SP = String.Format("{0}", (char)20);
//string ESC_CUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|P";
//string ESC_FEEDCUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|fP";
string ESC_CUT = ESC + "|50P";
string ESC_FEEDCUT = ESC + "|100fP";
string ESC_BITMAP1 = ESC + "|1B";
string ESC_BITMAP2 = ESC + "|2B";
string ESC_TOPLOGO = ESC + "|tL";
string ESC_BTMLOGO = ESC + "|bL";
string ESC_LINEFEED = ESC + "|lF";
string ESC_FEED = ESC + "|uF";
//string ESC_BOLD = ESC + "|bC";
//string ESC_NOT_BOLD = ESC + "|!bC";
string ESC_UNDERLINE = ESC + "|uC";
string ESC_COLOR = ESC + "|rC";
//string ESC_REVERSE = ESC + "|rvC";
//string ESC_NOT_REVERSE = ESC + "|!rvC";
string ESC_1MAG = ESC + "|1C";
string ESC_2MAG = ESC + "|4C";
string ESC_HMAG = ESC + "|2C";
string ESC_VMAG = ESC + "|3C";
string ESC_H1MAG = ESC + "|1hC";
string ESC_V1MAG = ESC + "|1vC";
string ESC_H2MAG = ESC + "|2hC";
string ESC_V2MAG = ESC + "|2vC";
string ESC_H3MAG = ESC + "|3hC";
string ESC_V3MAG = ESC + "|3vC";
string ESC_H4MAG = ESC + "|4hC";
string ESC_V4MAG = ESC + "|4vC";
string ESC_H5MAG = ESC + "|5hC";
string ESC_V5MAG = ESC + "|5vC";
string ESC_H6MAG = ESC + "|6hC";
string ESC_V6MAG = ESC + "|6vC";
string ESC_H7MAG = ESC + "|7hC";
string ESC_V7MAG = ESC + "|7vC";
string ESC_H8MAG = ESC + "|8hC";
string ESC_V8MAG = ESC + "|8vC";
string ESC_CENTER = ESC + "|cA";
string ESC_RIGHT = ESC + "|rA";
string ESC_NORMAL = ESC + "|N";
sCmdctrlTmp = "";
//정렬
switch (eAlignment)
{
case Alignment.Center: sCmdctrlTmp += ESC_CENTER; break;
case Alignment.Right: sCmdctrlTmp += ESC_RIGHT; break;
case Alignment.Left: sCmdctrlTmp += ESC_NORMAL; break;
}
//확대 Command를 설정.
//sCmdctrlTmp = GetCharactersizeCmd(eVerticalSize, eHorizontalSize);
switch (eVerticalSize)
{
case CharactersizeV.V_2: sCmdctrlTmp += ESC_V2MAG; break;
case CharactersizeV.V_3: sCmdctrlTmp += ESC_V3MAG; break;
case CharactersizeV.V_4: sCmdctrlTmp += ESC_V3MAG; break;
case CharactersizeV.V_5: sCmdctrlTmp += ESC_V4MAG; break;
case CharactersizeV.V_6: sCmdctrlTmp += ESC_V5MAG; break;
case CharactersizeV.V_7: sCmdctrlTmp += ESC_V7MAG; break;
case CharactersizeV.V_8: sCmdctrlTmp += ESC_V8MAG; break;
default: sCmdctrlTmp += ESC_V1MAG; break;
}
switch (eHorizontalSize)
{
case CharactersizeH.H_2: sCmdctrlTmp += ESC_H2MAG; break;
case CharactersizeH.H_3: sCmdctrlTmp += ESC_H3MAG; break;
case CharactersizeH.H_4: sCmdctrlTmp += ESC_H3MAG; break;
case CharactersizeH.H_5: sCmdctrlTmp += ESC_H4MAG; break;
case CharactersizeH.H_6: sCmdctrlTmp += ESC_H5MAG; break;
case CharactersizeH.H_7: sCmdctrlTmp += ESC_H7MAG; break;
case CharactersizeH.H_8: sCmdctrlTmp += ESC_H8MAG; break;
default: sCmdctrlTmp += ESC_H1MAG; break;
}
//UnderLine
if (eTextUnderLine == TextUnderLine.UnderLine)
sCmdctrlTmp += ESC_UNDERLINE;
//Bold
//if (TextBold.Bold == eBold)
// sCmdctrlTmp += ESC_BOLD;
//else
// sCmdctrlTmp += ESC_NOT_BOLD;
//Reverse
//if (TextReverseMode.ReverseMode == eTextReverseMode)
// sCmdctrlTmp += ESC_REVERSE;
//else
// sCmdctrlTmp += ESC_NOT_REVERSE;
if (sValue != "")
{
}
if (bLineFeed == true)
{
sValue = sCmdctrlTmp + sValue + "\r\n";
}
//출력
int nRet = pOPOSPrint.PrintNormal(OPOS.PTR_S_RECEIPT, sValue);
return bRet;
}
/// <summary>
/// Text Print
/// 문자열을 출력 합니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="eVerticalSize">세로확대(1배~8배)</param>
/// <param name="eHorizontalSize">가로확대(1배~8배)</param>
/// <param name="bBold">굵은글씨(BOLD)</param>
/// <param name="bUnderLine">밑줄(UnderLine)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, TextBold eBold, TextUnderLine eTextUnderLine, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, eAlignment, eVerticalSize, eHorizontalSize, eBold, eTextUnderLine, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, Alignment.Left, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="eVerticalSize">세로확대(1배~8배)</param>
/// <param name="eHorizontalSize">가로확대(1배~8배)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, eAlignment, eVerticalSize, eHorizontalSize, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// 진한문자열을 출력 할 수 있습니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="bBold">굵은글씨(BOLD)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextBold eBold, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, eBold, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// 진한문자열을 출력 할 수 있습니다.
/// </summary>
/// <param name="sValue">출력할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="bBold">굵은글씨(BOLD)</param>
/// <param name="bLineFeed">LineFeed 여부</param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextUnderLine eTextUnderLine, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, eTextUnderLine, TextReverseMode.Nomal, bLineFeed);
}
/// <summary>
/// 문자열을 출력 합니다.
/// 역상 출력을 합니다.
/// </summary>
/// <param name="sValue">출력 할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="eTextReverseMode">반전출력 모드 설정(Reverse Mode)</param>
/// <param name="bLineFeed"></param>
/// <returns></returns>
public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextReverseMode eTextReverseMode, bool bLineFeed)
{
return OposTextPrint(pOPOSPrint, sValue, Alignment.Left, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, eTextReverseMode, bLineFeed);
}
#endregion
/// <summary>
/// 문자열을 출력 합니다.
/// 역상 출력을 합니다.
/// </summary>
/// <param name="sValue">출력 할 문자</param>
/// <param name="eAlignment">정렬(Left, Center, Right)</param>
/// <param name="eTextReverseMode">반전출력 모드 설정(Reverse Mode)</param>
/// <param name="bLineFeed"></param>
/// <returns></returns>
public static bool OposBarPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue)
{
int nStat = 0;
if (sValue.Length % 2 == 0)
{
nStat = pOPOSPrint.PrintBarCode(OPOS.PTR_S_RECEIPT, sValue, OPOS.PTR_BCS_ITF, 50, 368, OPOS.PTR_BC_CENTER, OPOS.PTR_BC_TEXT_BELOW);
}
else
{
nStat = pOPOSPrint.PrintBarCode(OPOS.PTR_S_RECEIPT, "0" + sValue, OPOS.PTR_BCS_ITF, 50, 368, OPOS.PTR_BC_CENTER, OPOS.PTR_BC_TEXT_BELOW);
}
return true;
}
}
}