/// ------------------------------------------------------------------------------------ /// <summary> /// Provides access to the "MakeLabelFromText" method. /// </summary> /// <param name="labelText">text to put in the label</param> /// <param name="styleName">style name to use for the character style on the text</param> /// <param name="ann">The annotation.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public ITsString CallMakeLabelFromText(string labelText, string styleName, ScrScriptureNote ann) { CheckDisposed(); return base.MakeLabelFromText(labelText, styleName, ann); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given object agains the filter criteria /// </summary> /// <param name="hvoObj">ID of object to check against the filter criteria</param> /// <returns> /// <c>true</c> if the object passes the filter criteria; otherwise /// <c>false</c> /// </returns> /// <remarks>currently only handles basic filters (single cell)</remarks> /// ------------------------------------------------------------------------------------ public bool MatchesCriteria(int hvoObj) { int classId = m_cache.GetClassOfObject(hvoObj); if (classId != ScrScriptureNote.kClassId) return false; // Not an annotation or not one we will care about ScrScriptureNote note = new ScrScriptureNote(m_cache, hvoObj); if (note.AnnotationType != NoteType.CheckingError) return true; // Annotation is a Translator or Consultant note if (note.ResolutionOA != null) { foreach (StTxtPara para in note.ResolutionOA.ParagraphsOS) { if (para.Contents.Length > 0) return true; } } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert a new note at its correct position in the list. /// </summary> /// <param name="startRef">beginning reference note refers to</param> /// <param name="endRef">ending reference note refers to</param> /// <param name="beginObject">id of beginning object to which annotation refers</param> /// <param name="endObject">id of ending object to which annotation refers</param> /// <param name="guidNoteType">The GUID representing the CmAnnotationDefn to use for /// the type</param> /// <param name="wsSelector">The writing system selector, indicating which /// writing system the annotation refers to.</param> /// <param name="startOffset">The starting character offset.</param> /// <param name="endOffset">The ending character offset.</param> /// <param name="bldrQuote">Para builder to use to build the Quote paragraph</param> /// <param name="bldrDiscussion">Para builder to use to build the Discussion /// paragraph</param> /// <param name="bldrRecommendation">Para builder to use to build the /// Recommendation paragraph</param> /// <param name="bldrResolution">Para builder to use to build the Resolution /// paragraph</param> /// <param name="insertIndex">index where annotation is to be inserted into /// annotation list</param> /// <returns>note inserted into annotation list</returns> /// ------------------------------------------------------------------------------------ public IScrScriptureNote InsertNote(BCVRef startRef, BCVRef endRef, ICmObject beginObject, ICmObject endObject, Guid guidNoteType, int wsSelector, int startOffset, int endOffset, StTxtParaBldr bldrQuote, StTxtParaBldr bldrDiscussion, StTxtParaBldr bldrRecommendation, StTxtParaBldr bldrResolution, int insertIndex) { IScrScriptureNote annotation = new ScrScriptureNote(); NotesOS.InsertAt(annotation, insertIndex); // Initialize the annotation. ((ScrScriptureNote)annotation).InitializeNote(guidNoteType, startRef, endRef, beginObject, endObject, wsSelector, startOffset, endOffset, bldrQuote, bldrDiscussion, bldrRecommendation, bldrResolution); annotation.SourceRA = annotation.AnnotationType == NoteType.CheckingError ? m_cache.LangProject.DefaultComputerAgent : m_cache.LangProject.DefaultUserAgent; // Notify all windows that the new annotation exists m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, Hvo, (int)ScrBookAnnotationsTags.kflidNotes, insertIndex, 1, 0); return(annotation); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Export an Open XML for Exchanging Scripture Annotations (OXESA) file. /// </summary> /// ------------------------------------------------------------------------------------ public bool OnFileExportOXESA(object args) { CheckDisposed(); XmlScrAnnotationsList list = new XmlScrAnnotationsList(Cache); TeNotesVc vc = m_dataEntryView.NotesEditingHelper.CurrentNotesVc; int filterFlid = vc.NotesSequenceHandler.Tag; foreach (int hvoAnnotations in m_scr.BookAnnotationsOS.HvoArray) { int[] allHvos = Cache.GetVectorProperty(hvoAnnotations, filterFlid, true); List<int> notesToExport = new List<int>(); foreach (int noteHvo in allHvos) { ScrScriptureNote note = new ScrScriptureNote(m_cache, noteHvo); if (note.AnnotationTypeRA.Guid == LangProject.kguidAnnTranslatorNote || note.AnnotationTypeRA.Guid == LangProject.kguidAnnConsultantNote) { // When we are exporting only notes, we only want to export notes that // are translator notes or consultant notes (i.e. no checking error notes). notesToExport.Add(noteHvo); } } list.Add(new FdoObjectSet<IScrScriptureNote>(Cache, notesToExport.ToArray(), false)); } using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(Cache, FileType.OXESA)) { // TODO: Need to supply a decent default filename. Should it include // a date/time to avoid accidental overwriting? if (dlg.ShowSaveDialog(null, this) == DialogResult.OK) list.SerializeToFile(dlg.FileName); } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Makes a selection in the specified annotation (without scrolling the annotation in /// the view). /// </summary> /// <param name="vc">The notes view constructor</param> /// <param name="fScrollNearTop">if set to <c>true</c> scrolls the specified note to a /// position near the top of the view.</param> /// <param name="bookIndex">Index of the book.</param> /// <param name="iAnnotation">Index of the annotation.</param> /// <param name="iResponse">Index of the response (0 if setting the selection in one of /// the StJournalText fields rather than in a response.</param> /// <param name="noteTag">The tag indicating the field of the annotation where the /// selection is to be made.</param> /// <param name="rootSite">The root site.</param> /// <param name="fNoteIsExpanded">if <c>true</c> make a selection at the start and end so /// that the whole annotation can be scrolled into view. if set to <c>false</c> only /// make a selection at the start of the annotation.</param> /// ------------------------------------------------------------------------------------ internal void MakeSelectionInNote(TeNotesVc vc, bool fScrollNearTop, int bookIndex, int iAnnotation, int iResponse, ScrScriptureNote.ScrScriptureNoteTags noteTag, IVwRootSite rootSite, bool fNoteIsExpanded) { if (vc == null || vc.NotesSequenceHandler == null) return; SelectionHelper selHelper; if (fScrollNearTop) { // Make an un-installed selection at the top of the annotation in order to scroll the // annotation to the top of the view. selHelper = new SelectionHelper(); selHelper.NumberOfLevels = 2; selHelper.LevelInfo[0].cpropPrevious = 0; selHelper.LevelInfo[0].ich = -1; selHelper.LevelInfo[0].ihvo = iAnnotation; selHelper.LevelInfo[0].tag = vc.NotesSequenceHandler.Tag; selHelper.LevelInfo[0].ws = 0; selHelper.LevelInfo[1].cpropPrevious = 0; selHelper.LevelInfo[1].ich = -1; selHelper.LevelInfo[1].ihvo = bookIndex; selHelper.LevelInfo[1].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations; selHelper.LevelInfo[1].ws = 0; selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, -2); selHelper.IchAnchor = 0; selHelper.AssocPrev = false; selHelper.NumberOfPreviousProps = 2; if (fNoteIsExpanded) { selHelper.SetSelection(rootSite, true, true, VwScrollSelOpts.kssoNearTop); } else { // Annotation is collapsed. Only attempt a selection at the start of it. selHelper.SetSelection(rootSite, true, true); return; } } else EnsureNoteIsVisible(vc, bookIndex, iAnnotation, rootSite); // Now make the real (installed) selection in the desired field of the annotation. bool fIsResponse = (noteTag == ScrScriptureNote.ScrScriptureNoteTags.kflidResponses); selHelper = new SelectionHelper(); selHelper.NumberOfLevels = 4; selHelper.LevelInfo[0].tag = (int)StText.StTextTags.kflidParagraphs; selHelper.LevelInfo[0].ihvo = 0; selHelper.LevelInfo[1].tag = (int)noteTag; selHelper.LevelInfo[1].ihvo = iResponse; selHelper.LevelInfo[1].cpropPrevious = (fIsResponse ? 0 : 1); selHelper.LevelInfo[2].tag = vc.NotesSequenceHandler.Tag; selHelper.LevelInfo[2].ihvo = iAnnotation; selHelper.LevelInfo[3].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations; selHelper.LevelInfo[3].ihvo = bookIndex; selHelper.IchAnchor = 0; selHelper.AssocPrev = false; selHelper.SetSelection(rootSite, true, true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the annotation fragment. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayAnnotationFragment(IVwEnv vwenv, int hvo) { ScrScriptureNote ann = new ScrScriptureNote(m_cache, hvo); bool isExpanded = (m_expandTable.ContainsKey(hvo) && m_expandTable[hvo]); int hvoFirstResponse = ann.ResponsesOS.Count > 0 ? ann.ResponsesOS.HvoArray[0] : 0; bool responseExpanded = m_expandTable.ContainsKey(hvoFirstResponse) && m_expandTable[hvoFirstResponse]; // put the separator at the top of the note InsertNoteSeparator(vwenv); // Open a table to display the first line of the annotation. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; int borderThickness = 2000; int columnCount = 9; VwFramePosition framePos = VwFramePosition.kvfpVoid; if (ann.Hvo == SelectedNoteHvo) { columnCount = 7; framePos = (ann.ResponsesOS.Count == 0 || !isExpanded || !responseExpanded) ? VwFramePosition.kvfpBox : (VwFramePosition.kvfpAbove | VwFramePosition.kvfpVsides); } vwenv.OpenTable(columnCount, vlTable, // Table uses 100% of available width. borderThickness, VwAlignment.kvaLeft, // Default alignment. framePos, //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); vwenv.NoteDependency(new int[] { hvo, hvo }, new int[]{m_expansionTag, (int)ScrScriptureNote.ScrScriptureNoteTags.kflidResponses}, 2); // Specify column widths. The first argument is the number of columns, // not a column index. VwLength vlColumn; if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vlColumn.nVal = 13000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(2, vlColumn); vlColumn.nVal = 60000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); vlColumn.nVal = 2; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the CONNOT categories vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when showing quote vlColumn.nVal = 3; vlColumn.unit = VwUnit.kunRelative; vwenv.MakeColumns(1, vlColumn); // Column for the quote when collapsed vlColumn.nVal = 12000; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); // Column for the chooser button when not showing quote if (ann.Hvo != SelectedNoteHvo) { vlColumn.nVal = borderThickness; vlColumn.unit = VwUnit.kunPoint1000; vwenv.MakeColumns(1, vlColumn); } vwenv.OpenTableBody(); DisplayAnnotation(vwenv, ann, isExpanded); // Only display the responses if this note is expanded and has responses. if (!isExpanded || ann.ResponsesOS.Count == 0) { // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); return; } vwenv.NoteDependency(new int[] { ann.ResponsesOS.HvoArray[0] }, new int[] { m_expansionTag }, 1); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display expand box (+/-) in the second cell vwenv.OpenTableCell(1, 1); vwenv.AddObj(ann.ResponsesOS.HvoArray[0], this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display response label in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(m_responseLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); // Close table vwenv.CloseTableBody(); vwenv.CloseTable(); if (responseExpanded) { vwenv.AddObjVecItems((int)ScrScriptureNote.ScrScriptureNoteTags.kflidResponses, this, (int)NotesFrags.kfrResponse); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attempts to scroll to an annotation whose BeginObjectRAHvo is the same as the hvo /// of the paragraph where the anchor is in the specified editing helper's selection. /// </summary> /// <param name="editingHelper">The TE editing helper with information about the /// selection in the Scripture pane.</param> /// <param name="selectedText">The selected text or the word containing the IP if the /// selection is not a range.</param> /// <param name="fExactMatchOnly">if set to <c>true</c> then only scroll to a found /// note if the cited text is an exact match.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private bool ScrollToAnnotationByPara(TeEditingHelper editingHelper, string selectedText, bool fExactMatchOnly) { if (editingHelper == null || editingHelper.CurrentSelection == null) return false; ScrReference scrRef = editingHelper.CurrentStartRef; SelLevInfo[] info = editingHelper.CurrentSelection.GetLevelInfo( SelectionHelper.SelLimitType.Anchor); if (info.Length == 0) return false; int bookHvo = m_scr.BookAnnotationsOS[scrRef.Book - 1].Hvo; int[] annHvos = m_fdoCache.GetVectorProperty(bookHvo, m_vc.NotesSequenceHandler.Tag, false); if (annHvos.Length == 0) return false; int ich = editingHelper.CurrentSelection.IchAnchor; // Go through the annotations for the book and find the one whose // begin object is in the same as the selection's paragraph. for (int i = 0; i < annHvos.Length; i++) { ScrScriptureNote ann = new ScrScriptureNote(m_fdoCache, annHvos[i]); if (ann.BeginObjectRAHvo == info[0].hvo) { // When matching on the cited text, allow for the possibility that the // begin offset is off by a little bit since leading spaces and/or ORCs // may have been trimmed and subsequent editing may have messed up the // offsets a little. int adjustedBeginOffset = ann.BeginOffset - (string.IsNullOrEmpty(ann.CitedText) ? 1 : ann.CitedText.Length); if ((!fExactMatchOnly && ich >= ann.BeginOffset && ich <= ann.EndOffset) || (ich >= adjustedBeginOffset && selectedText == ann.CitedText)) { m_vc.SelectedNoteHvo = ann.Hvo; NotesEditingHelper.MakeSelectionInNote(m_vc, scrRef.Book - 1, i, this, m_vc.IsExpanded(ann.Hvo)); return true; } } } return false; }
public void CreateScrNoteCategories() { CheckDisposed(); XmlDocument doc = CreateCategoryXmlDoc(); // Create the annotation categories. DummyTeScrNoteCategoriesInit.CallCreateScrNoteCategories(m_scr, doc); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); // Set the note's category to Discourse-Chiasmus note.CategoriesRS.Append(m_scr.NoteCategoriesOA.PossibilitiesOS[0].SubPossibilitiesOS[0]); // Reload the annotation categories. DummyTeScrNoteCategoriesInit.CallCreateScrNoteCategories(m_scr, doc); // Confirm that the note's category is retained. Assert.AreEqual(m_scr.NoteCategoriesOA.PossibilitiesOS[0].SubPossibilitiesOS[0], note.CategoriesRS[0]); }
/// ------------------------------------------------------------------------------------ /// <summary> /// We override this method to make a selection in all of the views that are in a /// snynced group. This fixes problems where the user changes the selection in one of /// the slaves, but the master is not updated. Thus the view is not scrolled as the /// groups scroll position only scrolls the master's selection into view. (TE-3380) /// </summary> /// <param name="prootb"></param> /// <param name="vwselNew"></param> /// ------------------------------------------------------------------------------------ public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew) { CheckDisposed(); if (s_fInSelectionChanged) return; base.SelectionChanged(prootb, vwselNew); if (m_ignoreSelChanged || EditingHelper.CurrentSelection == null) return; SelLevInfo noteInfo = EditingHelper.CurrentSelection.GetLevelInfoForTag(m_currentNotesTag); if (noteInfo.hvo == m_prevNoteHvo) return; ScrScriptureNote ann = new ScrScriptureNote(m_fdoCache, noteInfo.hvo); s_fInSelectionChanged = true; try { // Remove highlighting on previously selected annotation, and add highlighting to selected annotation. SelectionHelper sel = EditingHelper.CurrentSelection; m_vc.SelectedNoteHvo = noteInfo.hvo; if (m_prevNoteHvo != 0) { // Make sure we use the index in the virtual property and not // the index in the list of notes. int ownerHvo = m_fdoCache.GetOwnerOfObject(m_prevNoteHvo); int ihvo = m_fdoCache.GetObjIndex(ownerHvo, m_currentNotesTag, m_prevNoteHvo); if (ihvo >= 0) // Could be -1 if not in the filter anymore (TE-8891) { m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, ownerHvo, m_currentNotesTag, ihvo, 1, 1); } } m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, ann.OwnerHVO, m_currentNotesTag, noteInfo.ihvo, 1, 1); sel.SetSelection(false); // restore selection taken from PropChange } finally { s_fInSelectionChanged = false; } // Set text of caption to indicate which annotation is selected m_notesMainWnd.InformationBarText = BaseInfoBarCaption + " - " + GetRefAsString(ann) + " " + GetQuotedText(ann.QuoteOA, 30); SetNoteUpdateTime(m_prevNoteHvo); m_prevNoteHvo = noteInfo.hvo; if (!m_fSendSyncScrollMsg) return; NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd; if (notesMainWnd != null && notesMainWnd.SyncHandler != null) { Trace.WriteLine("Calling SyncToAnnotation from NotesDataEntryView: " + ann.CitedText); notesMainWnd.SyncHandler.SyncToAnnotation(this, ann, m_scr); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the updateTime on the specified note. This method deletes the mark in the /// undo stack. If fStartNewMark is true then a new mark is created. /// </summary> /// <param name="noteHvo">The hvo of the note to be updated, or 0 to ignore</param> /// ------------------------------------------------------------------------------------ public void SetNoteUpdateTime(int noteHvo) { CheckDisposed(); IActionHandler handler = m_fdoCache.ActionHandlerAccessor; if (m_fIgnoreTmStmpUpdate || handler == null || handler.CurrentDepth > 0 || handler.TopMarkHandle == 0) { return; } if (!handler.get_TasksSinceMark(true)) handler.DiscardToMark(0); else { // Can happen... just continue on if (noteHvo != 0 && m_fdoCache.IsValidObject(noteHvo)) { ScrScriptureNote ann = new ScrScriptureNote(m_fdoCache, noteHvo); ann.DateModified = DateTime.Now; m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, noteHvo, (int)CmAnnotation.CmAnnotationTags.kflidDateModified, 0, 1, 1); } string sUndo; string sRedo; TeResourceHelper.MakeUndoRedoLabels("kstidDiffDlgUndoRedoEditNote", out sUndo, out sRedo); handler.CollapseToMark(0, sUndo, sRedo); // If no tasks since the mark actually change the data, they should all get // deleted when we collapse. } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an annotation expanded or contracted /// </summary> /// <param name="vwenv"></param> /// <param name="ann"></param> /// <param name="expanded"></param> /// ------------------------------------------------------------------------------------ private void DisplayAnnotation(IVwEnv vwenv, ScrScriptureNote ann, bool expanded) { #region First row has status, ref, category, & quote SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display expand box (+/-) in the first cell //InsertNoteSeparator(vwenv); vwenv.OpenTableCell(1, 1); vwenv.AddObj(ann.Hvo, this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display status in the second cell vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); if (ann.AnnotationType == NoteType.CheckingError) { // When the annotation is a checking error, we don't want clicking on the status // to change the status. Therefore, make the min and max the same. vwenv.AddIntPropPic((int)ScrScriptureNote.ScrScriptureNoteTags.kflidResolutionStatus, this, (int)NotesFrags.kfrStatus, 0, 0); } else { vwenv.AddIntPropPic((int)ScrScriptureNote.ScrScriptureNoteTags.kflidResolutionStatus, this, (int)NotesFrags.kfrStatus, (int)NoteStatus.Open, (int)NoteStatus.Closed); } vwenv.CloseTableCell(); // Display reference in the third cell and make it readonly. vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, 0); vwenv.OpenParagraph(); vwenv.AddProp((int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginRef, this, (int)NotesFrags.kfrScrRef); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display CONNOT category in the fourth (and possibly fifth and sixth) cell(s) vwenv.OpenTableCell(1, expanded ? 3 : 1); int hvoQuotePara = ann.QuoteOA.ParagraphsOS.HvoArray[0]; bool fQuoteParaRtoL = IsParaRightToLeft(hvoQuotePara); // Conc paragraphs don't work well for R-to-L: If the text doesn't fit, it will // show the trailing text rather than the leading text. if (fQuoteParaRtoL || expanded) vwenv.OpenParagraph(); else vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddObjVec((int)ScrScriptureNote.ScrScriptureNoteTags.kflidCategories, this, (int)NotesFrags.kfrConnotCategory); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display CONNOT category chooser button in the penultimate or last cell vwenv.OpenTableCell(1, 1); vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 1000); vwenv.set_IntProperty((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.AddPicture(m_picChooser, -(int)NotesFrags.kfrConnotCategory, 0, 0); vwenv.CloseTableCell(); // If not expanded, display the quote in the last cell if (!expanded) { vwenv.OpenTableCell(1, 1); StTxtPara quotePara = (StTxtPara)ann.QuoteOA.ParagraphsOS[0]; SetupWsAndDirectionForPara(vwenv, quotePara.Hvo); if (fQuoteParaRtoL) vwenv.OpenParagraph(); // Conc paragraphs don't work well for R-to-L else vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(quotePara.Contents.UnderlyingTsString); vwenv.CloseParagraph(); vwenv.CloseTableCell(); } CloseTableRow(vwenv, ann); #endregion if (!expanded) return; #region Second through fifth rows bool fRegularAnnotation = ann.AnnotationType != NoteType.CheckingError; //Second row has quote DisplayExpandableAnnotation(vwenv, ann, (int)ScrScriptureNote.ScrScriptureNoteTags.kflidQuote, ann.QuoteOAHvo, ann.QuoteOA, fRegularAnnotation ? m_quoteLabel : m_detailsLabel, !fRegularAnnotation); // Third row has discussion DisplayExpandableAnnotation(vwenv, ann, (int)ScrScriptureNote.ScrScriptureNoteTags.kflidDiscussion, ann.DiscussionOAHvo, ann.DiscussionOA, fRegularAnnotation ? m_discussionLabel : m_messageLabel, !fRegularAnnotation); // Fourth row has recommendation (i.e. suggestion) DisplayExpandableAnnotation(vwenv, ann, (int)ScrScriptureNote.ScrScriptureNoteTags.kflidRecommendation, ann.RecommendationOAHvo, ann.RecommendationOA, m_suggestionLabel); // Fifth row has resolution DisplayExpandableAnnotation(vwenv, ann, (int)ScrScriptureNote.ScrScriptureNoteTags.kflidResolution, ann.ResolutionOAHvo, ann.ResolutionOA, m_resolutionLabel); #endregion #region Sixth row has author SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display author in third cell vwenv.OpenTableCell(1, 3); vwenv.OpenParagraph(); SetDisabledColorForNote(vwenv); vwenv.AddString(m_authorLabel); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); #endregion #region Seventh row has dates SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display date created in third cell vwenv.OpenTableCell(1, 1); vwenv.OpenParagraph(); vwenv.AddString(m_createdLabel); vwenv.AddTimeProp((int)ScrScriptureNote.CmAnnotationTags.kflidDateCreated, 0); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display date modified in fourth/fifth cells vwenv.OpenTableCell(1, 2); vwenv.OpenParagraph(); vwenv.AddString(m_modifiedLabel); vwenv.AddTimeProp((int)CmAnnotation.CmAnnotationTags.kflidDateModified, 0); vwenv.CloseParagraph(); vwenv.CloseTableCell(); // Display date resolved in last two cells vwenv.OpenTableCell(1, 2); vwenv.OpenParagraph(); if (ann.ResolutionStatus == NoteStatus.Closed) { SetDisabledColorForNote(vwenv); vwenv.AddString(m_resolvedLabel); // TODO (TE-4039) This date is incorrect //vwenv.AddTimeProp(ScrScriptureNote.ScrScriptureNoteTags.kflidDateResolved, 0); } vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); #endregion }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert a new note at its correct position in the list. /// </summary> /// <param name="startRef">beginning reference note refers to</param> /// <param name="endRef">ending reference note refers to</param> /// <param name="beginObject">id of beginning object to which annotation refers</param> /// <param name="endObject">id of ending object to which annotation refers</param> /// <param name="guidNoteType">The GUID representing the CmAnnotationDefn to use for /// the type</param> /// <param name="wsSelector">The writing system selector, indicating which /// writing system the annotation refers to.</param> /// <param name="startOffset">The starting character offset.</param> /// <param name="endOffset">The ending character offset.</param> /// <param name="bldrQuote">Para builder to use to build the Quote paragraph</param> /// <param name="bldrDiscussion">Para builder to use to build the Discussion /// paragraph</param> /// <param name="bldrRecommendation">Para builder to use to build the /// Recommendation paragraph</param> /// <param name="bldrResolution">Para builder to use to build the Resolution /// paragraph</param> /// <param name="insertIndex">index where annotation is to be inserted into /// annotation list</param> /// <returns>note inserted into annotation list</returns> /// ------------------------------------------------------------------------------------ public IScrScriptureNote InsertNote(BCVRef startRef, BCVRef endRef, ICmObject beginObject, ICmObject endObject, Guid guidNoteType, int wsSelector, int startOffset, int endOffset, StTxtParaBldr bldrQuote, StTxtParaBldr bldrDiscussion, StTxtParaBldr bldrRecommendation, StTxtParaBldr bldrResolution, int insertIndex) { IScrScriptureNote annotation = new ScrScriptureNote(); NotesOS.InsertAt(annotation, insertIndex); // Initialize the annotation. ((ScrScriptureNote)annotation).InitializeNote(guidNoteType, startRef, endRef, beginObject, endObject, wsSelector, startOffset, endOffset, bldrQuote, bldrDiscussion, bldrRecommendation, bldrResolution); annotation.SourceRA = annotation.AnnotationType == NoteType.CheckingError ? m_cache.LangProject.DefaultComputerAgent : m_cache.LangProject.DefaultUserAgent; // Notify all windows that the new annotation exists m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, Hvo, (int)ScrBookAnnotationsTags.kflidNotes, insertIndex, 1, 0); return annotation; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the color of the note background. /// </summary> /// <param name="ann">The ann.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private Color GetNoteBackgroundColor(ScrScriptureNote ann) { switch (ann.AnnotationType) { case NoteType.Consultant: return Color.PaleGoldenrod; case NoteType.Translator: return Color.LightBlue; case NoteType.CheckingError: return Color.PaleGreen; default: return Color.Red; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set the background color based on the type of annotation /// </summary> /// <param name="ann">annotation</param> /// <param name="vwenv"></param> /// ------------------------------------------------------------------------------------ private void SetBackgroundColorForNote(ScrScriptureNote ann, IVwEnv vwenv) { int color = (int)ColorUtil.ConvertColorToBGR(GetNoteBackgroundColor(ann)); switch (ann.AnnotationType) { case NoteType.Consultant: vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, color); break; case NoteType.Translator: vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, color); break; case NoteType.CheckingError: vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, color); break; default: throw new Exception("Unexpected annotation type"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an expandable annotation of the specified type. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayExpandableAnnotation(IVwEnv vwenv, ScrScriptureNote ann, int tag, int hvo, IStJournalText paras, ITsString label, bool readOnly) { vwenv.NoteDependency(new int[] { hvo }, new int[] { m_expansionTag }, 1); SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first cell vwenv.OpenTableCell(1, 1); vwenv.CloseTableCell(); // Display +/- in the second cell, unless this is read-only vwenv.OpenTableCell(1, 1); if (!readOnly) vwenv.AddObjProp(tag, this, (int)NotesFrags.kfrExpansion); vwenv.CloseTableCell(); // Display text in the remaining cells vwenv.OpenTableCell(1, 5); vwenv.OpenConcPara(0, 0, 0, 0); vwenv.AddString(label); if (!m_expandTable.ContainsKey(hvo)) vwenv.AddString(((StTxtPara)paras.ParagraphsOS[0]).Contents.UnderlyingTsString); vwenv.CloseParagraph(); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); if (!m_expandTable.ContainsKey(hvo)) return; SetBackgroundColorForNote(ann, vwenv); OpenTableRow(vwenv, ann); // Display empty first and second cell vwenv.OpenTableCell(1, 2); vwenv.CloseTableCell(); // Display text in cells 3-7 vwenv.OpenTableCell(1, 5); if (!readOnly) SetEditBackground(vwenv); vwenv.AddObjProp(tag, this, (int)StTextFrags.kfrText); vwenv.CloseTableCell(); CloseTableRow(vwenv, ann); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays an expandable annotation of the specified type. /// </summary> /// ------------------------------------------------------------------------------------ private void DisplayExpandableAnnotation(IVwEnv vwenv, ScrScriptureNote ann, int tag, int hvo, IStJournalText paras, ITsString label) { DisplayExpandableAnnotation(vwenv, ann, tag, hvo, paras, label, false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle display of a Scripture reference or range. /// </summary> /// <param name="vwenv">View environment</param> /// <param name="tag">Tag</param> /// <param name="v">Not used. (usually <c>null</c>)</param> /// <param name="frag">Fragment to identify what type of prompt should be created.</param> /// <returns> /// ITsString that will be displayed as user prompt. /// </returns> /// ------------------------------------------------------------------------------------ public override ITsString DisplayVariant(IVwEnv vwenv, int tag, object v, int frag) { if (frag == (int)NotesFrags.kfrScrRef) { ScrScriptureNote ann = new ScrScriptureNote(Cache, vwenv.CurrentObject()); BCVRef startRef = new BCVRef(ann.BeginRef); string bookAbbrev = m_scrBooks.GetBookAbbrev(startRef.Book); string sAnnRef = ScrReference.MakeReferenceString(bookAbbrev, ann.BeginRef, ann.EndRef, m_scr.ChapterVerseSepr, m_scr.Bridge); return MakeLabelFromText(sAnnRef, ann); } return base.DisplayVariant(vwenv, tag, v, frag); }
public void GoToScrScriptureNoteRef_OrigParaGone() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; int ichStartExpected = para.Contents.Text.IndexOf("one"); Assert.IsTrue(ichStartExpected > 0, "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("one", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); StTxtPara para2 = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[1]; note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001001, 2001001, para2, para2, -1, 0 ,0, bldrQuote, null, null, null); // Now delete the paragraph the note refers to. exodus.SectionsOS[1].ContentOA.ParagraphsOS.RemoveAt(1); // Initial offsets are irrelevant since the original paragraph is deleted. note.BeginOffset = 10; note.EndOffset = 13; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the text referenced in the ScrScriptureNote is selected. Assert.IsTrue(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart, ichEnd; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); helper.EditedRootBox.Selection.TextSelInfo(true, out tss, out ichEnd, out assocPrev, out hvoSel, out tag, out ws); helper.EditedRootBox.Selection.GetSelectionString(out tss, "#"); Assert.AreEqual("one", tss.Text); Assert.AreEqual(ichStartExpected, ichStart); Assert.AreEqual(ichStartExpected + 3, ichEnd); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }
public void GoToScrScriptureNoteRef_OrigParaEmpty() { CheckDisposed(); ScrBook exodus = (ScrBook)ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus[1].ContentOA.ParagraphsOS[1]; int ichStartExpected = para.Contents.Text.IndexOf("three"); Assert.IsTrue(ichStartExpected > 0, "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("three", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001003, 2001003, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = ichStartExpected; note.EndOffset = ichStartExpected + 5; ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr(); bldr.ReplaceRgch(0, para.Contents.Length, string.Empty, 0, null); // We want to prevent data validation so that we can set up an empty paragraph. Cache.PropChangedHandling = PropChangedHandling.SuppressChangeWatcher; para.Contents.UnderlyingTsString = bldr.GetString(); Assert.AreEqual(0, para.Contents.Length, "Contents of paragraph 3 should have been deleted."); // Initial offsets are irrelevant since the original paragraph is empty. note.BeginOffset = 7; note.EndOffset = 12; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that a selection is made close to the empty paragraph with the deleted verse. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); Assert.AreEqual(2001002, helper.CurrentStartRef.BBCCCVVV); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shows the category chooser dialog to let the user set the category for the /// specified annotation. /// </summary> /// ------------------------------------------------------------------------------------ private void SetAnnotationCategory(ScrScriptureNote ann) { if (ann == null) return; // Not much we can do m_rootb.DestroySelection(); string sUndo, sRedo; TeResourceHelper.MakeUndoRedoLabels("kstidSetAnnotationCategory", out sUndo, out sRedo); using (new UndoTaskHelper(this, sUndo, sRedo, true)) using (new WaitCursor(this)) using (CategoryChooserDlg dlg = new CategoryChooserDlg(m_scr.NoteCategoriesOA, ann.CategoriesRS.HvoArray)) { if (dlg.ShowDialog(ParentForm) == DialogResult.OK && !dlg.GetPossibilities(ann.CategoriesRS)) { ann.DateModified = DateTime.Now; } } }
public void GoToScrScriptureNoteRef_TextExistethNot() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; Assert.IsFalse(para.Contents.Text.Contains("sixty-three"), "Unexpected data in paragraph"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); // Set text to something that does not exist in the verse to simiulate subsequent deletion. bldrQuote.AppendRun("sixty-three", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001001, 2001001, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = 100; note.EndOffset = 111; TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the selection is at the start of the verse. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); Assert.AreEqual(2, ichStart, "IP should be at start of verse, following chapter number and verse number."); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the Scripture reference of the specified annotation as string. /// </summary> /// <param name="ann">The specified annotation.</param> /// ------------------------------------------------------------------------------------ private string GetRefAsString(ScrScriptureNote ann) { BCVRef startRef = new BCVRef(ann.BeginRef); IScrBook book = m_scr.FindBook(startRef.Book); string titleText = ResourceHelper.GetResourceString("kstidScriptureTitle"); string introText = ResourceHelper.GetResourceString("kstidScriptureIntro"); return ScrReference.MakeReferenceString(book.BestUIName, startRef, new BCVRef(ann.EndRef), m_scr.ChapterVerseSepr, m_scr.Bridge, titleText, introText); }
public void GoToScrScriptureNoteRef_VerseDeleted() { CheckDisposed(); IScrBook exodus = ScrBook.FindBookByID(m_scr, 2); StTxtPara para = (StTxtPara)exodus.SectionsOS[1].ContentOA.ParagraphsOS[0]; int ichStartOrig = para.Contents.Text.IndexOf("two"); StTxtParaBldr bldrQuote = new StTxtParaBldr(Cache); ITsPropsFactory fact = TsPropsFactoryClass.Create(); bldrQuote.ParaProps = fact.MakeProps(ScrStyleNames.Remark, 0, 0); bldrQuote.AppendRun("two", fact.MakeProps(null, Cache.DefaultVernWs, 0)); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.InitializeNote(LangProject.kguidAnnConsultantNote, 2001002, 2001002, para, para, -1, 0 ,0, bldrQuote, null, null, null); note.BeginOffset = ichStartOrig; note.EndOffset = ichStartOrig + 3; // Now we delete verse two from that paragraph. int ichStartOfVerse2 = para.Contents.Text.IndexOf("2"); ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr(); bldr.Replace(ichStartOfVerse2, para.Contents.Length, string.Empty, null); para.Contents.UnderlyingTsString = bldr.GetString(); TeEditingHelper helper = m_draftView.TeEditingHelper; helper.GoToScrScriptureNoteRef(note); // Confirm that the selection is at the start of the verse 3. Assert.IsFalse(helper.EditedRootBox.Selection.IsRange); ITsString tss; int ichStart; bool assocPrev; int hvoSel, tag, ws; helper.EditedRootBox.Selection.TextSelInfo(false, out tss, out ichStart, out assocPrev, out hvoSel, out tag, out ws); Assert.AreEqual(2, ichStart, "IP should be after verse number one and chapter number one."); Assert.AreEqual(2001001, helper.CurrentStartRef.BBCCCVVV); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Looks for any annotations in the curtrently filtered set whose reference range /// covers the given Scripture reference. Any such annotations are expanded and the /// first on is scrolled to near the top of the view. /// </summary> /// ------------------------------------------------------------------------------------ internal void ScrollRefIntoView(ScrReference reference, string quotedText) { CheckDisposed(); if (reference.Book <= 0) return; bool fSaveSendSyncScrollMsg = m_fSendSyncScrollMsg; try { m_fSendSyncScrollMsg = false; int bookHvo = m_scr.BookAnnotationsOS[reference.Book - 1].Hvo; int[] annHvos = m_fdoCache.GetVectorProperty(bookHvo, m_vc.NotesSequenceHandler.Tag, false); int exactMatchingAnnotation = -1; int firstMatchingAnnotation = -1; for (int i = 0; i < annHvos.Length; i++) { ScrScriptureNote ann = new ScrScriptureNote(m_fdoCache, annHvos[i]); if (ann.BeginRef <= reference && ann.EndRef >= reference) { if (firstMatchingAnnotation < 0) firstMatchingAnnotation = i; string qtext = ((StTxtPara)ann.QuoteOA.ParagraphsOS[0]).Contents.Text; if (!string.IsNullOrEmpty(qtext) && !string.IsNullOrEmpty(quotedText) && qtext == quotedText && exactMatchingAnnotation < 0) { exactMatchingAnnotation = i; } } else if (firstMatchingAnnotation >= 0) break; } int idx = Math.Max(exactMatchingAnnotation, firstMatchingAnnotation); if (idx >= 0) NotesEditingHelper.MakeSelectionInNote(m_vc, reference.Book - 1, idx, this, m_vc.IsExpanded(annHvos[idx])); } finally { m_fSendSyncScrollMsg = fSaveSendSyncScrollMsg; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Connects the notes to new categories using a map created before the new categories /// were loaded. If the note category does not already exist, it will create the /// category. /// </summary> /// <param name="map">The map (for each writing system) from the note id to the /// full string path of the category name.</param> /// <remarks>Limitation: If any category is renamed, any notes that used the previous /// name will continue to use the old category. To fix this problem, we would need to /// specify in the category file (for each category with a changed name) how the old /// category maps to its renamed/relocated category).</remarks> /// ------------------------------------------------------------------------------------ private void ConnectNotesToNewCategories(Dictionary<int, List<string>> map) { foreach (int noteHvo in map.Keys) { ScrScriptureNote note = new ScrScriptureNote(m_scr.Cache, noteHvo); note.CategoriesRS.RemoveAll(); // Just in case List<string> strCategories = map[noteHvo]; foreach (string strCategory in strCategories) { note.CategoriesRS.Append(m_scr.NoteCategoriesOA.FindOrCreatePossibility( strCategory, m_scr.Cache.DefaultAnalWs)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attempts to scroll to the first annotation whose beginning reference's book is /// the same as the specified book. /// </summary> /// ------------------------------------------------------------------------------------ private bool ScrollToNonScrAnnotationByBook(int book, string selectedText) { int bookHvo = m_scr.BookAnnotationsOS[book - 1].Hvo; int[] annHvos = m_fdoCache.GetVectorProperty(bookHvo, m_vc.NotesSequenceHandler.Tag, false); if (annHvos.Length == 0) return false; int ihvo = 0; ScrScriptureNote ann; BCVRef bcvRef; // Go through the annotations for the book and find the one whose // cited text is the same as the specified selected text. for (int i = 0; i < annHvos.Length; i++) { ann = new ScrScriptureNote(m_fdoCache, annHvos[i]); bcvRef = new BCVRef(ann.BeginRef); if (ann.CitedText == selectedText && bcvRef.Chapter == 0) { ihvo = i; break; } } ann = new ScrScriptureNote(m_fdoCache, annHvos[ihvo]); bcvRef = new BCVRef(ann.BeginRef); if (bcvRef.Chapter > 0) return false; NotesEditingHelper.MakeSelectionInNote(m_vc, book - 1, ihvo, this, m_vc.IsExpanded(ann.Hvo)); return true; }
public void MakeLabelFromText_AnnotationOnFootnote() { CheckDisposed(); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.BeginRef = 01001011; note.EndRef = 01001011; StFootnote footnote = m_scrInMemoryCache.AddFootnote(m_gen, (IStTxtPara)m_gen.SectionsOS[1].ContentOA.ParagraphsOS[0], 0); note.BeginObjectRA = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo, "Whatever"); ITsString tss = m_vc.CallMakeLabelFromText("GEN 1:11", "WhoCares", note); Assert.AreEqual(3, tss.RunCount); Assert.AreEqual("\u0032", tss.get_RunText(0)); Assert.AreEqual("GEN 1:11", tss.get_RunText(1)); Assert.AreEqual("Marlett", tss.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptFontFamily)); Assert.AreEqual("WhoCares", tss.get_Properties(1).GetStrPropValue((int)FwTextPropType.ktptNamedStyle)); CheckFinalSpaceInReferenceLabel(tss); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Makes a selection in the specified annotation (without scrolling the annotation in /// the view). /// </summary> /// <param name="bookIndex">Index of the book.</param> /// <param name="iAnnotation">Index of the annotation.</param> /// <param name="iResponse">Index of the response (0 if setting the selection in one of /// the StJournalText fields rather than in a response.</param> /// <param name="noteTag">The tag indicating the field of the annotation where the /// selection is to be made.</param> /// ------------------------------------------------------------------------------------ internal void MakeSelectionInNote(int bookIndex, int iAnnotation, int iResponse, ScrScriptureNote.ScrScriptureNoteTags noteTag) { MakeSelectionInNote(CurrentNotesVc, true, bookIndex, iAnnotation, iResponse, noteTag, Control as IVwRootSite, true); }
public void MakeLabelFromText_AnnotationOnBackTrans() { CheckDisposed(); ScrScriptureNote note = new ScrScriptureNote(); m_scr.BookAnnotationsOS[0].NotesOS.Append(note); note.BeginRef = 01001011; note.EndRef = 01001011; StTxtPara para = (StTxtPara)m_gen.SectionsOS[1].ContentOA.ParagraphsOS[0]; note.BeginObjectRA = para.GetOrCreateBT(); ITsString tss = m_vc.CallMakeLabelFromText("GEN 1:11", "WhoCares", note); Assert.AreEqual(2, tss.RunCount); Assert.AreEqual("GEN 1:11", tss.get_RunText(0)); Assert.AreEqual("WhoCares", tss.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptNamedStyle)); CheckFinalSpaceInReferenceLabel(tss); }
public void TestCreateAnnotationResponse() { CheckDisposed(); ScrScriptureNote annotation = new ScrScriptureNote(); // add this annotation collection to the list FdoOwningSequence<IScrScriptureNote> genesisNotes = m_scr.BookAnnotationsOS[0].NotesOS; genesisNotes.Append(annotation); int cNotesBeforeResponse = genesisNotes.Count; IStJournalText response = annotation.CreateResponse(); Assert.IsNotNull(response); Assert.AreEqual(cNotesBeforeResponse, genesisNotes.Count, "Response annotation should not get added to master list."); Assert.AreEqual(1, annotation.ResponsesOS.Count); Assert.AreEqual(response.Hvo, annotation.ResponsesOS.HvoArray[0]); Assert.AreEqual(1, response.ParagraphsOS.Count); ITsTextProps ttpParaStyle = response.ParagraphsOS[0].StyleRules; Assert.AreEqual(ScrStyleNames.Remark, ttpParaStyle.GetStrPropValue( (int)FwTextPropType.ktptNamedStyle)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Make a label string to use in the view. /// </summary> /// <param name="labelText">text to put in the label</param> /// <param name="styleName">style name to use for the character style on the text</param> /// <param name="ann">The annotation</param> /// <returns>An ITsString</returns> /// ------------------------------------------------------------------------------------ protected ITsString MakeLabelFromText(string labelText, string styleName, ScrScriptureNote ann) { ITsTextProps ttpLabel = StyleUtils.CharStyleTextProps(styleName, m_cache.DefaultUserWs); ITsStrBldr bldr = TsStrBldrClass.Create(); if (ann != null && m_cache.IsValidObject(ann.BeginObjectRAHvo)) { StTxtPara startPara = ann.BeginObjectRA as StTxtPara; if (startPara != null) { int ownerOwnFlid = m_cache.GetOwningFlidOfObject(startPara.OwnerHVO); if (ownerOwnFlid == (int)ScrBook.ScrBookTags.kflidFootnotes) { ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Marlett"); bldr.Replace(0, 0, "\u0032", propsBldr.GetTextProps()); } } } bldr.Replace(bldr.Length, bldr.Length, labelText, ttpLabel); // Add a space with default paragraph characters. This prevents style bleed-through // from the label when the user types in the text with (part of) the label selected. bldr.Replace(bldr.Length, bldr.Length, " ", StyleUtils.CharStyleTextProps(null, m_cache.DefaultUserWs)); return bldr.GetString(); }