// }}} // GtkRenderer::renderBarcode() {{{ public void renderBarcode(BarcodeElement elm) { if(elm.symbologie==0) { Barcode39 barcode = new Barcode39(); //barcode.BarHeight=Conversions.dot2mm(this.heightMagnification); barcode.Code = elm.data; barcode.BarHeight = (float)elm.height; barcode.render((int)elm.fieldOriginX,(int)elm.fieldOriginY, this._da); } else { Console.WriteLine("Barcode "+elm._symbologieMap[elm.symbologie]+" are not implemented yet"); } }
// }}} // IplParser::_parseElementDefinition() {{{ /// <summary>Parse the code witch define an element.</summary> /// <param name="code">An Ipl instruction</param> /// <returns>boolean</returns> private bool _parseElementDefinition(string code) { Match result; Regex reg; int index = 0; char elementType = ' '; reg = new Regex(@"([HBLUW])(\d+),(.+)[;]"); result = reg.Match(code); if(result.Success) { elementType = System.Convert.ToChar(result.Groups[1].Value); index = System.Convert.ToInt32(result.Groups[2].Value); } else { reg = new Regex(@"([HBLUW])(\d+)[;]"); result = reg.Match(code); if(result.Success) { elementType = System.Convert.ToChar(result.Groups[1].Value); index = System.Convert.ToInt32(result.Groups[2].Value); } } if(this._commandType == IplParser.programMode) { double fieldOriginX = 0; double fieldOriginY = 0; string fieldDirection = ""; double height = 0; double width = 0; // o: Field Origin, Define {{{ reg = new Regex(@"[o](\d+),(\d+)[;]"); result = reg.Match(code); if(result.Success) { fieldOriginX = System.Convert.ToDouble(result.Groups[1].Value); fieldOriginY = System.Convert.ToDouble(result.Groups[2].Value); } // }}} // f: field direction, define {{{ reg = new Regex(@"([f]\d)[;]"); result = reg.Match(code); if(result.Success) { fieldDirection = System.Convert.ToString(result.Groups[1].Value); } // }}} // h: Height Magnification of bar,Box, or UDC, Define {{{ reg = new Regex(@"[h](\d+)[;]"); result = reg.Match(code); if(result.Success) { height = System.Convert.ToDouble(result.Groups[1].Value); } // }}} // w: Width of Line, Box, Bar, or Character, define {{{ reg = new Regex(@"[w](\d+)[;]"); result = reg.Match(code); if(result.Success) { width = System.Convert.ToDouble(result.Groups[1].Value); } // }}} if(elementType == 'B') { // barcode element {{{ BarcodeElement element = new BarcodeElement(index, fieldOriginX, fieldOriginY, fieldDirection, width, height); // c: Bar Code, Select Type // bar code type : cn[,m1][,m2][,m3] // n is the symbologie and m1, m2 and m3 are modifiers for that // symbologie - cf page 157 spec ipl. reg = new Regex(@"[c](\d+)"); result = reg.Match(code); if(result.Success) { element.symbologie = System.Convert.ToInt16(result.Groups[1].Value); } // modifiers : m reg = new Regex(@"[m](\d+)"); result = reg.Match(code); if(result.Success) { element.modifiers = System.Convert.ToInt16(result.Groups[1].Value); } // d: Field Data, Define Source reg = new Regex(@"[d](\d+),(.+)[;]"); result = reg.Match(code); if(result.Success) { if(result.Groups[1].Value == "3") { // XXX trouver la regex qui évite le split element.data = result.Groups[2].Value.Split(';')[0]; } else if(result.Groups[1].Value == "2") { element.data = result.Groups[2].Value.Split(';')[0].Split(',')[0]; } } else { element.waitData = true; } // i: Interpretive Field, Enable or Disable reg = new Regex(@"[i](\d+)"); result = reg.Match(code); if(result.Success) { element.interpretive = System.Convert.ToInt16(result.Groups[1].Value); } // p: Code39 Prefic Character, Define // r: Character Rotation or Bar Code Ratio, define reg = new Regex(@"[r](\d+)"); result = reg.Match(code); if(result.Success) { element.ratio = System.Convert.ToInt16(result.Groups[1].Value); } this._elements.Add(element); // }}} } else if(elementType == 'H') { // HumanReadable element {{{ HumanReadableElement element = new HumanReadableElement( index, fieldOriginX, fieldOriginY, fieldDirection, width, height); // b: Border around human-readable text, define // c: Font type, select (cn,m) m est l'espace entre les // chars reg = new Regex(@"[c](\d+)[;]"); result = reg.Match(code); if(result.Success) { element.font = element.getFont(System.Convert.ToInt32(result.Groups[1].Value)); } // d: field data, define source reg = new Regex(@"[d](\d+),(.+)[;]"); result = reg.Match(code); if(result.Success) { if(result.Groups[1].Value == "3") { // XXX trouver la regex qui évite le split element.data = result.Groups[2].Value.Split(';')[0]; } else if(result.Groups[1].Value == "2") { element.data = result.Groups[2].Value.Split(';')[0].Split(',')[0]; } } else { element.waitData = true; } // g: pitch size, set // k: point size, set // r: character rotation or bar code ratio, define reg = new Regex(@"[r](\d+)"); result = reg.Match(code); if(result.Success) { element.characterRotation = System.Convert.ToInt16(result.Groups[1].Value); } this._elements.Add(element); // }}} } else if(elementType == 'L') { // Line element {{{ LineBoxElement element = new LineBoxElement(index, IplElement.Line, fieldOriginX, fieldOriginY, fieldDirection, width, height); // l: length of line or box field, define reg = new Regex(@"[l](\d+)"); result = reg.Match(code); if(result.Success) { element.length = System.Convert.ToDouble(result.Groups[1].Value); } this._elements.Add(element); // }}} } else if(elementType == 'U') { // UDCs element {{{ // XXX not yet implemented //UDCsElement element = new UDCsElement(index); // c: Graphic, select // }}} } else if(elementType == 'W') { // Box element {{{ LineBoxElement element = new LineBoxElement(index, IplElement.Box, fieldOriginX, fieldOriginY, fieldDirection, width, height); // l: length of line or box field, define reg = new Regex(@"[l](\d+)"); result = reg.Match(code); if(result.Success) { element.length = System.Convert.ToDouble(result.Groups[1].Value); } this._elements.Add(element); // XXX not yet implemented //BoxElement element = new BoxElement(index); // l: Length of line or box field, Define // }}} } // Bitmap User-Defined Font Editing Commands // t: User-Defined Font Character, Create // u: Graphic or UDC, Define // X: Character Bitmap Origin Offset, Define // x: Bitmap Cell Width for Graphic or UDF, Define // y: Bitmap Cell Height for Graphic or UDF, Define // Z: Font Character Width, Define // z: Intercharacter Space for UDF, Define // Interpretive fields editing commands // b: border around human-readable text, define // c: font type, select // g: pitch size, set // k: point size, set } else if(this._commandType == IplParser.printMode) { } return true; }