Exemplo n.º 1
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            codes.Add(STARTMARKER);
            for (int i = 0; i < value.Length; i += 2)
            {
                codes.Add(int.Parse(value.Substring(i, 2)));
            }

            codes.Add(ENDMARKER);

            return codes;
        }
Exemplo n.º 2
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            codes.Add(STARTMARKER);
            for (int i = 0; i < value.Length; i += 2)
            {
                codes.Add(int.Parse(value.Substring(i, 2)));
            }

            codes.Add(ENDMARKER);

            return(codes);
        }
Exemplo n.º 3
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            codes.Insert(0, START);
            codes.Add(STOP);

            return(value);
        }
Exemplo n.º 4
0
        public override CodedValueCollection GetCodes(string value)
        {
            var result = new CodedValueCollection();

            for (int i = 0; i < value.Length; i++)
            {
                result.Add(int.Parse(value.Substring(i, 1)));
            }

            result.Insert(0, START);
            result.Add(STOP);

            return(result);
        }
Exemplo n.º 5
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            codes.Insert(0, START);
            codes.Add(STOP);

            return value;
        }
Exemplo n.º 6
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            foreach (var item in value.ToCharArray())
            {
                codes.Add(item);
            }

            codes.Insert(0, START);
            codes.Add(STOP);

            return(value);
        }
Exemplo n.º 7
0
        public override CodedValueCollection GetCodes(string value)
        {
            var result = new CodedValueCollection();

            for (int i = 0; i < value.Length; i++)
            {
                result.Add(int.Parse(value.Substring(i, 1)));
            }

            result.Insert(0, START);
            result.Add(STOP);

            return result;
        }
Exemplo n.º 8
0
        protected static string DoChecksumCalculation(string value, int factor, CodedValueCollection codes)
        {
            int tmp    = 0;
            int weight = 0;

            for (int i = 0; i < value.Length; i++)
            {
                weight = ((value.Length - i) % factor);
                if (weight == 0)
                {
                    weight = factor;
                }
                tmp += ((value[i] == '-' ? 10 : int.Parse(value.Substring(i, 1))) * weight);
            }

            tmp    = tmp % 11;
            value += tmp > 9 ? "-" : tmp.ToString();
            if (codes != null)
            {
                if (codes.Last() == LIMIT)
                {
                    codes.Insert(codes.Count - 1, tmp > 9 ? '-' : tmp + '0');
                }
                else
                {
                    codes.Add(tmp > 9 ? '-' : tmp + '0');
                }
            }

            return(value);
        }
Exemplo n.º 9
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            value = value.Replace(" ", "").Replace("-", "");

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            codes.Insert(0, STARTSTOP);
            codes.Add(STARTSTOP);

            return codes;
        }
Exemplo n.º 10
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            value = value.Replace(" ", "").Replace("-", "");

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            codes.Insert(0, STARTSTOP);
            codes.Add(STARTSTOP);

            return(codes);
        }
Exemplo n.º 11
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            value = value.Replace(" ", "").ToUpper();

            var index = ToBinary(ParsePair(value.Substring(0, 2)), 0, 8, codes);

            index = ToBinary(_Lookup[value.Substring(2, 1)], index, 5, codes);
            index = ToBinary(_Lookup[value.Substring(3, 1)], index, 4, codes);
            ToBinary(ParsePair(value.Substring(4, 2)), index, 8, codes);

            int p = codes.Sum() + 1;

            codes.Add(ALIGNMENTBAR);
            if (p % 2 == 0)
            {
                codes.Insert(0, ALIGNMENTBAR);
            }
            else
            {
                codes.Insert(0, ODDCOUNT);
            }

            return(codes);
        }
Exemplo n.º 12
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            if (!IsValidData(value))
                throw new ApplicationException();

            codes.Add(STARTMARKER);

            for (int i = 0; i < value.Length; i+=2)
            {
                codes.Add(int.Parse(value.Substring(i, 2)));
            }

            codes.Add(ENDMARKER);

            return value;
        }
Exemplo n.º 13
0
        public override string AddChecksum(string value, CodedValueCollection codes)
        {
            if (codes.Count == 13)
            {
                return(value);
            }

            int total = 0;

            for (int i = 0; i < codes.Count; i++)
            {
                if (i % 2 == 0)
                {
                    total += (codes[i] % 10);
                }
                else
                {
                    total += 3 * (codes[i] % 10);
                }
            }

            total = total % 10;
            codes.Add(total == 0 ? 20 : 30 - total);

            return(value + (total == 0 ? 0 : 10 - total).ToString());
        }
Exemplo n.º 14
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.Replace(" ", "").ToUpper();
            if (!IsValidData(value))
                throw new ApplicationException("The data was not valid.");

            int tmp = ParsePair(value.Substring(0, 2));
            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            tmp = _Lookup[value.Substring(2, 1)];
            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            codes.Add(_Lookup[value.Substring(3, 1)]);

            tmp = ParsePair(value.Substring(4, 2));
            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            int p = 1;
            foreach (int item in codes)
            {
                p += PatternSet[item].BlackCount;
            }

            codes.Add(ALIGNMENTBAR);
            if (p % 2 == 0)
                codes.Insert(0, ALIGNMENTBAR);
            else
                codes.Insert(0, ODDCOUNT);

            return null;
        }
Exemplo n.º 15
0
 public virtual CodedValueCollection GetCodes(string value)
 {
     var result = new CodedValueCollection();
     foreach (var item in value)
     {
         result.Add(item);
     }
     return result;
 }
Exemplo n.º 16
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            if (!IsValidData(value))
            {
                throw new ApplicationException();
            }

            codes.Add(STARTMARKER);

            for (int i = 0; i < value.Length; i += 2)
            {
                codes.Add(int.Parse(value.Substring(i, 2)));
            }

            codes.Add(ENDMARKER);

            return(value);
        }
Exemplo n.º 17
0
        public virtual CodedValueCollection GetCodes(string value)
        {
            var result = new CodedValueCollection();

            foreach (var item in value)
            {
                result.Add(item);
            }
            return(result);
        }
Exemplo n.º 18
0
        public override string AddChecksum(string value, CodedValueCollection codes)
        {
            codes.RemoveAt(codes.Count - 1);

            value = DoChecksumCalculation(value, 10, codes);

            if (value.Length >= 10)
                value = DoChecksumCalculation(value, 9,codes);

            codes.Add(LIMIT);

            return value;
        }
Exemplo n.º 19
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            CalculateParity(codes);

            return(value);
        }
Exemplo n.º 20
0
        public virtual CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));
            }

            CalculateParity(codes);

            return(codes);
        }
Exemplo n.º 21
0
        public virtual CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            for (int i = 0; i < value.Length; i++)
            {
                codes.Add(int.Parse(value.Substring(i, 1)));

            }

            CalculateParity(codes);

            return codes;
        }
Exemplo n.º 22
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.ToLower();
            string tmp = value.Replace(" ", "");

            tmp = base.ParseText(tmp, codes);

            foreach (char item in tmp.ToCharArray())
            {
                codes.Add(item);
            }

            return(value.Substring(1, value.Length - 2));
        }
Exemplo n.º 23
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.Trim('*');
            if (!IsValidData(value))
                throw new ApplicationException("Invalid data for this barcode.");

            value = "*" + value.ToUpper() + "*";

            foreach (char item in value.ToCharArray())
            {
                codes.Add(item);
            }

            return value;
        }
Exemplo n.º 24
0
        public override string AddChecksum(string value, CodedValueCollection codes)
        {
            codes.RemoveAt(codes.Count - 1);

            value = DoChecksumCalculation(value, 10, codes);

            if (value.Length >= 10)
            {
                value = DoChecksumCalculation(value, 9, codes);
            }

            codes.Add(LIMIT);

            return(value);
        }
Exemplo n.º 25
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            if (!IsValidData(value))
            {
                throw new ApplicationException();
            }

            string tmp = string.Format("{1}{0}{1}", value, (char)LIMIT);

            foreach (char item in tmp.ToCharArray())
            {
                codes.Add(item);
            }

            return(value);
        }
Exemplo n.º 26
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.Trim('*');
            if (!IsValidData(value))
            {
                throw new ApplicationException("Invalid data for this barcode.");
            }

            value = "*" + value.ToUpper() + "*";

            foreach (char item in value.ToCharArray())
            {
                codes.Add(item);
            }

            return(value);
        }
Exemplo n.º 27
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.Replace(" ", "").ToUpper();
            if (!IsValidData(value))
            {
                throw new ApplicationException("The data was not valid.");
            }

            int tmp = ParsePair(value.Substring(0, 2));

            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            tmp = _Lookup[value.Substring(2, 1)];
            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            codes.Add(_Lookup[value.Substring(3, 1)]);

            tmp = ParsePair(value.Substring(4, 2));
            codes.Add(tmp / 0x10);
            codes.Add(tmp % 0x10);

            int p = 1;

            foreach (int item in codes)
            {
                p += PatternSet[item].BlackCount;
            }

            codes.Add(ALIGNMENTBAR);
            if (p % 2 == 0)
            {
                codes.Insert(0, ALIGNMENTBAR);
            }
            else
            {
                codes.Insert(0, ODDCOUNT);
            }

            return(null);
        }
Exemplo n.º 28
0
		public override string AddChecksum(string value, CodedValueCollection codes)
		{
			if (codes.Count == 13)
				return value;

			int total = 0;
			for (int i = 0; i < codes.Count; i++)
			{
				if (i % 2 == 0)
					total += (codes[i] % 10);
				else
					total += 3 * (codes[i] % 10);
			}

			total = total % 10;
			codes.Add(total == 0 ? 20 : 30 - total);
			
			return value + (total == 0 ? 0 : 10 - total).ToString();
		}
Exemplo n.º 29
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            value = value.Replace(" ", "").ToUpper();

            var index = ToBinary(ParsePair(value.Substring(0, 2)), 0, 8, codes);
            index = ToBinary(_Lookup[value.Substring(2, 1)], index, 5, codes);
            index = ToBinary(_Lookup[value.Substring(3, 1)], index, 4, codes);
            ToBinary(ParsePair(value.Substring(4, 2)), index, 8, codes);

            int p = codes.Sum() + 1;
            codes.Add(ALIGNMENTBAR);
            if (p % 2 == 0)
                codes.Insert(0, ALIGNMENTBAR);
            else
                codes.Insert(0, ODDCOUNT);

            return codes;
        }
Exemplo n.º 30
0
        protected static string DoChecksumCalculation(string value, int factor, CodedValueCollection codes)
        {
            int tmp = 0;
            int weight = 0;
            for (int i = 0; i < value.Length; i++)
            {
                weight = ((value.Length - i) % factor);
                if (weight == 0)
                    weight = factor;
                tmp += ((value[i] == '-' ? 10 : int.Parse(value.Substring(i, 1))) * weight);
            }

            tmp = tmp % 11;
            value += tmp > 9 ? "-" : tmp.ToString();
            if (codes != null)
            {
                if (codes.Last() == LIMIT)
                    codes.Insert(codes.Count - 1, tmp > 9 ? '-' : tmp + '0');
                else
                    codes.Add(tmp > 9 ? '-' : tmp + '0');
            }

            return value;
        }
Exemplo n.º 31
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();
            foreach (char item in value.ToCharArray())
            {
                if (item == ' ')
                    codes.Add(38);
                else if (item == '$')
                    codes.Add(39);
                else if (item == '/')
                    codes.Add(40);
                else if (item == '+')
                    codes.Add(41);
                else if (item == '%')
                    codes.Add(42);

                else if (item >= '0' && item <= '9')
                    codes.Add(item - 48);
                else
                {
                    var tmp = AsciiEncoder.Lookup(item);

                    switch (tmp[0])
                    {
                        case '$':
                            codes.Add(SHIFT1);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '%':
                            codes.Add(SHIFT2);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '/':
                            codes.Add(SHIFT3);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '+':
                            codes.Add(SHIFT4);
                            codes.Add(tmp[1] - 55);
                            break;
                        default:
                            codes.Add(tmp[0] - 55);
                            break;
                    }
                }

            }

            codes.Insert(0, LIMIT);
            codes.Add(LIMIT);
            codes.Add(TERMINATOR);

            return codes;
        }
Exemplo n.º 32
0
        public override CodedValueCollection GetCodes(string value)
        {
            var codes = new CodedValueCollection();

            foreach (char item in value.ToCharArray())
            {
                if (item == ' ')
                {
                    codes.Add(38);
                }
                else if (item == '$')
                {
                    codes.Add(39);
                }
                else if (item == '/')
                {
                    codes.Add(40);
                }
                else if (item == '+')
                {
                    codes.Add(41);
                }
                else if (item == '%')
                {
                    codes.Add(42);
                }

                else if (item >= '0' && item <= '9')
                {
                    codes.Add(item - 48);
                }
                else
                {
                    var tmp = AsciiEncoder.Lookup(item);

                    switch (tmp[0])
                    {
                    case '$':
                        codes.Add(SHIFT1);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '%':
                        codes.Add(SHIFT2);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '/':
                        codes.Add(SHIFT3);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '+':
                        codes.Add(SHIFT4);
                        codes.Add(tmp[1] - 55);
                        break;

                    default:
                        codes.Add(tmp[0] - 55);
                        break;
                    }
                }
            }

            codes.Insert(0, LIMIT);
            codes.Add(LIMIT);
            codes.Add(TERMINATOR);

            return(codes);
        }
Exemplo n.º 33
0
        //ABCDE FGHIJ
        //01234 56789

        //12   11 10 9 8   7 6 5 4   3 2 1 0
        // 1    8  4 2 1   8 4 2 1   8 4 2 1

        /// <summary>
        /// Convert the encoded data into bar patterns
        /// </summary>
        /// <param name="data">data to encode</param>
        /// <returns>bar pattern collection</returns>
        public CodedValueCollection ConvertToBars(short[] data)
        {
            CodedValueCollection result = new CodedValueCollection();

            result.Add(ChooseBar(data[7] & 0x0004, data[4] & 0x0008));
            result.Add(ChooseBar(data[1] & 0x0400, data[0] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x1000, data[2] & 0x0100));
            result.Add(ChooseBar(data[5] & 0x0020, data[6] & 0x0800));
            result.Add(ChooseBar(data[8] & 0x0200, data[3] & 0x0002));
            result.Add(ChooseBar(data[0] & 0x0002, data[5] & 0x1000));
            result.Add(ChooseBar(data[2] & 0x0020, data[1] & 0x0100));
            result.Add(ChooseBar(data[4] & 0x0010, data[9] & 0x0800));
            result.Add(ChooseBar(data[6] & 0x0008, data[8] & 0x0400));
            result.Add(ChooseBar(data[3] & 0x0200, data[7] & 0x0040));

            result.Add(ChooseBar(data[5] & 0x0800, data[1] & 0x0010));
            result.Add(ChooseBar(data[8] & 0x0020, data[2] & 0x1000));
            result.Add(ChooseBar(data[9] & 0x0400, data[0] & 0x0004));
            result.Add(ChooseBar(data[7] & 0x0002, data[6] & 0x0080));
            result.Add(ChooseBar(data[3] & 0x0040, data[4] & 0x0200));
            result.Add(ChooseBar(data[0] & 0x0008, data[8] & 0x0040));
            result.Add(ChooseBar(data[6] & 0x0010, data[2] & 0x0080));
            result.Add(ChooseBar(data[1] & 0x0002, data[9] & 0x0200));
            result.Add(ChooseBar(data[7] & 0x0400, data[5] & 0x0004));
            result.Add(ChooseBar(data[4] & 0x0001, data[3] & 0x0100));

            result.Add(ChooseBar(data[6] & 0x0004, data[0] & 0x0010));
            result.Add(ChooseBar(data[8] & 0x0800, data[1] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x0100, data[3] & 0x1000));
            result.Add(ChooseBar(data[2] & 0x0040, data[7] & 0x0080));
            result.Add(ChooseBar(data[5] & 0x0002, data[4] & 0x0400));
            result.Add(ChooseBar(data[1] & 0x1000, data[6] & 0x0200));
            result.Add(ChooseBar(data[7] & 0x0008, data[8] & 0x0001));
            result.Add(ChooseBar(data[5] & 0x0100, data[9] & 0x0080));
            result.Add(ChooseBar(data[4] & 0x0040, data[2] & 0x0400));
            result.Add(ChooseBar(data[3] & 0x0010, data[0] & 0x0020));

            result.Add(ChooseBar(data[8] & 0x0010, data[5] & 0x0080));
            result.Add(ChooseBar(data[7] & 0x0800, data[1] & 0x0200));
            result.Add(ChooseBar(data[6] & 0x0001, data[9] & 0x0040));
            result.Add(ChooseBar(data[0] & 0x0040, data[4] & 0x0100));
            result.Add(ChooseBar(data[2] & 0x0002, data[3] & 0x0004));
            result.Add(ChooseBar(data[5] & 0x0200, data[8] & 0x1000));
            result.Add(ChooseBar(data[4] & 0x0800, data[6] & 0x0002));
            result.Add(ChooseBar(data[9] & 0x0020, data[7] & 0x0010));
            result.Add(ChooseBar(data[3] & 0x0008, data[1] & 0x0004));
            result.Add(ChooseBar(data[0] & 0x0080, data[2] & 0x0001));

            result.Add(ChooseBar(data[1] & 0x0008, data[4] & 0x0002));
            result.Add(ChooseBar(data[6] & 0x0400, data[3] & 0x0020));
            result.Add(ChooseBar(data[8] & 0x0080, data[9] & 0x0010));
            result.Add(ChooseBar(data[2] & 0x0800, data[5] & 0x0040));
            result.Add(ChooseBar(data[0] & 0x0100, data[7] & 0x1000));
            result.Add(ChooseBar(data[4] & 0x0004, data[8] & 0x0002));
            result.Add(ChooseBar(data[5] & 0x0400, data[3] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x0008, data[0] & 0x0200));
            result.Add(ChooseBar(data[6] & 0x0020, data[2] & 0x0010));
            result.Add(ChooseBar(data[7] & 0x0100, data[1] & 0x0080));

            result.Add(ChooseBar(data[5] & 0x0001, data[4] & 0x0020));
            result.Add(ChooseBar(data[2] & 0x0008, data[0] & 0x0400));
            result.Add(ChooseBar(data[6] & 0x1000, data[9] & 0x0004));
            result.Add(ChooseBar(data[3] & 0x0800, data[1] & 0x0040));
            result.Add(ChooseBar(data[8] & 0x0100, data[7] & 0x0200));
            result.Add(ChooseBar(data[5] & 0x0010, data[0] & 0x0800));
            result.Add(ChooseBar(data[1] & 0x0020, data[2] & 0x0004));
            result.Add(ChooseBar(data[9] & 0x0002, data[4] & 0x1000));
            result.Add(ChooseBar(data[8] & 0x0008, data[6] & 0x0040));
            result.Add(ChooseBar(data[7] & 0x0001, data[3] & 0x0080));

            result.Add(ChooseBar(data[4] & 0x0080, data[7] & 0x0020));
            result.Add(ChooseBar(data[0] & 0x1000, data[1] & 0x0800));
            result.Add(ChooseBar(data[2] & 0x0200, data[9] & 0x0001));
            result.Add(ChooseBar(data[6] & 0x0100, data[5] & 0x0008));
            result.Add(ChooseBar(data[3] & 0x0400, data[8] & 0x0004));

            return(result);
        }
Exemplo n.º 34
0
		protected override string ParseText(string value, CodedValueCollection codes)
		{
			value = base.ParseText(value, codes);

			for (int i = 0; i < value.Length; i++)
			{
				codes.Add(int.Parse(value.Substring(i, 1)));

			}

			CalculateParity(codes);

			return value;
		}
Exemplo n.º 35
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            char variant = Code128Helper.StartVariantB;
            int i = 0;
            bool shifted = false;

            StringBuilder ParsedText = new StringBuilder();

            if (value[0] < 128)
                value = AutoFormat(value);

            if (value[0] == Code128Helper.StartVariantA)
            {
                variant = Code128Helper.CODEA;
                codes.Add((int)Code128Helper.StartVariantA - 50);
                i++;
            }
            else if (value[0] == Code128Helper.StartVariantB)
            {
                variant = Code128Helper.CODEB;
                codes.Add((int)Code128Helper.StartVariantB - 50);
                i++;
            }
            else if (value[0] == Code128Helper.StartVariantC)
            {
                variant = Code128Helper.CODEC;
                codes.Add((int)Code128Helper.StartVariantC - 50);
                i++;
            }

            int tmp;
            do
            {
                if (value[i] == AiMarker)
                {
                    ParsedText.Append(AiMarker);
                    i++;
                }
                if (shifted)
                    if (variant == Code128Helper.CODEA)
                        variant = Code128Helper.CODEB;
                    else
                        variant = Code128Helper.CODEA;

                if (variant == Code128Helper.CODEA)
                {
                    tmp = EncodeCodeA(value[i], ParsedText);

                    if (value[i] == Code128Helper.CODEB || value[i] == Code128Helper.CODEC)
                        variant = value[i];

                    i++;
                }
                else if (variant == Code128Helper.CODEB)
                {
                    tmp = EncodeCodeB(value[i], ParsedText);

                    if (value[i] == Code128Helper.CODEA || value[i] == Code128Helper.CODEC)
                        variant = value[i];

                    i++;
                }
                else
                {
                    if (value[i] == Code128Helper.CODEA || value[i] == Code128Helper.CODEB)
                    {
                        tmp = (int)value[i] - 50;
                        variant = value[i];
                        i++;
                    }
                    else if (value[i] == Code128Helper.FNC1)
                    {
                        tmp = (int)value[i] - 50;
                        i++;
                    }
                    else
                    {
                        tmp = EncodeCodeC(value.Substring(i, 2), ParsedText);
                        i += 2;
                    }
                }

                codes.Add(tmp);

                if (shifted)
                {
                    if (variant == Code128Helper.CODEA)
                        variant = Code128Helper.CODEB;
                    else
                        variant = Code128Helper.CODEA;
                }

                shifted = (tmp == 98 && variant != Code128Helper.CODEC);

            } while (i < value.ToCharArray().Length);

            codes.Add(STOP);

            return ParsedText.ToString();
        }
Exemplo n.º 36
0
        //ABCDE FGHIJ
        //01234 56789
        //12   11 10 9 8   7 6 5 4   3 2 1 0
        // 1    8  4 2 1   8 4 2 1   8 4 2 1
        /// <summary>
        /// Convert the encoded data into bar patterns
        /// </summary>
        /// <param name="data">data to encode</param>
        /// <returns>bar pattern collection</returns>
        public CodedValueCollection ConvertToBars(short[] data)
        {
            CodedValueCollection result = new CodedValueCollection();

            result.Add(ChooseBar(data[7] & 0x0004, data[4] & 0x0008));
            result.Add(ChooseBar(data[1] & 0x0400, data[0] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x1000, data[2] & 0x0100));
            result.Add(ChooseBar(data[5] & 0x0020, data[6] & 0x0800));
            result.Add(ChooseBar(data[8] & 0x0200, data[3] & 0x0002));
            result.Add(ChooseBar(data[0] & 0x0002, data[5] & 0x1000));
            result.Add(ChooseBar(data[2] & 0x0020, data[1] & 0x0100));
            result.Add(ChooseBar(data[4] & 0x0010, data[9] & 0x0800));
            result.Add(ChooseBar(data[6] & 0x0008, data[8] & 0x0400));
            result.Add(ChooseBar(data[3] & 0x0200, data[7] & 0x0040));

            result.Add(ChooseBar(data[5] & 0x0800, data[1] & 0x0010));
            result.Add(ChooseBar(data[8] & 0x0020, data[2] & 0x1000));
            result.Add(ChooseBar(data[9] & 0x0400, data[0] & 0x0004));
            result.Add(ChooseBar(data[7] & 0x0002, data[6] & 0x0080));
            result.Add(ChooseBar(data[3] & 0x0040, data[4] & 0x0200));
            result.Add(ChooseBar(data[0] & 0x0008, data[8] & 0x0040));
            result.Add(ChooseBar(data[6] & 0x0010, data[2] & 0x0080));
            result.Add(ChooseBar(data[1] & 0x0002, data[9] & 0x0200));
            result.Add(ChooseBar(data[7] & 0x0400, data[5] & 0x0004));
            result.Add(ChooseBar(data[4] & 0x0001, data[3] & 0x0100));

            result.Add(ChooseBar(data[6] & 0x0004, data[0] & 0x0010));
            result.Add(ChooseBar(data[8] & 0x0800, data[1] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x0100, data[3] & 0x1000));
            result.Add(ChooseBar(data[2] & 0x0040, data[7] & 0x0080));
            result.Add(ChooseBar(data[5] & 0x0002, data[4] & 0x0400));
            result.Add(ChooseBar(data[1] & 0x1000, data[6] & 0x0200));
            result.Add(ChooseBar(data[7] & 0x0008, data[8] & 0x0001));
            result.Add(ChooseBar(data[5] & 0x0100, data[9] & 0x0080));
            result.Add(ChooseBar(data[4] & 0x0040, data[2] & 0x0400));
            result.Add(ChooseBar(data[3] & 0x0010, data[0] & 0x0020));

            result.Add(ChooseBar(data[8] & 0x0010, data[5] & 0x0080));
            result.Add(ChooseBar(data[7] & 0x0800, data[1] & 0x0200));
            result.Add(ChooseBar(data[6] & 0x0001, data[9] & 0x0040));
            result.Add(ChooseBar(data[0] & 0x0040, data[4] & 0x0100));
            result.Add(ChooseBar(data[2] & 0x0002, data[3] & 0x0004));
            result.Add(ChooseBar(data[5] & 0x0200, data[8] & 0x1000));
            result.Add(ChooseBar(data[4] & 0x0800, data[6] & 0x0002));
            result.Add(ChooseBar(data[9] & 0x0020, data[7] & 0x0010));
            result.Add(ChooseBar(data[3] & 0x0008, data[1] & 0x0004));
            result.Add(ChooseBar(data[0] & 0x0080, data[2] & 0x0001));

            result.Add(ChooseBar(data[1] & 0x0008, data[4] & 0x0002));
            result.Add(ChooseBar(data[6] & 0x0400, data[3] & 0x0020));
            result.Add(ChooseBar(data[8] & 0x0080, data[9] & 0x0010));
            result.Add(ChooseBar(data[2] & 0x0800, data[5] & 0x0040));
            result.Add(ChooseBar(data[0] & 0x0100, data[7] & 0x1000));
            result.Add(ChooseBar(data[4] & 0x0004, data[8] & 0x0002));
            result.Add(ChooseBar(data[5] & 0x0400, data[3] & 0x0001));
            result.Add(ChooseBar(data[9] & 0x0008, data[0] & 0x0200));
            result.Add(ChooseBar(data[6] & 0x0020, data[2] & 0x0010));
            result.Add(ChooseBar(data[7] & 0x0100, data[1] & 0x0080));

            result.Add(ChooseBar(data[5] & 0x0001, data[4] & 0x0020));
            result.Add(ChooseBar(data[2] & 0x0008, data[0] & 0x0400));
            result.Add(ChooseBar(data[6] & 0x1000, data[9] & 0x0004));
            result.Add(ChooseBar(data[3] & 0x0800, data[1] & 0x0040));
            result.Add(ChooseBar(data[8] & 0x0100, data[7] & 0x0200));
            result.Add(ChooseBar(data[5] & 0x0010, data[0] & 0x0800));
            result.Add(ChooseBar(data[1] & 0x0020, data[2] & 0x0004));
            result.Add(ChooseBar(data[9] & 0x0002, data[4] & 0x1000));
            result.Add(ChooseBar(data[8] & 0x0008, data[6] & 0x0040));
            result.Add(ChooseBar(data[7] & 0x0001, data[3] & 0x0080));

            result.Add(ChooseBar(data[4] & 0x0080, data[7] & 0x0020));
            result.Add(ChooseBar(data[0] & 0x1000, data[1] & 0x0800));
            result.Add(ChooseBar(data[2] & 0x0200, data[9] & 0x0001));
            result.Add(ChooseBar(data[6] & 0x0100, data[5] & 0x0008));
            result.Add(ChooseBar(data[3] & 0x0400, data[8] & 0x0004));

            return result;
        }
Exemplo n.º 37
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            foreach (var item in value.ToCharArray())
            {
                codes.Add(item);
            }

            codes.Insert(0, START);
            codes.Add(STOP);

            return value;
        }
Exemplo n.º 38
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            char variant = Code128Helper.StartVariantB;
            int  i       = 0;
            bool shifted = false;

            StringBuilder ParsedText = new StringBuilder();

            if (value[0] < 128)
            {
                value = AutoFormat(value);
            }

            if (value[0] == Code128Helper.StartVariantA)
            {
                variant = Code128Helper.CODEA;
                codes.Add((int)Code128Helper.StartVariantA - 50);
                i++;
            }
            else if (value[0] == Code128Helper.StartVariantB)
            {
                variant = Code128Helper.CODEB;
                codes.Add((int)Code128Helper.StartVariantB - 50);
                i++;
            }
            else if (value[0] == Code128Helper.StartVariantC)
            {
                variant = Code128Helper.CODEC;
                codes.Add((int)Code128Helper.StartVariantC - 50);
                i++;
            }

            int tmp;

            do
            {
                if (value[i] == AiMarker)
                {
                    ParsedText.Append(AiMarker);
                    i++;
                }
                if (shifted)
                {
                    if (variant == Code128Helper.CODEA)
                    {
                        variant = Code128Helper.CODEB;
                    }
                    else
                    {
                        variant = Code128Helper.CODEA;
                    }
                }

                if (variant == Code128Helper.CODEA)
                {
                    tmp = EncodeCodeA(value[i], ParsedText);

                    if (value[i] == Code128Helper.CODEB || value[i] == Code128Helper.CODEC)
                    {
                        variant = value[i];
                    }

                    i++;
                }
                else if (variant == Code128Helper.CODEB)
                {
                    tmp = EncodeCodeB(value[i], ParsedText);

                    if (value[i] == Code128Helper.CODEA || value[i] == Code128Helper.CODEC)
                    {
                        variant = value[i];
                    }

                    i++;
                }
                else
                {
                    if (value[i] == Code128Helper.CODEA || value[i] == Code128Helper.CODEB)
                    {
                        tmp     = (int)value[i] - 50;
                        variant = value[i];
                        i++;
                    }
                    else if (value[i] == Code128Helper.FNC1)
                    {
                        tmp = (int)value[i] - 50;
                        i++;
                    }
                    else
                    {
                        tmp = EncodeCodeC(value.Substring(i, 2), ParsedText);
                        i  += 2;
                    }
                }

                codes.Add(tmp);

                if (shifted)
                {
                    if (variant == Code128Helper.CODEA)
                    {
                        variant = Code128Helper.CODEB;
                    }
                    else
                    {
                        variant = Code128Helper.CODEA;
                    }
                }

                shifted = (tmp == 98 && variant != Code128Helper.CODEC);
            } while (i < value.ToCharArray().Length);

            codes.Add(STOP);

            return(ParsedText.ToString());
        }
Exemplo n.º 39
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            string tmp = null;
            foreach (char item in value.ToCharArray())
            {
                if (item == ' ')
                    codes.Add(38);
                else if (item == '$')
                    codes.Add(39);
                else if (item == '/')
                    codes.Add(40);
                else if (item == '+')
                    codes.Add(41);
                else if (item == '%')
                    codes.Add(42);

                else if (item >= '0' && item <= '9')
                    codes.Add(item - 48);
                else
                {
                    tmp = AsciiEncoder.Lookup(item);

                    switch (tmp[0])
                    {
                        case '$':
                            codes.Add(SHIFT1);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '%':
                            codes.Add(SHIFT2);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '/':
                            codes.Add(SHIFT3);
                            codes.Add(tmp[1] - 55);
                            break;
                        case '+':
                            codes.Add(SHIFT4);
                            codes.Add(tmp[1] - 55);
                            break;
                        default:
                            codes.Add(tmp[0]);
                            break;
                    }
                }

            }

            codes.Insert(0, LIMIT);
            codes.Add(LIMIT);
            codes.Add(TERMINATOR);

            return value;
        }
Exemplo n.º 40
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            if (!IsValidData(value))
                throw new ApplicationException();

            string tmp = string.Format("{1}{0}{1}", value, (char)LIMIT);

            foreach (char item in tmp.ToCharArray())
            {
                codes.Add(item);
            }

            return value;
        }
Exemplo n.º 41
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = value.ToLower();
            string tmp = value.Replace(" ", "");

            tmp = base.ParseText(tmp, codes);

            foreach (char item in tmp.ToCharArray())
            {
                codes.Add(item);
            }

            return value.Substring(1, value.Length - 2);
        }
Exemplo n.º 42
0
        protected override string ParseText(string value, CodedValueCollection codes)
        {
            value = base.ParseText(value, codes);

            string tmp = null;

            foreach (char item in value.ToCharArray())
            {
                if (item == ' ')
                {
                    codes.Add(38);
                }
                else if (item == '$')
                {
                    codes.Add(39);
                }
                else if (item == '/')
                {
                    codes.Add(40);
                }
                else if (item == '+')
                {
                    codes.Add(41);
                }
                else if (item == '%')
                {
                    codes.Add(42);
                }

                else if (item >= '0' && item <= '9')
                {
                    codes.Add(item - 48);
                }
                else
                {
                    tmp = AsciiEncoder.Lookup(item);

                    switch (tmp[0])
                    {
                    case '$':
                        codes.Add(SHIFT1);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '%':
                        codes.Add(SHIFT2);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '/':
                        codes.Add(SHIFT3);
                        codes.Add(tmp[1] - 55);
                        break;

                    case '+':
                        codes.Add(SHIFT4);
                        codes.Add(tmp[1] - 55);
                        break;

                    default:
                        codes.Add(tmp[0]);
                        break;
                    }
                }
            }

            codes.Insert(0, LIMIT);
            codes.Add(LIMIT);
            codes.Add(TERMINATOR);

            return(value);
        }