示例#1
0
        private static TermLocalizations GetTermLocalizations(string language)
        {
            TermLocalizations termLocalizations;

            //ScrText scr = new ScrText();
            string fileName = "";

            try
            {
                fileName = BiblicalTermsList.DefaultBiblicalTermsFileFolder + @"\BiblicalTerms" + language + ".xml";
                System.IO.TextReader reader = new StreamReader(fileName);

                using (reader)
                {
                    XmlSerializer xser = Utilities.Memento.CreateXmlSerializer(typeof(TermLocalizations));
                    termLocalizations = (TermLocalizations)xser.Deserialize(reader);
                }
            }
            catch (Exception exc)
            {
                // Fall back to English
                if (language != "En")
                {
                    return(GetTermLocalizations("En"));
                }

                MessageBox.Show(exc.Message + ": " + fileName);
                termLocalizations = null;
            }

            return(termLocalizations);
        }
        public void Show(AnchorsData theAnchors, StoryProjectData theStoryProject)
        {
            Show();
            Cursor curCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            try
            {
#if DEBUG
                // Test the Sword names vs. the names used by Paratext
                foreach (string str in AnchorData.mapSwordToParatextBookCodes.Values)
                {
                    VerseRef verser = new VerseRef(str + " 1:1");
                }
                foreach (string str in AnchorData.mapSwordToParatextBookCodes.Keys)
                {
                    string     strAnchor  = str + " 1:1";
                    AnchorData anchorData = new AnchorData(strAnchor, strAnchor);
                    VerseRef   verser     = new VerseRef(anchorData.AnchorAsVerseRef);
                }
#endif

                List <string> lstRefs = new List <string>();
                foreach (AnchorData anAnchor in theAnchors)
                {
                    VerseRef verseRef = new VerseRef(anAnchor.AnchorAsVerseRef);
                    lstRefs.Add(verseRef.BBBCCCVVV());
                }

                visibleTerms.Clear();
                progressBarLoadingKeyTerms.Maximum = _biblicalTerms.Terms.Count;
                progressBarLoadingKeyTerms.Value   = 0;
                foreach (Term term in _biblicalTerms.Terms)
                {
                    foreach (Verse aVerseReference in term.References)
                    {
                        if (lstRefs.Contains(aVerseReference.VerseRef.BBBCCCVVV()))
                        {
                            visibleTerms.Add(term);
                            break;
                        }
                    }
                    progressBarLoadingKeyTerms.Value++;
                }

                // indicate that we've checked the key terms here.
                theAnchors.IsKeyTermChecked = true;

                if (visibleTerms.Count == 0)
                {
                    MessageBox.Show(Localizer.Str("There are no Biblical Terms in this verse(s)."));
                    return;
                }

                renderings        = TermRenderingsList.GetTermRenderings(_projSettings.ProjectFolder, MainLang.LangCode);
                termLocalizations = TermLocalizations.Localizations;

                ColumnTermLemma.DefaultCellStyle.Font       = new Font("Charis SIL", 12);
                ColumnStatus.DefaultCellStyle.Font          = new Font("Wingdings", 11);
                ColumnRenderings.DefaultCellStyle.Font      = MainLang.FontToUse;
                ColumnRenderings.DefaultCellStyle.ForeColor = MainLang.FontColor;

                termIndexRequested = -1;
                LoadTermsList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Properties.Resources.IDS_KeyTermsProblem,
                                              Environment.NewLine, ex.Message), Properties.Resources.IDS_Caption);
                return;
            }
            finally
            {
                Cursor = curCursor;
            }
        }