Exemplo n.º 1
0
        /// <summary>
        /// Get List of Available Card Printers
        /// </summary>
        private string getDeviceList()
        {
            // get device list
            deviceList_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SmartComm2.SMART_PRINTER_LIST)));
            int convertedPointer = (int)deviceList_ptr.ToInt64();

            printerresponse = SmartComm2.SmartComm_GetDeviceList2((long)deviceList_ptr);
            object listUndefined = Marshal.PtrToStructure(deviceList_ptr, typeof(SmartComm2.SMART_PRINTER_LIST));

            deviceList = (SmartComm2.SMART_PRINTER_LIST)listUndefined;

            if (printerresponse != SmartComm2.SM_SUCCESS)
            {
                Marshal.FreeHGlobal(deviceList_ptr);
            }

            int i;

            SmartComm2.SMART_PRINTER_ITEM smartItem = deviceList.item[0];

            for (i = 0; i <= deviceList.n - 1; i++)
            {
                printerStrDescription = new string(deviceList.item[i].desc);
            }

            Marshal.FreeHGlobal(deviceList_ptr);
            return(printerStrDescription);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prints a card using the first printer on the card printer device list.
        /// </summary>
        public void PrintCard()
        {
            string strDesc = "";
            IntPtr strDesc_ptr;
            int    nres;
            IntPtr hsmart_ptr;

            SmartComm2.SMART_PRINTER_INFO DevInfo;
            IntPtr DevInfo_ptr;

            nres = AllocateCardprinter();

            if (nres != SmartComm2.SM_SUCCESS)
            {
                Marshal.FreeHGlobal(deviceList_ptr);
                return;
            }
            else
            {
                printerStatus = "no printer";
            }

            int i;

            SmartComm2.SMART_PRINTER_ITEM smartItem = deviceList.item[0];

            for (i = 0; i <= deviceList.n - 1; i++)
            {
                printerStatus = "Ready for printing";
                strDesc       = new string(deviceList.item[i].desc);
            }

            Marshal.FreeHGlobal(deviceList_ptr);
            printerStatus = "Preparing device";

            int devGroup;

            AquireDeviceInformation(strDesc, out strDesc_ptr, out nres, out DevInfo, out DevInfo_ptr, out devGroup);

            nres = 111111;
            try
            {
                OpenCardprinter(strDesc_ptr, out nres, out hsmart_ptr);

                nres = EnterSBSMode(nres);

                //SetPrinterStatus(nres);

                nres = PullCardIntoCardprinter(nres);

                //SetPrinterStatus(nres);

                nres = PrepareCardforPrinting(nres);

                //SetPrinterStatus(nres);

                nres = UpdatePrinterSettings(nres, DevInfo, devGroup);

                //SetPrinterStatus(nres);

                nres = PrepareCardText(nres);

                //SetPrinterStatus(nres);

                nres = PrintCard(nres, DevInfo);

                //SetPrinterStatus(nres);

                nres = CompleteFrontPrint(nres);

                nres = RotateCardifPossible(nres, DevInfo);

                //SetPrinterStatus(nres);

                nres = ClosePrintDocument(nres);

                //SetPrinterStatus(nres);

                nres = PresetCard(nres);

                //SetPrinterStatus(nres);

                nres = LeaveSBSMode(nres);

                //SetPrinterStatus(nres);
            }
            catch
            {
                throw;
            }
        }