public void FormatStr(string strIn, int width, ref List <string> list) { string strOut = ""; int i = 0; string space; while (i < strIn.Length) { int count = 0; if (list.Count == 0) { space = " "; } else { space = " "; } while (count < width - space.Length && i < strIn.Length) { strOut += strIn[i]; i++; count++; } i--; if (strOut[strOut.Length - 1].ToString() == " " || i == strIn.Length - 1) { strOut = FormattingText.DeleteSpace(strOut); list.Add(FormattingText.EndSpace(space + strOut, width)); } else { strOut = FormattingText.DeleteSpace(strOut); int tempt = strOut.Length - 1; count = 0; while (strOut[tempt] != ' ') { tempt--; count++; } list.Add(FormattingText.EndSpace(space + SomeNeedOverWrite.CopyStrToStr(strOut, 0, tempt), width)); i -= count; } i++; } }
void Parse() { if (Tegs.Count != 0) { if (Tegs[0].Position != 0) { FormatText.Add(SomeNeedOverWrite.CopyStrToStr(Content, 0, Tegs[0].Position)); } for (int i = 0, j = 1; i < Tegs.Count; i++, j++) { string listItem = j + "." + " " + SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 3, Tegs[i + 1].Position); FormatText.Add(listItem); i++; } } else { FormatText.Add(Content); } }
public virtual List <string> FormatStr(string strIn, int width) { int i = 0; while (i < strIn.Length) { int count = 0; string strOut = ""; while (count < width && i < strIn.Length) { strOut += strIn[i]; i++; count++; } i--; if (strOut[strOut.Length - 1].ToString() == " " | i == strIn.Length - 1 /*| strIn[i + 1].ToString() == " "*/) { strOut = FormattingText.DeleteSpace(strOut); _formatText.Add(FormattingText.EndSpace(strOut, width)); } else { strOut = FormattingText.DeleteSpace(strOut); int tempt = strOut.Length - 1; count = 0; while (strOut[tempt] != ' ') { tempt--; count++; } _formatText.Add(FormattingText.EndSpace(SomeNeedOverWrite.CopyStrToStr(strOut, 0, tempt), width)); i -= count; } i++; } return(_formatText); }
void Parse() { if (Tegs.Count != 0) { if (Tegs[0].Position != 0) { Text text = new Text(); text.Content = SomeNeedOverWrite.CopyStrToStr(Content, 0, Tegs[0].Position); text.Content = FormattingText.DeleteSpace(text.Content); if (text.Content.Length != 0) { ColumnContent.Add(text); } } for (int i = 0; i < Tegs.Count; i++) { switch (Tegs[i].TegType) { case "/с/": { Section section = new Section(); int j = EndTeg(i, "с/"); section.Content = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 3, Tegs[j].Position); section.Tegs = SomeNeedOverWrite.CopyListToList(Tegs, i + 1, j); ColumnContent.Add(section); i = j; break; } case "/к/": { Columns column = new Columns(); int j = EndTeg(i, "к/"); column.Content = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 3, Tegs[j].Position); column.Tegs = SomeNeedOverWrite.CopyListToList(Tegs, i + 1, j); ColumnContent.Add(column); i = j; break; } case "/з/": { Title title = new Title(); int j = EndTeg(i, "з/"); title.TitleTx = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 3, Tegs[j].Position); ColumnContent.Add(title); i = j; break; } case "/л/": { MarkerList mrList = new MarkerList(); int j = EndTeg(i, "л/"); mrList.Content = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 3, Tegs[j].Position); mrList.Tegs = SomeNeedOverWrite.CopyListToList(Tegs, i + 1, j); ColumnContent.Add(mrList); i = j; break; } } if (i < Tegs.Count - 2) { if (i < Tegs.Count - 1) { if ((Tegs[i + 1].Position - Tegs[i].Position + 4 > 3) && FormattingText.DeleteSpace(SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 4, Tegs[i + 1].Position)) != "") { Text text = new Text(); text.Content = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 4, Tegs[i + 1].Position); text.Content = FormattingText.DeleteSpace(text.Content); ColumnContent.Add(text); } } } if ((i == Tegs.Count - 1) && (Tegs[i].Position + 3 < Content.Length - 1)) { Text text = new Text(); text.Content = SomeNeedOverWrite.CopyStrToStr(Content, Tegs[i].Position + 4, Content.Length); text.Content = FormattingText.DeleteSpace(text.Content); if (text.Content.Length != 0) { ColumnContent.Add(text); } } } } else { Text text = new Text(); text.Content = Content; ColumnContent.Add(text); } }