本文整理汇总了C#中ILgWritingSystemFactory.get_EngineOrNull方法的典型用法代码示例。如果您正苦于以下问题:C# ILgWritingSystemFactory.get_EngineOrNull方法的具体用法?C# ILgWritingSystemFactory.get_EngineOrNull怎么用?C# ILgWritingSystemFactory.get_EngineOrNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILgWritingSystemFactory
的用法示例。
在下文中一共展示了ILgWritingSystemFactory.get_EngineOrNull方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeterminePasteWs
/// ------------------------------------------------------------------------------------
/// <summary>
/// Get a value determining if the new writing systems should be created as a side-effect
/// of a paste operation.
/// </summary>
/// <param name="wsf">writing system factory containing the new writing systems</param>
/// <param name="destWs">The destination writing system (writing system used at the
/// selection).</param>
/// <returns>
/// an indication of how the paste should be handled.
/// </returns>
/// ------------------------------------------------------------------------------------
public override PasteStatus DeterminePasteWs(ILgWritingSystemFactory wsf, out int destWs)
{
// Determine writing system at selection (destination for paste).
destWs = 0;
if (CurrentSelection != null)
destWs = CurrentSelection.GetWritingSystem(SelectionHelper.SelLimitType.Anchor);
if (destWs <= 0)
destWs = Cache.DefaultAnalWs; // set to default analysis, if 0.
// Get list of writing system names.
List<string> wsMissingNames = new List<string>();
int cws = wsf.NumberOfWs;
using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
{
wsf.GetWritingSystems(ptr, cws);
int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
IWritingSystem ws;
for (int iws = 0; iws < cws; iws++)
{
if (vws[iws] == 0)
continue;
ws = wsf.get_EngineOrNull(vws[iws]);
if (ws == null)
{
// found corrupt writing system--don't want to use any ws in this pasted string
return PasteStatus.UseDestWs;
}
if (Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(ws.IcuLocale) == 0)
wsMissingNames.Add(ws.LanguageName); // writing system not found in ws factory
}
}
PasteStatus pasteStatus;
if (wsMissingNames.Count > 0)
{
if (!Options.ShowPasteWsChoice)
return PasteStatus.UseDestWs;
// Ask user whether to use destination writing system or copy original writing systems.
LgWritingSystem lgws = new LgWritingSystem(Cache, destWs);
Debug.Assert(lgws != null);
using (AddWsFromPastedTextDlg newWsDlg = new AddWsFromPastedTextDlg(
m_cache.LangProject.Name.BestAnalysisAlternative.Text,
lgws.Name.BestAnalysisAlternative.Text, wsMissingNames))
{
newWsDlg.ShowDialog(Control.FindForm());
pasteStatus = newWsDlg.PasteStatus;
}
}
else // no missing writing systems in TsString to paste
pasteStatus = PasteStatus.PreserveWs;
return pasteStatus;
}
示例2: 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;
}
示例3: GetChrpForStyle
/// <summary>
/// Gets the character render properties for the given style name and writing system.
/// </summary>
/// <param name="styleName">The style name.</param>
/// <param name="styleSheet">The stylesheet.</param>
/// <param name="hvoWs">The HVO of the WS.</param>
/// <param name="writingSystemFactory">The writing system factory.</param>
/// <returns>The character render properties.</returns>
public static LgCharRenderProps GetChrpForStyle(string styleName, IVwStylesheet styleSheet,
int hvoWs, ILgWritingSystemFactory writingSystemFactory)
{
if (string.IsNullOrEmpty(writingSystemFactory.GetStrFromWs(hvoWs)))
{
try
{
throw new ArgumentException("This is a hard-to-reproduce scenario (TE-6891) where writing system (" + hvoWs + ") and factory are inconsistent. Call an expert (JohnT)");
}
catch (ArgumentException e)
{
Logger.WriteError(e);
Debug.Fail("This is a hard-to-reproduce scenario (TE-6891) where writing system and factory are inconsistent. Call an expert (JohnT) while you have this Assert active!");
hvoWs = writingSystemFactory.UserWs;
}
}
IVwPropertyStore vwps = VwPropertyStoreClass.Create();
vwps.Stylesheet = styleSheet;
vwps.WritingSystemFactory = writingSystemFactory;
ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, styleName);
ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoWs);
ITsTextProps ttp = ttpBldr.GetTextProps();
LgCharRenderProps chrps = vwps.get_ChrpFor(ttp);
IWritingSystem ws = writingSystemFactory.get_EngineOrNull(hvoWs);
ws.InterpretChrp(ref chrps);
return chrps;
}
示例4: ConvertersInUse
/// ------------------------------------------------------------------------------------
/// <summary>
/// Return a hash table from converter name to writing system name for converters
/// that are currently in use by some writing system. (This is a needed argument
/// for initializeing an AddCnvtrDlg, so that it can avoid deleting converters that
/// are currently in use by writing systems.)
/// </summary>
/// ------------------------------------------------------------------------------------
public static Set<string> ConvertersInUse(ILgWritingSystemFactory wsf)
{
Set<string> wsInUse = new Set<string>();
// Make a hash of the writing systems currently in use.
IWritingSystem currentWS;
int cws = wsf.NumberOfWs;
using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
{
wsf.GetWritingSystems(ptr, cws);
int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
for (int iws = 0; iws < cws; iws++)
{
if (vws[iws] == 0)
continue;
currentWS = wsf.get_EngineOrNull(vws[iws]);
if (currentWS == null)
continue;
string legMapping = currentWS.LegacyMapping;
if (legMapping == null)
continue;
wsInUse.Add(legMapping);
}
}
return wsInUse;
}
示例5: Initialize
/// <summary>
/// This sets the original wordform and morph-broken word into the dialog.
/// </summary>
public void Initialize(ITsString tssWord, string sMorphs, ILgWritingSystemFactory wsf,
FdoCache cache, StringTable stringTable, IVwStylesheet stylesheet)
{
CheckDisposed();
Debug.Assert(tssWord != null);
Debug.Assert(wsf != null);
ITsTextProps ttp = tssWord.get_Properties(0);
Debug.Assert(ttp != null);
int var;
int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
Debug.Assert(ws != 0);
ILgWritingSystem wsVern = wsf.get_EngineOrNull(ws);
Debug.Assert(wsVern != null);
m_txtMorphs.WritingSystemFactory = wsf;
m_txtMorphs.WritingSystemCode = ws;
m_txtMorphs.Text = sMorphs;
m_sMorphs = sMorphs;
// Fix the help strings to use the actual MorphType markers.
IMoMorphType mmtStem;
IMoMorphType mmtPrefix;
IMoMorphType mmtSuffix;
IMoMorphType mmtInfix;
IMoMorphType mmtBoundStem;
IMoMorphType mmtProclitic;
IMoMorphType mmtEnclitic;
IMoMorphType mmtSimulfix;
IMoMorphType mmtSuprafix ;
var morphTypeRepo = cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>();
morphTypeRepo.GetMajorMorphTypes(out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
out mmtBoundStem, out mmtProclitic, out mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
// Format the labels according to the MoMorphType Prefix/Postfix values.
string sExample1 = stringTable.GetString("EditMorphBreaks-Example1", "DialogStrings");
string sExample2 = stringTable.GetString("EditMorphBreaks-Example2", "DialogStrings");
string sStemExample = stringTable.GetString("EditMorphBreaks-stemExample", "DialogStrings");
string sAffixExample = stringTable.GetString("EditMorphBreaks-affixExample", "DialogStrings");
m_lblHelp2Example1.Text = String.Format(sExample1, mmtStem.Prefix ?? "", mmtStem.Postfix ?? "");
m_lblHelp2Example2.Text = String.Format(sExample2, mmtSuffix.Prefix ?? "", mmtSuffix.Postfix ?? "");
m_lblBreakStemExample.Text = String.Format(sStemExample, mmtStem.Prefix ?? "", mmtStem.Postfix ?? "");
m_lblBreakBoundStemExample.Text = String.Format(sStemExample, mmtBoundStem.Prefix ?? "", mmtBoundStem.Postfix ?? "");
m_lblBreakPrefixExample.Text = String.Format(sAffixExample,
mmtPrefix.Prefix == null ? "" : " " + mmtPrefix.Prefix,
mmtPrefix.Postfix == null ? "" : mmtPrefix.Postfix + " ");
m_lblBreakSuffixExample.Text = String.Format(sAffixExample,
mmtSuffix.Prefix == null ? "" : " " + mmtSuffix.Prefix,
mmtSuffix.Postfix == null ? "" : mmtSuffix.Postfix + " ");
m_lblBreakInfixExample.Text = String.Format(sAffixExample,
mmtInfix.Prefix == null ? "" : " " + mmtInfix.Prefix,
mmtInfix.Postfix == null ? "" : mmtInfix.Postfix + " ");
m_lblBreakProcliticExample.Text = String.Format(sAffixExample,
mmtProclitic.Prefix == null ? "" : " " + mmtProclitic.Prefix,
mmtProclitic.Postfix == null ? "" : mmtProclitic.Postfix + " ");
m_lblBreakEncliticExample.Text = String.Format(sAffixExample,
mmtEnclitic.Prefix == null ? "" : " " + mmtEnclitic.Prefix,
mmtEnclitic.Postfix == null ? "" : mmtEnclitic.Postfix + " ");
m_lblBreakSimulfixExample.Text = String.Format(sAffixExample,
mmtSimulfix.Prefix == null ? "" : " " + mmtSimulfix.Prefix,
mmtSimulfix.Postfix == null ? "" : mmtSimulfix.Postfix + " ");
m_lblBreakSuprafixExample.Text = String.Format(sAffixExample,
mmtSuprafix.Prefix == null ? "" : " " + mmtSuprafix.Prefix,
mmtSuprafix.Postfix == null ? "" : mmtSuprafix.Postfix + " ");
m_morphBreakContextMenu = new MorphBreakHelperMenu(m_txtMorphs, m_helpTopicProvider, cache, stringTable);
m_txtMorphs.AdjustForStyleSheet(this, null, stylesheet);
m_morphBreakHelper.Height = m_txtMorphs.Height;
}
示例6: setWsfAndWs
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the writing system factory and the writing system hvo.
/// </summary>
/// <param name="wsf">The WSF.</param>
/// <param name="ws">The ws.</param>
/// ------------------------------------------------------------------------------------
public void setWsfAndWs(ILgWritingSystemFactory wsf, int ws)
{
Debug.Assert(wsf != null, "Set the WritingSystemFactory first!");
ILgWritingSystem wsObj = wsf.get_EngineOrNull(ws);
m_rtl = (wsObj != null && wsObj.RightToLeftScript);
}
示例7: GetVernacularFont
private static Font GetVernacularFont(ILgWritingSystemFactory wsf, int wsVern, IVwStylesheet stylesheet)
{
if (stylesheet == null)
{
ILgWritingSystem wsEngine = wsf.get_EngineOrNull(wsVern);
string fontName = wsEngine.DefaultFontName;
return new Font(fontName, (float)10.0);
}
else
{
return FontHeightAdjuster.GetFontForNormalStyle(wsVern, stylesheet, wsf);
}
}
示例8: DeterminePasteWs
/// ------------------------------------------------------------------------------------
/// <summary>
/// Get a value determining if the new writing systems should be created as a side-effect
/// of a paste operation.
/// </summary>
/// <param name="wsf">writing system factory containing the new writing systems</param>
/// <param name="destWs">The destination writing system (writing system used at the
/// selection).</param>
/// <returns>
/// an indication of how the paste should be handled.
/// </returns>
/// ------------------------------------------------------------------------------------
public override PasteStatus DeterminePasteWs(ILgWritingSystemFactory wsf, out int destWs)
{
// Determine writing system at selection (destination for paste).
destWs = 0;
if (CurrentSelection != null)
destWs = CurrentSelection.GetWritingSystem(SelectionHelper.SelLimitType.Anchor);
if (destWs <= 0)
destWs = Cache.DefaultAnalWs; // set to default analysis, if 0.
int cws = wsf.NumberOfWs;
using (ArrayPtr ptr = MarshalEx.ArrayToNative<int>(cws))
{
wsf.GetWritingSystems(ptr, cws);
int[] vws = MarshalEx.NativeToArray<int>(ptr, cws);
for (int iws = 0; iws < cws; iws++)
{
if (vws[iws] != 0 && wsf.get_EngineOrNull(vws[iws]) == null)
{
// found corrupt writing system--don't want to use any ws in this pasted string
return PasteStatus.UseDestWs;
}
}
}
return PasteStatus.PreserveWs;
}
示例9: RawDictionaryId
// The raw id that should be used to create a dictionary for the given WS, if none exists.
private static string RawDictionaryId(int ws, ILgWritingSystemFactory wsf)
{
ILgWritingSystem wsEngine = wsf.get_EngineOrNull(ws);
if (wsEngine == null)
return null;
string wsId = wsEngine.SpellCheckingId;
if (String.IsNullOrEmpty(wsId))
{
// Our old spelling engine, Enchant, did not allow hyphen;
// keeping that rule in case we switch again or there is some other good reason for it that we don't know.
// Changing to underscore is OK since lang ID does not allow underscore.
return wsEngine.Id.Replace('-', '_');
}
if (wsId == "<None>")
return null;
return wsId;
}
示例10: setWsfAndWs
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the writing system factory and the writing system hvo.
/// </summary>
/// <param name="wsf">The WSF.</param>
/// <param name="ws">The ws.</param>
/// ------------------------------------------------------------------------------------
public void setWsfAndWs(ILgWritingSystemFactory wsf, int ws)
{
CheckDisposed();
IWritingSystem wsObj = wsf.get_EngineOrNull(ws);
m_rtl = (wsObj != null && wsObj.RightToLeft);
}
示例11: EnsureRealWs
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets (or makes) the writing system. If there isn't already one with this locale id,
/// we assume there is an XML language definition we can load.
/// </summary>
/// ------------------------------------------------------------------------------------
public IWritingSystem EnsureRealWs(ILgWritingSystemFactory wsf)
{
if (wsf.GetWsFromStr(m_icuLocale) == 0)
{
// Need to create a new writing system from the XML file.
LanguageDefinitionFactory ldf =
new LanguageDefinitionFactory(wsf, m_icuLocale);
string pathname = DirectoryFinder.LanguagesDirectory + "\\" + m_icuLocale + ".xml";
ldf.Deserialize(pathname);
ldf.LanguageDefinition.SaveWritingSystem(m_icuLocale);
}
return wsf.get_EngineOrNull(wsf.GetWsFromStr(m_icuLocale));
}
示例12: Initialize
/// <summary>
/// This sets the original wordform and morph-broken word into the dialog.
/// </summary>
/// <param name="sWord"></param>
/// <param name="sMorphs"></param>
public void Initialize(ITsString tssWord, string sMorphs, ILgWritingSystemFactory wsf,
FdoCache cache, SIL.Utils.StringTable stringTable, IVwStylesheet stylesheet)
{
CheckDisposed();
Debug.Assert(tssWord != null);
Debug.Assert(wsf != null);
ITsTextProps ttp = tssWord.get_Properties(0);
Debug.Assert(ttp != null);
int var;
int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
Debug.Assert(ws != 0);
IWritingSystem wsVern = wsf.get_EngineOrNull(ws);
Debug.Assert(wsVern != null);
// The following is needed for Graphite fonts.
string sFontVar = wsVern.FontVariation;
if (sFontVar == null)
sFontVar = "";
this.m_txtMorphs.WritingSystemFactory = wsf;
this.m_txtMorphs.WritingSystemCode = ws;
this.m_txtMorphs.Text = sMorphs;
m_sMorphs = sMorphs;
// Fix the help strings to use the actual MorphType markers.
IMoMorphType mmtStem = null;
IMoMorphType mmtPrefix = null;
IMoMorphType mmtSuffix = null;
IMoMorphType mmtInfix = null;
IMoMorphType mmtBoundStem = null;
IMoMorphType mmtProclitic = null;
IMoMorphType mmtEnclitic = null;
IMoMorphType mmtSimulfix = null;
IMoMorphType mmtSuprafix = null;
MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
out mmtBoundStem, out mmtProclitic, out mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
// Format the labels according to the MoMorphType Prefix/Postfix values.
string sExample1 = stringTable.GetString("EditMorphBreaks-Example1", "DialogStrings");
string sExample2 = stringTable.GetString("EditMorphBreaks-Example2", "DialogStrings");
string sStemExample = stringTable.GetString("EditMorphBreaks-stemExample", "DialogStrings");
string sAffixExample = stringTable.GetString("EditMorphBreaks-affixExample", "DialogStrings");
lblHelp2_Example1.Text = String.Format(sExample1,
mmtStem.Prefix == null ? "" : mmtStem.Prefix,
mmtStem.Postfix == null ? "" : mmtStem.Postfix);
lblHelp2_Example2.Text = String.Format(sExample2,
mmtSuffix.Prefix == null ? "" : mmtSuffix.Prefix,
mmtSuffix.Postfix == null ? "" : mmtSuffix.Postfix);
lblBreak_stemExample.Text = String.Format(sStemExample,
mmtStem.Prefix == null ? "" : mmtStem.Prefix,
mmtStem.Postfix == null ? "" : mmtStem.Postfix);
lblBreak_boundStemExample.Text = String.Format(sStemExample,
mmtBoundStem.Prefix == null ? "" : mmtBoundStem.Prefix,
mmtBoundStem.Postfix == null ? "" : mmtBoundStem.Postfix);
lblBreak_prefixExample.Text = String.Format(sAffixExample,
mmtPrefix.Prefix == null ? "" : " " + mmtPrefix.Prefix,
mmtPrefix.Postfix == null ? "" : mmtPrefix.Postfix + " ");
lblBreak_suffixExample.Text = String.Format(sAffixExample,
mmtSuffix.Prefix == null ? "" : " " + mmtSuffix.Prefix,
mmtSuffix.Postfix == null ? "" : mmtSuffix.Postfix + " ");
lblBreak_infixExample.Text = String.Format(sAffixExample,
mmtInfix.Prefix == null ? "" : " " + mmtInfix.Prefix,
mmtInfix.Postfix == null ? "" : mmtInfix.Postfix + " ");
lblBreak_procliticExample.Text = String.Format(sAffixExample,
mmtProclitic.Prefix == null ? "" : " " + mmtProclitic.Prefix,
mmtProclitic.Postfix == null ? "" : mmtProclitic.Postfix + " ");
lblBreak_encliticExample.Text = String.Format(sAffixExample,
mmtEnclitic.Prefix == null ? "" : " " + mmtEnclitic.Prefix,
mmtEnclitic.Postfix == null ? "" : mmtEnclitic.Postfix + " ");
lblBreak_simulfixExample.Text = String.Format(sAffixExample,
mmtSimulfix.Prefix == null ? "" : " " + mmtSimulfix.Prefix,
mmtSimulfix.Postfix == null ? "" : mmtSimulfix.Postfix + " ");
lblBreak_suprafixExample.Text = String.Format(sAffixExample,
mmtSuprafix.Prefix == null ? "" : " " + mmtSuprafix.Prefix,
mmtSuprafix.Postfix == null ? "" : mmtSuprafix.Postfix + " ");
morphBreakContextMenu = new MorphBreakHelperMenu(m_txtMorphs, FwApp.App, cache, stringTable);
m_txtMorphs.AdjustForStyleSheet(this, null, stylesheet);
}
示例13: GetVernacularFont
private Font GetVernacularFont(ILgWritingSystemFactory wsf, int wsVern, IVwStylesheet stylesheet)
{
if (stylesheet == null)
{
IWritingSystem wsEngine = wsf.get_EngineOrNull(wsVern);
string fontName = wsEngine.DefaultSansSerif;
return new Font(fontName, (float)10.0);
}
else
{
return SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.GetFontForNormalStyle(wsVern, stylesheet, wsf);
}
}