本文整理汇总了C#中IVwRootBox.MakeRangeSelection方法的典型用法代码示例。如果您正苦于以下问题:C# IVwRootBox.MakeRangeSelection方法的具体用法?C# IVwRootBox.MakeRangeSelection怎么用?C# IVwRootBox.MakeRangeSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwRootBox
的用法示例。
在下文中一共展示了IVwRootBox.MakeRangeSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeRangeSelection
/// -----------------------------------------------------------------------------------
/// <summary>
/// Make a range selection based upon our saved selection info.
/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
/// Callers should check to make sure the selection is still valid before using it.
/// </summary>
/// <param name="rootBox"></param>
/// <param name="fInstall"></param>
/// <exception cref="Exception">throws if unable to make an end selection</exception>
/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
/// -----------------------------------------------------------------------------------
public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
{
int iAnchor = 0;
int iEnd = 1;
if (!m_fEndSet)
{ // No end information set, so use iAnchor as end
iEnd = iAnchor;
}
if (m_selInfo[iEnd] == null)
{
m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
}
// This change was proposed in change set 37331 but it's not clear what crash sometimes happens if it's not done.
// Apparently it doesn't always crash because some TeDllTests fail if we do this.
// Don't make a selection if the property indicates not to: see comment about -2 in InterlinDocForAnalysis.HandleSelectionChange
//if (m_selInfo[iAnchor].tagTextProp == -2)
// return null; // crashes if allowed to continue
// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
// the RootSite of the selection change.
IVwSelection vwSelAnchor;
try
{
vwSelAnchor = rootBox.MakeTextSelection(
m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
null, false);
}
catch (Exception e)
{
Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
"Making the anchor selection failed, this is probably an empty editable field.");
throw;
}
IVwSelection vwSelEnd;
try
{
vwSelEnd = rootBox.MakeTextSelection(
m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
null, false);
}
catch (Exception)
{
Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
"The anchor has rgvsli but the end does not; since making the end selection failed, this is probably a mistake.");
throw;
}
return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
}
示例2: SelectAll
/// <summary>
/// Selects the contents of the whole rootbox.
/// </summary>
/// <param name="rootb"></param>
/// <param name="fEditable">if set to <c>true</c> tries to start and end the selection in an editable field.</param>
/// <param name="fInstall">if set to <c>true</c> installs the selection.</param>
/// <returns></returns>
internal static IVwSelection SelectAll(IVwRootBox rootb, bool fEditable, bool fInstall)
{
IVwSelection selDocument = null;
IVwSelection selStart = rootb.MakeSimpleSel(true, fEditable, false, false);
IVwSelection selEnd = rootb.MakeSimpleSel(false, fEditable, false, false);
if (selStart != null && selEnd != null)
selDocument = rootb.MakeRangeSelection(selStart, selEnd, fInstall);
return selDocument;
}
示例3: MakeRangeSelection
/// -----------------------------------------------------------------------------------
/// <summary>
/// Make a range selection based upon our saved selection info.
/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
/// Callers should check to make sure the selection is still valid before using it.
/// </summary>
/// <param name="rootBox"></param>
/// <param name="fInstall"></param>
/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
/// -----------------------------------------------------------------------------------
public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
{
int iAnchor = 0;
int iEnd = 1;
if (!m_fEndSet)
{ // No end information set, so use iAnchor as end
iEnd = iAnchor;
}
if (m_selInfo[iEnd] == null)
{
m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
}
// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
// the RootSite of the selection change.
IVwSelection vwSelAnchor = rootBox.MakeTextSelection(
m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
null, false);
IVwSelection vwSelEnd = rootBox.MakeTextSelection(
m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
null, false);
return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
}