public Prostration(int number, ProstrationType type, Verse verse) { this.number = number; this.type = type; this.verse = verse; if (verse != null) { verse.Prostration = this; } }
// find by prostration type public static List<Verse> FindVerses(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, ProstrationType prostration_type) { return DoFindVerses(book, find_scope, current_selection, previous_result, prostration_type); }
private static List<Verse> DoFindVerses(List<Verse> source, ProstrationType prostration_type) { List<Verse> result = new List<Verse>(); if (source != null) { if (source.Count > 0) { Book book = source[0].Book; switch (prostration_type) { case ProstrationType.None: { // add nothing } break; case ProstrationType.Obligatory: { foreach (Verse verse in source) { if (verse.Prostration != null) { if (verse.Prostration.Type == ProstrationType.Obligatory) { result.Add(verse); } } } } break; case ProstrationType.Recommended: { foreach (Verse verse in source) { if (verse.Prostration != null) { if (verse.Prostration.Type == ProstrationType.Recommended) { result.Add(verse); } } } } break; default: { foreach (Verse verse in source) { if (verse.Prostration != null) { result.Add(verse); } } } break; } } } return result; }
private static List<Verse> DoFindVerses(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, ProstrationType prostration_type) { List<Verse> source = GetSourceVerses(book, find_scope, current_selection, previous_result); return DoFindVerses(source, prostration_type); }
private void FindByProstration() { if (m_client != null) { PrepareNewSearch(); if (!FindByProstrationTypeObligatoryCheckBox.Checked && !FindByProstrationTypeRecommendedCheckBox.Checked) { m_find_by_prostration_type = ProstrationType.None; } else if (FindByProstrationTypeObligatoryCheckBox.Checked && !FindByProstrationTypeRecommendedCheckBox.Checked) { m_find_by_prostration_type = ProstrationType.Obligatory; } else if (!FindByProstrationTypeObligatoryCheckBox.Checked && FindByProstrationTypeRecommendedCheckBox.Checked) { m_find_by_prostration_type = ProstrationType.Recommended; } else if (FindByProstrationTypeObligatoryCheckBox.Checked && FindByProstrationTypeRecommendedCheckBox.Checked) { m_find_by_prostration_type = ProstrationType.Both; } m_client.FindVerses(m_find_by_prostration_type); if (m_client.FoundVerses != null) { int verse_count = m_client.FoundVerses.Count; m_find_result_header = verse_count + ((verse_count == 1) ? " verse" : " verses") + " with " + m_find_by_prostration_type.ToString() + " prostrations" + " in " + m_client.FindScope.ToString(); DisplayFoundVerses(true); } } }
// find by prostration type /// <summary> /// Find verses with given prostration type. /// </summary> /// <param name="prostration_type"></param> /// <returns>Number of found verses. Result is stored in FoundVerses.</returns> public int FindVerses(ProstrationType prostration_type) { m_found_verses = Server.FindVerses(m_book, m_find_scope, m_selection, m_found_verses, prostration_type); if (m_found_verses != null) { return m_found_verses.Count; } return 0; }