/// <summary> /// Build by project by reference array of verse text for this term /// </summary> internal void ReadVerseText(Term myTerm, StoryProjectData theSPD, ProgressBar progressBarLoadingKeyTerms) { mapReferenceToVerseTextList = new Dictionary <string, List <string> >(); ArrayList vrefs = new ArrayList(); foreach (var vref in myTerm.VerseRefs()) { vrefs.Add(vref.BBBCCCVVVS()); } // List<VerseRef> vrefs = new List<VerseRef>(myTerm.VerseRefs()); // get the current stories only (not the obsolete ones) StoriesData theStories = theSPD[Properties.Resources.IDS_MainStoriesSet]; progressBarLoadingKeyTerms.Maximum = theStories.Count; progressBarLoadingKeyTerms.Value = 0; for (int nStoryNumber = 0; nStoryNumber < theStories.Count; nStoryNumber++) { StoryData aStory = theStories[nStoryNumber]; for (int nVerseNumber = 0; nVerseNumber < aStory.Verses.Count; nVerseNumber++) { VerseData aVerse = aStory.Verses[nVerseNumber]; for (int nAnchorNumber = 0; nAnchorNumber < aVerse.Anchors.Count; nAnchorNumber++) { AnchorData anAnchor = aVerse.Anchors[nAnchorNumber]; VerseRef theVerseRef = new VerseRef(anAnchor.AnchorAsVerseRef); int nIndex = vrefs.BinarySearch(theVerseRef.BBBCCCVVVS()); if (nIndex < 0) { continue; } string strVerseReference = String.Format("Story: '{0}' line: {1} anchor: {2}", aStory.Name, nVerseNumber + 1, anAnchor.JumpTarget); List <string> astrVerseText = new List <string>(projectVariablesList.Count); if (theSPD.ProjSettings.Vernacular.HasData) { astrVerseText.Add(aVerse.VernacularText.ToString()); } if (theSPD.ProjSettings.NationalBT.HasData) { astrVerseText.Add(aVerse.NationalBTText.ToString()); } if (theSPD.ProjSettings.InternationalBT.HasData) { astrVerseText.Add(aVerse.InternationalBTText.ToString()); } // keep track of this verse and it's reference if (!mapReferenceToVerseTextList.ContainsKey(strVerseReference)) { mapReferenceToVerseTextList.Add(strVerseReference, astrVerseText); } // we don't need to do any more anchors with this same line of the same story // so set the anchor # to the number of anchors so the next outer for loop // will think it's finished nAnchorNumber = aVerse.Anchors.Count; break; } } progressBarLoadingKeyTerms.Value++; } }
public string Html(ProjectSettings projectSettings, VerseData.ViewItemToInsureOn viewItemToInsureOn, StoryStageLogic stageLogic, TeamMemberData loggedOnMember, int nVerseIndex, int nNumCols, bool bHasOutsideEnglishBTer) { int nNumTestQuestionCols = 0; bool bShowVernacular = (VerseData.IsViewItemOn(viewItemToInsureOn, VerseData.ViewItemToInsureOn.eVernacularLangField)); bool bShowNationalBT = (projectSettings.NationalBT.HasData && (bHasOutsideEnglishBTer || (VerseData.IsViewItemOn(viewItemToInsureOn, VerseData.ViewItemToInsureOn.eNationalLangField) && !projectSettings.Vernacular.HasData))); bool bShowEnglishBT = (VerseData.IsViewItemOn(viewItemToInsureOn, VerseData.ViewItemToInsureOn.eEnglishBTField) && (!bHasOutsideEnglishBTer || (stageLogic.MemberTypeWithEditToken != TeamMemberData.UserTypes.eProjectFacilitator) || (loggedOnMember.MemberType != TeamMemberData.UserTypes.eProjectFacilitator))); if (bShowVernacular) { nNumTestQuestionCols++; } if (bShowNationalBT) { nNumTestQuestionCols++; } if (bShowEnglishBT) { nNumTestQuestionCols++; } string strRow = null; for (int i = 0; i < Count; i++) { TestQuestionData testQuestionData = this[i]; strRow += testQuestionData.Html(nVerseIndex, i, nNumTestQuestionCols, bShowVernacular, bShowNationalBT, bShowEnglishBT); } /* * // make a cell out of the testing question boxes * string strHtmlCell = String.Format(Properties.Resources.HTML_TableCellWidth, * 100, * strRow); * * // add combine with the 'tst:' header cell into a Table Row * string strHtml = String.Format(Properties.Resources.HTML_TableRow, * strHtmlCell); * // add exegetical comments as their own rows * for (int i = 0; i < Count; i++) * { * AnchorData anchorData = this[i]; * if (anchorData.ExegeticalHelpNotes.Count > 0) * strHtml += anchorData.ExegeticalHelpNotes.Html(nVerseIndex, i); * } */ // make a sub-table out of all this strRow = String.Format(Properties.Resources.HTML_TableRow, String.Format(Properties.Resources.HTML_TableCellWithSpan, nNumCols, String.Format(Properties.Resources.HTML_TableNoBorder, strRow))); return(strRow); }
public string Html(HtmlConNoteControl htmlConNoteCtrl, StoryStageLogic theStoryStage, TeamMemberData LoggedOnMember, int nVerseIndex, int nConversationIndex) { System.Diagnostics.Debug.Assert(Count > 0); if (Count == 0) { return(null); } // r1: "Round: n"; "button" // r2-n: "Label:"; "value in textbox" string strRow = String.Format(Properties.Resources.HTML_TableCellWithSpanAndWidth, 100, 2, String.Format("{0}{1}", CstrRoundLabel, RoundNum)); // only the initiator of a conversation gets the buttons to delete, hide or // end conversation. CommInstance aCInitiator = this[0]; if (CanDoConversationButtons(LoggedOnMember.MemberType, aCInitiator.Initiator)) { strRow += String.Format(Properties.Resources.HTML_TableCell, String.Format(Properties.Resources.HTML_Button, ButtonId(nVerseIndex, nConversationIndex, CnBtnIndexDelete), "return window.external.OnClickDelete(this.id);", "Delete")); strRow += String.Format(Properties.Resources.HTML_TableCell, String.Format(Properties.Resources.HTML_Button, ButtonId(nVerseIndex, nConversationIndex, CnBtnIndexHide), "return window.external.OnClickHide(this.id);", (Visible) ? CstrButtonLabelHide : CstrButtonLabelUnhide)); strRow += String.Format(Properties.Resources.HTML_TableCell, String.Format(Properties.Resources.HTML_Button, ButtonId(nVerseIndex, nConversationIndex, CnBtnIndexEndConversation), "return window.external.OnClickEndConversation(this.id);", (IsFinished) ? CstrButtonLabelConversationReopen : CstrButtonLabelConversationEnd)); } string strHtml = String.Format(Properties.Resources.HTML_TableRowId, ButtonRowId(nVerseIndex, nConversationIndex), strRow); string strHtmlTable = null; for (int i = 0; i < Count; i++) { CommInstance aCI = this[i]; strRow = null; Color clrRow; if (IsFromMentor(aCI)) { strRow += String.Format(Properties.Resources.HTML_TableCell, MentorLabel); clrRow = CommentColor; } else { strRow += String.Format(Properties.Resources.HTML_TableCell, MenteeLabel); clrRow = ResponseColor; } string strColor = VerseData.HtmlColor(clrRow); // only the last one is editable and then only if the right person is // logged in string strHtmlElementId; if (IsEditable(theStoryStage, i, LoggedOnMember, aCI)) { strHtmlElementId = TextareaId(nVerseIndex, nConversationIndex); strRow += String.Format(Properties.Resources.HTML_TableCellForTextArea, "#FF0000", String.Format(Properties.Resources.HTML_TextareaWithRefDrop, strHtmlElementId, StoryData.CstrLangInternationalBtStyleClassName, aCI)); strHtmlTable += String.Format(Properties.Resources.HTML_TableRowIdColor, TextareaRowId(nVerseIndex, nConversationIndex), strColor, strRow); } else { strHtmlElementId = TextParagraphId(nVerseIndex, nConversationIndex, i); string strHyperlinkedText = aCI.ToString().Replace("\r\n", "<br />"); // regexParagraph.Replace(aCI.ToString(), ParagraphFound); strHyperlinkedText = regexBibRef.Replace(strHyperlinkedText, BibleReferenceFound); strHyperlinkedText = regexLineRef.Replace(strHyperlinkedText, LineReferenceFound); strHyperlinkedText = regexItalics.Replace(strHyperlinkedText, EmphasizedTextFound); strHyperlinkedText = regexHttpRef.Replace(strHyperlinkedText, HttpReferenceFound); strRow += String.Format(Properties.Resources.HTML_TableCellWidth, 100, String.Format(Properties.Resources.HTML_ParagraphText, strHtmlElementId, StoryData.CstrLangInternationalBtStyleClassName, strHyperlinkedText)); strHtmlTable += String.Format(Properties.Resources.HTML_TableRowIdColor, TextareaReadonlyRowId(nVerseIndex, nConversationIndex, i), strColor, strRow); } // keep track of the element id so we can use it during 'Search/Replace' operations aCI.HtmlElementId = strHtmlElementId; aCI.HtmlConNoteCtrl = htmlConNoteCtrl; } string strEmbeddedTable = String.Format(Properties.Resources.HTML_Table, strHtmlTable); strHtml += String.Format(Properties.Resources.HTML_TableRowIdColor, ConversationTableRowId(nVerseIndex, nConversationIndex), "#CCFFAA", String.Format(Properties.Resources.HTML_TableCellWithSpan, 5, strEmbeddedTable)); return(strHtml); }
static void Main(string[] args) { string[] astrBt = File.ReadAllLines(CstrBtFile); CleanSfmFileContents(ref astrBt); string[] astrRet = File.ReadAllLines(CstrRetFile); CleanSfmFileContents(ref astrRet); string[] astrCon = File.ReadAllLines(CstrConFile); CleanSfmFileContents(ref astrCon); string[] astrCoa = File.ReadAllLines(CstrCoaFile); CleanSfmFileContents(ref astrCoa); OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Browse for the existing version of the output file (so we can reuse the GUIDs)"; StoriesData theStories; bool bUsingStoryProject; if (dlg.ShowDialog() == DialogResult.OK) { StoryProject projFile = new StoryProject(); projFile.ReadXml(dlg.FileName); ProjectSettings projSettings = new ProjectSettings(Path.GetDirectoryName(dlg.FileName), Path.GetFileNameWithoutExtension(dlg.FileName)); theStories = new StoriesData(projFile, projSettings); // import the member ids so we keep their same guids foreach (TeamMemberData aTMD in theStories.TeamMembers.Values) { MemberGuid(theStories.TeamMembers, aTMD.Name, aTMD.MemberType); } bUsingStoryProject = true; } else { ProjectSettings projSettings = new ProjectSettings(Path.GetDirectoryName(CstrDefOutputFile), Path.GetFileNameWithoutExtension(CstrDefOutputFile)); theStories = new StoriesData(projSettings); bUsingStoryProject = false; } // skip down to the title of the first story (in each file) int nIndexBt = 0, nIndexRet = 0, nIndexCon = 0, nIndexCoa = 0; SkipTo(@"\t ", null, @"\t ", astrBt, ref nIndexBt); SkipTo(@"\t ", null, @"\t ", astrRet, ref nIndexRet); SkipTo(@"\t ", null, @"\t ", astrCon, ref nIndexCon); SkipTo(@"\t ", null, @"\t ", astrCoa, ref nIndexCoa); int nStoryNumber = 0; while (nIndexBt != -1) { System.Diagnostics.Debug.Assert( (astrBt[nIndexBt] == astrRet[nIndexRet]) && (astrBt[nIndexBt] == astrCon[nIndexCon]) && (astrBt[nIndexBt] == astrCoa[nIndexCoa]), "Fixup problem in data files: one file has an extra record"); string strStoryName = astrBt[nIndexBt].Substring(3); StoryData story; if (bUsingStoryProject) { story = theStories[nStoryNumber++]; } else { story = new StoryData(strStoryName, null); } Console.WriteLine("Story: " + strStoryName); // first process the 'story front matter (reason, testors, etc)' string strTestorGuid; DoStoryFrontMatter(theStories, story, astrBt, ref nIndexBt, bUsingStoryProject, out strTestorGuid); int nVerseNumber = 0; while (nIndexBt < astrBt.Length) { string strRef = astrBt[nIndexBt].Substring(4); Console.WriteLine(" ln: " + strRef); VerseData verse; if (bUsingStoryProject) { System.Diagnostics.Debug.Assert((nVerseNumber < story.Verses.Count), String.Format("Verse count not the same: this could be because some verse in chapter with '{0}' has no data for all files (so it wasn't ultimately added the first time thru)", strRef)); verse = story.Verses[nVerseNumber]; // clear out any data that doesn't have guids (so we don't add them again) verse.Anchors.Clear(); verse.TestQuestions.Clear(); // these have IDs, but they're member IDs which should get picked up correctly verse.Retellings.Clear(); // same here } else { verse = new VerseData(); } DoVerseData(verse, astrBt, strTestorGuid, ref nIndexBt); // now grab the retelling if (SkipTo(@"\ln ", strRef, @"\c ", astrRet, ref nIndexRet)) { DoRetellingData(astrRet, ref nIndexRet, verse, strTestorGuid); } // now grab the consultant notes if (SkipTo(@"\ln ", strRef, @"\c ", astrCon, ref nIndexCon)) { DoConsultData(astrCon, ref nIndexCon, bUsingStoryProject, verse.ConsultantNotes, @"\con", CstrConsultantsInitials, CastrConsultantMenteeSfms, ConsultNoteDataConverter.CommunicationDirections.eConsultantToCrafter, ConsultNoteDataConverter.CommunicationDirections.eCrafterToConsultant); } // now grab the coach notes if (SkipTo(@"\ln ", strRef, @"\c ", astrCoa, ref nIndexCoa)) { DoConsultData(astrCoa, ref nIndexCoa, bUsingStoryProject, verse.CoachNotes, @"\cch", CstrCoachsInitials, CastrCoachMenteeSfms, ConsultNoteDataConverter.CommunicationDirections.eCoachToConsultant, ConsultNoteDataConverter.CommunicationDirections.eConsultantToCoach); } if (verse.HasData) { if (bUsingStoryProject) { nVerseNumber++; } else { story.Verses.Add(verse); } } if ((nIndexBt >= astrBt.Length) || (astrBt[nIndexBt].Substring(0, 3) == @"\c ")) { // TODO: for others, we could do a special case if there's a second record with an earlier retelling // (but for K&D, those lines aren't likely to have any association with the current version of the story... if (nIndexBt < astrBt.Length) { System.Diagnostics.Debug.Assert( (astrBt[nIndexBt] == astrRet[nIndexRet]) && (astrBt[nIndexBt] == astrCon[nIndexCon]) && (astrBt[nIndexBt] == astrCoa[nIndexCoa]), "Fixup problem in data files: one file has an extra record"); } break; } } story.ProjStage.ProjectStage = StoryStageLogic.ProjectStages.eCoachReviewTest2Notes; if (!bUsingStoryProject) { theStories.Add(story); } SkipTo(@"\t ", null, @"\t ", astrBt, ref nIndexBt); SkipTo(@"\t ", null, @"\t ", astrRet, ref nIndexRet); SkipTo(@"\t ", null, @"\t ", astrCon, ref nIndexCon); SkipTo(@"\t ", null, @"\t ", astrCoa, ref nIndexCoa); } theStories.ProjSettings.Vernacular.LangName = CstrVernName; theStories.ProjSettings.Vernacular.LangCode = CstrVernCode; theStories.ProjSettings.Vernacular.FullStop = CstrVernFullStop; theStories.ProjSettings.NationalBT.LangName = CstrNatlName; theStories.ProjSettings.NationalBT.LangCode = CstrNatlCode; theStories.ProjSettings.NationalBT.FullStop = CstrNatlFullStop; theStories.ProjSettings.InternationalBT.LangName = CstrIntlName; theStories.ProjSettings.InternationalBT.LangCode = CstrIntlCode; SaveXElement(theStories.GetXml, theStories.ProjSettings.ProjectFileName); }
private static bool DoVerseData(VerseData verse, string[] astrBt, string strTestorGuid, ref int nIndexBt) { int nTQIndex = -1; string strMarker, strData; ParseLine(astrBt[++nIndexBt], out strMarker, out strData); // check to see if this verse is empty if (strMarker == @"\ln") { return(false); } bool bVerseMarkerHasData = false; while ((strMarker != @"\ln") && (strMarker != @"\c")) // until we hit the next line or the next chapter { if (strMarker == CstrVernCodeSfm) { verse.VernacularText.SetValue(strData); bVerseMarkerHasData = true; } else if (strMarker == CstrNatlCodeSfm) { verse.NationalBTText.SetValue(strData); bVerseMarkerHasData = true; } else if (strMarker == @"\bt") { verse.InternationalBTText.SetValue(strData); bVerseMarkerHasData = true; } else if (strMarker == @"\anc") { Dictionary <string, string> map = GetListOfAnchors(strData); foreach (KeyValuePair <string, string> kvp in map) { verse.Anchors.AddAnchorData(kvp.Key, kvp.Value); } } else if (strMarker == @"\tsth") { verse.TestQuestions.AddTestQuestion(); verse.TestQuestions[++nTQIndex].QuestionVernacular.SetValue(strData); } else if (strMarker == @"\tst") { verse.TestQuestions[nTQIndex].QuestionEnglish.SetValue(strData); } else if (strMarker == @"\ans") { if (nTQIndex >= 0) { System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(strTestorGuid)); verse.TestQuestions[nTQIndex].Answers.AddNewLine(strTestorGuid).SetValue(strData); } } else if (strMarker == @"\cn") { System.Diagnostics.Debug.Assert(verse.Anchors.Count > 0); verse.Anchors[0].ExegeticalHelpNotes.AddExegeticalHelpNote(strData); } else if (lstSfmsToIgnore.Contains(strMarker)) { Console.WriteLine("Found, but don't care about marker:" + strMarker); } else if (!String.IsNullOrEmpty(strMarker) && !String.IsNullOrEmpty(strData)) { System.Diagnostics.Debug.Assert(false, String.Format("not handling the '{0}' marker", strMarker)); } // do next line if (++nIndexBt < astrBt.Length) { ParseLine(astrBt[nIndexBt], out strMarker, out strData); } else { break; } } return(bVerseMarkerHasData); }
public StoryLineControl(StoryEditor aSE, VerseBtControl ctrlVerse, VerseData aVerseData) : base(aSE.theCurrentStory.ProjStage) { InitializeComponent(); tableLayoutPanel.SuspendLayout(); SuspendLayout(); _aVerseData = aVerseData; // clobber the base class table layout panel's configuration. We're 'column-oriented' instead // first add another row so that we have two rows (row(0)=label, row(1)=text) System.Diagnostics.Debug.Assert(tableLayoutPanel.RowCount == 1, "otherwise, adjust assumption here: StoryLineControl.cs.30"); InsertRow(1); // remove the columns, because we're going to add them back as equal sizes. while (tableLayoutPanel.ColumnCount > 0) { RemoveColumn(tableLayoutPanel.ColumnCount - 1); } int nNumColumns = 0; if (aSE.viewVernacularLangFieldMenuItem.Checked) { InsertColumn(nNumColumns); if (ctrlVerse.VerseNumber == 1) { InitLabel(aSE.StoryProject.ProjSettings.Vernacular.LangName, nNumColumns); } // if we're in the one of the states where the user is entering in the // national or international BT, then disable the Vernacular as a tab stop. bool bDisableTabStopVernacular = ((aSE.theCurrentStory.ProjStage.ProjectStage == StoryStageLogic.ProjectStages.eProjFacTypeNationalBT) || (aSE.theCurrentStory.ProjStage.ProjectStage == StoryStageLogic.ProjectStages.eProjFacTypeInternationalBT) || (aSE.theCurrentStory.ProjStage.ProjectStage == StoryStageLogic.ProjectStages.eBackTranslatorTypeInternationalBT)); _aVerseData.VernacularText.Transliterator = ctrlVerse.TransliteratorVernacular; InitTextBox(ctrlVerse, CstrFieldNameVernacular, _aVerseData.VernacularText, aSE.StoryProject.ProjSettings.Vernacular, bDisableTabStopVernacular, nNumColumns); nNumColumns++; } if (aSE.viewNationalLangFieldMenuItem.Checked) { InsertColumn(nNumColumns); if (ctrlVerse.VerseNumber == 1) { InitLabel(aSE.StoryProject.ProjSettings.NationalBT.LangName, nNumColumns); } // if we're in the one of the states where the user is entering in the // international BT, then disable the National BT as a tab stop. bool bDisableTabStopNationalBT = ((aSE.theCurrentStory.ProjStage.ProjectStage == StoryStageLogic.ProjectStages.eProjFacTypeInternationalBT) || (aSE.theCurrentStory.ProjStage.ProjectStage == StoryStageLogic.ProjectStages.eBackTranslatorTypeInternationalBT)); _aVerseData.NationalBTText.Transliterator = ctrlVerse.TransliteratorNationalBT; InitTextBox(ctrlVerse, CstrFieldNameNationalBt, _aVerseData.NationalBTText, aSE.StoryProject.ProjSettings.NationalBT, bDisableTabStopNationalBT, nNumColumns); nNumColumns++; } if (aSE.viewEnglishBTFieldMenuItem.Checked) { InsertColumn(nNumColumns); if (ctrlVerse.VerseNumber == 1) { InitLabel(aSE.StoryProject.ProjSettings.InternationalBT.LangName, nNumColumns); } InitTextBox(ctrlVerse, CstrFieldNameInternationalBt, _aVerseData.InternationalBTText, aSE.StoryProject.ProjSettings.InternationalBT, false, nNumColumns); nNumColumns++; } tableLayoutPanel.ResumeLayout(false); ResumeLayout(false); }