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


C# ITsString.GetBldr方法代码示例

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


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

示例1: SetString

		public override void SetString(int hvo, int tag, ITsString tss)
		{
			if (!ShowSpaces || tag != StTxtParaTags.kflidContents || tss.Text == null)
			{
				base.SetString(hvo, tag, tss);
				return;
			}
			var text = tss.Text;
			var bldr = tss.GetBldr();
			int index = text.IndexOf(' ');
			while (index >= 0)
			{
				int nVar;
				if (bldr.get_PropertiesAt(index).GetIntPropValues((int) FwTextPropType.ktptBackColor, out nVar) == KzwsBackColor)
					bldr.Replace(index, index + 1, AnalysisOccurrence.KstrZws, null);
				index = text.IndexOf(' ', index + 1);
			}
			for (int irun = bldr.RunCount - 1; irun >= 0;  irun--)
			{
				int nVar;
				if (bldr.get_Properties(irun).GetIntPropValues((int) FwTextPropType.ktptBackColor, out nVar) == KzwsBackColor)
				{
					int ichMin, ichLim;
					bldr.GetBoundsOfRun(irun, out ichMin, out ichLim);
					bldr.SetIntPropValues(ichMin, ichLim, (int)FwTextPropType.ktptBackColor, -1, -1);
				}
			}

			base.SetString(hvo, tag, bldr.GetString());
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:30,代码来源:ShowSpaceDecorator.cs

示例2: GetAdjustedTsString

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Make sure that all runs of the given ts string will fit within the given height.
		/// </summary>
		/// <param name="tss">(Potentially) unadjusted TsString -- may have some pre-existing
		/// adjustments, but if it does, we (probably) ignore those and recheck every run</param>
		/// <param name="dympMaxHeight">The maximum height (in millipoints) of the Ts String.</param>
		/// <param name="styleSheet"></param>
		/// <param name="writingSystemFactory"></param>
		/// -------------------------------------------------------------------------------------
		public static ITsString GetAdjustedTsString(ITsString tss, int dympMaxHeight,
			IVwStylesheet styleSheet, ILgWritingSystemFactory writingSystemFactory)
		{
			if (dympMaxHeight == 0)
				return tss;

			ITsStrBldr bldr = null;

			int runCount = tss.RunCount;
			for (int irun = 0; irun < runCount; irun++)
			{
				ITsTextProps props = tss.get_Properties(irun);
				int var;
				int wsTmp = props.GetIntPropValues((int)FwTextPropType.ktptWs,
					out var);
				string styleName =
					props.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle);

				int height;
				string name;
				float sizeInPoints;
				using (Font f = GetFontForStyle(styleName, styleSheet, wsTmp, writingSystemFactory))
				{
					height = GetFontHeight(f);
					name = f.Name;
					sizeInPoints = f.SizeInPoints;
				}
				int curHeight = height;
				// incrementally reduce the size of the font until the text can fit
				while (curHeight > dympMaxHeight)
				{
					using (var f = new Font(name, sizeInPoints - 0.25f))
					{
						curHeight = GetFontHeight(f);
						name = f.Name;
						sizeInPoints = f.SizeInPoints;
					}
				}

				if (curHeight != height)
				{
					// apply formatting to the problem run
					if (bldr == null)
						bldr = tss.GetBldr();

					int iStart = tss.get_MinOfRun(irun);
					int iEnd = tss.get_LimOfRun(irun);
					bldr.SetIntPropValues(iStart, iEnd,
						(int)FwTextPropType.ktptFontSize,
						(int)FwTextPropVar.ktpvMilliPoint, (int)(sizeInPoints * 1000.0f));
				}
			}

			if (bldr != null)
				return bldr.GetString();
			else
				return tss;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:68,代码来源:FontHeightAdjuster.cs

示例3: GetSubString

		ITsString GetSubString(ITsString tss, int ichMin, int ichLim)
		{
			ITsStrBldr tsb = tss.GetBldr();
			int len = tss.get_Length();
			if (ichLim < len)
				tsb.Replace(ichLim, tss.get_Length(), null, null);
			if (ichMin > 0)
				tsb.Replace(0, ichMin, null, null);
			return tsb.GetString();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:10,代码来源:ConcForm.cs

示例4: RemoveIntProp

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified integer property from a Structured text string.
		/// </summary>
		/// <param name="tss">The structured text string.</param>
		/// <param name="intProp">integer property to remove from the tss.</param>
		/// <returns>tss without ORCs.</returns>
		/// ------------------------------------------------------------------------------------
		public static ITsString RemoveIntProp(ITsString tss, int intProp)
		{
			if (tss == null)
				return tss;

			ITsStrBldr tssBldr = tss.GetBldr();
			// Note that the RunCount of the builder may CHANGE during this loop; don't cache the run count.
			for (int iRun = 0; iRun < tssBldr.RunCount; iRun++)
			{
				// Check the integer properties of each run.
				ITsTextProps tpp = tssBldr.get_PropertiesAt(iRun);

				for (int iProp = 0; iProp < tpp.IntPropCount; iProp++)
				{
					int var;
					int propType;
					int propValue = tpp.GetIntProp(iProp, out propType, out var);
					if (propType == intProp)
					{
						ITsPropsBldr ttpBldr = tpp.GetBldr();
						// Remove integer property
						ttpBldr.SetIntPropValues(intProp, -1, -1);

						// Update the run using new properties.
						int ichMin, ichLim;
						tssBldr.GetBoundsOfRun(iRun, out ichMin, out ichLim);
						tssBldr.Replace(ichMin, ichLim, tssBldr.get_RunText(iRun), ttpBldr.GetTextProps());
					}
				}

			}
			return tssBldr.GetString();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:41,代码来源:TsStringUtils.cs

示例5: MakeWssSuggestions

		private ICollection<SpellCorrectMenuItem> MakeWssSuggestions(ITsString tssWord,
			List<int> wss, IVwRootBox rootb, int hvoObj, int tag, int wsAlt,
			int ichMin, int ichLim)
		{
			List<SpellCorrectMenuItem> result = new List<SpellCorrectMenuItem>(wss.Count + 1);

			// Make an item with inserted spaces.
			ITsStrBldr bldr = tssWord.GetBldr();
			int wsFirst = TsStringUtils.GetWsOfRun(tssWord, 0);
			int offset = 0;
			for (int irun = 1; irun < tssWord.RunCount; irun++)
			{
				int wsNew = TsStringUtils.GetWsOfRun(tssWord, irun);
				if (wsNew != wsFirst)
				{
					int ichInsert = tssWord.get_MinOfRun(irun) + offset;
					bldr.Replace(ichInsert, ichInsert, " ", null);
					wsFirst = wsNew;
					offset++;
				}
			}
			ITsString suggest = bldr.GetString();
			string menuItemText = suggest.Text;
			result.Add(new SpellCorrectMenuItem(rootb, hvoObj, tag, wsAlt, ichMin, ichLim, menuItemText, suggest));

			// And items for each writing system.
			foreach (int ws in wss)
			{
				bldr = tssWord.GetBldr();
				bldr.SetIntPropValues(0, bldr.Length, (int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, ws);
				suggest = bldr.GetString();
				ILgWritingSystemFactory wsf = rootb.DataAccess.WritingSystemFactory;
				ILgWritingSystem engine = wsf.get_EngineOrNull(ws);
				string wsName = engine.LanguageName;
				string itemText = string.Format(RootSiteStrings.ksMlStringIsMono, tssWord.Text, wsName);
				result.Add(new SpellCorrectMenuItem(rootb, hvoObj, tag, wsAlt, ichMin, ichLim, itemText, suggest));
			}

			return result;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:40,代码来源:SpellCheckHelper.cs

示例6: ConvertCVNumbersInStringForBT

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Return a TsString in which any CV numbers have been replaced by their BT equivalents
		/// (in the specified writing system). Other properties, including style, are copied
		/// from the input numbers.
		/// </summary>
		/// <param name="input">The input.</param>
		/// <param name="wsTrans">The ws trans.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public ITsString ConvertCVNumbersInStringForBT(ITsString input, int wsTrans)
		{
			ITsStrBldr bldr = null;
			// reverse order so we don't mess up offsets if new numbers differ in length.
			for (int iRun = input.RunCount - 1; iRun >= 0; iRun--)
			{
				string styleName = input.get_Properties(iRun).GetStrPropValue(
					(int)FwTextPropType.ktptNamedStyle);

				if (styleName == ScrStyleNames.ChapterNumber ||
					styleName == ScrStyleNames.VerseNumber)
				{
					string number = ConvertVerseChapterNumForBT(input.get_RunText(iRun));
					if (number == null)
						continue; // pathologically an empty string has verse number style??
					if (bldr == null)
						bldr = input.GetBldr(); // we have an actual change.
					int ichMin, ichLim;
					input.GetBoundsOfRun(iRun, out ichMin, out ichLim);
					bldr.SetIntPropValues(ichMin, ichLim, (int)FwTextPropType.ktptWs,
						(int)FwTextPropVar.ktpvDefault, wsTrans);
					bldr.Replace(ichMin, ichLim, number, null);
				}
			}
			if (bldr != null)
				return bldr.GetString();
			return input;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:38,代码来源:FdoScripture.cs

示例7: MultiLineInsertData

		public MultiLineInsertData(Selection whereToInsert, List<ITsString> stringToInsert, List<IStyle> styles)
		{
			if (stringToInsert == null || stringToInsert.Count <= 0)
				return;
			ParaStyles = styles;
			Selection = whereToInsert;
			if(stringToInsert.Count == 1)
			{
				ITsString tsString = stringToInsert[0];
				int charIndexOfNextRun;
				int startOfUnprocessedLines = tsString.Text.IndexOfAny(new[] { '\r', '\n' });
				int limOfUnprocessedLines = tsString.Text.LastIndexOfAny(new[] { '\r', '\n' }) + 1;
				int otherStartOfUnprocessedLines = tsString.Text.IndexOf(@"\par");
				int otherLimOfUnprocessedLines = tsString.Text.LastIndexOf(@"\par")+1;
				startOfUnprocessedLines =
					Math.Min(startOfUnprocessedLines != -1 ? startOfUnprocessedLines : otherStartOfUnprocessedLines,
							 otherStartOfUnprocessedLines != -1 ? otherStartOfUnprocessedLines : startOfUnprocessedLines);
				limOfUnprocessedLines = Math.Max(limOfUnprocessedLines, otherLimOfUnprocessedLines);
				TsStrAppendToFirstPara = tsString.Substring(0, startOfUnprocessedLines);
				if (limOfUnprocessedLines == tsString.Length)
					TsStrPrependToLastPara =
						TsStrFactoryClass.Create().EmptyString(
							tsString.Runs().Reverse().Where(run => run.Props.GetWs() > 0).First().Props.GetWs());
				else
				{
					TsStrPrependToLastPara = tsString.Substring(limOfUnprocessedLines);
					if (TsStrPrependToLastPara.Text == "\r" || TsStrPrependToLastPara.Text == "\n" ||
						TsStrPrependToLastPara.Text == @"\par")
					{
						var bldr = TsStrPrependToLastPara.GetBldr();
						bldr.Replace(0, TsStrPrependToLastPara.Text.Length, "", null);
						TsStrPrependToLastPara = bldr.GetString();
					}
				}
				if (TsStrAppendToFirstPara.Text == "\r" || TsStrAppendToFirstPara.Text == "\n" || TsStrAppendToFirstPara.Text == @"\par")
				{
					var bldr = TsStrAppendToFirstPara.GetBldr();
					bldr.Replace(0, TsStrAppendToFirstPara.Text.Length, "", null);
					TsStrAppendToFirstPara = bldr.GetString();
				}
				InsertedTsStrLines = new List<ITsString>();
				while (true)
				{
					startOfUnprocessedLines = AdvancePastLineBreak(startOfUnprocessedLines, tsString.Text);
					if (startOfUnprocessedLines >= limOfUnprocessedLines)
						break;
					int limIndex = tsString.Text.IndexOfAny(new[] { '\r', '\n' }, startOfUnprocessedLines);
					int	otherIndex = tsString.Text.IndexOf(@"\par", startOfUnprocessedLines);
					limIndex = Math.Min(limIndex != -1 ? limIndex : otherIndex, otherIndex != -1 ? otherIndex : limIndex);
					string nextString = tsString.Text.Substring(startOfUnprocessedLines, limIndex - startOfUnprocessedLines);
					nextString = nextString.Trim(new[] { '\r', '\n' });
					nextString = nextString.Replace(@"\par", "");
					var bldr =
						TsStrFactoryClass.Create().MakeString(nextString, tsString.get_WritingSystemAt(startOfUnprocessedLines)).GetBldr();
					for (int runIndex = tsString.get_RunAt(startOfUnprocessedLines); runIndex < tsString.get_RunAt(limIndex); runIndex++)
					{
						int start = tsString.get_MinOfRun(runIndex) - startOfUnprocessedLines;
						int end = tsString.get_LimOfRun(runIndex) - startOfUnprocessedLines;
						bldr.Replace(start, end, bldr.Text.Substring(start, end - start), tsString.get_Properties(runIndex));
					}
					InsertedTsStrLines.Add(bldr.GetString());
					startOfUnprocessedLines = limIndex;
				}
			}
			else
			{
				TsStrAppendToFirstPara = stringToInsert.First();
				TsStrPrependToLastPara = stringToInsert.Last();
				stringToInsert.Remove(stringToInsert.First());
				stringToInsert.Remove(stringToInsert.Last());
				InsertedTsStrLines = stringToInsert;
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:73,代码来源:MultiLineInsertData.cs

示例8: SetStringValue

		// In this subclass we're setting a multistring.
		protected override void SetStringValue(int hvoStringOwner, ITsString tss)
		{
			if (!m_fFieldAllowsMultipleRuns && tss.RunCount > 1)
			{
				// Illegally trying to store a multi-run TSS in a single-run field. This will fail.
				// Typically it's just that we tried to insert an English comma or similar.
				// Patch it up by making the whole string take on the properties of the first run.
				var bldr = tss.GetBldr();
				bldr.SetProperties(0, bldr.Length, tss.get_Properties(0));
				tss = bldr.GetString();
			}
			m_sda.SetMultiStringAlt(hvoStringOwner, m_flid, m_ws, tss);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:14,代码来源:BulkEditBar.cs

示例9: Lookup

		/// <summary>
		/// Given the string the user typed, generate the best available guess as to which of the options
		/// he intended. Set hvoNew to 0 (and return tssTyped) if it doesn't match any option.
		/// It is assumed that he is setting an object in property m_tag of object m_hvoParent.
		/// </summary>
		/// <param name="tssTyped"></param>
		/// <returns></returns>
		protected virtual ITsString Lookup(ITsString tssTyped, out ICmObject objNew)
		{
			var parent = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(m_hvoParent);
			string sTyped = tssTyped == null ? "" : tssTyped.Text;
			if (sTyped == null)
				sTyped = "";
			int cchTyped = sTyped.Length;
			if (cchTyped == 0)
			{
				// Otherwise we'd match the first item and arbitrarily insert it when the user backspaces to
				// nothing. Seems better to wait till at least one letter is typed to try to match.
				objNew = null;
				return tssTyped;
			}

			int ipossibility = -1;
			foreach(ICmObject obj in parent.ReferenceTargetCandidates(m_tag))
			{
				ipossibility ++;
				string key = null;
				if (ipossibility < m_shortnames.Count)
					key = m_shortnames[ipossibility]; // Use the cache as far as it goes
				else
				{
					key = obj.ShortName;
					m_shortnames.Add(key); // extend the cache for next time.
				}
				if (sTyped.Length < key.Length && key.Substring(0, cchTyped) == sTyped)
				{
					objNew = obj;
					ITsStrBldr bldr = tssTyped.GetBldr();
					bldr.Replace(0, bldr.Length, key, null);
					// Clear any underlining left over from previous bad value.
					bldr.SetIntPropValues(0, bldr.Length, (int) FwTextPropType.ktptUnderline,
						-1, -1);
					bldr.SetIntPropValues(0, bldr.Length, (int) FwTextPropType.ktptUnderColor,
						-1, -1);
					return bldr.GetString(); // Same ws as input, contents replaced.
				}
			}
			objNew = null;

			return tssTyped;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:51,代码来源:TypeAheadSupportVc.cs

示例10: EnsureValidWs

		/// <summary>
		/// Check that the ws in the ITsString is still valid.  If it isn't, set it to the given
		/// default value.
		/// </summary>
		/// <param name="wsEdit"></param>
		/// <param name="tss"></param>
		/// <returns></returns>
		private ITsString EnsureValidWs(int wsEdit, ITsString tss)
		{
			if (tss != null)
			{
				ITsStrBldr tsb = tss.GetBldr();
				ITsTextProps ttp = tsb.get_Properties(0);
				int nVar;
				int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
				string sWs = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(ws);
				if (sWs == null)
				{
					tsb.SetIntPropValues(0, tsb.Length, (int)FwTextPropType.ktptWs, nVar, wsEdit);
					return tsb.GetString();
				}
			}
			return tss;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:24,代码来源:FwFindReplaceDlg.cs

示例11: StoreFreeAnnotationForClipboard

			/// <summary>
			/// Store a free-form annotation piece in the given builder, first stripping out
			/// the label and direction markers if possible.
			/// </summary>
			private void StoreFreeAnnotationForClipboard(ITsStrBldr tsbLine, ITsString tssPiece)
			{
				ITsStrBldr tsb = tssPiece.GetBldr();
				int ich;
				if (tsb.Text != null)
				{
					ich = tsb.Text.IndexOfAny(m_rgchDirMkrs);
					while (ich >= 0)
					{
						tsb.Replace(ich, ich + 1, null, null);
						if (tsb.Text == null)
							break;
						ich = tsb.Text.IndexOfAny(m_rgchDirMkrs);
					}
				}
				string sPiece = tsb.Text;
				if (sPiece != null)
				{
					string sLabel = ITextStrings.ksFree_.Trim();
					ich = sPiece.IndexOf(sLabel);
					if (ich < 0)
					{
						sLabel = ITextStrings.ksNote_.Trim();
						ich = sPiece.IndexOf(sLabel);
					}
					if (ich < 0)
					{
						sLabel = ITextStrings.ksLit_.Trim();
						ich = sPiece.IndexOf(sLabel);
					}
					if (ich >= 0)
					{
						int cch = sLabel.Length;
						if (ich == 0 || ich + cch == sPiece.Length)
							tsb.Replace(ich, ich + cch, null, null);
					}
				}
				if (tsb.Text != null && tsb.Text.IndexOf(' ') == 0)
					tsb.Replace(0, 1, null, null);
				if (tsb.Text != null && tsb.Text.LastIndexOf(' ') == tsb.Length - 1)
					tsb.Replace(tsb.Length - 1, tsb.Length, null, null);

				tsbLine.ReplaceTsString(tsbLine.Length, tsbLine.Length, tsb.GetString());
				tsbLine.Replace(tsbLine.Length, tsbLine.Length, m_bldrLineTabs.ToString(), null);
			}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:49,代码来源:InterlinDocView.cs

示例12: SubString

		// Get a substring of a tsString.
		ITsString SubString(ITsString tss, int ichMin, int ichLim)
		{
			ITsStrBldr bldr = tss.GetBldr();
			int cch = tss.Length;
			if (ichLim < cch)
				bldr.ReplaceTsString(ichLim, cch, null);
			if (ichMin > 0)
				bldr.ReplaceTsString(0, ichMin, null);
			return bldr.GetString();
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:11,代码来源:InterlinDocView.cs

示例13: OutputItemNumber

		/// <summary>
		/// The view wants to output the given tss, which is the generated number of an item in a sequence.
		/// We are passed both the composite string that a real view would display, and the XML node from
		/// which we got the spec that indicated we should number this sequence.
		/// </summary>
		internal void OutputItemNumber(ITsString tss, XmlNode delimitNode)
		{
			if (m_sFormat != "xhtml")
			{
				AddString(tss);
				return;
			}
			string cssClass = XmlUtils.GetOptionalAttributeValue(delimitNode, "cssNumber");
			if (cssClass == null)
			{
				AddString(tss);
				return;
			}
			var tag = XmlUtils.GetAttributeValue(delimitNode, "number"); // optional normally, but then this is not called
			int ich;
			for (ich = 0; ich < tag.Length; ich++)
			{
				if (tag[ich] == '%')
				{
					if (ich == tag.Length - 1 || tag[ich + 1] != '%')
						break;
				}
			}
			string before = tag.Substring(0, ich); // arbitratily it is all 'before' if no %.
			string after = ich < tag.Length - 1 ? tag.Substring(ich + 2) : "";
			if (!m_xhtml.NumberStyles.ContainsKey(cssClass))
			{
				m_xhtml.NumberStyles[cssClass] = new Tuple<string, string>(before, after);
			}
			// Strip of the literal text from the string and make a special element out of it.
			var bldr = tss.GetBldr();
			if (before.Length > 0)
				bldr.Replace(0, before.Length, "", null);
			if (after.Length > 0)
				bldr.Replace(bldr.Length - after.Length, bldr.Length, "", null);
			// We want the number to be part of the item. However, the VC outputs it just before the item.
			// So we postpone outputting the number until the AddObj call. Yuck.
			m_delayedItemNumberClass = cssClass;
			m_delayedItemNumberValue = bldr.GetString();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:45,代码来源:ConfiguredExport.cs

示例14: AppendLeftoverBtToLastSeg

		/// <summary>
		/// If this paragraph segment is the last one for its group, but there are left-over BT segments,
		/// append them to this.
		/// </summary>
		/// <param name="group"></param>
		/// <param name="iParaSeg"></param>
		/// <param name="tssFt"></param>
		/// <returns></returns>
		private ITsString AppendLeftoverBtToLastSeg(SegGroup group, int iParaSeg, ITsString tssFt)
		{
			if (iParaSeg == group.ParaSegs.Count - 1 && iParaSeg < group.BtSegs.Count - 1)
			{
				// We have left over translations. Append them.
				ITsStrBldr bldr = tssFt.GetBldr();
				for (int j = iParaSeg + 1; j < group.BtSegs.Count; j++)
					AppendWithOptionalSpace(bldr, group.BtSegs[j].String);
				tssFt = bldr.GetString();
			}
			return tssFt;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:20,代码来源:BtConverter.cs

示例15: UpdatePhraseTextForWordItems

		/// <summary>
		/// This method will update the phraseText ref item with the contents of the item entries under the word
		/// </summary>
		/// <param name="wsFactory"></param>
		/// <param name="tsStrFactory"></param>
		/// <param name="phraseText"></param>
		/// <param name="word"></param>
		/// <param name="lastWasWord"></param>
		/// <param name="space"></param>
		private static void UpdatePhraseTextForWordItems(ILgWritingSystemFactory wsFactory, ITsStrFactory tsStrFactory, ref ITsString phraseText, Word word, ref bool lastWasWord, char space)
		{
			bool isWord = false;
			foreach (var item in word.Items)
			{
				switch (item.type)
				{
					case "txt": //intentional fallthrough
						isWord = true;
						goto case "punct";
					case "punct":
						ITsString wordString = tsStrFactory.MakeString(item.Value,
							GetWsEngine(wsFactory, item.lang).Handle);
						if (phraseText == null)
						{
							phraseText = wordString;
						}
						else
						{
							var phraseBldr = phraseText.GetBldr();
							if (lastWasWord && isWord) //two words next to each other deserve a space between
							{
								phraseBldr.ReplaceTsString(phraseText.Length, phraseText.Length,
								   tsStrFactory.MakeString("" + space, GetWsEngine(wsFactory, item.lang).Handle));
							}
							else if (!isWord) //handle punctuation
							{
								wordString = GetSpaceAdjustedPunctString(wsFactory, tsStrFactory,
									item, wordString, space, lastWasWord);
							}
							phraseBldr.ReplaceTsString(phraseBldr.Length, phraseBldr.Length, wordString);
							phraseText = phraseBldr.GetString();
						}
						lastWasWord = isWord;
						return; // only handle the baseline "txt" or "punct" once per "word" bundle, especially don't want extra writing system content in the baseline.
				}
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:47,代码来源:BIRDInterlinearImporter.cs


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