public override List <string> Show(int width)
        {
            Parse();
            List <string> list = new List <string>();

            for (int i = 0; i < FormatText.Count; i++)
            {
                FormatText[i] = FormattingText.DeleteSpace(FormatText[i]);
                FormatStr(FormatText[i], width, ref list);
            }
            return(list);
        }
Beispiel #2
0
 public virtual List <string> Show(int width)
 {
     Content = FormattingText.DeleteSpace(Content);
     if (Content.Length <= width)
     {
         _formatText.Add(FormattingText.EndSpace(Content, width));
     }
     else
     {
         return(FormatStr(Content, width));
     }
     return(_formatText);
 }
        public override List <string> Show(int width)
        {
            TitleTx = FormattingText.DeleteSpace(TitleTx);
            string edit = "    ";

            TitleTx = edit + TitleTx.ToUpper();
            if (TitleTx.Length <= width)
            {
                _formatText.Add(FormattingText.EndSpace(TitleTx, width));
            }
            else
            {
                _formatText = FormatStr(TitleTx, width);
            }
            return(_formatText);
        }
        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++;
            }
        }
Beispiel #5
0
        public override List <string> Show(int width)
        {
            Parse();
            List <string> formatText = new List <string>();
            List <string> textFragment;

            for (int i = 0; i < SectionContent.Count; i++)
            {
                bool check = (SectionContent[i].GetType().ToString() == "WpfApplication1.Columns");
                if (check)
                {
                    if ((i == SectionContent.Count - 1) || (SectionContent[i + 1].GetType().ToString() != "WpfApplication1.Columns"))
                    {
                        textFragment = SectionContent[i].Show(width - 7);
                        for (int j = 0; j < textFragment.Count; j++)
                        {
                            formatText.Add("    " + textFragment[j]);
                        }
                    }
                    else
                    {
                        textFragment = FormattingText.Show(SectionContent[i].Show(width / 2 - 5), SectionContent[i + 1].Show(width / 2 - 5));
                        for (int j = 0; j < textFragment.Count; j++)
                        {
                            formatText.Add("    " + textFragment[j]);
                        }
                        i++;
                    }
                }
                else
                {
                    textFragment = SectionContent[i].Show(width - 1);
                    for (int j = 0; j < textFragment.Count; j++)
                    {
                        formatText.Add(" " + textFragment[j]);
                    }
                }
            }
            formatText.Add("");
            return(formatText);
        }
        List <string> Show(int width)
        {
            Parse();
            List <string> formatText   = new List <string>();
            List <string> textFragment = new List <string>();

            for (int i = 0; i < _formatDocument.Count; i++)
            {
                bool check = (_formatDocument[i].GetType().ToString() == "WpfApplication1.Columns");
                if (check)
                {
                    if ((i == _formatDocument.Count - 1) || (_formatDocument[i + 1].GetType().ToString() != "WpfApplication1.Columns"))
                    {
                        textFragment = _formatDocument[i].Show(width - 7);
                        for (int j = 0; j < textFragment.Count; j++)
                        {
                            formatText.Add("    " + textFragment[j]);
                        }
                    }
                    else
                    {
                        textFragment = FormattingText.Show(_formatDocument[i].Show(width / 2 - 5), _formatDocument[i + 1].Show(width / 2 - 5));
                        for (int j = 0; j < textFragment.Count; j++)
                        {
                            formatText.Add("    " + textFragment[j]);
                        }
                    }
                }
                else
                {
                    textFragment = _formatDocument[i].Show(width);
                    for (int j = 0; j < textFragment.Count; j++)
                    {
                        formatText.Add(textFragment[j]);
                    }
                }
            }
            return(formatText);
        }
Beispiel #7
0
        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);
            }
        }