当前位置: 首页>>代码示例>>C#>>正文


C# SelectionHelper.UpdateScrollLocation方法代码示例

本文整理汇总了C#中SIL.FieldWorks.Common.RootSites.SelectionHelper.UpdateScrollLocation方法的典型用法代码示例。如果您正苦于以下问题:C# SelectionHelper.UpdateScrollLocation方法的具体用法?C# SelectionHelper.UpdateScrollLocation怎么用?C# SelectionHelper.UpdateScrollLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SIL.FieldWorks.Common.RootSites.SelectionHelper的用法示例。


在下文中一共展示了SelectionHelper.UpdateScrollLocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertFootnote


//.........这里部分代码省略.........
			// (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)
						ichSel--;

					TsStringUtils.InsertOrcIntoPara(footnote.Guid, FwObjDataTypes.kodtNameGuidHot,
						tssBldr, ichSel, ichSel, ws);
					bt.set_String(ws, tssBldr.GetString());
					iFootnote = footnote.IndexInOwner;

					if (tssSelectedText.Length > 0)
					{
						ICmTranslation btFootnoteTrans = ((IStTxtPara)footnote.ParagraphsOS[0]).GetBT();
						ITsString btFootnoteTss = btFootnoteTrans.Translation.get_String(ws);

						// Insert any selected text into this back translation for the footnote paragraph.
						btFootnoteTrans.Translation.set_String(ws, tssSelectedText);
					}
				}
			}

			if (footnote == null)
				MiscUtils.ErrorBeep(); // No footnote reference ORC inserted
			else
			{
				// Update the selection in the view that the footnote was inserted.
				selHelper.UpdateScrollLocation(); // Make sure this is up-to-date
				selHelper = new SelectionHelper(selHelper); // Get a new copy, so any subsequent changes won't affect us.
				selHelper.IchAnchor++;
				selHelper.AssocPrev = false; // Associate away from the newly inserted marker to avoid shifting scroll position by a couple pixels
				selHelper.IchEnd = selHelper.IchAnchor;
				Callbacks.RequestVisibleSelectionAtEndOfUow(selHelper);
			}

			return footnote;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:TeEditingHelper.cs


注:本文中的SIL.FieldWorks.Common.RootSites.SelectionHelper.UpdateScrollLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。