protected void TurnOnResource(string strModuleName)
 {
     moduleVersion = manager.getModule(strModuleName);
     System.Diagnostics.Debug.Assert(moduleVersion != null);
     m_nBook    = 0;             // forces a refresh
     m_nChapter = 0;
     m_nVerse   = 0;
     DisplayVerses();
 }
Example #2
0
        /// <summary>
        /// Returns the verse text.
        /// </summary>
        /// <param name="version">Bible version - obtained from getBibles()</param>
        /// <param name="b">1-based book (1..66)</param>
        /// <param name="c">1-based chapter (1..150)</param>
        /// <param name="v">2-based verse (1..?)</param>
        /// <returns></returns>
        public string getVerseText(string version, int b, int c, int v)
        {
            SWModule module = getModule(version);

            VerseKey vk = new VerseKey();

            vk.AutoNormalize((char)0);
            // Or else it will get improperly normalized before it's fully configured.

            if (b < 40)
            {
                vk.Testament((char)1);
                // OT =  1..39 -> Sword = 1..39
                vk.Book((char)b);
            }
            else
            {
                vk.Testament((char)2);
                // NT = 40..66 -> Sword = 1..27
                vk.Book((char)(b - 39));
            }

            vk.Chapter(c);
            vk.Verse(v);

            /* vk.Error() would return an error (non-zero) if only vk.Testament is set (even though
             * it sets Book = Chapter = Verse = 1).
             *
             * If there's an error in vk, the increment below would be ignored, so we either have
             * to call vk.Error() to clear it, or set the Book, Chapter, and Verse.
             *  vk.Error();
             *  vk.Book((char)1);
             *  vk.Chapter(1);
             *  vk.Verse(1);
             *
             * The following two don't work because incrementing the index takes us through
             * headings and other non-verse indices:
             *      vk.increment(verseIdx);
             *      vk.Index(vk.Index() + verseIdx);
             */

            if (vk.Error() != '\0')
            {
                // report the error
            }

            return(DreamTools.Sword_ConvertEncoding(module.RenderText(vk)).Trim());
        }
Example #3
0
        private void ShowNote(SWModule module, SWKey tmpKey, string NoteType)
        {
            AttributeListMap     list;
            AttributeTypeListMap listType;
            AttributeValueMap    listValue;

            // this line looks like it's not needed, but it is. It has some non-obvious side effect
            //  such that if it's missing, then the call to "list.get(new SWBuf(NoteType));" fails
            string s = module.RenderText(tmpKey);

            listType  = module.getEntryAttributesMap();
            list      = listType.get(new SWBuf("Footnote"));
            listValue = list.get(new SWBuf(NoteType));
            string strFootnote = listValue.get(new SWBuf("body")).c_str();

            SetDisplayText(strFootnote);                // module.StripText(strFootnote));
        }
        protected void InitializeSword()
        {
            // Initialize Module Variables
            filterManager = new MarkupFilterMgr((char)Sword.FMT_HTMLHREF, (char)Sword.ENC_HTML);

            /* NOTE: GC.SuppressFinalize(filterManager);
             *  This must be placed here so the garbage collector (GC) doesn't try to clean up
             * something that was already cleaned up.  If this is not left in an error will
             * occur when the application closes.  This happens because when the SWMgr is
             * cleaned by the GC it cleans its own filter and removes it from memory.  When
             * the GC then tries to clean up the filterManager object it doesn't really
             * exist in memory anymore and therefore it throws an exception saying some
             * memory is probably corrupt because this object points to trash in memory.
             * -Richard Parsons 11-21-2006
             */
            GC.SuppressFinalize(filterManager);

            manager = new SWMgr(filterManager);
            if (manager == null)
            {
                throw new ApplicationException("Unable to create the Sword utility manager");
            }

            foreach (string strPath in GetModuleLocations())
            {
                manager.augmentModules(strPath);
            }

            // first determine all the possible resources available
            int numOfModules = (int)manager.getModules().size();

            for (int i = 0; i < numOfModules; i++)
            {
                if (manager.getModuleAt(i).Type().Equals("Biblical Texts"))                 //Limit to just bibles, comment out to see all modules
                {
                    string strModuleName = manager.getModuleAt(i).Name();
                    if (lstModulesToSuppress.Contains(strModuleName))
                    {
                        continue;
                    }

                    string strModuleDesc = manager.getModuleAt(i).Description();
                    if (Properties.Settings.Default.SwordModulesUsed.Contains(strModuleName))
                    {
                        lstBibleResources.Add(new SwordResource(strModuleName, strModuleDesc, true));
                        InitSwordResourceRadioButton(strModuleName, strModuleDesc);
                    }
                    else
                    {
                        lstBibleResources.Add(new SwordResource(strModuleName, strModuleDesc, false));
                    }
                }
            }

            string moduleToStartWith = CstrNetFreeModuleName;

            if (!string.IsNullOrEmpty(Properties.Settings.Default.LastSwordModuleUsed))
            {
                moduleToStartWith = Properties.Settings.Default.LastSwordModuleUsed;
            }

            moduleVersion = manager.getModule(moduleToStartWith);
            if (moduleVersion == null)
            {
                throw new ApplicationException(String.Format("Can't find the Sword module '{0}'. Is Sword installed?", Properties.Settings.Default.SwordModulesUsed[0]));
            }

            // Setup the active module
            // Word of Christ in red
            manager.setGlobalOption("Words of Christ in Red", "On");

            //Footnotes
            manager.setGlobalOption("Footnotes", "On");

            /* NOTE: This is needed so the DOM Script I'm using for strongs numbers,
             * morph, and footnote tags will work.  This basicly allows the webbrowser
             * control to talk to my form control using DOM Script using the command
             * window.external.<the public method from this form>;
             * -Richard Parsons 01-31-2007
             */
            webBrowserNetBible.ObjectForScripting = this;

            if (tableLayoutPanelSpinControls.Controls[CstrRadioButtonPrefix + moduleToStartWith] is RadioButton)
            {
                RadioButton rb = (RadioButton)tableLayoutPanelSpinControls.Controls[CstrRadioButtonPrefix + moduleToStartWith];
                rb.Checked = true;
            }
        }
Example #5
0
        public BibleVersion(BackgroundWorker worker, DoWorkEventArgs evArg, string version, System.Data.DataTable replacements)
        {
            _version      = version;
            _replacements = replacements;
            int i = 0, b = -1, book;

            System.EventArgs e = new System.EventArgs();
            SWModule         module = SwordW.Instance().getModule(version);
            VerseKey         vk = new VerseKey("Gen 1:1");

            while (vk.Error() == '\0')
            {
                if ((i % 300) == 0)
                {
                    int progress = (int)(((float)i / 31102F) * 100);
                    worker.ReportProgress(progress);
                }
                string t = DreamTools.Sword_ConvertEncoding(module.RenderText(vk)).Trim();
                book = vk.Book();

                // Book numbering is 1-based and starts back up from 1 in the New Testament
                // OT = 1, NT = 2
                if (vk.Testament() == (char)2)
                {
                    book += 39;
                }
                BibleVerse v = new BibleVerse(i, book - 1, vk.Chapter(), vk.Verse(), Replace(t));
                verses[i] = v;

                // book is 1-based, b is 0-based
                if (b < book - 1)
                {
                    b = book - 1;
                    BibleBooks[b].Long = vk.getBookName();
                    Console.WriteLine("Processing " + BibleBooks[b].Long);
                    if (worker.CancellationPending)
                    {
                        evArg.Cancel = true;
                    }
                }

                i++;
                vk.increment();
            }

            _VerseCount = i;

            for (i = 0; i < this.BibleBooks.Length; i++)
            {
                if (BibleBooks[i].Long == null)
                {
                    BibleBooks[i].Long = "";
                }
                string bk = BibleBooks[i].Long;
                bk = Regex.Replace(bk.Trim(), @"^III ", "3 ");
                bk = Regex.Replace(bk, @"^II ", "2 ");
                bk = Regex.Replace(bk, @"^I ", "1 ");
                BibleBooks[i].Long  = bk;
                BibleBooks[i].Short = bk;
            }

            worker.ReportProgress(100);
        }