// private textCursor _cursor; protected textSectionBase(int __height, int __width, int __leftRightMargin = 0, int __leftRightPadding = 0) : base(" ", " ", __width, __leftRightMargin, __leftRightPadding) { height = __height; //setStyle(textSectionLineStyleName.content); cursor = new textCursor(this, textCursorMode.fixedZone, textCursorZone.innerZone); //init(); }
/// <summary> /// Od trenutne pozicije kursora vraca substring date duzine. Ako je length = -1 onda do desnog kraja dozvoljene zone. /// </summary> /// <param name="length"></param> /// <param name="copyCompleteLine">Da li da iskopira celu liniju</param> /// <returns></returns> public string @select(textCursor cursor, int length = -1, bool copyCompleteLine = false) { Int32 start = cursor.x; if (copyCompleteLine) { cursor.moveToCorner(textCursorZoneCorner.Left); start = cursor.x; length = cursor.selectToCorner(textCursorZoneCorner.Right).x; } else { if (length == -1) { length = cursor.selectToCorner(textCursorZoneCorner.Right).x; //cursor.moveToCorner(textCursorZoneCorner.Right); } } String output = contentLines.select(cursor.y, start, length); /* * var ln = contentLines[cursor.y]; * if (!String.IsNullOrEmpty(ln)) * { * length = Math.Min(length - start, ln.Length - start); * * ln.Substring(start, length); * } else * { * } * // output = "[" + cursor.y + "] " + output; /// debug */ return(output); }
/// <summary> /// upisuje prosledjen unos, primenjuje limit ako je dat - ako nije> limit je u skladu za zonom /// </summary> /// <param name="input"></param> /// <param name="limit"></param> /// <param name="writeCompleteLine"></param> public void write(textCursor cursor, string input, int limit = -1, bool writeCompleteLine = false) { Int32 start = cursor.x; Int32 length = input.Length; if (limit != -1) { length = Math.Min(length, limit); } if (writeCompleteLine) { cursor.moveToCorner(textCursorZoneCorner.Left); start = cursor.x; length = Math.Min(cursor.selectToCorner(textCursorZoneCorner.Right).x, length); } var ln = contentLines[cursor.y]; //length = Math.Min(ln.Length - start, input.Length - start); String st = contentLines[cursor.y].Substring(0, start); String md = input.Substring(0, length); Int32 led = ln.Length - (st.Length + md.Length); String ed = ln.Substring(st.Length + md.Length, led); contentLines[cursor.y] = st + md + ed; //String output = ln.Substring(start, length); //return output; // contentLine = contentLine.Insert(start, input.Substring(0, length)).Substring(0, length); }
protected textLineContentBase(string __mrDecoration, string __bgDecoration, int __width, int __leftRightMargin, int __leftRightPadding) : base(__mrDecoration, __bgDecoration, __width, __leftRightMargin, __leftRightPadding) { setupFieldFormat("{0}", 10, 10); cursor = new textCursor(this, textCursorMode.fixedZone, textCursorZone.innerZone); }