public Chapter(Book book, int number, string name, string transliterated_name, string english_name, RevelationPlace revelation_place, int revelation_order, int bowing_count, List <Verse> verses) { this.book = book; this.number = number; this.sorted_number = number; this.name = name; this.transliterated_name = transliterated_name; this.english_name = english_name; this.revelation_place = revelation_place; this.revelation_order = revelation_order; this.bowing_count = bowing_count; this.verses = verses; if (this.verses != null) { foreach (Verse verse in this.verses) { verse.Chapter = this; } } }
public SuraDocument(XmlDocument rawDoc) { htmlDocument = new XmlDocument(); htmlDocument.LoadXml(rawDoc.LastChild.OuterXml.Replace("xmlns=\"http://www.w3.org/1999/xhtml\"", "")); suraSection = htmlDocument.SelectSingleNode("html/body/section"); Aayas = new Dictionary <int, Aaya>(); if (suraSection != null) { // data-place="Makkah" data-order="5" data-sura="1" data-mushaf="pakistani" RevelationPlace = (QuranMushafAPI.RevelationPlace)Enum.Parse(typeof(QuranMushafAPI.RevelationPlace), suraSection.Attributes["data-place"].Value); if (XmlFunctions.CheckAndLoadInt(suraSection, "data-sura", -1) > -1) { SuraNumber = XmlFunctions.CheckAndLoadInt(suraSection, "data-sura", -1); } if (XmlFunctions.CheckAndLoadInt(suraSection, "data-order", -1) > -1) { RevelationOrder = XmlFunctions.CheckAndLoadInt(suraSection, "data-order", -1); } CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; MushafType = (QuranMushafAPI.Mushaf)Enum.Parse(typeof(QuranMushafAPI.Mushaf), textInfo.ToTitleCase(suraSection.Attributes["data-mushaf"].Value)); Aayas = new Dictionary <int, Aaya>(); XmlNodeList aayas = suraSection.SelectNodes("span[@data-type='aaya']"); foreach (XmlNode aaya in aayas) { Aaya a = new Aaya(aaya); Aayas.Add(a.AayaNumber, a); } } }
// find by revelation place public static List<Chapter> FindChapters(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, RevelationPlace revelation_place) { return DoFindChapters(book, find_scope, current_selection, previous_result, revelation_place); }
private static List<Chapter> DoFindChapters(List<Verse> source, RevelationPlace revelation_place) { List<Chapter> result = new List<Chapter>(); List<Verse> found_verses = new List<Verse>(); if (source != null) { if (source.Count > 0) { Book book = source[0].Book; foreach (Verse verse in source) { switch (revelation_place) { case RevelationPlace.None: { // add nothing } break; case RevelationPlace.Makkah: { if (verse.Chapter != null) { if (verse.Chapter.RevelationPlace == RevelationPlace.Makkah) { found_verses.Add(verse); } } } break; case RevelationPlace.Medina: { if (verse.Chapter != null) { if (verse.Chapter.RevelationPlace == RevelationPlace.Medina) { found_verses.Add(verse); } } } break; case RevelationPlace.Both: { found_verses.Add(verse); } break; } } } } int current_chapter_number = -1; foreach (Verse verse in found_verses) { if (verse.Chapter != null) { if (current_chapter_number != verse.Chapter.Number) { current_chapter_number = verse.Chapter.Number; result.Add(verse.Chapter); } } } return result; }
private static List<Chapter> DoFindChapters(Book book, FindScope find_scope, Selection current_selection, List<Verse> previous_result, RevelationPlace revelation_place) { List<Verse> source = GetSourceVerses(book, find_scope, current_selection, previous_result); return DoFindChapters(source, revelation_place); }
private void FindByRevelation() { if (m_client != null) { PrepareNewSearch(); if (!FindByRevelationPlaceMakkahRadioButton.Checked && !FindByRevelationPlaceMedinaRadioButton.Checked) { m_find_by_revelation_place = RevelationPlace.None; } else if (FindByRevelationPlaceMakkahRadioButton.Checked && !FindByRevelationPlaceMedinaRadioButton.Checked) { m_find_by_revelation_place = RevelationPlace.Makkah; } else if (!FindByRevelationPlaceMakkahRadioButton.Checked && FindByRevelationPlaceMedinaRadioButton.Checked) { m_find_by_revelation_place = RevelationPlace.Medina; } else if (FindByRevelationPlaceMakkahRadioButton.Checked && FindByRevelationPlaceMedinaRadioButton.Checked) { m_find_by_revelation_place = RevelationPlace.Both; } m_client.FindChapters(m_find_by_revelation_place); if (m_client.FoundChapters != null) { m_client.FoundVerses = new List<Verse>(); foreach (Chapter chapter in m_client.FoundChapters) { m_client.FoundVerses.AddRange(chapter.Verses); } if (m_client.FoundVerses != null) { int chapter_count = m_client.FoundChapters.Count; m_find_result_header = chapter_count + ((chapter_count == 1) ? " chapter" : " chapters") + " revealed in " + m_find_by_revelation_place.ToString() + " in " + m_client.FindScope.ToString(); DisplayFoundChapters(true); } } } }
// find by revelation place /// <summary> /// Find chapters that were revealed at given revelation place. /// </summary> /// <param name="revelation_place"></param> /// <returns>Number of found chapters. Result is stored in FoundChapters.</returns> public int FindChapters(RevelationPlace revelation_place) { m_found_chapters = Server.FindChapters(m_book, m_find_scope, m_selection, m_found_verses, revelation_place); if (m_found_chapters != null) { return m_found_chapters.Count; } return 0; }