#include "stdafx.h"
#include "MPosControllerPrinter.h"

//////////////////////////////////////////////////////////////////////////

CMPosControllerPrinter::CMPosControllerPrinter()
: CMPosControllerDevices(_T("MPosControllerPrinter.dll"))
{
	LoadDll();
}

CMPosControllerPrinter::~CMPosControllerPrinter()
{
}

bool CMPosControllerPrinter::LoadDll()
{ 	
	if(m_hDll == 0)
		return FALSE;

	fprintText						= (pPrintText)GetProcAddress(m_hDll, "printText");
	fprintBitmapFile				= (pPrintBitmapFile)GetProcAddress(m_hDll, "printBitmapFile");
	fprintImageFile					= (pPrintImageFile)GetProcAddress(m_hDll, "printImageFile");
	fprintImage						= (pPrintImage)GetProcAddress(m_hDll, "printImage");
	fprintBase64Image				= (pPrintBase64Image)GetProcAddress(m_hDll, "printBase64Image");

	fprint1DBarcode					= (pPrint1DBarcode)GetProcAddress(m_hDll, ("print1DBarcode"));
	fprintQRCode					= (pPrintQRCode)GetProcAddress(m_hDll, ("printQRCode"));
	fprintPDF417					= (pPrintPDF417)GetProcAddress(m_hDll, ("printPDF417"));
	fprintDataMatrix				= (pPrintDataMatrix)GetProcAddress(m_hDll, ("printDataMatrix"));
	fprintGS1Databar				= (pPrintGS1Databar)GetProcAddress(m_hDll, ("printGS1Databar"));
	fprintGS1DatabarMobile			= (pPrintGS1DatabarMobile)GetProcAddress(m_hDll, ("printGS1DatabarMobile"));
	fprintCompositeSymbology		= (pPrintCompositeSymbology)GetProcAddress(m_hDll, ("printCompositeSymbology"));
	fprintMaxicode					= (pPrintMaxicode)GetProcAddress(m_hDll, ("printMaxicode"));
	fprintAztec						= (pPrintAztec)GetProcAddress(m_hDll, ("printAztec"));

	fsetCharacterset				= (pSetCharacterset)GetProcAddress(m_hDll, "setCharacterset");
	fsetInternationalCharacterset	= (pSetInternationalCharacterset)GetProcAddress(m_hDll, "setInternationalCharacterset");
	fcutPaper						= (pCutPaper)GetProcAddress(m_hDll, "cutPaper");

	fsetPagemode					= (pSetPagemode)GetProcAddress(m_hDll, "setPagemode");
	fsetPagemodePrintArea			= (pSetPagemodePrintArea)GetProcAddress(m_hDll, "setPagemodePrintArea");
	fsetPagemodeDirection			= (pSetPagemodeDirection)GetProcAddress(m_hDll, "setPagemodeDirection");
	fsetPagemodePosition			= (pSetPagemodePosition)GetProcAddress(m_hDll, "setPagemodePosition");
	fprintLine						= (pPrintLine)GetProcAddress(m_hDll, "printLine");
	fprintBox						= (pPrintBox)GetProcAddress(m_hDll, "printBox");

	fasbEnable						= (pasbEnable)GetProcAddress(m_hDll, "asbEnable");

	fgetModelName					= (pgetModelName)GetProcAddress(m_hDll, "getModelName");
	fgetFirmwareVersion				= (pgetFirmwareVersion)GetProcAddress(m_hDll, "getFirmwareVersion");

	fdisplayString					= (pDisplayString)GetProcAddress(m_hDll, ("displayString"));
	fclearScreen					= (pClearScreen)GetProcAddress(m_hDll, ("clearScreen"));
	fstoreImageFile 				= (pStoreImageFile)GetProcAddress(m_hDll, ("storeImageFile"));
	fdisplayImage					= (pDisplayImage)GetProcAddress(m_hDll, ("displayImage"));
	fclearImage						= (pClearImage)GetProcAddress(m_hDll, ("clearImage"));
	fshowCursor						= (pShowCursor)GetProcAddress(m_hDll, ("showCursor"));

	return TRUE;
}

int CMPosControllerPrinter::printText(LPCWSTR data, int fontType, int fontWidth, int fontHeight, int bold, int underline, int reverse, int alignment)
{
	return fprintText(m_nBgtId, data, fontType, fontWidth, fontHeight, bold, underline, reverse, alignment);
}

int CMPosControllerPrinter::printBitmapFile(LPCWSTR filename, int width, int alignment, int brightness, BOOL isDithering, BOOL isCompress)
{
	return fprintBitmapFile(m_nBgtId, filename, width, alignment, brightness, isDithering, isCompress);
}

int CMPosControllerPrinter::printImageFile(LPCWSTR filename, int width, int alignment, int threshold, int ditheringType, int compressType)
{
	return fprintImageFile(m_nBgtId, filename, width, alignment, threshold, ditheringType, compressType);
}

int CMPosControllerPrinter::printImage(char* image, int imageLength, int width, int alignment, int threshold, int ditheringType, int compressType)
{
	return fprintImage(m_nBgtId, image, imageLength, width, alignment, threshold, ditheringType, compressType);
}

int CMPosControllerPrinter::printBase64Image(LPCWSTR base64String, int width, int alignment, int threshold, int ditheringType, int compressType)
{
	return fprintBase64Image(m_nBgtId, base64String, width, alignment, threshold, ditheringType, compressType);
}

int CMPosControllerPrinter::print1DBarcode(LPCWSTR data, int symbology, int barWidth, int height, int alignment, int textPosition)
{
	return fprint1DBarcode(m_nBgtId, data, symbology, barWidth, height, alignment, textPosition);
}

int CMPosControllerPrinter::printQRCode(LPCWSTR data, int model, int alignment, int moduleSize, int eccLevel)
{
	return fprintQRCode(m_nBgtId, data, model, alignment, moduleSize, eccLevel);
}

int CMPosControllerPrinter::printPDF417(LPCWSTR data, int symbol, int alignment, int columnNumber, int rowNumber, int moduleWidth, int moduleHeight, int eccLevel)
{
	return fprintPDF417(m_nBgtId, data, symbol, alignment, columnNumber, rowNumber, moduleWidth, moduleHeight, eccLevel);
}

int CMPosControllerPrinter::printDataMatrix(LPCWSTR data, int alignment, int moduleSize)
{
	return fprintDataMatrix(m_nBgtId, data, alignment, moduleSize);
}

int CMPosControllerPrinter::printGS1Databar(LPCWSTR data, int symbol, int alignment, int size)
{
	return fprintGS1Databar(m_nBgtId, data, symbol, alignment, size);
}

int CMPosControllerPrinter::printGS1DatabarMobile(LPCWSTR data, int symbol, int alignment, int moduleWidth, int moduleHeight, int segmentHeight, int separatorHeight)
{
	return fprintGS1DatabarMobile(m_nBgtId, data, symbol, alignment, moduleWidth, moduleHeight, segmentHeight, separatorHeight);
}

int CMPosControllerPrinter::printCompositeSymbology(LPCWSTR data, LPCWSTR cData, int symbol, int cSymbol, int alignment, int size)
{
	return fprintCompositeSymbology(m_nBgtId, data, cData, symbol, cSymbol, alignment, size);
}

int CMPosControllerPrinter::printMaxicode(LPCWSTR data, int mode, int alignment)
{
	return fprintMaxicode(m_nBgtId, data, mode, alignment);
}

int CMPosControllerPrinter::printAztec(LPCWSTR data, int alignment, int moduleSize, int eccLevel, int mode)
{
	return fprintAztec(m_nBgtId, data, alignment, moduleSize, eccLevel, mode);
}

int CMPosControllerPrinter::setCharacterset(int characterset)
{
	return fsetCharacterset(m_nBgtId, characterset);
}

int CMPosControllerPrinter::setInternationalCharacterset(int internationalCharset)
{
	return fsetInternationalCharacterset(m_nBgtId, internationalCharset);
}

int CMPosControllerPrinter::cutPaper(int cutType)
{
	return fcutPaper(m_nBgtId, cutType);
}

int CMPosControllerPrinter::setPagemode(int mode)
{
	return fsetPagemode(m_nBgtId, mode);
}

int CMPosControllerPrinter::setPagemodePrintArea(int x, int y, int width, int height)
{
	return fsetPagemodePrintArea(m_nBgtId, x, y, width, height);
}

int CMPosControllerPrinter::setPagemodeDirection(int direction)
{
	return fsetPagemodeDirection(m_nBgtId, direction);
}

int CMPosControllerPrinter::setPagemodePosition(int x, int y)
{
	return fsetPagemodePosition(m_nBgtId, x, y);
}

int CMPosControllerPrinter::printLine(int x1, int y1, int x2, int y2, int thickness)
{
	return fprintLine(m_nBgtId, x1, y1, x2, y2, thickness);
}

int CMPosControllerPrinter::printBox(int left, int top, int right, int bottom, int thickness)
{
	return fprintBox(m_nBgtId, left, top, right, bottom, thickness);
}

int CMPosControllerPrinter::asbEnable(bool enable)
{
	return fasbEnable(m_nBgtId, enable);
}

LPCTSTR CMPosControllerPrinter::getModelName()
{
	return fgetModelName(m_nBgtId);
}

LPCTSTR CMPosControllerPrinter::getFirmwareVersion()
{
	return fgetFirmwareVersion(m_nBgtId);
}

int CMPosControllerPrinter::displayString(LPCTSTR data, int codePage, int internationalCharacterSet, int line)
{
	return fdisplayString(m_nBgtId, data, codePage, internationalCharacterSet, line);
}

int CMPosControllerPrinter::clearScreen()
{	
	return fclearScreen(m_nBgtId);
}

int CMPosControllerPrinter::storeImageFile(LPCTSTR filename, int width, int imageNumber)
{
	return fstoreImageFile(m_nBgtId, filename, width, imageNumber);
}

int CMPosControllerPrinter::displayImage(int imageNumber, int xPos, int yPos)
{
	return fdisplayImage(m_nBgtId, imageNumber, xPos, yPos);
}

int CMPosControllerPrinter::clearImage(int imageNumber)
{
	return fclearImage(m_nBgtId, imageNumber);
}

int CMPosControllerPrinter::showCursor(int cursor)
{
	return fshowCursor(m_nBgtId, cursor);
}