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


C# IVwSelection.SetIpTypingProps方法代码示例

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


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

示例1: PreventIPAssociationWithVerseRun

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Prevents IP-only selections from being associated with a verse number run.
		/// </summary>
		/// <param name="vwselNew">The new selection.</param>
		/// <param name="prootb">The root box.</param>
		/// <param name="updatedSelection"></param>
		/// ------------------------------------------------------------------------------------
		private void PreventIPAssociationWithVerseRun(IVwSelection vwselNew, IVwRootBox prootb,
			ref bool updatedSelection)
		{
			// Need to commit any editing in progress - otherwise attempt to read
			// paragraph that follows may get stale data.  This follows the example in
			// EditingHelper.SelectionChanged(). Also verify selection is still valid.
			Commit(vwselNew);
			if (!vwselNew.IsValid)
				return;

			SelectionHelper helper = SelectionHelper.Create(vwselNew, prootb.Site);

			// Get the tss that the IP is in
			ITsString tssSelectedScrPara = null;

			if (helper.LevelInfo.Length > 0)
			{
				switch (m_cache.GetClassOfObject(helper.LevelInfo[0].hvo))
				{
					case CmTranslation.kclsidCmTranslation:
						int hvo = helper.LevelInfo[0].hvo;
						int btWs = Callbacks.GetWritingSystemForHvo(hvo);
						CmTranslation trans = new CmTranslation(m_cache, hvo);
						tssSelectedScrPara = trans.Translation.GetAlternative(btWs).UnderlyingTsString;
						break;

					case StTxtPara.kclsidStTxtPara:
						StTxtPara para = new StTxtPara(m_cache, helper.LevelInfo[0].hvo);
						tssSelectedScrPara = para.Contents.UnderlyingTsString;
						break;
					case CmPicture.kclsidCmPicture:
					case StFootnote.kclsidStFootnote:
					default:
						// Not sure what it is, but it probably doesn't contain verse text...
						break;
				}
			}

			// Following code includes checking zero-length paragraphs for association with
			// the VerseNumber style so that empty paras will use the default character style
			if (tssSelectedScrPara == null)
				return;

			// Get the text props and run info of the run the IP is associating with
			int charPos = helper.IchAnchor;

			if (helper.AssocPrev && charPos > 0)
				charPos -= 1;

			if (charPos > tssSelectedScrPara.Length) // workaround for TE-5561
				charPos = tssSelectedScrPara.Length;

			TsRunInfo tri;
			ITsTextProps ttp = tssSelectedScrPara.FetchRunInfoAt(charPos, out tri);

			// These are the boundary conditions that require our intervention
			// regarding verse numbers.
			bool fEdgeOfTss = (helper.IchAnchor == 0 ||
			helper.IchAnchor == tssSelectedScrPara.Length);
			bool fBeginOfRun = (helper.IchAnchor == tri.ichMin);
			bool fEndOfRun = (helper.IchAnchor == tri.ichLim);

			if (!fEdgeOfTss && !fBeginOfRun && !fEndOfRun)
				return;

			// If the IP is associated with a verse number style run
			if (ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle) != ScrStyleNames.VerseNumber)
				return;

			try
			{
				m_selectionUpdateInProcess = true; //set our semaphore

				// We must disassociate the IP from the verse number style run...

				// If IP is at beginning or end of paragraph, need to reset selection to
				// default paragraph chars (null style).
				if (fEdgeOfTss)
				{
					// REVIEW: Should we be re-getting this, or just using the one we have?
					vwselNew = prootb.Selection;
					ITsPropsBldr bldr = ttp.GetBldr();
					bldr.SetStrPropValue((int) FwTextPropType.ktptNamedStyle, null);
					vwselNew.SetIpTypingProps(bldr.GetTextProps());
				}
				else
				{
					// Else make the selection be associated with the other adjacent run.
					helper.AssocPrev = fBeginOfRun;
					helper.SetSelection(true);
				}

//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:TeEditingHelper.cs


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