using System;
using System.Runtime.InteropServices;
using System.Text;


namespace BIXOLON
{
    public class MPosControllerLabelPrinter
    {
        int nBgtId;
        int ndeviceId;

        public Int32 selectInterface(int interfaceType, string address)
        {
            nBgtId = MPOSLabelPrinterLib.selectInterface(interfaceType, address);
            return nBgtId;
        }

        public Int32 selectCommandMode(int commandMode)
        {
            return MPOSLabelPrinterLib.selectCommandMode(nBgtId, commandMode);
        }

        public Int32 setTimeout(int timeout)
        {
            return MPOSLabelPrinterLib.setTimeout(nBgtId, timeout);
        }

        public Int32 openService()
        {
            Int32 ret = MPOSLabelPrinterLib.openService(nBgtId);
            if (ret == MPosConst.RES_SUCCESS || ret == MPosConst.RES_ALREADY_OPEN)
                ndeviceId = MPOSLabelPrinterLib.getDeviceId(nBgtId);

            return ret;
        }

        public Int32 openServiceById(int openDeviceId, int timeout)
        {
            Int32 ret = MPOSLabelPrinterLib.openServiceById(nBgtId, openDeviceId, timeout);
            if (ret == MPosConst.RES_SUCCESS || ret == MPosConst.RES_ALREADY_OPEN)
                ndeviceId = MPOSLabelPrinterLib.getDeviceId(nBgtId);

            return ret;
        }

        public Int32 openUSBSerial(int positionNumber)
        {
            Int32 ret = MPOSLabelPrinterLib.openUSBSerial(nBgtId, positionNumber);
            if (ret == MPosConst.RES_SUCCESS || ret == MPosConst.RES_ALREADY_OPEN)
                ndeviceId = MPOSLabelPrinterLib.getDeviceId(nBgtId);

            return ret;
        }

        public Int32 closeService(int closeTimeout)
        {
            return MPOSLabelPrinterLib.closeService(nBgtId, closeTimeout);
        }

        public Int32 lsOpen()
        {
            return MPOSLabelPrinterLib.lsOpen(nBgtId);
        }

        public Int32 getDeviceId()
        {
            return MPOSLabelPrinterLib.getDeviceId(nBgtId);
        }

        public Int32 directIO(byte[] data, int dataLength)
        {
            return MPOSLabelPrinterLib.directIO(nBgtId, data, dataLength);
        }

        public Int32 setTransaction(int transactionMode)
        {
            return MPOSLabelPrinterLib.setTransaction(nBgtId, transactionMode);
        }

        public Int32 setReadMode(int readMode)
        {
            return MPOSLabelPrinterLib.setReadMode(nBgtId, readMode);
        }

        public Int32 convertHID(int newDeviceType)
        {
            return MPOSLabelPrinterLib.convertHID(nBgtId, newDeviceType);
        }

        public Int32 setStatusUpdateEvent(MPOSLabelPrinterLib.fnStatusUpdateEventCallback StatusUpdateEventCallback)
        {
            return MPOSLabelPrinterLib.setStatusUpdateEvent(nBgtId, StatusUpdateEventCallback);
        }

        public Int32 setDataEvent(MPOSLabelPrinterLib.fnDataEventCallback DataEventCallback)
        {
            return MPOSLabelPrinterLib.setDataEvent(nBgtId, DataEventCallback);
        }

        public Int32 checkPrinterStatus()
        {
            return MPOSLabelPrinterLib.checkPrinterStatus(nBgtId);
        }

        public Int32 printBuffer(int numberOfCopies)
        {
            return MPOSLabelPrinterLib.printBuffer(nBgtId, numberOfCopies);
        }
        public Int32 printRawData(byte[] rawData, int rawDataLength)
        {
            return MPOSLabelPrinterLib.printRawData(nBgtId, rawData, rawDataLength);
        }
        public Int32 drawTextDeviceFont(string data, int xPos, int yPos, char fontSelection, int fontWidth, int fontHeight, int rightSpace, int rotation, bool reverse, bool bold, bool rightToLeft, int alignment)
        {
            return MPOSLabelPrinterLib.drawTextDeviceFont(nBgtId, data, xPos, yPos, fontSelection, fontWidth, fontHeight, rightSpace, rotation, reverse, bold, rightToLeft, alignment);
        }
        public Int32 drawTextVectorFont(string data, int xPos, int yPos, char fontSelection, int fontWidth, int fontHeight, int rightSpace, int rotation, bool reverse, bool bold, bool italic, bool rightToLeft, int alignment)
        {
            return MPOSLabelPrinterLib.drawTextVectorFont(nBgtId, data, xPos, yPos, fontSelection, fontWidth, fontHeight, rightSpace, rotation, reverse, bold, italic, rightToLeft, alignment);
        }

        public Int32 drawBarcode1D(string data, int xPos, int yPos, int barcodeType, int widthNarrow, int widthWide, int height, int hri, int quietZoneWidth, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcode1D(nBgtId, data, xPos, yPos, barcodeType, widthNarrow, widthWide, height, hri, quietZoneWidth, rotation);
        }
        public Int32 drawBarcodeMaxiCode(string data, int xPos, int yPos, int mode)
        {
            return MPOSLabelPrinterLib.drawBarcodeMaxiCode(nBgtId, data, xPos, yPos, mode);
        }
        public Int32 drawBarcodePDF417(string data, int xPos, int yPos, int rowCount, int columnCount, int eccLevel, int dataCompression, bool hri, int startPosition, int moduleWidth, int barHeight, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodePDF417(nBgtId, data, xPos, yPos, rowCount, columnCount, eccLevel, dataCompression, hri, startPosition, moduleWidth, barHeight, rotation);
        }
        public Int32 drawBarcodeQRCode(string data, int xPos, int yPos, int size, int model, int eccLevel, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeQRCode(nBgtId, data, xPos, yPos, size, model, eccLevel, rotation);
        }
        public Int32 drawBarcodeDataMatrix(string data, int xPos, int yPos, int size, bool reverse, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeDataMatrix(nBgtId, data, xPos, yPos, size, reverse, rotation);
        }
        public Int32 drawBarcodeAztec(string data, int xPos, int yPos, int size, bool extendedChannel, int eccLevel, bool menuSymbol, int numberOfSymbols, string optionalID, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeAztec(nBgtId, data, xPos, yPos, size, extendedChannel, eccLevel, menuSymbol, numberOfSymbols, optionalID, rotation);
        }
        public Int32 drawBarcodeCode49(string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int hri, int startingMode, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeCode49(nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, hri, startingMode, rotation);
        }
        public Int32 drawBarcodeCodaBlock(string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool securityLevel, int datacolumns, char mode, int encode)
        {
            return MPOSLabelPrinterLib.drawBarcodeCodaBlock(nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, securityLevel, datacolumns, mode, encode);
        }
        public Int32 drawBarcodeMicroPDF(string data, int xPos, int yPos, int moduleWidth, int height, int mode, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeMicroPDF(nBgtId, data, xPos, yPos, moduleWidth, height, mode, rotation);
        }
        public Int32 drawBarcodeIMB(string data, int xPos, int yPos, bool hri, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeIMB(nBgtId, data, xPos, yPos, hri, rotation);
        }
        public Int32 drawBarcodeMSI(string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool printCheckDigit, int hri, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeMSI(nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, printCheckDigit, hri, rotation);
        }
        public Int32 drawBarcodePlessey(string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool printCheckDigit, int hri, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodePlessey(nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, printCheckDigit, hri, rotation);
        }
        public Int32 drawBarcodeTLC39(string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int rowHeightOfMicroPDF417, int narrowWidthOfMicroPDF417, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeTLC39(nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, rowHeightOfMicroPDF417, narrowWidthOfMicroPDF417, rotation);
        }
        public Int32 drawBarcodeRSS(string data, int xPos, int yPos, int barcodeType, int magnification, int separatorHeight, int height, int segmentWidth, int rotation)
        {
            return MPOSLabelPrinterLib.drawBarcodeRSS(nBgtId, data, xPos, yPos, barcodeType, magnification, separatorHeight, height, segmentWidth, rotation);
        }
        public Int32 drawBlock(int startPosX, int startPosY, int endPosX, int endPosY, string option, int thickness)
        {
            return MPOSLabelPrinterLib.drawBlock(nBgtId, startPosX, startPosY, endPosX, endPosY, option, thickness);
        }
        public Int32 drawCircle(int startPosX, int startPosY, int size, int multiplier)
        {
            return MPOSLabelPrinterLib.drawCircle(nBgtId, startPosX, startPosY, size, multiplier);
        }
        public Int32 drawImageFile(string filename, int startPosX, int startPosY, int width, int threshold, int ditheringType, int compressType)
        {
            return MPOSLabelPrinterLib.drawImageFile(nBgtId, filename, startPosX, startPosY, width, threshold, ditheringType, compressType);
        }
        public Int32 drawBase64Image(string base64String, int startPosX, int startPosY, int width, int threshold, int ditheringType, int compressType)
        {
            return MPOSLabelPrinterLib.drawBase64Image(nBgtId, base64String, startPosX, startPosY, width, threshold, ditheringType, compressType);
        }
        public Int32 setCharacterset(int characterset, int internationalCharset)
        {
            return MPOSLabelPrinterLib.setCharacterset(nBgtId, characterset, internationalCharset);
        }
        public Int32 setPrintingType(char printingType)
        {
            return MPOSLabelPrinterLib.setPrintingType(nBgtId, printingType);
        }
        public Int32 setMargin(int horizontalMargin, int verticalMargin)
        {
            return MPOSLabelPrinterLib.setMargin(nBgtId, horizontalMargin, verticalMargin);
        }
        public Int32 setLength(int labelLength, int gapLength, string mediaType, int offsetLength)
        {
            return MPOSLabelPrinterLib.setLength(nBgtId, labelLength, gapLength, mediaType, offsetLength);
        }
        public Int32 setWidth(int labelWidth)
        {
            return MPOSLabelPrinterLib.setWidth(nBgtId, labelWidth);
        }
        public Int32 setSpeed(int speed)
        {
            return MPOSLabelPrinterLib.setSpeed(nBgtId, speed);
        }
        public Int32 setDensity(int density)
        {
            return MPOSLabelPrinterLib.setDensity(nBgtId, density);
        }
        public Int32 setOrientation(char orientation)
        {
            return MPOSLabelPrinterLib.setOrientation(nBgtId, orientation);
        }
        public Int32 setOffset(int offset)
        {
            return MPOSLabelPrinterLib.setOffset(nBgtId, offset);
        }
        public Int32 setCuttingPosition(int position)
        {
            return MPOSLabelPrinterLib.setCuttingPosition(nBgtId, position);
        }
        public Int32 setAutoCutter(bool enableAutoCutter, int cuttingPeriod)
        {
            return MPOSLabelPrinterLib.setAutoCutter(nBgtId, enableAutoCutter, cuttingPeriod);
        }
        public Int32 setRewinder(bool enable)
        {
            return MPOSLabelPrinterLib.setRewinder(nBgtId, enable);
        }
        public Int32 setupRFID(int rfidType, int numberOfRetries, int numberOfLabel, int radioPower)
        {
            return MPOSLabelPrinterLib.setupRFID(nBgtId, rfidType, numberOfRetries, numberOfLabel, radioPower);
        }
        public Int32 setEPCDataStructure(int totalSize, string fieldSizes)
        {
            return MPOSLabelPrinterLib.setEPCDataStructure(nBgtId, totalSize, fieldSizes);
        }
        public Int32 setRFIDPosition(int transPosition)
        {
            return MPOSLabelPrinterLib.setRFIDPosition(nBgtId, transPosition);
        }
        public Int32 calibrateRFID()
        {
            return MPOSLabelPrinterLib.calibrateRFID(nBgtId);
        }
        public Int32 writeRFID(int dataType, int startingBlockNumber, int dataLength, string data)
        {
            return MPOSLabelPrinterLib.writeRFID(nBgtId, dataType, startingBlockNumber, dataLength, data);
        }
        public Int32 setRFIDPassword(string oldAccessPwd, string oldKillPwd, string newAccessPwd, string newKillPwd)
        {
            return MPOSLabelPrinterLib.setRFIDPassword(nBgtId, oldAccessPwd, oldKillPwd, newAccessPwd, newKillPwd);
        }
        public Int32 lockRFID()
        {
            return MPOSLabelPrinterLib.lockRFID(nBgtId);
        }
        public string getStatisticsData(int info)
        {
            return MPOSLabelPrinterLib.getStatisticsData(nBgtId, info);
        }
        public Int32 getPrinterDPI()
        {
            return MPOSLabelPrinterLib.getPrinterDPI(nBgtId);
        }
        public Int32 getMaxWidth()
        {
            return MPOSLabelPrinterLib.getMaxWidth(nBgtId);
        }
        public string getSupportedSpeeds()
        {
            return MPOSLabelPrinterLib.getSupportedSpeeds(nBgtId);
        }
        public string getModelName()
        {
            return MPOSLabelPrinterLib.getModelName(nBgtId);
        }
        public string getFirmwareVersion()
        {
            return MPOSLabelPrinterLib.getFirmwareVersion(nBgtId);
        }               
    }


    public class MPOSLabelPrinterLib
    {
    private const string MPOS_LabePrinter_LIB_NAME = "MPosControllerLabelPrinter.dll";

        [DllImport("kernel32.dll", EntryPoint = "LoadLibrary")]
        private extern static int LoadLibrary(string librayName);

        [DllImport("kernel32.dll", EntryPoint = "GetLastError")]
        private extern static int GetLastError();

        [DllImport("kernel32.dll", EntryPoint = "GetProcAddress", CharSet = CharSet.Ansi)]
        private extern static IntPtr GetProcAddress(int hwnd, string procedureName);

        [DllImport("kernel32.dll", EntryPoint = "FreeLibrary")]
        private extern static bool FreeLibrary(int hModule);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "selectInterface")]
        public extern static Int32 selectInterface(int interfaceType, [MarshalAs(UnmanagedType.LPWStr)] string address);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "selectCommandMode")]
        public extern static Int32 selectCommandMode(int bgtId, int commandMode);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setTimeout")]
        public extern static Int32 setTimeout(int bgtId, int timeout);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "openService")]
        public extern static Int32 openService(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "openServiceById")]
        public extern static Int32 openServiceById(int bgtId, int openDeviceId, int timeout);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "openUSBSerial")]
        public extern static Int32 openUSBSerial(int bgtId, int positionNumber);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "closeService")]
        public extern static Int32 closeService(int bgtId, int closeTimeout);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "isOpen")]
        public extern static Int32 lsOpen(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getDeviceId")]
        public extern static Int32 getDeviceId(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "directIO")]
        public extern static Int32 directIO(int bgtId, byte[] data, int dataLength);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setTransaction")]
        public extern static Int32 setTransaction(int bgtId, int transactionMode);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setReadMode")]
        public extern static Int32 setReadMode(int bgtId, int readMode);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "convertHID")]
        public extern static Int32 convertHID(int bgtId, int newDeviceType);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setStatusUpdateEvent")]
        public extern static Int32 setStatusUpdateEvent(int bgtId, fnStatusUpdateEventCallback StatusUpdateEventCallback);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setDataEvent")]
        public extern static Int32 setDataEvent(int bgtId, fnDataEventCallback DataEventCallback);

        public delegate void fnStatusUpdateEventCallback(int status);
        public delegate void fnDataEventCallback([MarshalAs(UnmanagedType.LPWStr)]StringBuilder data);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "checkPrinterStatus")]
        public extern static Int32 checkPrinterStatus(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "printBuffer")]
        public extern static Int32 printBuffer(int bgtId, int numberOfCopies);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "printRawData")]
        public extern static Int32 printRawData(int bgtId, byte[] rawData, int rawDataLength);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawTextDeviceFont")]
        public extern static Int32 drawTextDeviceFont(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, char fontSelection, int fontWidth, int fontHeight, int rightSpace, int rotation, bool reverse, bool bold, bool rightToLeft, int alignment);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawTextVectorFont")]
        public extern static Int32 drawTextVectorFont(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, char fontSelection, int fontWidth, int fontHeight, int rightSpace, int rotation, bool reverse, bool bold, bool italic, bool rightToLeft, int alignment);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcode1D")]
        public extern static Int32 drawBarcode1D(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int barcodeType, int widthNarrow, int widthWide, int height,int hri, int quietZoneWidth, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeMaxiCode")]
        public extern static Int32 drawBarcodeMaxiCode(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int mode);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodePDF417")]
        public extern static Int32 drawBarcodePDF417(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int rowCount, int columnCount, int eccLevel, int dataCompression, bool hri, int startPosition, int moduleWidth, int barHeight, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeQRCode")]
        public extern static Int32 drawBarcodeQRCode(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int size, int model, int eccLevel, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeDataMatrix")]
        public extern static Int32 drawBarcodeDataMatrix(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int size, bool reverse, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeAztec")]
        public extern static Int32 drawBarcodeAztec(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int size, bool extendedChannel, int eccLevel, bool menuSymbol, int numberOfSymbols, [MarshalAs(UnmanagedType.LPWStr)] string optionalID, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeCode49")]
        public extern static Int32 drawBarcodeCode49(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int hri, int startingMode, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeCodaBlock")]
        public extern static Int32 drawBarcodeCodaBlock(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool securityLevel, int datacolumns, char mode, int encode);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeMicroPDF")]
        public extern static Int32 drawBarcodeMicroPDF(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int moduleWidth, int height, int mode, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeIMB")]
        public extern static Int32 drawBarcodeIMB(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, bool hri, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeMSI")]
        public extern static Int32 drawBarcodeMSI(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool printCheckDigit, int hri, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodePlessey")]
        public extern static Int32 drawBarcodePlessey(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, bool printCheckDigit, int hri, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeTLC39")]
        public extern static Int32 drawBarcodeTLC39(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int rowHeightOfMicroPDF417, int narrowWidthOfMicroPDF417, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBarcodeRSS")]
        public extern static Int32 drawBarcodeRSS(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string data, int xPos, int yPos, int barcodeType, int magnification, int separatorHeight, int height, int segmentWidth, int rotation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBlock")]
        public extern static Int32 drawBlock(int bgtId, int startPosX, int startPosY, int endPosX, int endPosY, [MarshalAs(UnmanagedType.LPWStr)] string option, int thickness);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawCircle")]
        public extern static Int32 drawCircle(int bgtId, int startPosX, int startPosY, int size, int multiplier);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawImageFile")]
        public extern static Int32 drawImageFile(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string filename, int startPosX, int startPosY, int width, int threshold, int ditheringType, int compressType);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "drawBase64Image")]
        public extern static Int32 drawBase64Image(int bgtId, [MarshalAs(UnmanagedType.LPWStr)] string base64String, int startPosX, int startPosY, int width, int threshold, int ditheringType, int compressType);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setCharacterset")]
        public extern static Int32 setCharacterset(int bgtId, int characterset, int internationalCharset);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setPrintingType")]
        public extern static Int32 setPrintingType(int bgtId, char printingType);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setMargin")]
        public extern static Int32 setMargin(int bgtId, int horizontalMargin, int verticalMargin);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setLength")]
        public extern static Int32 setLength(int bgtId, int labelLength, int gapLength, [MarshalAs(UnmanagedType.LPWStr)] string mediaType, int offsetLength);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setWidth")]
        public extern static Int32 setWidth(int bgtId, int labelWidth);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setSpeed")]
        public extern static Int32 setSpeed(int bgtId, int speed);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setDensity")]
        public extern static Int32 setDensity(int bgtId, int density);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setOrientation")]
        public extern static Int32 setOrientation(int bgtId, char orientation);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setOffset")]
        public extern static Int32 setOffset(int bgtId, int offset);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setCuttingPosition")]
        public extern static Int32 setCuttingPosition(int bgtId, int position);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setAutoCutter")]
        public extern static Int32 setAutoCutter(int bgtId, bool enableAutoCutter, int cuttingPeriod);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setRewinder")]
        public extern static Int32 setRewinder(int bgtId, bool enable);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setupRFID")]
        public extern static Int32 setupRFID(int bgtId, int rfidType, int numberOfRetries, int numberOfLabel, int radioPower);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setEPCDataStructure")]
        public extern static Int32 setEPCDataStructure(int bgtId, int totalSize, [MarshalAs(UnmanagedType.LPWStr)] string fieldSizes);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setRFIDPosition")]
        public extern static Int32 setRFIDPosition(int bgtId, int transPosition);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "calibrateRFID")]
        public extern static Int32 calibrateRFID(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "writeRFID")]
        public extern static Int32 writeRFID(int bgtId, int dataType, int startingBlockNumber, int dataLength, [MarshalAs(UnmanagedType.LPWStr)] string data);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "setRFIDPassword")]
        public extern static Int32 setRFIDPassword(int bgtId, string oldAcessPwd, string oldKillPwd, string newAccessPwd, string newKillPwd);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "lockRFID")]
        public extern static Int32 lockRFID(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getStatisticsData")]
        public extern static string getStatisticsData(int bgtId, int info);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getPrinterDPI")]
        public extern static Int32 getPrinterDPI(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getMaxWidth")]
        public extern static Int32 getMaxWidth(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getSupportedSpeeds")]
        public extern static  string getSupportedSpeeds(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getModelName")]
        public extern static string getModelName(int bgtId);

        [DllImport(MPOS_LabePrinter_LIB_NAME, EntryPoint = "getFirmwareVersion")]
        public extern static string getFirmwareVersion(int bgtId);
    }
}
