本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.ReduceToIp方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.ReduceToIp方法的具体用法?C# SelectionHelper.ReduceToIp怎么用?C# SelectionHelper.ReduceToIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.Common.RootSites.SelectionHelper
的用法示例。
在下文中一共展示了SelectionHelper.ReduceToIp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertFootnote
/// ------------------------------------------------------------------------------------
/// <summary>
/// Inserts a footnote at the given selection
/// </summary>
/// <param name="selHelper">Current selection information</param>
/// <param name="styleName">style name for created footnote</param>
/// <param name="iFootnote">out: If selHelper is in vernacular para, the ihvo of the
/// footnote just inserted. If selHelper is in back trans, the ihvo of the footnote
/// corresponding to the ref ORC just inserted in the BT, or -1 no corresponding</param>
/// <returns>The created/corresponding footnote</returns>
/// ------------------------------------------------------------------------------------
public virtual ScrFootnote InsertFootnote(SelectionHelper selHelper, string styleName,
out int iFootnote)
{
CheckDisposed();
// Get any selected text.
ITsString tssSelected;
IVwSelection vwsel = selHelper.Selection;
if (IsSelectionInOneEditableProp(vwsel))
vwsel.GetSelectionString(out tssSelected, string.Empty);
else
tssSelected = StringUtils.MakeTss(string.Empty, m_cache.DefaultVernWs);
int hvoObj;
ITsString tssPara;
int propTag;
int ws;
selHelper.ReduceToIp(SelectionHelper.SelLimitType.Bottom, false, false);
int ichSel = GetSelectionInfo(selHelper, out hvoObj, out propTag, out tssPara, out ws);
if (propTag == (int)StTxtPara.StTxtParaTags.kflidContents)
ws = Cache.DefaultVernWs;
// get book info
IScrBook book = GetCurrentBook(m_cache);
// get paragraph info
int paraHvo = selHelper.GetLevelInfoForTag((int)StText.StTextTags.kflidParagraphs).hvo;
StTxtPara para = new StTxtPara(m_cache, paraHvo);
if (tssSelected.Length > 0)
{
tssSelected = StringUtils.RemoveORCsAndStylesFromTSS(tssSelected,
new List<string>(new string[] {ScrStyleNames.ChapterNumber, ScrStyleNames.VerseNumber}),
false, m_cache.LanguageWritingSystemFactoryAccessor);
if (tssSelected.Length > 0)
{
ITsStrBldr bldr = tssSelected.GetBldr();
bldr.SetStrPropValue(0, bldr.Length, (int) FwTextPropType.ktptNamedStyle, ScrStyleNames.ReferencedText);
bldr.ReplaceRgch(bldr.Length, bldr.Length, " ", 1, StyleUtils.CharStyleTextProps(null, ws));
tssSelected = bldr.GetString();
}
}
ScrFootnote footnote = null;
string undo;
string redo;
if (styleName == ScrStyleNames.CrossRefFootnoteParagraph)
TeResourceHelper.MakeUndoRedoLabels("kstidInsertCrossReference", out undo, out redo);
else
TeResourceHelper.MakeUndoRedoLabels("kstidInsertFootnote", out undo, out redo);
using (UndoTaskHelper undoTaskHelper =
new UndoTaskHelper(Callbacks.EditedRootBox.Site, undo, redo, true))
{
try
{
if (propTag == (int)StTxtPara.StTxtParaTags.kflidContents)
{
// Inserting footnote into the vernacular paragraph
iFootnote = FindFootnotePosition(book, selHelper);
ITsStrBldr tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();
// create the footnote and insert its marker into the paragraph's string
// builder.
footnote = ScrFootnote.InsertFootnoteAt(book, styleName, iFootnote, tsStrBldr, ichSel);
// BEFORE we insert the ORC in the paragraph, we need to insert an empty
// paragraph into the new StFootnote, because the para style is needed to
// determine the footnote marker type.
StTxtPara footnotePara = new StTxtPara();
footnote.ParagraphsOS.Append(footnotePara);
// If we wait for this to be created by the VC, its creation won't be part of the
// Undo task, and we won't be able to Undo creating the footnote, because the paragraph
// will own something that Undo doesn't know to delete (TE-7988).
footnotePara.GetOrCreateBT();
ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
styleName);
footnotePara.StyleRules = propsBldr.GetTextProps();
// Record information, as if we were typing the footnote caller, that allows
// segment boundaries to be adjusted properly.
OnAboutToEdit();
// update the paragraph contents to include the footnote marker
para.Contents.UnderlyingTsString = tsStrBldr.GetString();
// Finish off any necessary annotation adjustments.
m_annotationAdjuster.OnFinishedEdit();
// Insert the selected text (or an empty run) into the footnote paragraph.
//.........这里部分代码省略.........
示例2: ReduceSelectionToIp
/// ------------------------------------------------------------------------------------
/// <summary>
/// This is the workhorse that actually reduces a range selection to a simple insertion
/// point, given the specified index to indicate the limit where the IP is to be
/// created.
/// </summary>
/// <param name="limit">Specify Top to place the IP at the top-most limit of the
/// selection. Specify Bottom to place the IP at the bottom-most limit of the selection.
/// Specify Anchor to place the IP at the point where the user initiated the selection.
/// Specify End to place the IP at the point where the user completed the selection. Be
/// aware the user may select text in either direction, thus the end of the selection\
/// could be visually before the anchor. For a simple insertion point or a selection
/// entirely within a single StText, this parameter doesn't actually make any
/// difference.</param>
/// <param name="fMakeVisible">Indicates whether to scroll the IP into view.</param>
/// <param name="fInstall">True to install the created selection, false otherwise</param>
/// ------------------------------------------------------------------------------------
protected virtual SelectionHelper ReduceSelectionToIp(SelLimitType limit, bool fMakeVisible,
bool fInstall)
{
SelectionHelper textSelHelper = new SelectionHelper(this);
textSelHelper.ReduceToIp(limit);
// and make the selection
if (fInstall)
textSelHelper.SetSelection(m_rootSite, true, fMakeVisible);
return textSelHelper;
}
示例3: ReduceSelectionToIp
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets a (new) selection helper that represents an insertion point at the specified
/// limit of this selection
/// </summary>
/// <param name="limit">Specify Top to place the IP at the top-most limit of the
/// selection. Specify Bottom to place the IP at the bottom-most limit of the selection.
/// Specify Anchor to place the IP at the point where the user initiated the selection.
/// Specify End to place the IP at the point where the user completed the selection. Be
/// aware the user may select text in either direction, thus the end of the selection\
/// could be visually before the anchor. For a simple insertion point or a selection
/// entirely within a single StText, this parameter doesn't actually make any
/// difference.</param>
/// <param name="fMakeVisible">Indicates whether to scroll the IP into view.</param>
/// <param name="fInstall">True to install the created selection, false otherwise</param>
/// ------------------------------------------------------------------------------------
public virtual SelectionHelper ReduceSelectionToIp(SelLimitType limit, bool fMakeVisible,
bool fInstall)
{
SelectionHelper textSelHelper = new SelectionHelper(this);
return textSelHelper.ReduceToIp(limit, fMakeVisible, fInstall) == null ? null : textSelHelper;
}
示例4: InsertFootnote
/// ------------------------------------------------------------------------------------
/// <summary>
/// Inserts a footnote at the given selection
/// </summary>
/// <param name="selHelper">Current selection information</param>
/// <param name="styleName">style name for created footnote</param>
/// <param name="iFootnote">out: If selHelper is in vernacular para, the ihvo of the
/// footnote just inserted. If selHelper is in back trans, the ihvo of the footnote
/// corresponding to the ref ORC just inserted in the BT, or -1 no corresponding</param>
/// <returns>The created/corresponding footnote</returns>
/// ------------------------------------------------------------------------------------
public virtual IStFootnote InsertFootnote(SelectionHelper selHelper, string styleName,
out int iFootnote)
{
CheckDisposed();
// Get any selected text.
ITsString tssSelectedText;
IVwSelection vwsel = selHelper.Selection;
if (!IsSelectionInUserPrompt && IsSelectionInOneEditableProp(vwsel))
vwsel.GetSelectionString(out tssSelectedText, string.Empty);
else
tssSelectedText = TsStringUtils.MakeTss(string.Empty, m_cache.DefaultVernWs);
int hvoObj;
ITsString tssSel; // This is either the vernacular or the BT, depending on the selection location.
int propTag;
int ws;
selHelper.ReduceToIp(SelectionHelper.SelLimitType.Bottom, false, false);
int ichSel = GetSelectionInfo(selHelper, out hvoObj, out propTag, out tssSel, out ws);
if (propTag == StTxtParaTags.kflidContents)
ws = Cache.DefaultVernWs;
// Make sure the selection is updated with the new ich position in case it was wrong
// (e.g. If the selection is in a user prompt) (TE-8919)
selHelper.IchAnchor = selHelper.IchEnd = ichSel;
// get book info
IScrBook book = GetCurrentBook(m_cache);
// get paragraph info
int paraHvo = selHelper.GetLevelInfoForTag(StTextTags.kflidParagraphs).hvo;
IScrTxtPara para = m_repoScrTxtPara.GetObject(paraHvo);
tssSelectedText = TsStringUtils.GetCleanTsString(tssSelectedText, ScrStyleNames.ChapterAndVerse);
Debug.Assert(tssSelectedText != null);
if (tssSelectedText.Length > 0)
{
ITsStrBldr bldr = tssSelectedText.GetBldr();
bldr.SetStrPropValue(0, bldr.Length, (int)FwTextPropType.ktptNamedStyle, ScrStyleNames.ReferencedText);
bldr.ReplaceRgch(bldr.Length, bldr.Length, " ", 1, StyleUtils.CharStyleTextProps(null, ws));
tssSelectedText = bldr.GetString();
}
//Cache.ActionHandlerAccessor.AddAction(new UndoWithRefreshAction());
IScrFootnote footnote = null;
iFootnote = -1;
if (propTag == StTxtParaTags.kflidContents)
{
// Inserting footnote into the vernacular paragraph
iFootnote = FindFootnotePosition(book, selHelper);
ITsStrBldr tsStrBldr = para.Contents.GetBldr();
// create the footnote and insert its marker into the paragraph's string
// builder.
footnote = book.InsertFootnoteAt(iFootnote, tsStrBldr, ichSel);
// BEFORE we insert the ORC in the paragraph, we need to insert an empty
// paragraph into the new StFootnote, because the para style is needed to
// determine the footnote marker type.
IStTxtPara footnotePara = footnote.AddNewTextPara(styleName);
// update the paragraph contents to include the footnote marker
para.Contents = tsStrBldr.GetString();
// Insert the selected text (or an empty run) into the footnote paragraph.
footnotePara.Contents = tssSelectedText;
}
else
{
IMultiString bt = null;
if (propTag == SegmentTags.kflidFreeTranslation)
{
// Inserting footnote reference ORC into a segment free translation
ISegment segment = m_repoSegment.GetObject(selHelper.GetLevelInfoForTag(StTxtParaTags.kflidSegments).hvo);
bt = segment.FreeTranslation;
footnote = FindVernParaFootnote(segment, ws);
}
else if (propTag == CmTranslationTags.kflidTranslation)
{
// Inserting footnote reference ORC into a back translation
footnote = FindVernParaFootnote(ichSel, tssSel, para);
bt = para.GetBT().Translation;
}
if (footnote != null)
{
// Insert footnote reference ORC into back translation paragraph.
ITsStrBldr tssBldr = tssSel.GetBldr();
//if reference to footnote already somewhere else in para, delete it first
int ichDel = TsStringUtils.DeleteOrcFromBuilder(tssBldr, footnote.Guid);
if (ichDel >= 0 && ichSel > ichDel)
//.........这里部分代码省略.........