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


C# ITsString.get_WritingSystem方法代码示例

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


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

示例1: GetCleanSingleRunTsString

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a TsString made from the ashes of the input parameter which has:
		/// 1) only one run
		/// 2) uses the ws of the 1st run of the input TsString.
		/// </summary>
		/// <param name="tss">structured text string</param>
		/// ------------------------------------------------------------------------------------
		public static ITsString GetCleanSingleRunTsString(ITsString tss)
		{
			return MakeTss(tss.Text, tss.get_WritingSystem(0));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:12,代码来源:TsStringUtils.cs

示例2: GetWsOfRun

		/// <summary>
		/// Get the writing system of the specified run of a TsString.
		/// </summary>
		public static int GetWsOfRun(ITsString tss, int irun)
		{
			return tss.get_WritingSystem(irun);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:7,代码来源:TsStringUtils.cs

示例3: GetFirstVernacularWs

		/// <summary>
		/// Gets the first vernacular ws.
		/// </summary>
		/// <param name="vernWsVecImage">The vern ws vec image, like "seh pt mar-fonipa".</param>
		/// <param name="wsf">The Writing System Factory.</param>
		/// <param name="text">The text.</param>
		/// <returns>
		/// The first vernacular ws used in the text or -1 if none
		/// </returns>
		public static int GetFirstVernacularWs(string vernWsVecImage, ILgWritingSystemFactory wsf, ITsString text)
		{
			int wid = -1; // writing system id
			for (int runSeq = 0; runSeq < text.RunCount; runSeq++)
			{
				wid = text.get_WritingSystem(runSeq);
				var ws = wsf.get_EngineOrNull(wid);
				if (ws != null)
				{   // ws.Id is short like "en"
					if (vernWsVecImage.IndexOf(ws.Id) >= 0)
						break; // wid > -1
				}
				wid = -1;
			}
			return wid;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:25,代码来源:TsStringUtils.cs

示例4: TextFromTsString

        public static string TextFromTsString(ITsString tss, ILgWritingSystemFactory wsf)
        {
            // This will replace SafeTsStringText, and will actually deal with <span> elements

            // Spec: the TsString properties ktptWs (an int property) and ktptNamedStyle (a string property)
            // will be replaced with lang="(wsStr)" and class="styleName_PropValue". Other properties, that
            // LF doesn't process, will be preserved in the class attribute as well, as follows:
            //
            // 1) Determine whether the property is an int property or a string property.
            // 2) Call either IntPropertyName() or StringPropertyName() to get its name.
            // 3) Create a class string in format "propC_N_NAME_VALUE" where:
            //      - C is "i" for int props or "s" for string props
            //      - N is the property number
            //      - NAME is, of course, the property name
            //      - VALUE is the property's value, with two special cases:
            //          * in string properties, spaces are first replaced by "_SPACE_"
            //          * in int properties, there's a value and a "variation", and VALUE is both of them separated by _
            //
            // Result: class="propi_1_ktptWs_1_0 props_1_ktptFontFamily_Times_SPACE_New_SPACE_Roman"

            if (tss == null)
                return null;
            int[] intPropsToSkip = new int[] { (int)FwTextPropType.ktptWs };
            int[] strPropsToSkip = new int[] { (int)FwTextPropType.ktptNamedStyle };
            int mainWs = tss.get_WritingSystem(0);
            var resultBuilder = new StringBuilder();
            foreach (TsRunPart run in tss.Runs())
            {
                string runText = run.Text;
                ITsTextProps props = run.Props;
                int ws = props.GetWs();
                string namedStyle = props.Style();
                List<string> classes = ClassesFromTsTextProps(props, intPropsToSkip, strPropsToSkip);

                bool needSpan = false;
                string langAttr = null;
                string classAttr = null;
                if (ws != mainWs)
                {
                    needSpan = true;
                    langAttr = String.Format(" lang=\"{0}\"", wsf.GetStrFromWs(ws));
                }
                if (namedStyle != null)
                {
                    needSpan = true;
                    classes.Insert(0, String.Format("styleName_{0}", namedStyle.Replace(" ", "_SPACE_")));
                }
                if (classes.Count > 0)
                {
                    needSpan = true;
                    classAttr = String.Format(" class=\"{0}\"", String.Join(" ", classes));
                }

                if (needSpan)
                {
                    var spanBuilder = new StringBuilder();
                    spanBuilder.Append("<span");
                    if (langAttr != null)
                        spanBuilder.Append(langAttr);
                    if (classAttr != null)
                        spanBuilder.Append(classAttr);
                    spanBuilder.Append(">");
                    spanBuilder.Append(runText);
                    spanBuilder.Append("</span>");
                    resultBuilder.Append(spanBuilder.ToString());
                }
                else
                    resultBuilder.Append(runText);
            }
            return resultBuilder.ToString();
        }
开发者ID:ermshiperete,项目名称:LfMerge,代码行数:71,代码来源:ConvertFdoToMongoTsStrings.cs

示例5: HasWs

		/// <summary>
		/// Return true if the specified string has a run in the specified WS
		/// </summary>
		public static bool HasWs(ITsString tss, int ws)
		{
			var crun = tss.RunCount;
			for (int i = 0; i < crun; i++)
			{
				if (tss.get_WritingSystem(i) == ws)
					return true;
			}
			return false;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:13,代码来源:StringServices.cs

示例6: GetWsFromString

		private static int GetWsFromString(ITsString tss, int ichMin, int ichLim)
		{
			if (tss == null || tss.Length == 0 || ichMin >= ichLim)
				return 0;
			int runMin = tss.get_RunAt(ichMin);
			int runMax = tss.get_RunAt(ichLim - 1);
			int ws = tss.get_WritingSystem(runMin);
			if (runMin == runMax)
				return ws;
			for (int i = runMin + 1; i <= runMax; ++i)
			{
				int wsT = tss.get_WritingSystem(i);
				if (wsT != ws)
					return 0;
			}
			return ws;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:StTextSlice.cs


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