本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.GetTss方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.GetTss方法的具体用法?C# SelectionHelper.GetTss怎么用?C# SelectionHelper.GetTss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.Common.RootSites.SelectionHelper
的用法示例。
在下文中一共展示了SelectionHelper.GetTss方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelIsInEmptyTranslation
private bool SelIsInEmptyTranslation(SelectionHelper helper, int flid, int hvo)
{
if (helper.IsRange)
return false; // range can't be in empty comment.
if (flid != SegmentTags.kflidFreeTranslation && flid != SegmentTags.kflidLiteralTranslation)
return false; // translation is always a comment.
if (helper.GetTss(SelectionHelper.SelLimitType.Anchor).Length != 0)
return false; // translation is non-empty.
return true;
}
示例2: GetCurrentRefRange
/// ------------------------------------------------------------------------------------
/// <summary>
/// Common utility for the CurrentRef* properties
/// </summary>
/// <param name="selection"></param>
/// <param name="selLimit">The limit of the selection (anchor, end, etc.) to get the
/// reference of</param>
/// <returns>the start and end reference of the given selection, as an array of two
/// ScrReference objects</returns>
/// ------------------------------------------------------------------------------------
protected virtual ScrReference[] GetCurrentRefRange(SelectionHelper selection,
SelectionHelper.SelLimitType selLimit)
{
if (m_cache == null || selection == null || BookFilter == null)
return new ScrReference[] {ScrReference.Empty, ScrReference.Empty};
ILocationTracker tracker = ((ITeView)Control).LocationTracker;
// If there is a current book...
BCVRef start = new BCVRef();
BCVRef end = new BCVRef();
int iBook = tracker.GetBookIndex(selection, selLimit);
if (iBook >= 0 && BookFilter.BookCount > 0)
{
try
{
ScrBook book = BookFilter.GetBook(iBook);
// if there is not a current section, then use the book and chapter/verse of 0.
int hvoSection = tracker.GetSectionHvo(CurrentSelection, selLimit);
if (hvoSection >= 0)
{
// If there is a section...
ScrSection section = new ScrSection(m_cache, hvoSection);
int paraHvo = selection.GetLevelInfoForTag(
(int)StText.StTextTags.kflidParagraphs, selLimit).hvo;
ScrTxtPara scrPara = new ScrTxtPara(m_cache, paraHvo);
// Get the ich at either the beginning or the end of the selection,
// as specified with limit. (NB that this is relative to the property, not the whole paragraph.)
int ich;
// Get the TsString, whether in vern or BT
ITsString tss;
SelLevInfo segInfo;
int refWs;
if (selection.GetLevelInfoForTag(StTxtPara.SegmentsFlid(Cache), selLimit, out segInfo))
{
// selection is in a segmented BT segment. Figure the reference based on where the segment is
// in the underlying paragraph.
tss = scrPara.Contents.UnderlyingTsString; // for check below on range of ich.
CmBaseAnnotation seg = new CmBaseAnnotation(Cache, segInfo.hvo);
ich = seg.BeginOffset;
Debug.Assert(seg.BeginObjectRAHvo == scrPara.Hvo);
refWs = -1; // ich is in the paragraph itself, not some CmTranslation
}
else
{
ich = selection.GetIch(selLimit);
// Get the TsString, whether in vern or BT
tss = selection.GetTss(selLimit);
refWs = GetCurrentBtWs(selLimit); // figures out whether it's in a CmTranslation or the para itself.
}
Debug.Assert(tss == null || ich <= tss.Length);
if (tss != null && ich <= tss.Length)
{
scrPara.GetBCVRefAtPosition(refWs, ich, true, out start, out end);
// If the chapter number is 0, then use the chapter from the section reference
if (end.Chapter == 0)
end.Chapter = BCVRef.GetChapterFromBcv(section.VerseRefMin);
if (start.Chapter == 0)
start.Chapter = BCVRef.GetChapterFromBcv(section.VerseRefMin);
}
}
else
{
// either it didn't find a level or it didn't find an index. Either way,
// it couldn't find a section.
start.Book = end.Book = book.CanonicalNum;
}
}
catch
{
// Bummer man, something went wrong... don't sweat it though, it happens...
// This can occur if you are in the introduction or other location that lacks
// relevant information or other necessary stuff.
}
}
return new ScrReference[] {new ScrReference(start, m_scr.Versification),
new ScrReference(end, m_scr.Versification)}; ;
}
示例3: SelIsInEmptyTranslation
private bool SelIsInEmptyTranslation(SelectionHelper helper, int flid, int hvo)
{
if (helper.IsRange)
return false; // range can't be in empty comment.
if (flid != (int)CmAnnotation.CmAnnotationTags.kflidComment)
return false; // translation is always a comment.
if (helper.GetTss(SelectionHelper.SelLimitType.Anchor).Length != 0)
return false; // translation is non-empty.
int hvoType = Cache.GetObjProperty(hvo, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType);
return (hvoType == m_vc.FtSegmentDefn || hvoType == m_vc.LtSegmentDefn);
}
示例4: GetIndexToRemove
protected int GetIndexToRemove(int[] hvos, SelectionHelper sel, bool forward)
{
int hvo = GetItemHvo(sel, SelectionHelper.SelLimitType.Top);
for (int i = 0; i < hvos.Length; i++)
{
if (hvos[i] == hvo)
{
ITsString tss = sel.GetTss(SelectionHelper.SelLimitType.Anchor);
// if the current ich is at the end of the current string, then we can safely assume
// we are at the end of the current item, so remove it or the next item based on what
// key was pressed, otherwise we are in the middle in which
// case the entire item is selected, or at the beginning, so we remove it or the previous
// item based on what key was pressed
if (sel.IchAnchor == tss.Length)
{
if (forward)
return i == hvos.Length ? -1 : i + 1;
else
return i;
}
else
{
if (forward)
return i == hvos.Length ? -1 : i;
else
return i - 1;
}
}
}
return -1;
}
示例5: GetIndexToRemove
protected int GetIndexToRemove(ICmObject[] objs, SelectionHelper sel, bool forward)
{
ICmObject obj = GetCmObject(sel, SelectionHelper.SelLimitType.Top);
for (int i = 0; i < objs.Length; i++)
{
if (objs[i] == obj)
{
var tss = sel.GetTss(SelectionHelper.SelLimitType.Anchor);
// if the current ich is at the end of the current string, then we can safely assume
// we are at the end of the current item, so remove it or the next item based on what
// key was pressed, otherwise we are in the middle in which
// case the entire item is selected, or at the beginning, so we remove it or the previous
// item based on what key was pressed
if (sel.IchAnchor == tss.Length)
{
if (forward)
return i == objs.Length ? -1 : i + 1;
return i;
}
if (forward)
return i == objs.Length ? -1 : i;
return i - 1;
}
}
return -1;
}
示例6: GetCurrentRefRange
/// ------------------------------------------------------------------------------------
/// <summary>
/// Common utility for the CurrentRef* properties
/// </summary>
/// <param name="selhelper">The selection helper representing the current selection
/// (or sometimes the current reduced to an IP)</param>
/// <param name="selLimit">The limit of the selection (anchor, end, etc.) to get the
/// reference of</param>
/// <returns>the start and end reference of the given selection, as an array of two
/// ScrReference objects</returns>
/// ------------------------------------------------------------------------------------
protected ScrReference[] GetCurrentRefRange(SelectionHelper selhelper,
SelectionHelper.SelLimitType selLimit)
{
if (m_cache == null || selhelper == null || BookFilter == null)
return new ScrReference[] {ScrReference.Empty, ScrReference.Empty};
ILocationTracker tracker = ((ITeView)Control).LocationTracker;
// If there is a current book...
BCVRef start = new BCVRef();
BCVRef end = new BCVRef();
int iBook = tracker.GetBookIndex(selhelper, selLimit);
if (iBook >= 0 && BookFilter.BookCount > 0)
{
try
{
IScrBook book = BookFilter.GetBook(iBook);
// if there is not a current section, then use the book and chapter/verse of 0.
IScrSection section = tracker.GetSection(selhelper, selLimit);
if (section != null)
{
// If there is a section...
int paraHvo = selhelper.GetLevelInfoForTag(StTextTags.kflidParagraphs, selLimit).hvo;
IScrTxtPara scrPara = m_cache.ServiceLocator.GetInstance<IScrTxtParaRepository>().GetObject(paraHvo);
// Get the ich at either the beginning or the end of the selection,
// as specified with limit. (NB that this is relative to the property, not the whole paragraph.)
int ich;
// Get the TsString, whether in vern or BT
ITsString tss;
int refWs;
SelLevInfo segInfo;
int textPropTag = 0;
if (selhelper.GetLevelInfoForTag(StTxtParaTags.kflidSegments, selLimit, out segInfo))
{
// selection is in a segmented BT segment. Figure the reference based on where the segment is
// in the underlying paragraph.
tss = scrPara.Contents; // for check below on range of ich.
ISegment seg = m_repoSegment.GetObject(segInfo.hvo);
ich = seg.BeginOffset;
Debug.Assert(seg.Paragraph == scrPara);
refWs = -1; // ich is in the paragraph itself, not some CmTranslation
}
else
{
textPropTag = selhelper.GetTextPropId(selLimit);
if (textPropTag == SimpleRootSite.kTagUserPrompt)
{
ich = 0;
tss = null;
}
else
{
ich = selhelper.GetIch(selLimit);
tss = selhelper.GetTss(selLimit); // Get the TsString, whether in vern or BT
if (ich < 0 || tss == null)
{
HandleFootnoteAnchorIconSelected(selhelper.Selection, (hvo, flid, wsDummy, ichAnchor) =>
{
SelectionHelper helperTemp = new SelectionHelper(selhelper);
ich = helperTemp.IchAnchor = helperTemp.IchEnd = ichAnchor;
helperTemp.SetSelection(false, false);
tss = helperTemp.GetTss(selLimit);
});
}
}
refWs = GetCurrentBtWs(selLimit); // figures out whether it's in a CmTranslation or the para itself.
}
Debug.Assert(tss == null || ich <= tss.Length);
if ((tss != null && ich <= tss.Length) || textPropTag == SimpleRootSite.kTagUserPrompt)
{
scrPara.GetRefsAtPosition(refWs, ich, true, out start, out end);
// If the chapter number is 0, then use the chapter from the section reference
if (end.Chapter == 0)
end.Chapter = BCVRef.GetChapterFromBcv(section.VerseRefMin);
if (start.Chapter == 0)
start.Chapter = BCVRef.GetChapterFromBcv(section.VerseRefMin);
}
}
else
{
// either it didn't find a level or it didn't find an index. Either way,
// it couldn't find a section.
start.Book = end.Book = book.CanonicalNum;
}
}
catch
{
//.........这里部分代码省略.........