private string Code_128() { int achecksum = 0; string startcode = ""; string aresult = ""; int i = 0; string cadc; int idx; BarcodeType btyp; string text = CurrentText; while (i < text.Length) { btyp = BarType; if (btyp == BarcodeType.Code128) { btyp = Code128.FindNewType(text, i); } switch (btyp) { case BarcodeType.Code128A: achecksum = 103; startcode = Code128.StartA; break; case BarcodeType.Code128B: achecksum = 104; startcode = Code128.StartB; break; case BarcodeType.Code128C: achecksum = 105; startcode = Code128.StartC; break; } // Start code if (i == 0) { aresult = aresult + DoConvert(startcode); } // Look for EAN control if (text[i] == (char)0xBF) { aresult = aresult + DoConvert("411131"); achecksum = achecksum + 102 * (i + 1); i++; if (i >= text.Length) { break; } } switch (btyp) { case BarcodeType.Code128A: case BarcodeType.Code128B: while (i < text.Length) { idx = Code128.FindCodeAB(btyp, text[i]); if (idx < 0) { idx = Code128.FindCodeAB(btyp, ' '); } aresult = aresult + DoConvert(Code128.table[idx].data); achecksum = achecksum + idx * (i + 1); i++; // Look for EAN control if (i < text.Length) { if (text[i] == (char)0xBF) { aresult = aresult + DoConvert("411131"); achecksum = achecksum + 102 * (i + 1); i++; break; } } } break; case BarcodeType.Code128C: cadc = ""; while (i < text.Length) { cadc = cadc + text[i]; if (cadc.Length > 1) { idx = Code128.FindCodeC(cadc); if (idx < 0) { idx = Code128.FindCodeC("00"); } achecksum = achecksum + idx * ((i + 1) / 2); aresult = aresult + DoConvert(Code128.table[idx].data); cadc = ""; } i++; // Look for EAN control if (i < text.Length) { if (text[i] == (char)0xBF) { aresult = aresult + DoConvert("411131"); achecksum = achecksum + 102 * (i + 1); i++; break; } } } break; } } achecksum = achecksum % 103; aresult = aresult + DoConvert(Code128.table[achecksum].data); aresult = aresult + DoConvert(Code128.Stop); return(aresult); }