private void BuildRenderings(string strProjectFolder, string termId) { termRenderingsList = new List <TermRendering>(); int projectNum = 0; for (int i = 0; i < scrTextNames.Count; i++) { string name = scrTextNames[i]; /* until we have a "TermRenderingsList" xml file for this project, we can't use this feature * the BiblicalTermsEn.xml in the BiblicalTerms folder is *not* one of these and won't work. * string strPath = strProjectFolder; * if (i > 0) * strPath = BiblicalTermsList.DefaultBiblicalTermsFileFolder; */ TermRenderingsList termRenderings = TermRenderingsList.GetTermRenderings(strProjectFolder, name); TermRendering termRendering = termRenderings.GetRendering(termId); termRenderingsList.Add(termRendering); string val = termRendering.Renderings; val += FormattedNotes(termRendering); projectVariablesList[projectNum]["Renderings"] = val; ++projectNum; } }
private static TermRenderingsList Deserialize(string fileName) { TermRenderingsList renderings2; try { using (TextReader reader = new StreamReader(fileName)) { XmlSerializer xser = Utilities.Memento.CreateXmlSerializer(typeof(TermRenderingsList)); renderings2 = (TermRenderingsList)xser.Deserialize(reader); } } catch (Exception ex) { // Save corrupt file try { File.Move(fileName, fileName + ".corrupt"); } catch { } MessageBox.Show(string.Format(Localizer.Str("Error reading {1}. Backup {2} was made and file was reset.\r\n{0}"), ex.Message, fileName, Path.GetFileName(fileName + ".corrupt"))); renderings2 = new TermRenderingsList(); } renderings2.RenderingsChanged = false; return(renderings2); }
/// <summary> /// If there is an already open version of the rendering for this ScrText, reload them. /// The receive operation may have updated them. /// </summary> /// <param name="scrTextName"></param> public static void ReloadAfterReceive(string strProjectFolder, string scrTextName) { TermRenderingsList renderings2 = GetFromCache(scrTextName); if (renderings2 == null) { return; } if (!File.Exists(FileName(strProjectFolder, scrTextName))) { return; } TermRenderingsList renderings3 = Deserialize(FileName(strProjectFolder, scrTextName)); renderings2.renderings = renderings3.renderings; renderings2.renderingsDict = null; EventHandler handler = TermRenderingsForceReload; if (handler != null) { handler(renderings2, null); } }
/// <summary> /// Gets renderings for specified project. /// </summary> /// <param name="scrTextName"></param> /// <returns></returns> public static TermRenderingsList GetTermRenderings(string strProjectFolder, string scrTextName) { TermRenderingsList renderings2 = GetFromCache(scrTextName); if (renderings2 != null) { return(renderings2); } if (File.Exists(FileName(strProjectFolder, scrTextName))) { renderings2 = Deserialize(FileName(strProjectFolder, scrTextName)); } else { renderings2 = new TermRenderingsList(); } renderings2.ScrTextName = scrTextName; globalDictionary[scrTextName] = renderings2; return(renderings2); }
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; } }