public Int32 tabPosition(printHorizontal field) { ISupportsTextCursor target_e = target as ISupportsTextCursor; switch (field) { case printHorizontal.left: return(target.innerLeftPosition); break; case printHorizontal.middle: if (target_e != null) { return(target_e.leftFieldWidth + target.innerLeftPosition); } break; case printHorizontal.right: if (target_e != null) { return(target.innerRightPosition - target_e.rightFieldWidth); } break; } return(0); }
public String getLineFormat(Int32 targetWidth, printHorizontal horizontal) { String lineFormat = ""; Int32 dW = targetWidth - width; Int32 dWl = dW / 2; Int32 dWr = dW - 1 - dWl; if (dW > 0) { switch (horizontal) { case printHorizontal.left: lineFormat = "{0," + (-width).ToString() + "}{1,1}{2," + dWr.ToString() + "}"; break; case printHorizontal.middle: lineFormat = "{1," + dWl.ToString() + "}{0," + width.ToString() + "}{2," + dWr.ToString() + "}"; break; case printHorizontal.right: lineFormat = "{1," + dW.ToString() + "}{0," + width.ToString() + "}{2,0}"; break; } } return(lineFormat); }
public Int32 appendLine(String content, String contentInnerFormat = "{0}", printHorizontal hor = printHorizontal.left, String deco = " ", Int32 index = -1) { String cl = String.Format(contentInnerFormat, content); Int32 innerWidth = width - padding.leftAndRight; List <string> lns = cl.wrapLine(innerWidth); String fr = getLineFormat(hor, deco); Int32 c = 0; foreach (String ln in lns) { String lno = String.Format(fr, ln); Int32 ind = index + c; if (index == -1) { ind = -1; } Add(lno, ind); c++; } return(lns.Count); }
public String getLineFormat(printHorizontal hor, String deco = " ") { String format = ""; format += deco.Repeat(padding.left); Int32 innerWidth = width - padding.leftAndRight; switch (hor) { case printHorizontal.left: format += "{0," + (-innerWidth).ToString() + "}"; break; case printHorizontal.middle: case printHorizontal.right: format += "{0," + (innerWidth).ToString() + "}"; break; case printHorizontal.hide: format += deco.Repeat(innerWidth); break; } format += deco.Repeat(padding.right); return(format); }
/// <summary> /// Ubacuje jedno polje u trenutnu liniju /// </summary> /// <param name="__content"></param> /// <param name="input"></param> /// <param name="field"></param> /// <param name="__fieldFormat"></param> /// <param name="__background"></param> /// <returns></returns> protected String insertField(String __content, String input, printHorizontal field, String __fieldFormat = "", String __background = "") { if (String.IsNullOrEmpty(input)) { return(__content); } if (String.IsNullOrEmpty(__background)) { __background = backgroundDecoration; } if (String.IsNullOrEmpty(__content)) { __content = marginDecoration.Repeat(margin.left) + backgroundDecoration.Repeat(innerBoxedWidth) + marginDecoration.Repeat(margin.right); // __background.Repeat( //__content = writeInlineBackground(__content, "", __background); } if (String.IsNullOrEmpty(__fieldFormat)) { __fieldFormat = fieldFormats[field]; } var fieldFormatEmpty = String.Format(__fieldFormat, ""); var fieldFormatEmptyLen = fieldFormatEmpty.Length; Int32 fieldWidth = 0; switch (field) { case printHorizontal.left: fieldWidth = leftFieldWidth; break; case printHorizontal.middle: fieldWidth = middleFieldWidth; break; case printHorizontal.right: fieldWidth = rightFieldWidth; break; default: fieldWidth = innerWidth; break; } if (fieldWidth == 0) { return(__content); } input = input.trimToWidth(fieldWidth - fieldFormatEmptyLen, field); var toInsert = String.Format(__fieldFormat, input); __content = writeInlineText(__content, toInsert, field, fieldWidth); return(__content); }
public String getFormated(String line, printHorizontal hor, String decoLeft = "", String decoRight = "") { String newLine = ""; String format = getLineFormat(line.Length, hor); newLine = String.Format(format, line, decoLeft, decoRight); return(newLine); }
/// <summary> /// Upisuje jedno polje u dati tab, omogucava custom format za polje /// </summary> /// </summary> /// <param name="content"></param> /// <param name="tab"></param> /// <param name="toInnerLine"></param> /// <param name="customFormat"></param> /// <param name="customBackground"></param> /// <returns></returns> public String writeField(String content, printHorizontal tab, Int32 toInnerLine = -1, String customFormat = "", String customBackground = "") { if (toInnerLine != -1) { cursor.moveLineTo(toInnerLine); } contentLine = insertField(contentLine, content, tab, customFormat, customBackground); return(contentLine); }
public List <String> getContent(Int32 targetWidth, printHorizontal horizontal) { String lineFormat = getLineFormat(targetWidth, horizontal); List <String> inserts = new List <string>(); foreach (String ln in this) { inserts.Add(String.Format(lineFormat, ln, "", "")); } return(inserts); }
public void setContent(_textBlock content, printHorizontal horizontal, printVertical vertical, Boolean doInsertEmptyLines = true) { String lineFormat = ""; Int32 dW = width - content.width; Int32 dWl = dW / 2; Int32 dWr = dW - dWl; Int32 dH = height - content.height; List <String> inserts = content.getContent(width, horizontal); switch (vertical) { case printVertical.bottom: dH = height - content.height; if (doInsertEmptyLines) { setToEmptyLine(0, dH); } insertLines(inserts, dH); break; case printVertical.center: dH = height - content.height; dH = dH / 2; if (doInsertEmptyLines) { setToEmptyLine(0, dH); } insertLines(inserts, dH); if (doInsertEmptyLines) { setToEmptyLine(dH); } break; case printVertical.top: dH = height - content.height; insertLines(inserts, 0); if (doInsertEmptyLines) { setToEmptyLine(dH); } break; } }
// public static String getTableCellValue(this String content,) public static Tuple <String, String> getTableColumnHead(this printHorizontal position, string dcCaption) { String headingline = ""; //.add(dcCaption, "|"); String underline = ""; //.add("-".Repeat(dcCaption.Length), "|"); Int32 len = dcCaption.Length; if (len < 2) { len = 2; } switch (position) { case printHorizontal.left: headingline = "|" + dcCaption + " "; underline = "|:" + "-".Repeat(dcCaption.Length); break; case printHorizontal.middle: headingline = "|" + dcCaption + " "; underline = "|:" + "-".Repeat(dcCaption.Length - 2) + ":"; break; case printHorizontal.right: headingline = "|" + dcCaption + " "; underline = "|" + "-".Repeat(dcCaption.Length - 1) + ":"; break; default: break; } Tuple <String, String> output = new Tuple <string, string>(headingline, underline); return(output); }
/// <summary> /// Renderuje preko __content sadrzaja __textToInsert u skladu sa formatiranjem i printHorizontal podesavanjem. /// </summary> /// <param name="__content">Postojeci sadrzaj</param> /// <param name="__textToInsert">Sadrzaj koji treba da se insertuje</param> /// <param name="horizontal">TextAligment - mesto gde treba sadrzaj da se insertuje</param> /// <param name="__widthLimit">Ogranicenje duzine sadrzaja za ubacivanje. Ukoliko ostane -1 onda je limit innerWidth</param> /// <returns>Azurirani sadrzaj</returns> public virtual String writeInlineText(String __content, String __textToInsert, printHorizontal horizontal, Int32 __widthLimit = -1) { String output = __content; if (String.IsNullOrEmpty(output)) { output = ""; } if (output.Length < width) { output = " ".Repeat(width); } if (__widthLimit == -1) { __widthLimit = innerWidth; } __textToInsert = __textToInsert.trimToWidth(__widthLimit, horizontal); Int32 insertLen = 0; switch (horizontal) { case printHorizontal.left: insertLen = Math.Min(__textToInsert.Length, innerWidth); output = output.overwrite(innerLeftPosition, insertLen, __textToInsert); break; case printHorizontal.middle: Int32 startPos = margin.left + padding.left + (innerWidth / 2); startPos -= (__textToInsert.Length / 2); insertLen = __textToInsert.Length; output = output.overwrite(startPos, insertLen, __textToInsert); break; case printHorizontal.right: insertLen = __textToInsert.Length; output = output.overwrite(innerRightPosition - insertLen, insertLen, __textToInsert); break; default: break; } return(output); }
public Boolean tab(printHorizontal field) { x = tabPosition(field); return(checkPositions()); }
/// <summary> /// Osigurava trimovanje tacno na zadatu duzinu /// </summary> /// <param name="__textToInsert">Tekst koji treba da se trimuje</param> /// <param name="widthLimit"></param> /// <param name="horizontal"></param> /// <returns></returns> public static String trimToWidth(this String __textToInsert, Int32 widthLimit, printHorizontal horizontal) { String output = __textToInsert; if (__textToInsert.Length > widthLimit) { switch (horizontal) { case printHorizontal.left: output = output.Substring(0, widthLimit); //output = output.overwrite(innerLeftPosition, insertLen, __textToInsert); break; case printHorizontal.middle: Int32 diff = (__textToInsert.Length - widthLimit) / 2; Int32 len = (__textToInsert.Length - widthLimit); if (len > widthLimit) { len -= widthLimit - len; } output = output.Substring(diff, len); break; case printHorizontal.right: Int32 len2 = (__textToInsert.Length - widthLimit); output = output.Substring(len2); break; default: break; } } else { return(output); } return(output); }
public static selectRangeArea takeColumnGroup(this selectRangeArea area, Int32 y, Int32 yT, Int32 leftZone, Int32 rightZone, printHorizontal horizontal) { selectRangeArea output = new selectRangeArea(area.x, y, area.BottomRight.x, y + yT); switch (horizontal) { case printHorizontal.left: output = new selectRangeArea(area.x, y, area.x + leftZone, y + yT); break; case printHorizontal.middle: output = new selectRangeArea(area.x + leftZone, y, area.BottomRight.x - rightZone, y + yT); break; case printHorizontal.right: output = new selectRangeArea(area.BottomRight.x - rightZone, y, area.BottomRight.x, y + yT); break; case printHorizontal.hide: break; } // output = area.getCrossection(output); return(output); }