Ejemplo n.º 1
0
        protected override void OnSetRenderInfo(BarcodeConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            string toEncode = newToken.TextToEncode;
            int    encoding = newToken.EncodingType;
            bool   colorsBW = newToken.ColorsBW;

            Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt();

            ColorBgra primary;
            ColorBgra secondary;

            if (colorsBW)
            {
                primary   = Color.Black;
                secondary = Color.White;
            }
            else
            {
                primary   = EnvironmentParameters.PrimaryColor;
                secondary = EnvironmentParameters.SecondaryColor;
            }

            switch (encoding)
            {
            case CODE_39:
                barcode = Code39.CreateCode39(selection, srcArgs.Surface, toEncode, primary, secondary);
                break;

            case CODE_39_MOD_43:
                barcode = Code39.CreateCode39mod43(selection, srcArgs.Surface, toEncode, primary, secondary);
                break;

            case FULL_ASCII_CODE_39:
                barcode = Code39.CreateFullAsciiCode39(selection, srcArgs.Surface, toEncode, primary, secondary);
                break;

            case POSTNET:
                barcode = Postnet.Create(selection, srcArgs.Surface, toEncode, primary, secondary);
                break;

            case UPCA:
                barcode = UPCa.Create(selection, srcArgs.Surface, toEncode, primary, secondary);
                break;
            }
        }
Ejemplo n.º 2
0
        internal static bool ValidateText(string text, int encoding)
        {
            switch (encoding)
            {
            case CODE_39:
                return(Code39.ValidateCode39(text));

            case CODE_39_MOD_43:
                return(Code39.ValidateCode39mod43(text));

            case FULL_ASCII_CODE_39:
                return(Code39.ValidateFullAsciiCode39(text));

            case POSTNET:
                return(Postnet.Validate(text));

            case UPCA:
                return(UPCa.Validate(text));

            default:
                return(false);
            }
        }