本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.Stub方法的具体用法?C# SelectionHelper.Stub怎么用?C# SelectionHelper.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.Common.RootSites.SelectionHelper
的用法示例。
在下文中一共展示了SelectionHelper.Stub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimulateHyperlinkOnly
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets up a TsString to be returned from the selection helper so that it will appear
/// to the editing helper as though we're editing a string consisting of only a hyperlink.
/// </summary>
/// ------------------------------------------------------------------------------------
private void SimulateHyperlinkOnly(SelectionHelper selHelper,
IchPosition start, IchPosition end)
{
ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();
bldr.Replace(0, 0, "Google", m_ttpHyperlink);
selHelper.Stub(selH => selH.GetTss(Arg<SelectionHelper.SelLimitType>.Is.Anything))
.Return(bldr.GetString());
selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Anything))
.Return(m_ttpHyperlink);
int ichStart = 0;
int ichEnd = 0;
switch (start)
{
case IchPosition.EarlyInHyperlink: ichStart = 2; break;
case IchPosition.EndOfString:
case IchPosition.EndOfHyperlink: ichStart = bldr.Length; break;
}
switch (end)
{
case IchPosition.LateInHyperlink: ichEnd = 4; break;
case IchPosition.EndOfString:
case IchPosition.EndOfHyperlink: ichEnd = bldr.Length; break;
}
selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
}
示例2: SimulateTextFollowedByHyperlink
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets up a TsString to be returned from the selection helper so that it will appear
/// to the editing helper as though we're editing a string with some plain text followed
/// by a hyperlink.
/// </summary>
/// ------------------------------------------------------------------------------------
private void SimulateTextFollowedByHyperlink(SelectionHelper selHelper,
ITsTextProps ttpPrecedingText, IchPosition start, IchPosition end)
{
ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();
bldr.Replace(bldr.Length, bldr.Length, "some plain text", ttpPrecedingText);
bldr.Replace(0, 0, "Google", m_ttpHyperlink);
selHelper.Stub(selH => selH.GetTss(Arg<SelectionHelper.SelLimitType>.Is.Anything))
.Return(bldr.GetString());
int ichStart = 0;
int ichEnd = bldr.Length;
switch (start)
{
case IchPosition.StartOfString:
selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
SelectionHelper.SelLimitType.Top))).Return(ttpPrecedingText);
break;
case IchPosition.StartOfHyperlink:
selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
SelectionHelper.SelLimitType.Top))).Return(m_ttpHyperlink);
ichStart = "some plain text".Length;
break;
}
switch (end)
{
case IchPosition.StartOfHyperlink: ichEnd = "some plain text".Length; break;
}
selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
SelectionHelper.SelLimitType.Bottom))).Return(m_ttpHyperlink);
selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
}