本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.RemoveLevel方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.RemoveLevel方法的具体用法?C# SelectionHelper.RemoveLevel怎么用?C# SelectionHelper.RemoveLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.Common.RootSites.SelectionHelper
的用法示例。
在下文中一共展示了SelectionHelper.RemoveLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeletePicture
/// ------------------------------------------------------------------------------------
/// <summary>
/// Deletes the picture specified by the hvo.
/// </summary>
/// <param name="helper">Selection containing the picture.</param>
/// <param name="hvoPic">hvo of picture.</param>
/// ------------------------------------------------------------------------------------
protected void DeletePicture(SelectionHelper helper, int hvoPic)
{
int paraHvo = helper.GetLevelInfoForTag((int)StText.StTextTags.kflidParagraphs).hvo;
Debug.Assert(paraHvo != 0);
int iBook, iSection;
iBook = ((ITeView)Control).LocationTracker.GetBookIndex(helper,
SelectionHelper.SelLimitType.Anchor);
iSection = ((ITeView)Control).LocationTracker.GetSectionIndexInBook(helper,
SelectionHelper.SelLimitType.Anchor);
StTxtPara para = new StTxtPara(m_cache, paraHvo);
// Find the ORC and delete it from the paragraph
ITsString contents = para.Contents.UnderlyingTsString;
int startOfRun = 0;
for(int i = 0; i < contents.RunCount; i++)
{
string str = contents.get_Properties(i).GetStrPropValue(
(int)FwTextPropType.ktptObjData);
if (str != null)
{
Guid guid = MiscUtils.GetGuidFromObjData(str.Substring(1));
int hvo = m_cache.GetIdFromGuid(guid);
if (hvo == hvoPic)
{
ITsStrBldr bldr = contents.GetBldr();
startOfRun = contents.get_MinOfRun(i);
bldr.Replace(startOfRun, contents.get_LimOfRun(i),
string.Empty, null);
para.Contents.UnderlyingTsString = bldr.GetString();
break;
}
}
}
// TODO (TE-4967): do a prop change that actually works.
// m_cache.PropChanged(null, PropChangeType.kpctNotifyAll,
// para.Hvo, (int)StTxtPara.StTxtParaTags.kflidContents,
// startOfRun, 0, 1);
if (FwApp.App != null)
FwApp.App.RefreshAllViews(m_cache);
m_cache.DeleteObject(hvoPic);
// TODO (TimS): This code to create a selection in the paragraph the picture was
// in probably won't work when deleting a picture in back translation
// material (which isn't possible to insert yet).
((ITeView)Control).LocationTracker.SetBookAndSection(helper,
SelectionHelper.SelLimitType.Anchor, iBook, iSection);
helper.RemoveLevel((int)StTxtPara.StTxtParaTags.kflidContents);
if (Callbacks != null && Callbacks.EditedRootBox != null) // may not exist in tests.
{
try
{
MakeSimpleTextSelection(helper.LevelInfo,
(int)StTxtPara.StTxtParaTags.kflidContents, startOfRun);
}
catch
{
// If we couldn't make the selection in the contents, it's probably because
// we are in a user prompt, so try that instead.
MakeSimpleTextSelection(helper.LevelInfo, (int)SimpleRootSite.kTagUserPrompt,
startOfRun);
}
Callbacks.EditedRootBox.Site.ScrollSelectionIntoView(Callbacks.EditedRootBox.Selection,
VwScrollSelOpts.kssoNearTop);
}
}