Ejemplo n.º 1
0
 protected void appendText(
     MessageToSend ms,
     Verse verse,
     Boolean is_first_verse,
     Boolean is_last_verse,
     UserColourTheme uct)
 {
     //String text = (verse.text).Replace("<lb>", "");
     parseText(ms, verse, is_first_verse, is_last_verse,uct);
        // ms.Append(text, ms);
 }
Ejemplo n.º 2
0
        /*protected String parseSCTags(
            String text)
        {
            int b_index = text.IndexOf("scstart-");
            String sc_text;
            string message_text = "";
            if (b_index != -1)
            {
                int e_index = text.IndexOf("-scend");
                string variable_name = text.Substring(b_index + 1, e_index - b_index - 1);
                sc_text = text.Substring(start_title_index, end_title_index - start_title_index );
                message_text = parseMessage(us, message.Replace('[' + variable_name + ']', us.getVariable(variable_name)));

            }
        }*/
        /*replace info tags and div tags*/
        protected void parseText(
            MessageToSend ms,
            Verse verse,
            Boolean is_first_verse,
            Boolean is_last_verse,
            UserColourTheme uct)
        {
            Color color = Color.Empty;
            if (uct != null)
                color = uct.getBibleTextColour();
            String tag_contents = "";
            int start_title_index = -1;
            int end_title_index = -1;
            String paragraph_title = "";
            Boolean start_of_verse = true;

            String  message = parseSCTags(verse.text);
            message = parseXMLCodes(message);
            if (is_first_verse)
            {
                Verse prev_verse = verse.getPreviousVerse();
                if (prev_verse != null)
                {
                    String initial_title = getParagaphTitleFromVerse(prev_verse);
                    //test if title is at beginning of verse....
                    if (initial_title != null)
                    {
                        //first test if title is at the beginning of string and
                        String prev_verse_test = removeTags(prev_verse.text).Trim();
                        if (prev_verse_test.IndexOf(initial_title) != 0)
                        {
                            ms.Append("\r\n");
                            if(uct!=null)
                                ms.Append(removeTags(initial_title), color,new TextMarkup[] { TextMarkup.Bold });
                            else
                                ms.Append(removeTags(initial_title), new TextMarkup[] { TextMarkup.Bold });
                            ms.Append("\r\n");
                        }
                    }
                }
            }
            int b_index = message.IndexOf('<');
            if (b_index == -1)
            {
                if(uct!=null)
                    ms.Append(message,color);
                else
                    ms.Append(message);
                return;
            }
            while (b_index != -1)
            {
                int e_index = message.IndexOf('>');
                if (e_index == -1)
                {
                    Console.WriteLine("NO CLOSING TAG FOUND FOR A VERSE: " + message);
                    return;
                }
                tag_contents = message.Substring(b_index + 1, e_index - b_index - 1);
                if (tag_contents.Contains(PARAGRAPH_TITLE_TAG))
                {
                    end_title_index = message.IndexOf("<lb>", e_index);
                    start_title_index = message.IndexOf("<head>") + 6; // move past head tag also
                    paragraph_title = message.Substring(start_title_index, end_title_index - start_title_index /*- 1*/);
                    if ((is_first_verse || !is_last_verse) && paragraph_title != null && !paragraph_title.Trim().Equals("")
                        && !(is_first_verse && is_last_verse && !start_of_verse))
                    {
                            ms.Append("\r\n");
                            if(uct!=null)
                                ms.Append(paragraph_title.Trim(),color, new TextMarkup[] { TextMarkup.Bold });
                            else
                                ms.Append(paragraph_title.Trim(), new TextMarkup[] { TextMarkup.Bold });
                            ms.Append("\r\n");
                            ms.Append("\r\n");
                    }
                    message = message.Remove(b_index, end_title_index - b_index + 4);
                }
                else if (tag_contents.Contains(PARAGRAPH_TAG))
                {
                    if (start_of_verse)
                    {
                        if(uct!=null)
                            ms.Append(" (" + verse.verse_id + ") ",color, TextMarkup.Bold);
                        else
                            ms.Append(" (" + verse.verse_id + ") ", TextMarkup.Bold);
                        start_of_verse = false;
                    }
                    if(uct!=null)
                        ms.Append(removeTags(message.Substring(0, b_index)),color);
                    else
                        ms.Append(removeTags(message.Substring(0, b_index)));
                    if(!(verse.chapter.chapter_id == 1 && verse.verse_id == 1))
                    {
                        ms.Append("\r\n");
                       // ms.Append("\r\n");
                    }
                    message = message.Remove(0, e_index+1);
                }
               /* else if (tag_contents.Equals(ITALIC_TAG))
                {
                    if (start_of_verse)
                    {
                        ms.Append(" (" + verse.verse_id + ") ", TextMarkup.Bold);
                        start_of_verse = false;
                    }
                    ms.Append(message.Substring(0, b_index));
                    message = message.Remove(0, e_index + 1); //remove opening tag and previous text
                    int e_italic_index = message.IndexOf("<" + END_ITALIC_TAG + ">");
                    ms.Append(message.Substring(0, e_italic_index), TextMarkup.Italics);
                    message = message.Remove(0, e_italic_index+ 4); //remove closing tag and previous text
                }
                else if (tag_contents.Equals(BOLD_TAG))
                {
                    if (start_of_verse)
                    {
                        ms.Append(" (" + verse.verse_id + ") ", TextMarkup.Bold);
                        start_of_verse = false;
                    }
                    ms.Append(message.Substring(0, b_index));
                    message = message.Remove(0, e_index + 1); //remove opening tag and previous text
                    int e_italic_index = message.IndexOf("<" + END_BOLD_TAG + ">");
                    ms.Append(message.Substring(0, e_italic_index), TextMarkup.Bold);
                    message = message.Remove(0, e_italic_index + 4); //remove closing tag and previous text
                }*/
                else
                {
                    message = message.Remove(b_index, e_index - b_index+1);
                }
                b_index = message.IndexOf('<');
            }
            if (start_of_verse)
            {
                if(uct!=null)
                    ms.Append(" (" + verse.verse_id + ") ", color, TextMarkup.Bold);
                else
                    ms.Append(" (" + verse.verse_id + ") ", TextMarkup.Bold);
            }
            if (uct != null)
            {
                ms.Append(parseSCTags(removeTags(message)), color);
            }
            else
            {
                ms.Append(parseSCTags(removeTags(message)));
            }
        }
Ejemplo n.º 3
0
        public override void parseAndAppendBibleText(
            List<Verse> list,
            MessageToSend ms,
            UserColourTheme uct)
        {
            Color color = Color.Empty;
            if (uct != null)
                color = uct.getBibleTextColour();
            string tmp = "";
            Boolean is_last_verse_in_section = false;
            //int verse_end_id = 0;
            int current_chapter = -1;
            if (list.Count > 0)
                current_chapter = list[0].chapter.chapter_id;
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != null)
                {
                    if (list[i].chapter.chapter_id != current_chapter)
                    {
                        if(uct!=null)
                            ms.Append("\r\n" + list[i].book.name + " " + list[i].chapter.chapter_id + "\r\n", color, TextMarkup.Bold);
                        else
                            ms.Append("\r\n" + list[i].book.name + " " + list[i].chapter.chapter_id + "\r\n", TextMarkup.Bold);
                    }

                    //   verse_end_id = list[i].verse_id;
                    is_last_verse_in_section = i == (list.Count - 1);
                    if (i == 0)
                    {
                        appendText(ms, list[i], true, is_last_verse_in_section, uct);
                    }
                    else
                    {

                        appendText(ms, list[i], false, is_last_verse_in_section, uct);
                    }
                }
                current_chapter = list[i].chapter.chapter_id;
            }
            // section += verse_end_id.ToString();
            if (uct != null)
                ms.Append(tmp + "\r\n", color);
            else
                ms.Append(tmp + "\r\n");
        }