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


C# ITsString.get_PropertiesAt方法代码示例

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


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

示例1: MakeEmbeddedNscSuggestion

		private IList<SpellCorrectMenuItem> MakeEmbeddedNscSuggestion(ref ITsString tssWord, IVwStylesheet styles, IVwRootBox rootb,
			int hvoObj, int tag, int wsAlt, int ichMin, int ichLim, out ITsString tssKeepOrcs)
		{
			List<SpellCorrectMenuItem> result = new List<SpellCorrectMenuItem>();
			// Make an item with inserted spaces.
			ITsStrBldr bldr = tssWord.GetBldr();
			int spCur = SpellCheckProps(tssWord, 0, styles);
			int offset = 0;
			bool foundDiff = false;
			bool fHasOrc = false;
			ITsStrBldr bldrWord = null;
			ITsStrBldr bldrKeepOrcs = null;
			int bldrWordOffset = 0;
			// Start at 0 even though we already got its props, because it just might be an ORC.
			for (int ich = 0; ich < tssWord.Length; ich++)
			{
				if (tssWord.GetChars(ich, ich + 1) == "\xfffc")
				{
					ITsTextProps ttp = tssWord.get_PropertiesAt(ich);
					string objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData);
					if (objData.Length == 0 || objData[0] != Convert.ToChar((int)FwObjDataTypes.kodtGuidMoveableObjDisp))
					{
						fHasOrc = true;
						int ichInsert = ich + offset;
						bldr.Replace(ichInsert, ichInsert, " ", null);
						spCur = -50 - ich; // Same trick as SpellCheckProps to ensure won't match anything following.
						offset++;
						foundDiff = true;
					}
					else
					{
						// An ORC we want to ignore, but not lose. We will strip it out of the word we will
						// actually spell-check if we don't find other ORC problems, but save it to be
						// inserted at the end of any correction word. We might still use
						// our own "insert missing spaces" option, too, if we find another ORC of a different type.
						// In that case, this ORC just stays as part of the string, without spaces inserted.
						if (bldrWord == null)
						{
							bldrWord = tssWord.GetBldr();
							bldrKeepOrcs = TsStrBldrClass.Create();
						}
						bldrWord.Replace(ich - bldrWordOffset, ich - bldrWordOffset + 1, "", null);
						bldrKeepOrcs.Replace(bldrKeepOrcs.Length, bldrKeepOrcs.Length, "\xfffc", ttp);
						bldrWordOffset++;
					}
				}
				else // not an orc, see if props changed.
				{
					int spNew = SpellCheckProps(tssWord, ich, styles);
					if (spNew != spCur)
					{
						int ichInsert = ich + offset;
						bldr.Replace(ichInsert, ichInsert, " ", null);
						spCur = spNew;
						offset++;
						foundDiff = true;
					}
				}
			}
			if (bldrWord != null)
			{
				tssWord = bldrWord.GetString();
				tssKeepOrcs = bldrKeepOrcs.GetString();
			}
			else
			{
				tssKeepOrcs = null;
			}
			if (!foundDiff)
				return result;
			ITsString suggest = bldr.GetString();
			// There might still be an ORC in the string, in the pathological case of a picture anchor and embedded verse number
			// in the same word(!). Leave it in the replacement, but not in the menu item.
			string menuItemText = suggest.Text.Replace("\xfffc", "");
			if (fHasOrc)
				menuItemText = RootSiteStrings.ksInsertMissingSpaces;
			result.Add(new SpellCorrectMenuItem(rootb, hvoObj, tag, wsAlt, ichMin, ichLim, menuItemText, suggest));
			return result;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:79,代码来源:SpellCheckHelper.cs

示例2: InsertORCAt

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts an ORC pointing to this picture at the specified location.
		/// </summary>
		/// <param name="tss">String into which ORC is to be inserted</param>
		/// <param name="ich">character offset where insertion is to occur</param>
		/// <param name="hvoObj">The object that owns the given tss</param>
		/// <param name="flid">The owning flid of the tss</param>
		/// <param name="ws">The writing system alternative (used only for multi's)</param>
		/// ------------------------------------------------------------------------------------
		public void InsertORCAt(ITsString tss, int ich, int hvoObj, int flid, int ws)
		{
			// REVIEW: Why do we have InsertORCAt when InsertOwningORCIntoPara probably does much
			// the same thing? InsertORCAt is used in production code. InsertOwningORCIntoPara is
			// used in some tests.
			System.Diagnostics.Debug.Assert(tss.Length >= ich);

			// Make a TsTextProps with the relevant object data and the same ws as its
			// context.
			byte[] objData = MiscUtils.GetObjData(m_cache.GetGuidFromId(Hvo),
				(byte)FwObjDataTypes.kodtGuidMoveableObjDisp);
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetStrPropValueRgch((int)FwTextPropType.ktptObjData,
				objData, objData.Length);
			int nvar;
			int wsRun = tss.get_PropertiesAt(ich).
				GetIntPropValues((int)FwTextPropType.ktptWs, out nvar);
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsRun);

			// Insert the orc with the resulting properties.
			ITsStrBldr tsStrBldr = tss.GetBldr();
			tsStrBldr.Replace(ich, ich, new string(StringUtils.kchObject, 1),
				propsBldr.GetTextProps());

			if (ws == 0)
				m_cache.SetTsStringProperty(hvoObj, flid, tsStrBldr.GetString());
			else
			{
				// This branch has probably not been tested, not currently used.
				m_cache.SetMultiStringAlt(hvoObj, flid, ws, tsStrBldr.GetString());
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:CmPicture.cs

示例3: SpellCheckProps

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Answer the spelling status of the indicated character in the string, unless it is an
		/// ORC, in which case, for each ORC we answer a different value (that is not any of the
		/// valid spelling statuses).
		/// Enhance JohnT: we don't want to consider embedded-picture ORCs to count as
		/// different; we may strip them out before we start checking the word.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		int SpellCheckProps(ITsString tss, int ich, IVwStylesheet styles)
		{
			// For our purposes here, ORC (0xfffc) is considered to have a different spelling status from everything else,
			// even from every other ORC in the string. This means we always offer to insert spaces adjacent to them.
			if (ich < tss.Length && tss.GetChars(ich, ich + 1)[0] == 0xfffc)
			{
				return -50 - ich;
			}
			ITsTextProps props = tss.get_PropertiesAt(ich);
			string style = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
			int var, val;
			if (styles != null && !string.IsNullOrEmpty(style))
			{
				ITsTextProps styleProps = styles.GetStyleRgch(style.Length, style);
				if (styleProps != null)
				{
					val = styleProps.GetIntPropValues((int)FwTextPropType.ktptSpellCheck, out var);
					if (var != -1)
						return val; // style overrides
				}
			}
			val = props.GetIntPropValues((int)FwTextPropType.ktptSpellCheck, out var);
			if (var == -1)
				return 0; // treat unspecified the same as default.
			else
				return val;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:36,代码来源:SpellCheckHelper.cs

示例4: GetIchLimRef_IfIchInRefAtParaStart

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if the paragraph starts with chapter/verse run and the ich is within one
		/// of these runs.
		/// </summary>
		/// <param name="tss">paragraph string</param>
		/// <param name="ich">character offset</param>
		/// <returns>ich after the reference or -1 if the paragraph does not begin with a
		/// chapter/verse run</returns>
		/// ------------------------------------------------------------------------------------
		private static int GetIchLimRef_IfIchInRefAtParaStart(ITsString tss, int ich)
		{
			int iRun = tss.get_RunAt(ich);
			ITsTextProps firstTtp = tss.get_Properties(0);
			ITsTextProps ttp = tss.get_PropertiesAt(ich);

			if ((StStyle.IsStyle(ttp, ScrStyleNames.VerseNumber) ||
				StStyle.IsStyle(ttp, ScrStyleNames.ChapterNumber)) && iRun == 0)
			{
				return GetLimOfReference(tss, iRun, ref ttp);
			}
			else if (StStyle.IsStyle(firstTtp, ScrStyleNames.ChapterNumber) &&
				StStyle.IsStyle(ttp, ScrStyleNames.VerseNumber) && iRun == 1)
			{
				// The first run is a chapter and the next is a verse number run.
				// Return the lim of the verse number (current) run.
				return tss.get_LimOfRun(iRun);
			}
			else if (iRun == 0 && IsBlank(tss, iRun))
			{
				// The first run contains only white space.
				// Ignore this run and check the following runs.
				if (tss.RunCount > 1)
				{
					ttp = tss.get_Properties(iRun + 1);
					if (StStyle.IsStyle(ttp, ScrStyleNames.VerseNumber) ||
						StStyle.IsStyle(ttp, ScrStyleNames.ChapterNumber))
					{
						return GetLimOfReference(tss, iRun + 1, ref ttp);
					}
				}
			}
			// Paragraph doesn't begin with a chapter/verse number run (or the ich
			// wasn't in it).
			return -1;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:46,代码来源:TeEditingHelper.cs

示例5: ReplaceRangeInBt

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert/replace the range in the given back translation with the given chapter and verse.
		/// </summary>
		/// <param name="hvoObj">The id of the translation being modified</param>
		/// <param name="propTag">The flid (i.e. Translation)</param>
		/// <param name="wsAlt">The writing system of the back translation multiString alt</param>
		/// <param name="ichMin">character offset Min at which we will replace in the tss
		///  </param>
		/// <param name="ichLim">end of the range at which we will replace in the tss </param>
		/// <param name="sChapterNumIns">The chapter number string to be inserted, if any</param>
		/// <param name="sVerseNumIns">The verse number string to be inserted, if any</param>
		/// <param name="tssBt">ref: The given structured string from the BT, in which we will
		/// replace</param>
		/// <param name="ichLimIns">output: gets set to the end of what we inserted</param>
		/// ------------------------------------------------------------------------------------
		private void ReplaceRangeInBt(int hvoObj, int propTag, int wsAlt, int ichMin, int ichLim,
			ref string sChapterNumIns, ref string sVerseNumIns, ref ITsString tssBt, out int ichLimIns)
		{
			ichLimIns = -1;

			// Insert the chapter number, if defined
			if (sChapterNumIns != null)
			{
				string oldText = tssBt.get_RunText(tssBt.get_RunAt(ichMin));
				ITsTextProps oldProps = tssBt.get_PropertiesAt(ichMin);

				if (oldText == sChapterNumIns && oldProps.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle) == ScrStyleNames.ChapterNumber)
				{
					ichMin += sChapterNumIns.Length;
					sChapterNumIns = null;
				}
				else
				{
					ITsTextProps ttpChap = StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, wsAlt);
					ReplaceInParaOrBt(hvoObj, propTag, wsAlt, sChapterNumIns, ttpChap, ichMin, ichLim,
						ref tssBt, out ichLimIns);
					// adjust range for verse insert
					ichMin += sChapterNumIns.Length;
					ichLim = ichMin;
				}
			}

			// Insert the verse number, if defined. If the text has not changed, then do not make
			// the change so an undo task will not be created.
			if (sVerseNumIns != null)
			{
				string oldText = tssBt.GetChars(ichMin, ichLim);
				ITsTextProps oldProps = tssBt.get_PropertiesAt(ichMin);

				if (oldText == sVerseNumIns && oldProps.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle) == ScrStyleNames.VerseNumber)
					sVerseNumIns = null;
				else
				{
					ITsTextProps ttpVerse = StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, wsAlt);
					ReplaceInParaOrBt(hvoObj, propTag, wsAlt, sVerseNumIns, ttpVerse,
						ichMin, ichLim, ref tssBt, out ichLimIns);
				}
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:60,代码来源:TeEditingHelper.cs

示例6: InsertSpaceIfNeeded

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts a space if the character before the ichIp is not white space and not in a
		/// chapter number run.
		/// This method is used when the insert is to be at the original IP, not when the ich
		/// was moved to a "word" boundary.
		/// </summary>
		/// <param name="hvoObj">The id of the paragraph or translation being modified</param>
		/// <param name="propTag">The flid (i.e. Contents or Translation)</param>
		/// <param name="ichIp">the ich into the tss at the IP</param>
		/// <param name="wsAlt">The writing system, if a back translation multiString alt</param>
		/// <param name="tss">ref: the tss that will have a space added, if needed</param>
		/// <param name="ichLimInserted">ref: the end of the inserted verse number run;
		/// not changed if nothing inserted</param>
		/// ------------------------------------------------------------------------------------
		private void InsertSpaceIfNeeded(int hvoObj, int propTag, int ichIp, int wsAlt,
			ref ITsString tss, ref int ichLimInserted)
		{
			int ichIns = ichIp;
			if (ichIns > 0)
			{
				//If previous character is neither white space nor a chapter number...
				ITsTextProps ttp = tss.get_PropertiesAt(ichIns - 1);
				if (!UnicodeCharProps.get_IsSeparator(tss.Text[ichIns - 1]) &&
					!StStyle.IsStyle(ttp, ScrStyleNames.ChapterNumber))
				{
					//add a space.
					ReplaceInParaOrBt(hvoObj, propTag, wsAlt, " ", tss.get_PropertiesAt(ichIns),
						ichIns, ichIns, ref tss, out ichLimInserted);
				}
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:32,代码来源:TeEditingHelper.cs

示例7: GetVernVerseNumberToInsert

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Given a position and selection in a vernacular paragraph string, use the current
		/// reference and context to build the appropriate verse number string to insert at the
		/// ich position. Ususally the current verse reference + 1.
		/// </summary>
		/// <param name="tss">The string</param>
		/// <param name="ich">The character position we would like to insert a verse number at.
		/// This is either on the current selection, or moved to a nearby "word" boundary.
		/// </param>
		/// <param name="selHelper">The selection helper on or near the ich</param>
		/// <param name="fInVerse">true if ich is at an existing verse number</param>
		/// <returns>The verse number string to insert, or null if the verse number would be
		/// out of range</returns>
		/// ------------------------------------------------------------------------------------
		private string GetVernVerseNumberToInsert(ITsString tss, int ich, SelectionHelper selHelper,
			bool fInVerse)
		{

			//Get the BCV end ref at the current selection
			ScrReference refToInsert = CurrentEndRef;

			// Note that our ich may be at a "word" boundary near the selection.
			// If the ich is on a verse number, update refToInsert.Verse to its end value.
			if (fInVerse)
			{
				string sVerseRun = tss.get_RunText(tss.get_RunAt(ich));
				refToInsert.Verse = ScrReference.VerseToIntEnd(sVerseRun);
			}

			//  If verse number is already at the end of this chapter (or beyond), quit now!
			if (refToInsert.Verse >= refToInsert.LastVerse)
				return null;

			// Calculate the default next verse number: current verse ref + 1
			string sVerseNum = m_scr.ConvertToString(refToInsert.Verse + 1);

			// If we are already in a verse, we are done; this is the usual case for a verse num update
			if (fInVerse)
				return sVerseNum;

			// we are inserting in text at ich...

			// If we are at the beginning of the first scripture section, we insert verse 1.
			if (selHelper.LevelInfo[0].ihvo == 0 && ich == 0 &&
				IsFirstScriptureSection())
			{
				sVerseNum = m_scr.ConvertToString(1);
			}

			// If we directly follow a chapter number, we insert verse 1!
			if (ich > 0)
			{
				ITsTextProps ttpPrev = tss.get_PropertiesAt(ich - 1);
				if (ttpPrev.GetStrPropValue(
					(int)FwTextPropType.ktptNamedStyle)	==
					ScrStyleNames.ChapterNumber)
				{
					sVerseNum = m_scr.ConvertToString(1);
				}
			}
			return sVerseNum;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:63,代码来源:TeEditingHelper.cs

示例8: InitializeConcordanceSearch

		private bool InitializeConcordanceSearch(ICmObject cmo, ITsString tssObj)
		{
			string sType = cmo.GetType().Name;
			string sTag = m_mediator.StringTbl.GetString(sType, "ClassNames");
			SetDefaultVisibilityOfItems(false, sTag);
			m_fObjectConcorded = true;
			m_hvoMatch = cmo.Hvo;
			m_backupHvo = cmo.Owner == null ? 0 : cmo.Owner.Hvo;
			ITsTextProps ttpObj = tssObj.get_PropertiesAt(0);
			int nVar;
			int ws = ttpObj.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
			m_fwtbItem.WritingSystemCode = (ws > 0) ? ws : m_cache.DefaultVernWs;
			int dyHeight = m_fwtbItem.PreferredHeight;
			m_fwtbItem.Height = dyHeight;
			m_fwtbItem.Tss = tssObj;
			int dxWidth = m_fwtbItem.PreferredWidth;
			m_fwtbItem.Width = dxWidth;
			LoadMatches(true);
			return true;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:20,代码来源:ConcordanceControl.cs

示例9: GetWsFromTsString

		private int GetWsFromTsString(ITsString tss)
		{
			ITsTextProps ttp = tss.get_PropertiesAt(0);
			int var;
			return ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:6,代码来源:DiscourseExporter.cs

示例10: FindLastFootnoteInString

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Searches TsString backwards for last footnote reference.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="tss"></param>
		/// <param name="ich">Character index to start search, or -1 to start at the end of
		/// the string.</param>
		/// <param name="fSkipCurrentPosition">If <c>true</c> we search backwards starting with the
		/// run before ich, otherwise we start with the run ich is in.</param>
		/// <returns>Last footnote in string, or <c>null</c> if footnote can't be found.</returns>
		/// ------------------------------------------------------------------------------------
		public static ScrFootnote FindLastFootnoteInString(FdoCache cache, ITsString tss,
			ref int ich, bool fSkipCurrentPosition)
		{
			if (ich == -1)
			{
				fSkipCurrentPosition = false;
				ich = tss.Length;
			}
			ITsTextProps tprops = (fSkipCurrentPosition ? null : tss.get_PropertiesAt(ich));
			int footnoteHvo = (fSkipCurrentPosition ? 0 : GetFootnoteFromProps(cache, tprops));
			//TODO: TE-4199 if ich beyond the text, we must fix this so we do not skip the last run
			int irun = tss.get_RunAt(ich);
			while (footnoteHvo <= 0 && irun > 0)
			{
				irun--;
				tprops = tss.get_Properties(irun);
				footnoteHvo = GetFootnoteFromProps(cache, tprops);
			}
			ich = tss.get_MinOfRun(irun);
			return footnoteHvo <= 0 ? null : new ScrFootnote(cache, footnoteHvo);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:33,代码来源:ScrFootnote.cs

示例11: FindIntPropInTss

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines if the specified integer property is used in the specified ITsString.
		/// </summary>
		/// <param name="tss">The ITsString.</param>
		/// <param name="intProp"></param>
		/// <returns><c>true</c> if any run in the tss uses the specified property; <c>false</c>
		/// otherwise</returns>
		/// ------------------------------------------------------------------------------------
		private bool FindIntPropInTss(ITsString tss, int intProp)
		{
			for (var iRun = 0; iRun < tss.RunCount; iRun++)
			{
				// Check the integer properties of each run.
				var tpp = tss.get_PropertiesAt(iRun);

				for (var iProp = 0; iProp < tpp.IntPropCount; iProp++)
				{
					int var;
					int propType;
					tpp.GetIntProp(iProp, out propType, out var);
					if (propType == intProp)
						return true;
				}
			}
			return false;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:27,代码来源:TsStringUtilsTests.cs

示例12: GetWsAtOffset

		/// <summary>
		/// Get the ws at the given (ich) char offset in the tss.
		/// </summary>
		/// <param name="tss"></param>
		/// <param name="ich">char offset</param>
		/// <returns></returns>
		public static int GetWsAtOffset(ITsString tss, int ich)
		{
			if (tss == null)
				return 0;
			int ws, nVar;
			ws = tss.get_PropertiesAt(ich).GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
			return ws;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:14,代码来源:StringUtils.cs


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