示例#1
0
        private static BiblicalTermsList GetBiblicalTermsLocal(string path)
        {
            BiblicalTermsList btl = null;

            if (!File.Exists(path))
            {
                return(null);
            }

            using (TextReader reader = new StreamReader(path))
            {
                try
                {
                    XmlSerializer xser = Utilities.Memento.CreateXmlSerializer(typeof(BiblicalTermsList));
                    btl = (BiblicalTermsList)xser.Deserialize(reader);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(path + ": " + exc.Message);
                    return(null);
                }
            }

            btl.Terms.ForEach(term => term.Versification = btl.Versification);
            btl.termsFileName = path;
            return(btl);
        }
示例#2
0
        /// <summary>
        /// Return a list of all Biblical Terms.
        /// If this has already been read, use previously read list.
        /// List is found in "BiblicalTerms.xml" in Paratext executable directory.
        /// </summary>
        /// <returns></returns>
        public static BiblicalTermsList GetBiblicalTerms()
        {
            if (biblicalTerms != null)
            {
                return(biblicalTerms);
            }

            if (biblicalTermsPath == "")
            {
                biblicalTermsPath = DefaultBiblicalTermsFileName;
            }

            if (biblicalTermsPath.EndsWith("\\MyBiblicalTerms.xml"))
            {
                return(GetMyBiblicalTermsList());
            }

            biblicalTerms = GetBiblicalTermsLocal(biblicalTermsPath);
            if (biblicalTerms == null && biblicalTermsPath != DefaultBiblicalTermsFileName)
            {
                biblicalTermsPath = DefaultBiblicalTermsFileName;
                biblicalTerms     = GetBiblicalTermsLocal(biblicalTermsPath);
            }

            CreateIndexDictionary(biblicalTerms);
            RemoveDuplicateReferences();

            return(biblicalTerms);
        }
示例#3
0
        // Assign an index to each term and create a map from id to index
        private static void CreateIndexDictionary(BiblicalTermsList btl)
        {
            int index = 0;

            btl.idToIndexDictionary = new Dictionary <string, int>();

            foreach (Term term in btl.Terms)
            {
                btl.idToIndexDictionary[term.Id] = index;
                term.Index = index;
                ++index;
            }
        }
        readonly BiblicalTermsList _biblicalTerms;           // All Biblical terms

        public BiblicalKeyTermsForm(StoryEditor theSE, ProjectSettings projSettings, ProjectSettings.LanguageInfo liMainLang)
        {
            _theSE        = theSE;
            MainLang      = liMainLang;
            _projSettings = projSettings;
            InitializeComponent();
            _biblicalTerms = BiblicalTermsList.GetBiblicalTerms();
            htmlBuilder    = new BiblicalTermsHTMLBuilder(projSettings);

            // TODO: temporary hack. If we are using the Hindi 'MyKeyTerms' db, then
            // change the 'English Gloss' column header to Hindi and change the font
            if (_biblicalTerms.IsMyBiblicalTerms)
            {
                ColumnGlossEnglish.HeaderText            = "Gloss";
                ColumnGlossEnglish.DefaultCellStyle.Font = new Font("Arial Unicode MS", 12);
            }
        }
示例#5
0
        /// <summary>
        /// Get terms list for My Paratext Project/MyBiblicalTerms.xml.
        /// Create an empty list if this does not exist yet.
        /// </summary>
        /// <returns></returns>
        public static BiblicalTermsList GetMyBiblicalTermsList()
        {
            if (myBiblicalTermsList != null)
            {
                return(myBiblicalTermsList);
            }

            string fileName = Path.Combine(Path.Combine(StoryProjectData.GetRunningFolder, "BiblicalTerms"), "MyBiblicalTerms.xml");

            myBiblicalTermsList = GetBiblicalTermsLocal(fileName);

            if (myBiblicalTermsList != null)
            {
                CreateIndexDictionary(myBiblicalTermsList);
                return(myBiblicalTermsList);
            }

            myBiblicalTermsList = new BiblicalTermsList();
            myBiblicalTermsList.termsFileName = fileName;
            CreateIndexDictionary(myBiblicalTermsList);

            return(myBiblicalTermsList);
        }
示例#6
0
        /* rde
         *
         * public static void SelectAllBiblicalTermsList()
         * {
         *      ForceReloadOfTerms();
         *      biblicalTermsPath = Path.Combine(
         *              Path.Combine(Program.DataPath, "BiblicalTerms"),
         *              "AllBiblicalTerms.xml");
         *
         *      Properties.Settings.Default.BiblicalTermsPath = biblicalTermsPath;
         *
         *      OnBiblicalTermsListChanged();
         * }
         */

        private static void ForceReloadOfTerms()
        {
            biblicalTerms       = null;
            myBiblicalTermsList = null;
        }