Пример #1
0
        public static void customDecoderInit()
        {
            Debug.WriteLine("Decoder initialization");

            //register your copy of library with given SDK key
            int registerResult = BarcodeHelper.MWBregisterSDK("SDKkey");

            if (registerResult == BarcodeHelper.MWB_RTREG_OK)
            {
                Debug.WriteLine("Registration OK");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_KEY)
            {
                Debug.WriteLine("Registration Invalid Key");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_CHECKSUM)
            {
                Debug.WriteLine("Registration Invalid Checksum");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_APPLICATION)
            {
                Debug.WriteLine("Registration Invalid Application");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_SDK_VERSION)
            {
                Debug.WriteLine("Registration Invalid SDK Version");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_KEY_VERSION)
            {
                Debug.WriteLine("Registration Invalid Key Version");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_INVALID_PLATFORM)
            {
                Debug.WriteLine("Registration Invalid Platform");
            }
            else
            if (registerResult == BarcodeHelper.MWB_RTREG_KEY_EXPIRED)
            {
                Debug.WriteLine("Registration Key Expired");
            }

            // choose code type or types you want to search for

            // Our sample app is configured by default to search all supported barcodes...
            BarcodeHelper.MWBsetActiveCodes(BarcodeHelper.MWB_CODE_MASK_25 |
                                            BarcodeHelper.MWB_CODE_MASK_39 |
                                            BarcodeHelper.MWB_CODE_MASK_93 |
                                            BarcodeHelper.MWB_CODE_MASK_128 |
                                            BarcodeHelper.MWB_CODE_MASK_AZTEC |
                                            BarcodeHelper.MWB_CODE_MASK_DM |
                                            BarcodeHelper.MWB_CODE_MASK_EANUPC |
                                            BarcodeHelper.MWB_CODE_MASK_PDF |
                                            BarcodeHelper.MWB_CODE_MASK_QR |
                                            BarcodeHelper.MWB_CODE_MASK_CODABAR |
                                            BarcodeHelper.MWB_CODE_MASK_RSS |
                                            BarcodeHelper.MWB_CODE_MASK_MAXICODE |
                                            BarcodeHelper.MWB_CODE_MASK_DOTCODE |
                                            BarcodeHelper.MWB_CODE_MASK_11 |
                                            BarcodeHelper.MWB_CODE_MASK_MSI |
                                            BarcodeHelper.MWB_CODE_MASK_POSTAL);

            // But for better performance, only activate the symbologies your application requires...
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_25 );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_39 );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_93 );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_128 );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_AZTEC );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_DM );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_EANUPC );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_PDF );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_QR );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_CODABAR );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_RSS );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_MAXICODE );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_DOTCODE );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_11 );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_MSI );
            // BarcodeHelper.MWB_setActiveCodes( BarcodeHelper.MWB_CODE_MASK_POSTAL );


            // Our sample app is configured by default to search both directions...
            BarcodeHelper.MWBsetDirection((uint)BarcodeHelper.MWB_SCANDIRECTION_HORIZONTAL | (uint)BarcodeHelper.MWB_SCANDIRECTION_VERTICAL);
            // set the scanning rectangle based on scan direction(format in pct: x, y, width, height)
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_25, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_39, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_93, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_128, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_AZTEC, RECT_FULL_2D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DM, RECT_FULL_2D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_EANUPC, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_PDF, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_QR, RECT_FULL_2D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_RSS, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_CODABAR, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DOTCODE, RECT_DOTCODE);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_11, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MSI, RECT_FULL_1D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MAXICODE, RECT_FULL_2D);
            BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_POSTAL, RECT_FULL_1D);

            // But for better performance, set like this for PORTRAIT scanning...
            // BarcodeHelper.MWB_setDirection(BarcodeHelper.MWB_SCANDIRECTION_VERTICAL);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_25, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_39, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_93, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_128, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_AZTEC, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DM, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_EANUPC, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_PDF, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_QR, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_RSS, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_CODABAR, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DOTCODE, RECT_DOTCODE);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_11, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MSI, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MAXICODE, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_POSTAL, RECT_FULL_1D);


            // or like this for LANDSCAPE scanning - Preferred for dense or wide codes...
            // BarcodeHelper.MWB_setDirection(BarcodeHelper.MWB_SCANDIRECTION_HORIZONTAL);
            // set the scanning rectangle based on scan direction(format in pct: x, y, width, height)
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_25, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_39, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_93, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_128, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_AZTEC, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DM, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_EANUPC, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_PDF, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_QR, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_RSS, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_CODABAR, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_DOTCODE, RECT_DOTCODE);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_11, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MSI, RECT_FULL_1D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_MAXICODE, RECT_FULL_2D);
            //BarcodeHelper.MWBsetScanningRect(BarcodeHelper.MWB_CODE_MASK_POSTAL, RECT_FULL_1D);

            BarcodeHelper.MWBsetMinLength(BarcodeHelper.MWB_CODE_MASK_25, 5);
            BarcodeHelper.MWBsetMinLength(BarcodeHelper.MWB_CODE_MASK_MSI, 5);
            BarcodeHelper.MWBsetMinLength(BarcodeHelper.MWB_CODE_MASK_39, 5);
            BarcodeHelper.MWBsetMinLength(BarcodeHelper.MWB_CODE_MASK_CODABAR, 5);
            BarcodeHelper.MWBsetMinLength(BarcodeHelper.MWB_CODE_MASK_11, 5);

            BarcodeHelper.MWBsetResultType(BarcodeHelper.MWB_RESULT_TYPE_MW);


            // set decoder effort level (1 - 5)
            // for live scanning scenarios, a setting between 1 to 3 will suffice
            // levels 4 and 5 are typically reserved for batch scanning
            BarcodeHelper.MWBsetLevel(2);

            //get and print Library version
            int    ver        = BarcodeHelper.MWBgetLibVersion();
            int    v1         = (ver >> 16);
            int    v2         = (ver >> 8) & 0xff;
            int    v3         = (ver & 0xff);
            String libVersion = v1.ToString() + "." + v2.ToString() + "." + v3.ToString();

            Debug.WriteLine("Lib version: " + libVersion);
        }