public override string renderLine(printerItem p) { if (p is printerLine) { var _p = ((printerLine)p); List <string> _result = new List <string>(); int _xdpm = Convert.ToInt32(_p.x * dpm); int _ydpm = Convert.ToInt32(_p.y * dpm); if (_p.textSize == 0) { Font _font = new Font("Swis721 BT", _p.charSize); _p.textSize = TextMeasurer.MeasureString(_p.textData, _font, dpi).Width; //* 1.7F; } else { for (float i = 1; i < 100; i += 0.1F) { Font _font = new Font("Swis721 BT", i); if (TextMeasurer.MeasureString(_p.textData, _font, dpi).Width > _p.textSize) { _p.charSize = i; break; } } } float _charSize_mm = _p.charSize * 0.3527777777778F; //textSize = textSize == 0F ? ): textSize; float _width = _p.textSize * dpm; // = 2.1F * (textSize - 1); int _charWidthDPM = _charSize_mm == 0 ? Convert.ToInt32(Math.Ceiling(_p.textSize / _p.textData.Length * dpm)) : Convert.ToInt32(_charSize_mm * dpm); //(textSize / textData.Length) < ((textSize-1)*2+10) ? (textSize / textData.Length): ((textSize - 1) * 2 + 10); switch (_p.align) { case "C": _xdpm = (_xdpm - Convert.ToInt32(_width / 2F)); _result.Add(string.Format("^FT{0},{1},0", _xdpm, _ydpm)); break; case "D": case "R": _result.Add(string.Format("^FT{0},{1},1", _xdpm, _ydpm)); //(_charWidth*1.2).ToString() //_width = _xdpm; break; case "I": case "L": _result.Add(string.Format("^FT{0},{1},0", _xdpm, _ydpm)); break; } if (_p.style.IndexOf("M") != -1) { _p.textData = _p.textData.ToUpper(); } //labelBody.Add(string.Format("^FB{0},1,0,{1},0",Convert.ToInt32(_width),_alignChar)); //labelBody.Add(string.Format("^FO{0},{1}",_xdpm,_ydpm));//(_charWidth*1.2).ToString() _result.Add("^PA1,1,1,1"); _result.Add(string.Format("^AX{0},{1},{2}", _p.Rotated ? "R" : "", _charWidthDPM, _charWidthDPM)); _result.Add(string.Format("^FH^FD{0}^FS", _p.textData)); return(string.Join("\n", _result)); } else if (p is printerBarcode) { var _p = (printerBarcode)p; List <string> _result = new List <string>(); int _xdpm = Convert.ToInt32(_p.x * dpm); int _ydpm = Convert.ToInt32(_p.y * dpm); int _heightDpm = Convert.ToInt32(_p.Height * dpm); switch (_p.align) { case "C": _xdpm = (_xdpm - Convert.ToInt32(_p.Width / 2F)); _xdpm = _xdpm < 0 ? 0 : _xdpm; _result.Add(string.Format("^FO{0},{1}", _xdpm, _ydpm)); break; case "D": _xdpm = (_xdpm - Convert.ToInt32(_p.Width)); _result.Add(string.Format("^FO{0},{1}", _xdpm, _ydpm)); //(_charWidth*1.2).ToString() //_width = _xdpm; break; case "I": _result.Add(string.Format("^FO{0},{1}", _xdpm, _ydpm)); break; } _result.Add(string.Format("^BY{0},3,{1}", _p.xDimension, _heightDpm)); _result.Add(string.Format("^BC{0},{1},{2},N,N,N", _p.Rotated ? "R" : "N", _heightDpm, _p.HumanReadable ? "Y" : "N")); _result.Add(string.Format("^FD{0}^FS", _p.textData)); return(string.Join("\n", _result)); } else { return(""); } }
public virtual string renderLine(printerItem p) { return(""); }