Esempio n. 1
0
        /// <summary>
        /// Gets the valid characters list.
        /// </summary>
        /// <param name="key">The valid characters parameter key.</param>
        /// <param name="ws">The writing system</param>
        /// <returns></returns>
        private string GetValidCharactersList(string key, IWritingSystem ws)
        {
            if (key.StartsWith("ValidCharacters_"))
            {
                // If the key contains a locale ID, then don't use the default vernacular
                // writing system, build one from the locale.
                string identifier = key.Substring(key.IndexOf("_") + 1);
                ws = m_cache.ServiceLocator.WritingSystemManager.Get(LangTagUtils.ToLangTag(identifier));
            }
            else if (key == "AlwaysValidCharacters")
            {
                var bldr = new StringBuilder(13);

                // Add the vernacular digits 0 through 9.
                for (int i = 0; i < 10; i++)
                {
                    bldr.Append(m_scr.ConvertToString(i));
                }

                if (ws.RightToLeftScript)
                {
                    // Add the LTR and RTL marks.
                    bldr.Append('\u202A');
                    bldr.Append('\u202B');
                }

                // Add the line separator.
                bldr.Append('\u2028');
                return(bldr.ToString());
            }

            var validChars = ValidCharacters.Load(ws, LoadException ?? NoErrorReport, m_legacyOverridesFile);

            return(validChars != null ? validChars.SpaceDelimitedList : string.Empty);
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert a book
        /// </summary>
        /// <returns>The new book</returns>
        /// ------------------------------------------------------------------------------------
        public IScrBook Do()
        {
            IScripture scr = m_cache.LangProject.TranslatedScriptureOA;
            int        hvoTitle;
            IScrBook   newBook = ScrBook.CreateNewScrBook(m_bookID, scr, out hvoTitle);

            m_bookHvo = newBook.Hvo;

            // Insert the new book title and set the book names
            newBook.InitTitlePara();
            newBook.Name.CopyAlternatives(newBook.BookIdRA.BookName);
            newBook.Abbrev.CopyAlternatives(newBook.BookIdRA.BookAbbrev);

            // Now insert the first section for the new book.
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                   m_cache.DefaultVernWs);

            ScrSection.CreateScrSection(newBook, 0, scr.ConvertToString(1), textProps, false);

            // Do synchronize stuff
            if (FwApp.App != null)
            {
                FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncReloadScriptureControl, 0, 0),
                                      m_cache);
            }

            // Use Redo for rest of sync'ing and updating book filter
            Redo(false);

            return(newBook);
        }