private void ShuffleCards() { switch (difficulty) { case 1: currentScriptures.AddRange(easyScriptures); break; case 2: currentScriptures.AddRange(easyScriptures); currentScriptures.AddRange(mediumScriptures); break; case 3: currentScriptures.AddRange(mediumScriptures); currentScriptures.AddRange(hardScriptures); break; } for (int i = 0; i < currentScriptures.Count - 1; i++) { int j = Random.Range(i, currentScriptures.Count); Scripture temp = currentScriptures[i]; currentScriptures[i] = currentScriptures[j]; currentScriptures[j] = temp; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Call the base class method /// </summary> /// ------------------------------------------------------------------------------------ public static void CallCreateScrNoteCategories(Scripture scr, XmlDocument doc) { DummyTeScrNoteCategoriesInit noteCategoriesInitializer = new DummyTeScrNoteCategoriesInit(null, scr, doc.SelectSingleNode("TEScrNoteCategories")); noteCategoriesInitializer.CreateScrNoteCategories(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:MultipleFilterDlg"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public MultipleFilterDlg(FdoCache cache, ICmFilter filter) : this() { m_cache = cache; m_scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_filter = filter; // Initialize the enabled status of the group boxes. chkStatus_CheckedChanged(null, null); chkType_CheckedChanged(null, null); chkScrRange_CheckedChanged(null, null); // Initialize the beginning and ending default Scripture references. int firstBook = 1; int lastBook = ScrReference.LastBook; if (m_scr.ScriptureBooksOS.Count > 0) { firstBook = m_scr.ScriptureBooksOS[0].CanonicalNum; lastBook = m_scr.ScriptureBooksOS[m_scr.ScriptureBooksOS.Count - 1].CanonicalNum; } scrBookFrom.Initialize(new ScrReference(firstBook, 1, 1, m_scr.Versification), m_scr, false); scrBookTo.Initialize(new ScrReference(lastBook, 1, 0, m_scr.Versification).LastReferenceForBook, m_scr, false); // Update the controls from the filter in the database. InitializeFromFilter(); chkCategory.Checked = tvCatagories.Load(m_cache, m_filter, null); chkCategory_CheckedChanged(null, null); }
public async Task <IActionResult> PutScripture(int id, Scripture scripture) { if (id != scripture.ID) { return(BadRequest()); } _context.Entry(scripture).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScriptureExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void SetRoot(int hvo) { CheckDisposed(); if (hvo != 0) { ICmObject co = CmObject.CreateFromDBObject(Cache, hvo); if (Scripture.IsResponsibleFor(co as StText)) { m_hvoRoot = hvo; // StText (i.e. Scripture) } else { m_hvoRoot = co.OwnerHVO; // Text (i.e. non-scripture). Editable. } SetupVc(); } else { m_hvoRoot = 0; ReadOnlyView = true; if (m_vc != null) { m_vc.IsScripture = false; m_vc.Editable = false; } } ChangeOrMakeRoot(m_hvoRoot, m_vc, TitleContentsVc.kfragRoot, m_styleSheet); }
public async Task <ActionResult <Scripture> > PostScripture(Scripture scripture) { _context.Scripture.Add(scripture); await _context.SaveChangesAsync(); return(CreatedAtAction("GetScripture", new { id = scripture.ID }, scripture)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ScrCheckingTokenizer"/> class. /// </summary> /// <param name="book">The book being parsed.</param> /// <param name="chapterNum">The 1-basede canonical chapter number being parse, or 0 to /// parse the whole book</param> /// ------------------------------------------------------------------------------------ public ScrCheckingTokenizer(ScrBook book, int chapterNum) { m_book = book; m_scr = (Scripture)book.Owner; m_chapterNum = chapterNum; m_writingSystemLocales = new Dictionary <int, string>(); Reset(); }
public override void FixtureSetup() { base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; ScrReferenceTests.InitializeScrReferenceForTests(); }
private ITsString TitleForWs(int ws) { ITsString tssTitle = null; if (ScriptureServices.ScriptureIsResponsibleFor(this)) { Scripture scripture = Cache.LangProject.TranslatedScriptureOA as Scripture; if (scripture != null) { tssTitle = scripture.BookChapterVerseBridgeAsTss(this, ws); if (OwningFlid == ScrSectionTags.kflidHeading) { string sFmt = Strings.ksSectionHeading; int iMin = sFmt.IndexOf("{0}"); if (iMin < 0) { tssTitle = m_cache.MakeUserTss(sFmt); } else { ITsIncStrBldr tisb = TsIncStrBldrClass.Create(); if (iMin > 0) { tisb.AppendTsString(m_cache.MakeUserTss(sFmt.Substring(0, iMin))); } tisb.AppendTsString(tssTitle); if (iMin + 3 < sFmt.Length) { tisb.AppendTsString(m_cache.MakeUserTss(sFmt.Substring(iMin + 3))); } tssTitle = tisb.GetString(); } } } } else if (Owner is IText) { IText text = Owner as IText; tssTitle = text.Name.get_String(ws); } else { // throw? } if (tssTitle == null) { tssTitle = TsStrFactoryClass.Create().EmptyString(Cache.DefaultAnalWs); } return(tssTitle); }
void SetupVc() { if (m_vc == null || m_hvoRoot == 0) { return; } Debug.Assert(m_hvoRoot != 0, "m_hvoRoot should be set before using SetupVc()."); ICmObject co = CmObject.CreateFromDBObject(Cache, m_hvoRoot); m_vc.IsScripture = Scripture.IsResponsibleFor(co as StText); // don't allow editing scripture titles. m_vc.Editable = !m_vc.IsScripture; this.ReadOnlyView = !m_vc.Editable; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Scripture = await _context.Scripture.FirstOrDefaultAsync(m => m.ID == id); if (Scripture == null) { return(NotFound()); } return(Page()); }
public async Task OnGetAsync(string scriptureBook, string searchString, int?sort) { IQueryable <string> bookQuery = from m in _context.Scripture orderby m.Book select m.Book; IOrderedQueryable <Scripture> scriptureList; if (sort == 2) { // using LINQ to get list of books. scriptureList = from m in _context.Scripture orderby m.DateAdded select m; } else { // using LINQ to get list of books. scriptureList = from m in _context.Scripture orderby m.Book select m; } // using System.Linq if (!String.IsNullOrEmpty(searchString)) { scriptureList = (IOrderedQueryable <Scripture>)scriptureList.Where(s => s.Note.Contains(searchString)); } if (!String.IsNullOrEmpty(scriptureBook)) { scriptureList = (IOrderedQueryable <Scripture>)scriptureList.Where(x => x.Book == scriptureBook); } Books = new SelectList(await bookQuery.Distinct().ToListAsync()); Scripture = await scriptureList.ToListAsync(); SearchString = searchString; ScriptureBook = scriptureBook; var result = Scripture.Select((x, i) => new { Group = i / 5, Value = x }) .GroupBy(item => item.Group, g => g.Value) .Select(g => g.Where(x => true)); ScriptureList = result; }
///------------------------------------------------------------------------------- /// <summary> /// When the Source button is clicked, display the import wizard. /// </summary> ///------------------------------------------------------------------------------- private void btnSource_Click(object sender, System.EventArgs e) { ILangProject lp = m_cache.LangProject; Scripture scr = (Scripture)lp.TranslatedScriptureOA; using (ImportWizard importWizard = new ImportWizard(lp.Name.AnalysisDefaultWritingSystem, scr, m_StyleSheet, m_cache, m_helpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { // Ditch any in-memory changes made to the settings. Reload from the DB. m_importSettings.RevertToSaved(); } // If there are no files after showing the wizard, close the import dialog if (InitBookNameList() == 0) { MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return; } // Update the file ranges for import because they may have changed. The default // set of settings may also have changed, so we re-retrieve them from the DB. m_importSettings = (ScrImportSet)scr.DefaultImportSettings; scrPsgFrom.Initialize(new ScrReference(StartRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); // Update the passage controls to reflect the new range of files available // Only make changes that do not expand the available range of books since a // range may have been specified before the wizard was run that we do not // want to overwrite if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference)) { SetStartRefToFirstImportableBook(); } if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference)) { SetEndRefToLastImportableBook(); } } btnOK.Focus(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Scripture = await _context.Scripture .Include(s => s.book).FirstOrDefaultAsync(m => m.ID == id); if (Scripture == null) { return(NotFound()); } ViewData["BookName"] = new SelectList(_context.Set <Book>(), "BookId", "BookName"); return(Page()); }
///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, ScrImportSet settings, string helpFile) : this() { m_StyleSheet = styleSheet; m_cache = cache; Scripture scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; m_helpFile = helpFile; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef.ContainsKey(m_cache)) { StartRef = s_StartRef[m_cache]; } else { SetStartRefToFirstImportableBook(); } if (s_EndRef.ContainsKey(m_cache)) { EndRef = s_EndRef[m_cache]; } else { SetEndRefToLastImportableBook(); } // Finish constructing the ScrBookControl objects. Paratext.ScrVers versification = scr.Versification; scrPsgFrom.Initialize(new ScrReference(StartRef, versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, versification), scr, m_importSettings.BooksForProject.ToArray()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Scripture = await _context.Scripture.FindAsync(id); if (Scripture != null) { _context.Scripture.Remove(Scripture); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Writes the list of annotations to the specified cache. /// </summary> /// <param name="cache">The cache.</param> /// <param name="styleSheet">The style sheet.</param> /// <param name="OXESADir">The OXESA directory.</param> /// ------------------------------------------------------------------------------------ protected void WriteToCache(FdoCache cache, FwStyleSheet styleSheet, string OXESADir) { Scripture scr = cache.LangProject.TranslatedScriptureOA as Scripture; try { foreach (XmlScrNote ann in Annotations) { ScrNoteImportManager.Initialize(scr, ann.BeginScrBCVRef.Book, OXESADir); ann.WriteToCache(scr, styleSheet); } } finally { ScrNoteImportManager.Cleanup(); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Scripture = await _context.Scripture .Include(s => s.Book) .Include(s => s.Book.Volume) .FirstOrDefaultAsync(m => m.ScriptureId == id); if (Scripture == null) { return(NotFound()); } return(Page()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attempt to set the selection immediately following the last character of the closest /// verse number to the requested verse. If no section exists within one chapter of the /// requested verse, the selection will not be changed. /// </summary> /// <param name="targetRef">Reference to seek</param> /// <returns>true if the selected is changed (to the requested verse or one nearby); /// false otherwise</returns> /// ------------------------------------------------------------------------------------ public bool GotoVerse(ScrReference targetRef) { CheckDisposed(); Scripture scr = new Scripture(m_fdoCache, HvoScripture); int iBook = 0; foreach (ScrBook book in scr.ScriptureBooksOS) { if (book.BookIdRA.OwnOrd == targetRef.Book) { // found the book ScrSection prevSection; int iSection = 0; foreach (ScrSection section in book.SectionsOS) { if (section.VerseRefStart <= targetRef) { if (section.VerseRefEnd >= targetRef) { int ihvoPara; // index of paragraph containing the verse int ichPosition; //place to put IP. FindVerseNumber(section, targetRef, out ihvoPara, out ichPosition); SetInsertionPoint(iBook, iSection, ihvoPara, ichPosition, false); return(true); } prevSection = section; } else { // try finding a close enough verse ref in previous section } iSection++; } } iBook++; } return(false); }
public void SetScripture(Scripture mine) { myScripture = mine; myText.UnwrappedText = myScripture.text; myText.NeedsLayout = true; verseSourceText.UnwrappedText = myScripture.verse; verseSourceText.NeedsLayout = true; if (myScripture.isAccurate) { target = SlotSide.RIGHT; } else { target = SlotSide.LEFT; } }
public void Init() { m_inMemoryCache = ScrInMemoryFdoCache.Create(this); m_inMemoryCache.InitializeLangProject(); m_inMemoryCache.InitializeScripture(); m_inMemoryCache.AddBookToMockedScripture(1, "Genesis"); m_inMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_inMemoryCache.AddBookToMockedScripture(5, "Deuteronomy"); m_James = m_inMemoryCache.AddBookToMockedScripture(59, "James"); m_inMemoryCache.AddBookToMockedScripture(66, "Revelation"); m_fdoCache = m_inMemoryCache.Cache; m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; m_ctrlOwner = new Form(); ILgWritingSystemFactory wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor; m_scp = new DummyScrPassageControl(null, m_scr, false); m_dbScp = new DummyScrPassageControl(null, m_scr, true); m_ctrlOwner.Controls.Add(m_scp); m_ctrlOwner.Controls.Add(m_dbScp); m_ctrlOwner.CreateControl(); if (m_scp.DropDownWindow != null) { m_scp.DropDownWindow.Close(); } if (m_dbScp.DropDownWindow != null) { m_dbScp.DropDownWindow.Close(); } // Forcing the reference to this should reset the ScrReference object for us // which, we hope will cause some strange errors to occur when running in // console mode. The tests seem to always work in gui mode but not console mode. m_scp.ScReference = new ScrReference(01001001, m_scr.Versification); m_dbScp.ScReference = new ScrReference(01001001, m_scr.Versification); }
private void SetupVc() { if (m_vc == null || m_hvoRoot == 0) { return; } int wsFirstPara = Cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, m_hvoRoot, (int)StText.StTextTags.kflidParagraphs); if (wsFirstPara == -1) { // The paragraph's first character has no valid writing system...this seems to be possible // when it consists entirely of a picture. Rather than crashing, presume the default. wsFirstPara = Cache.DefaultVernWs; } m_vc.SetupVernWsForText(wsFirstPara); StText stText = new StText(Cache, m_hvoRoot); if (m_configurationParameters != null) { m_vc.Editable = SIL.Utils.XmlUtils.GetOptionalBooleanAttributeValue( m_configurationParameters, "editable", true) && !Scripture.IsResponsibleFor(stText); } }
public void HardLineBreak() { CheckDisposed(); // Set IP in the middle of the second Scripture section head in James. // Then press Shift-Enter. This should put a hard line break in the middle of this // section head and the IP should be at the beginning of the second line. DummyDraftView draftView = m_draftForm.DraftView; draftView.RootBox.Activate(VwSelectionState.vssEnabled); draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); KeyEventArgs e = new KeyEventArgs(Keys.Right); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); // We should be between the 'a' and 'n' of the word "and" in the section head // containing "Faith and Wisdom". SelectionHelper selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); int ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(7, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have split the line between the 'a' and 'n' of the word "and". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(8, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. Scripture scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); ScrBook james = (ScrBook)scr.ScriptureBooksOS[1]; ScrSection modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[7]); // Second test: // Set IP at the beginning of the second Scripture section head in James. // Then press Shift-Enter. This should put an empty line at the beginning of this // section head and the IP should be at the beginning of the second line. draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have an blank line before Faith and Wisdom. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(2, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head containing "Faith and Wisdom". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); james = (ScrBook)scr.ScriptureBooksOS[1]; modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[0]); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the <see cref="TeScrInitializer.CreateScrBookAnnotations"/> method /// </summary> /// <param name="scr">The Scripture object in the DB</param> /// ------------------------------------------------------------------------------------ public void CallCreateScrBookAnnotations(Scripture scr) { CreateScrBookAnnotations(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the settings for Import, either from database or from wizard /// </summary> /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns> /// ------------------------------------------------------------------------------------ protected ScrImportSet GetImportSettings() { ILangProject proj = m_cache.LangProject; Scripture scr = (Scripture)proj.TranslatedScriptureOA; ScrImportSet importSettings = new ScrImportSet(m_cache, scr.DefaultImportSettingsHvo, m_styleSheet, FwApp.App.HelpFile); importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(); if (!importSettings.BasicSettingsExist) { // REVIEW DavidO: Should I use AnalysisDefaultWritingSystem or // VernacularDefaultWritingSystem or something else. using (ImportWizard importWizard = new ImportWizard(proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; } } else { StringCollection sInvalidFiles; bool fCompletedWizard = false; while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles)) { // Display the "Project Not Found" message box using (ScrImportSetMessage dlg = new ScrImportSetMessage()) { string[] files = new string[sInvalidFiles.Count]; sInvalidFiles.CopyTo(files, 0); dlg.InvalidFiles = files; dlg.HelpURL = FwApp.App.HelpFile; dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm"; dlg.DisplaySetupOption = true; switch (dlg.ShowDialog()) { case DialogResult.OK: // Setup... { using (ImportWizard importWizard = new ImportWizard( proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; fCompletedWizard = true; } break; } case DialogResult.Cancel: return(null); case DialogResult.Retry: // Loop around until user gets tired. break; } } } if (!fCompletedWizard) { if (ParatextProjHasUnmappedMarkers(importSettings)) { // TODO: Show message box and then bring up import wizard } } } return(importSettings); }
/// <summary> /// Load sections into the books of a scripture tree view optionally including the /// heading as well as the content of each section. /// </summary> /// <param name="cache"></param> /// <param name="fIncludeHeadings"></param> public void LoadSections(FdoCache cache, bool fIncludeHeadings) { try { cache.EnableBulkLoadingIfPossible(true); // first load the book ids. this.Nodes.Clear(); this.LoadBooks(cache); TreeNode bibleNode; if (this.Nodes.Count == 1) { bibleNode = this.Nodes[0]; } else if (this.Nodes.Count > 0) { throw new ArgumentException("We should only have 1 Bible node, not " + this.Nodes.Count); } else { return; } if (cache.LangProject.TranslatedScriptureOA == null) { return; } Scripture scripture = cache.LangProject.TranslatedScriptureOA as Scripture; foreach (TreeNode testament in bibleNode.Nodes) { foreach (TreeNode bookNode in testament.Nodes) { IScrBook book = ScrBook.CreateFromDBObject(cache, (int)bookNode.Tag) as IScrBook; // Add Title node. if (book.TitleOAHvo != 0) { TreeNode titleNode = new TreeNode(ResourceHelper.GetResourceString("kstidScriptureTitle")); titleNode.Name = book.TitleOAHvo.ToString(); titleNode.Tag = book.TitleOAHvo; bookNode.Nodes.Add(titleNode); } // Add Sections. foreach (IScrSection section in book.SectionsOS) { string chapterVerseBridge = scripture.ChapterVerseBridgeAsString(section); if (fIncludeHeadings && section.HeadingOAHvo != 0) { // Include the heading text if it's not empty. See LT-8764. int cTotal = 0; foreach (IStTxtPara para in section.HeadingOA.ParagraphsOS) { cTotal += para.Contents.Length; } if (cTotal > 0) { string sFmt = ResourceHelper.GetResourceString("kstidSectionHeading"); TreeNode node = new TreeNode(String.Format(sFmt, chapterVerseBridge)); node.Name = String.Format(sFmt, section.Hvo.ToString()); node.Tag = section.HeadingOAHvo; // expect an StText bookNode.Nodes.Add(node); } } TreeNode sectionNode = new TreeNode(chapterVerseBridge); sectionNode.Name = section.Hvo.ToString(); sectionNode.Tag = section.ContentOAHvo; // expect an StText bookNode.Nodes.Add(sectionNode); } // Add Footnotes in reverse order, so we can insert them in the proper order. List <IStFootnote> footnotes = new List <IStFootnote>(book.FootnotesOS); footnotes.Reverse(); foreach (IStFootnote footnote in footnotes) { ScrFootnote scrFootnote = footnote as ScrFootnote; if (scrFootnote == null) { scrFootnote = new ScrFootnote(cache, footnote.Hvo); } // insert under the relevant section, if any (LTB-408) int hvoContainingObj; if (scrFootnote.TryGetContainingSectionHvo(out hvoContainingObj) || scrFootnote.TryGetContainingTitle(out hvoContainingObj)) { string nodeName = scripture.ContainingRefAsString(scrFootnote); TreeNode footnoteNode = new TreeNode(nodeName); footnoteNode.Tag = footnote.Hvo; footnoteNode.Name = "Footnote"; // see if we can lookup the node of this section. int nodeIndex = bookNode.Nodes.IndexOfKey(hvoContainingObj.ToString()); //TreeNode[] sectionNodes = bookNode.Nodes.Find(hvoSection.ToString(), false); //if (sectionNodes != null && sectionNodes.Length > 0) if (nodeIndex >= 0) { bookNode.Nodes.Insert(nodeIndex + 1, footnoteNode); } else { bookNode.Nodes.Add(footnoteNode); // insert at end. } } } } } } finally { cache.EnableBulkLoadingIfPossible(false); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public DBMultilingScrBooks(Scripture scr) : base(scr) { m_scripture = scr; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:TeChecksDataSource"/> class. /// </summary> /// <param name="cache">The cache.</param> /// ------------------------------------------------------------------------------------ public ScrChecksDataSource(FdoCache cache) { m_cache = cache; m_scr = cache.LangProject.TranslatedScriptureOA as Scripture; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shuts down the cache. /// </summary> /// <remarks>This method is called after each test</remarks> /// ------------------------------------------------------------------------------------ public override void Exit() { m_scr = null; base.Exit(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Allows subclasses to do other stuff to initialize the cache before it gets used /// </summary> /// ------------------------------------------------------------------------------------ protected override void InitializeCache() { m_scrInMemoryCache.InitializeScripture(); m_scr = Cache.LangProject.TranslatedScriptureOA as Scripture; base.InitializeCache(); }