Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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());
        }
Beispiel #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;
        }
Beispiel #15
0
 public virtual CodedValueCollection GetCodes(string value)
 {
     var result = new CodedValueCollection();
     foreach (var item in value)
     {
         result.Add(item);
     }
     return result;
 }
Beispiel #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);
        }
Beispiel #17
0
        public virtual CodedValueCollection GetCodes(string value)
        {
            var result = new CodedValueCollection();

            foreach (var item in value)
            {
                result.Add(item);
            }
            return(result);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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));
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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();
		}
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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;
		}
Beispiel #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();
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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());
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
        }