/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the book properties on the current ScrBook and ScrBookRef. /// </summary> /// ------------------------------------------------------------------------------------ protected void UpdateBookProperties() { // Save book names and abbreviations to the current ScrBook m_listBookInfo.SaveMultiLingualStrings(); // All new settings in the book should now be written to the ScrBookRef m_currentBook.BookIdRA.BookName.CopyAlternatives(m_currentBook.Name, false); m_currentBook.BookIdRA.BookAbbrev.CopyAlternatives(m_currentBook.Abbrev, false); ScrBookRef scrBookRef = (ScrBookRef)m_currentBook.Cache.ScriptureReferenceSystem.BooksOS[m_currentBook.CanonicalNum - 1]; scrBookRef.BookName.CopyAlternatives(m_currentBook.Name, false); scrBookRef.BookAbbrev.CopyAlternatives(m_currentBook.Abbrev, false); }
/// ------------------------------------------------------------------------------------- /// <summary> /// Create all of the ScrBookRef objects for each book of Scripture /// </summary> /// <param name="progressDlg">Progress dialog so the user can cancel</param> /// ------------------------------------------------------------------------------------- protected void CreateScrBookRefs(IAdvInd4 progressDlg) { IScrRefSystem scr = m_cache.ScriptureReferenceSystem; // If there are books existing, then delete them first. for (int i = scr.BooksOS.Count - 1; i >= 0; i--) { scr.BooksOS.RemoveAt(i); } XmlDocument doc = new XmlDocument(); doc.Load(DirectoryFinder.FWCodeDirectory + @"\Translation Editor\ScrBookRef.xml"); ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor; //Select and display the value of all the ISBN attributes. XmlNodeList tagList = doc.SelectNodes("/ScrBookRef/writingsystem"); progressDlg.SetRange(0, tagList.Count * ScrReference.LastBook); progressDlg.Position = 0; progressDlg.Title = TeResourceHelper.GetResourceString("kstidCreatingBookNames"); foreach (XmlNode writingSystem in tagList) { XmlAttributeCollection attributes = writingSystem.Attributes; string sLocale = attributes.GetNamedItem("iculocale").Value; int ws = m_cache.LanguageEncodings.GetWsFromIcuLocale(sLocale); if (ws == 0) { // It is possible that the XML file contains more languages than the // database. If so, just ignore this writing system. continue; } short iBook = 0; XmlNodeList WSBooks = writingSystem.SelectNodes("book"); foreach (XmlNode book in WSBooks) { XmlAttributeCollection bookAttributes = book.Attributes; string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value; Debug.Assert(sSilBookId != null); // Make sure books are coming in canonical order. Debug.Assert(ScrReference.BookToNumber(sSilBookId) == iBook + 1); string sName = bookAttributes.GetNamedItem("Name").Value; string sAbbrev = bookAttributes.GetNamedItem("Abbreviation").Value; string sAltName = bookAttributes.GetNamedItem("AlternateName").Value; progressDlg.Message = string.Format( TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName); progressDlg.Step(0); // check for the book id ScrBookRef bookRef = null; if (scr.BooksOS.Count > iBook) { bookRef = (ScrBookRef)scr.BooksOS[iBook]; Debug.Assert(bookRef != null); } else { // add this book to the list bookRef = new ScrBookRef(); scr.BooksOS.Append(bookRef); } if (sName != null) { bookRef.BookName.SetAlternative(sName, ws); } if (sAbbrev != null) { bookRef.BookAbbrev.SetAlternative(sAbbrev, ws); } if (sAltName != null) { bookRef.BookNameAlt.SetAlternative(sAltName, ws); } iBook++; } } }