}//Encode()

        /// <summary>
        /// Encodes the raw data into binary form representing bars and spaces.
        /// </summary>
        internal Image Encode()
        {
            DateTime dtStartTime = DateTime.Now;

            //make sure there is something to encode
            if (Raw_Data.Trim() == "")
            {
                throw new System.Exception("EENCODE-1: Input data not allowed to be blank.");
            }

            if (this.EncodedType == EncodingType.UNSPECIFIED)
            {
                throw new System.Exception("EENCODE-2: Symbology type not allowed to be unspecified.");
            }

            this.Encoded_Value = "";
            this._Country_Assigning_Manufacturer_Code = "N/A";

            IBarcode ibarcode;

            switch (this.Encoded_Type)
            {
            case EncodingType.UCC12:
            case EncodingType.UPCA:     //Encode_UPCA();
                ibarcode = new UPCA(Raw_Data);
                break;

            case EncodingType.UCC13:
            case EncodingType.EAN13:     //Encode_EAN13();
                ibarcode = new EAN13(Raw_Data);
                break;

            case EncodingType.Interleaved2of5:     //Encode_Interleaved2of5();
                ibarcode = new Interleaved2of5(Raw_Data);
                break;

            case EncodingType.Industrial2of5:
            case EncodingType.Standard2of5:     //Encode_Standard2of5();
                ibarcode = new Standard2of5(Raw_Data);
                break;

            case EncodingType.LOGMARS:
            case EncodingType.CODE39:     //Encode_Code39();
                ibarcode = new Code39(Raw_Data);
                break;

            case EncodingType.CODE39Extended:
                ibarcode = new Code39(Raw_Data, true);
                break;

            case EncodingType.Codabar:     //Encode_Codabar();
                ibarcode = new Codabar(Raw_Data);
                break;

            case EncodingType.PostNet:     //Encode_PostNet();
                ibarcode = new Postnet(Raw_Data);
                break;

            case EncodingType.ISBN:
            case EncodingType.BOOKLAND:     //Encode_ISBN_Bookland();
                ibarcode = new ISBN(Raw_Data);
                break;

            case EncodingType.JAN13:     //Encode_JAN13();
                ibarcode = new JAN13(Raw_Data);
                break;

            case EncodingType.UPC_SUPPLEMENTAL_2DIGIT:     //Encode_UPCSupplemental_2();
                ibarcode = new UPCSupplement2(Raw_Data);
                break;

            case EncodingType.MSI_Mod10:
            case EncodingType.MSI_2Mod10:
            case EncodingType.MSI_Mod11:
            case EncodingType.MSI_Mod11_Mod10:
            case EncodingType.Modified_Plessey:     //Encode_MSI();
                ibarcode = new MSI(Raw_Data, Encoded_Type);
                break;

            case EncodingType.UPC_SUPPLEMENTAL_5DIGIT:     //Encode_UPCSupplemental_5();
                ibarcode = new UPCSupplement5(Raw_Data);
                break;

            case EncodingType.UPCE:     //Encode_UPCE();
                ibarcode = new UPCE(Raw_Data);
                break;

            case EncodingType.EAN8:     //Encode_EAN8();
                ibarcode = new EAN8(Raw_Data);
                break;

            case EncodingType.USD8:
            case EncodingType.CODE11:     //Encode_Code11();
                ibarcode = new Code11(Raw_Data);
                break;

            case EncodingType.CODE128:     //Encode_Code128();
                ibarcode = new Code128(Raw_Data);
                break;

            case EncodingType.CODE128A:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.A);
                break;

            case EncodingType.CODE128B:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.B);
                break;

            case EncodingType.CODE128C:
                ibarcode = new Code128(Raw_Data, Code128.TYPES.C);
                break;

            case EncodingType.ITF14:
                ibarcode = new ITF14(Raw_Data);
                break;

            case EncodingType.CODE93:
                ibarcode = new Code93(Raw_Data);
                break;

            default: throw new System.Exception("EENCODE-2: Unsupported encoding type specified.");
            }//switch

            this.Encoded_Value  = ibarcode.Encoded_Value;
            this.Raw_Data       = ibarcode.RawData;
            this.Formatted_Data = ibarcode.FormattedData;
            this._EncodingTime  = ((TimeSpan)(DateTime.Now - dtStartTime)).TotalMilliseconds;

            _Encoded_Image = (Image)Generate_Image();

            _XML = GetXML();

            return(EncodedImage);
        }//Encode
示例#2
0
        private static string GetSymbology(string Data, Enums.Type EncodingType)
        {
            ISymbology SymbologyUsing = null;

            switch (EncodingType)
            {
            case Enums.Type.UCC12:
            case Enums.Type.UPCA:
                SymbologyUsing = new UPCA(Data);
                break;

            case Enums.Type.UCC13:
            case Enums.Type.EAN13:
                SymbologyUsing = new EAN13(Data);
                break;

            case Enums.Type.Interleaved2of5:
                SymbologyUsing = new Interleaved2of5(Data);
                break;

            case Enums.Type.Industrial2of5:
            case Enums.Type.Standard2of5:
                SymbologyUsing = new Standard2of5(Data);
                break;

            case Enums.Type.LOGMARS:
            case Enums.Type.CODE39:
                SymbologyUsing = new Code39(Data);
                break;

            case Enums.Type.CODE39Extended:
                SymbologyUsing = new Code39(Data);
                break;

            case Enums.Type.Codabar:
                SymbologyUsing = new Codabar(Data);
                break;

            case Enums.Type.PostNet:
                SymbologyUsing = new Postnet(Data);
                break;

            case Enums.Type.ISBN:
            case Enums.Type.BOOKLAND:
                SymbologyUsing = new ISBN(Data);
                break;

            case Enums.Type.JAN13:
                SymbologyUsing = new JAN13(Data);
                break;

            case Enums.Type.UPC_SUPPLEMENTAL_2DIGIT:
                SymbologyUsing = new UPCSupplement2(Data);
                break;

            case Enums.Type.MSI_Mod10:
            case Enums.Type.MSI_2Mod10:
            case Enums.Type.MSI_Mod11:
            case Enums.Type.MSI_Mod11_Mod10:
            case Enums.Type.Modified_Plessey:
                SymbologyUsing = new MSI(Data);
                break;

            case Enums.Type.UPC_SUPPLEMENTAL_5DIGIT:
                SymbologyUsing = new UPCSupplement5(Data);
                break;

            case Enums.Type.UPCE:
                SymbologyUsing = new UPCE(Data);
                break;

            case Enums.Type.EAN8:
                SymbologyUsing = new EAN8(Data);
                break;

            case Enums.Type.USD8:
            case Enums.Type.CODE11:
                SymbologyUsing = new Code11(Data);
                break;

            case Enums.Type.CODE128:
                SymbologyUsing = new Code128(Data);
                break;

            case Enums.Type.CODE128A:
                SymbologyUsing = new Code128A(Data);
                break;

            case Enums.Type.CODE128B:
                SymbologyUsing = new Code128B(Data);
                break;

            case Enums.Type.CODE128C:
                SymbologyUsing = new Code128C(Data);
                break;

            case Enums.Type.ITF14:
                SymbologyUsing = new ITF14(Data);
                break;

            case Enums.Type.CODE93:
                SymbologyUsing = new Code93(Data);
                break;

            case Enums.Type.TELEPEN:
                SymbologyUsing = new Telepen(Data);
                break;
            }
            return(SymbologyUsing.Encode());
        }