本文整理汇总了C#中ITsString类的典型用法代码示例。如果您正苦于以下问题:C# ITsString类的具体用法?C# ITsString怎么用?C# ITsString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITsString类属于命名空间,在下文中一共展示了ITsString类的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());
}
示例2: InterlinearExporter
protected InterlinearExporter(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
: base(null, cache.MainCacheAccessor, hvoRoot)
{
m_cache = cache;
m_writer = writer;
ktagParaSegments = InterlinVc.ParaSegmentTag(cache);
ktagSegmentForms = InterlinVc.SegmentFormsTag(cache);
m_flidStringValue = CmBaseAnnotation.StringValuePropId(cache);
m_lineChoices = lineChoices;
m_defaultGlossVirtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
m_vc = vc;
m_tssPendingTitle = tssTextName;
m_tssTitleAbbreviation = tssTextAbbreviation;
// Get morphtype information that we need later. (plus stuff we don't...) See LT-8288.
IMoMorphType mmtStem;
IMoMorphType mmtPrefix;
IMoMorphType mmtSuffix;
IMoMorphType mmtInfix;
IMoMorphType mmtBoundStem;
IMoMorphType mmtSimulfix;
IMoMorphType mmtSuprafix;
MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
}
示例3: FindOrCreateWordform
/// <summary>
/// Find (create, if needed) a wordform for the given ITsString.
/// </summary>
/// <param name="cache"></param>
/// <param name="tssContents">The form to find.</param>
/// <returns>A wordform with the given form.</returns>
public static IWfiWordform FindOrCreateWordform(FdoCache cache, ITsString tssContents)
{
IWfiWordform wf;
if (!cache.ServiceLocator.GetInstance<IWfiWordformRepository>().TryGetObject(tssContents, out wf))
wf = cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create(tssContents);
return wf;
}
示例4: UpdatePicture
///// ------------------------------------------------------------------------------------
///// <summary>
///// Append a picture to the end of the paragraph using the given writing system.
///// </summary>
///// <param name="ws">given writing system</param>
///// <param name="strBldr">The string builder for the paragraph being composed</param>
///// ------------------------------------------------------------------------------------
//public void AppendPicture(int ws, ITsStrBldr strBldr)
//{
// // Make a TsTextProps with the relevant object data and the same ws as its
// // context.
// byte[] objData = MiscUtils.GetObjData(this.Guid,
// (byte)FwObjDataTypes.kodtGuidMoveableObjDisp);
// ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
// propsBldr.SetStrPropValueRgch((int)FwTextPropType.ktptObjData,
// objData, objData.Length);
// propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, ws);
// // Insert the orc with the resulting properties.
// strBldr.Replace(strBldr.Length, strBldr.Length,
// new string(TsStringUtils.kChObject, 1), propsBldr.GetTextProps());
//}
/// ------------------------------------------------------------------------------------
/// <summary>
/// Update the properties of a CmPicture with the given file, caption, and folder.
/// </summary>
/// <param name="srcFilename">The full path to the filename (this might be an "internal"
/// copy of the original the user chose)</param>
/// <param name="captionTss">The caption</param>
/// <param name="sFolder">The name of the CmFolder where picture should be stored</param>
/// <param name="ws">The WS for the location in the caption MultiUnicode to put the
/// caption</param>
/// ------------------------------------------------------------------------------------
public void UpdatePicture(string srcFilename, ITsString captionTss, string sFolder, int ws)
{
// Set the caption first since creating the CmFile will throw if srcFilename is empty.
if (ws != 0)
Caption.set_String(ws, captionTss);
ICmFile file = PictureFileRA;
if (file == null)
{
ICmFolder folder = DomainObjectServices.FindOrCreateFolder(m_cache, LangProjectTags.kflidPictures, sFolder);
PictureFileRA = DomainObjectServices.FindOrCreateFile(folder, srcFilename);
}
else
{
Debug.Assert(sFolder == CmFolderTags.LocalPictures,
"TODO: If we ever actually support use of different folders, we need to handle folder changes.");
if (srcFilename != null && !FileUtils.PathsAreEqual(srcFilename, file.AbsoluteInternalPath))
file.InternalPath = srcFilename;
}
// We shouldn't need to this in the new FDO.
//m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, Hvo,
// (int)CmPicture.CmPictureTags.kflidCaption, ws, 0 , 0);
//m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, file.Hvo,
// (int)CmFile.CmFileTags.kflidInternalPath, 0, 1, 1);
}
示例5: CreateTestData
private ITsString m_tssVerse; // text to include in a verse
#region Setup
/// ------------------------------------------------------------------------------------
/// <summary>
/// Overridden to only create a book with no content, heading, title, etc.
/// </summary>
/// ------------------------------------------------------------------------------------
protected override void CreateTestData()
{
m_genesis = AddBookToMockedScripture(1, "Genesis");
m_genesisRevision = AddArchiveBookToMockedScripture(1, "Genesis");
m_tssVerse = TsStringUtils.MakeTss("verse text", Cache.DefaultVernWs);
}
示例6: SetupComponentsForEntryCreation
/// <summary>
/// Helper
/// </summary>
private LexEntryComponents SetupComponentsForEntryCreation(out int germanWsId,
out ILexEntryFactory lexFactory, out ITsString tssGermanGloss)
{
germanWsId = Cache.WritingSystemFactory.GetWsFromStr("de");
Cache.LangProject.AnalysisWritingSystems.Add(
Cache.WritingSystemFactory.get_EngineOrNull(germanWsId) as IWritingSystem);
lexFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
tssGermanGloss = Cache.TsStrFactory.MakeString("da", germanWsId);
var tssVernacForm = Cache.TsStrFactory.MakeString("bunk",
Cache.WritingSystemFactory.GetWsFromStr(Cache.LangProject.DefaultVernacularWritingSystem.Id));
var msa = new SandboxGenericMSA
{
MainPOS = Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Where(
pos => pos.Name.AnalysisDefaultWritingSystem.Text == "noun")
.Cast<IPartOfSpeech>()
.FirstOrDefault(),
MsaType = MsaType.kStem
};
var lexEntryComponents = new LexEntryComponents()
{
GlossAlternatives = new List<ITsString>() { tssGermanGloss },
LexemeFormAlternatives = new List<ITsString>() { tssVernacForm },
MSA = msa,
MorphType = Cache.LangProject.LexDbOA.MorphTypesOA.PossibilitiesOS.Where(
mt => mt.Name.AnalysisDefaultWritingSystem.Text == "stem")
.Cast<IMoMorphType>()
.FirstOrDefault()
};
return lexEntryComponents;
}
示例7: RunIsCorrect
/// ------------------------------------------------------------------------------------
/// <summary>
/// Verifies that the given run of the given ITsString contains the specified text and
/// properties.
/// </summary>
/// <param name="tss">The ITsString to test</param>
/// <param name="iRun">Zero-based run index to check</param>
/// <param name="expectedText">Expected contents of run</param>
/// <param name="expectedCharStyle">Expected character style name, or null if expecting
/// default paragraph character props</param>
/// <param name="expectedWs">Expected writing system for the run</param>
/// <param name="fExpectNFD">Pass <c>true</c> to make sure that TSS is in normal
/// form decomposed (which it probably should be if it has been saved to the DB); pass
/// <c>false</c> if the string is not expected to be decomposed.</param>
/// ------------------------------------------------------------------------------------
public static void RunIsCorrect(ITsString tss, int iRun, string expectedText,
string expectedCharStyle, int expectedWs, bool fExpectNFD)
{
Assert.AreEqual(fExpectNFD,
tss.get_IsNormalizedForm(FwNormalizationMode.knmNFD));
// If both strings are null then they're equal and there's nothing else to compare.
if (expectedText == null)
{
Assert.IsNull(tss.Text);
return;
}
// If both strings are 0-length, then they're equal; otherwise compare them.
if (expectedText.Length == 0)
Assert.AreEqual(0, tss.Length);
else
{
// compare strings
// apparently IndexOf performs Unicode normalization.
if (expectedText.IndexOf(tss.get_RunText(iRun), StringComparison.Ordinal) != 0)
{
Assert.Fail("Run " + iRun + " text differs. Expected <" +
expectedText + "> but was <" + tss.get_RunText(iRun) + ">");
}
}
ITsTextProps ttp1 = StyleUtils.CharStyleTextProps(expectedCharStyle, expectedWs);
ITsTextProps ttp2 = tss.get_Properties(iRun);
string sWhy;
if (!TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out sWhy))
Assert.Fail(sWhy);
}
示例8: Replace
/// ------------------------------------------------------------------------------------
/// <summary>
/// Replaces the specified portion of the original string with the new string.
/// </summary>
/// <param name="tss">The original string.</param>
/// <param name="startIndex">The start index.</param>
/// <param name="length">The length.</param>
/// <param name="tssReplace">The new string.</param>
/// <returns>The new string with the requested replacements made</returns>
/// ------------------------------------------------------------------------------------
public static ITsString Replace(this ITsString tss, int startIndex, int length, ITsString tssReplace)
{
int cch = tss.Length;
Debug.Assert(startIndex >= 0 && startIndex + length <= cch);
ITsStrBldr bldr = tss.GetBldr();
bldr.ReplaceTsString(startIndex, startIndex + length, tssReplace);
return bldr.GetString();
}
示例9: WordMaker
/// <summary>
/// Start it off analyzing a string.
/// </summary>
/// <param name="tss"></param>
/// <param name="cpe">engine to use.</param>
public WordMaker(ITsString tss, ILgCharacterPropertyEngine cpe)
{
m_tss = tss;
m_ich = 0;
m_st = tss.get_Text();
m_cch = m_st.Length;
m_cpe = cpe;
}
示例10: 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;
}
示例11: Insert
/// ------------------------------------------------------------------------------------
/// <summary>
/// Insert the specified string into the first argument/recipient at the specified position.
/// </summary>
/// ------------------------------------------------------------------------------------
public static ITsString Insert(this ITsString tss, int startIndex, ITsString tssInsert)
{
int cch = tss.Length;
Debug.Assert(startIndex >= 0 && startIndex <= cch);
if (tssInsert.Length == 0)
return tss;
ITsStrBldr bldr = tss.GetBldr();
bldr.ReplaceTsString(startIndex, startIndex, tssInsert);
return bldr.GetString();
}
示例12: SummaryDialogForm
private bool m_fShouldLink; // set true by btnLexicon_Click, caller should call LinkToLexicon after dialog closes.
#endregion
#region Constructor/destructor
/// ------------------------------------------------------------------------------------
/// <summary>
/// Constructor for a single LexEntry object.
/// </summary>
/// <param name="leui"></param>
/// <param name="wf"></param>
/// <param name="helpProvider"></param>
/// <param name="helpFileKey">string key to get the help file name</param>
/// ------------------------------------------------------------------------------------
public SummaryDialogForm(LexEntryUi leui, ITsString tssForm, IHelpTopicProvider helpProvider,
string helpFileKey, IVwStylesheet styleSheet)
{
InitializeComponent();
m_rghvo = new List<int>(1);
m_rghvo.Add(leui.Object.Hvo);
m_cache = leui.Object.Cache;
m_mediator = leui.Mediator;
Initialize(tssForm, helpProvider, helpFileKey, styleSheet);
}
示例13: Create
/// <summary>
/// Create a new sense and add it to the given entry.
/// </summary>
/// <param name="entry"></param>
/// <param name="sandboxMSA"></param>
/// <param name="gloss"></param>
/// <returns></returns>
public ILexSense Create(ILexEntry entry, SandboxGenericMSA sandboxMSA, ITsString gloss)
{
var sense = new LexSense();
entry.SensesOS.Add(sense);
sense.SandboxMSA = sandboxMSA;
if (gloss != null)
{
sense.Gloss.set_String(gloss.get_WritingSystemAt(0), gloss);
}
return sense;
}
示例14: Create
public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, int hvoRoot,
InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
{
if (mode != null && mode.ToLowerInvariant() == "elan")
{
return new InterlinearExporterForElan(cache, writer, hvoRoot, lineChoices, vc, tssTextName,
tssTextAbbreviation);
}
else
{
return new InterlinearExporter(cache, writer, hvoRoot, lineChoices, vc, tssTextName, tssTextAbbreviation);
}
}
示例15: GetTextRepresentationOfTsString
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the text representation of a TsString.
/// </summary>
/// <param name="tss">The TsString.</param>
/// <returns>text representation of the TsString</returns>
/// ------------------------------------------------------------------------------------
private string GetTextRepresentationOfTsString(ITsString tss)
{
string tssRepresentation = string.Empty;
for (int iRun = 0; iRun < tss.RunCount; iRun++)
{
tssRepresentation += "<RUN";
// writing system of run
int nVar;
int ws = tss.get_Properties(iRun).GetIntPropValues(
(int)FwTextPropType.ktptWs, out nVar);
if (ws != -1)
{
IWritingSystem wsObj = Services.WritingSystemManager.Get(ws);
tssRepresentation += " WS='" + wsObj.Id + "'";
}
// character style of run
string charStyle = tss.get_Properties(iRun).GetStrPropValue(
(int)FwTextPropType.ktptNamedStyle);
string runText = tss.get_RunText(iRun);
// add the style tags
if (charStyle != null)
tssRepresentation += " CS='" + charStyle + @"'";
tssRepresentation += ">";
// add the text for the tag
if (runText != null && runText != string.Empty)
{
var newString = new StringBuilder(runText.Length * 2);
for (var i = 0; i < runText.Length; i++)
{
// remove '<' and '>' from the text
if (runText[i] == '<')
newString.Append("<");
else if (runText[i] == '>')
newString.Append(">");
else
newString.Append(runText[i]);
}
tssRepresentation += newString.ToString();
}
// add the run end tag
tssRepresentation += "</RUN>";
}
return tssRepresentation;
}