/// <summary> /// Static version for avoiding creating actual object. /// </summary> /// <param name="cache"></param> /// <param name="hvo"></param> /// <param name="tsb"></param> /// <returns></returns> public static void ShortName1Static(FdoCache cache, int hvo, ITsIncStrBldr tsb) { ISilDataAccess sda = cache.MainCacheAccessor; int wsVern = cache.DefaultVernWs; // try vernacular citation ITsString label = sda.get_MultiStringAlt(hvo, (int)LexEntry.LexEntryTags.kflidCitationForm, wsVern); if (label.Length != 0) { tsb.AppendTsString(label); return; } // try lexeme form int hvoLf = sda.get_ObjectProp(hvo, (int)LexEntry.LexEntryTags.kflidLexemeForm); if (hvoLf != 0) { label = sda.get_MultiStringAlt(hvoLf, (int)MoForm.MoFormTags.kflidForm, wsVern); if (label.Length != 0) { tsb.AppendTsString(label); return; } } // Try the first alternate form with the wsVern WS. for (int i = 0; i < sda.get_VecSize(hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms); i++) { int hvoAm = sda.get_VecItem(hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms, i); label = sda.get_MultiStringAlt(hvoAm, (int)MoForm.MoFormTags.kflidForm, wsVern); if (label.Length != 0) { tsb.AppendTsString(label); return; } } // give up tsb.AppendTsString(cache.MakeUserTss(Strings.ksQuestions)); // was "??", not "???" }
/// <summary> /// Return the name for the specified CmPossibility (or '???' if it has no name /// or hvo is 0). Return the best available analysis or vernacular name (in that order). /// </summary> /// <param name="cache"></param> /// <param name="hvo"></param> /// <returns></returns> public static ITsString BestAnalysisOrVernReverseName(FdoCache cache, int hvo) { ITsString tss = null; if (hvo != 0) { tss = cache.LangProject.GetMagicStringAlt( SIL.FieldWorks.FDO.LangProj.LangProject.kwsFirstAnalOrVern, hvo, (int)LexRefType.LexRefTypeTags.kflidReverseName); } if (tss == null) { tss = cache.MakeUserTss(Strings.ksQuestions); // JohnT: how about this? //return cache.MakeUserTss("a " + this.GetType().Name + " with no name"); } return tss; }
/// <summary> /// Similarly get a name in some WS, preferring vernacular. /// </summary> /// <param name="cache"></param> /// <param name="hvo"></param> /// <returns></returns> public static ITsString BestVernOrAnalysisName(FdoCache cache, int hvo) { ITsString tss = null; if (hvo != 0) { tss = cache.LangProject.GetMagicStringAlt( LangProject.kwsFirstVernOrAnal, hvo, (int)CmPossibility.CmPossibilityTags.kflidName); } if (tss == null || tss.Length == 0) { tss = cache.MakeUserTss(Strings.ksQuestions); // JohnT: how about this? //return cache.MakeUserTss("a " + this.GetType().Name + " with no name"); } return tss; }
public void SetDlgInfo(CmObjectUi obj, FdoCache cache, XCore.Mediator mediator) { CheckDisposed(); StringTable strings = mediator.StringTbl; m_cache = cache; IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator); Debug.Assert(obj != null); Debug.Assert(obj.Object != null); Text = String.Format(FdoUiStrings.ksDeleteX, strings.GetString(obj.ClassName, "ClassNames")); // Set the s_helpTopic based on the window title and rearrange the buttons if neccesary switch (obj.ClassName) { case "WfiWordform": s_helpTopic = "khtpDeleteWordform"; break; } if (s_helpTopic != null) { buttonHelp.Visible = true; buttonHelp.Enabled = true; this.helpProvider = new System.Windows.Forms.HelpProvider(); this.helpProvider.HelpNamespace = FwApp.App.HelpFile; this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0)); this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); } else { m_deleteButton.Location = m_cancelButton.Location; m_cancelButton.Location = buttonHelp.Location; } //Use an FWTextBox so that strings of different writing systems will //be displayed with the correct stylesheet settings. m_descriptionBox3.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor; m_descriptionBox3.WritingSystemCode = m_cache.LangProject.DefaultUserWritingSystem; m_descriptionBox3.StyleSheet = stylesheet; ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create(); tisb3.AppendTsString(obj.Object.DeletionTextTSS); m_descriptionBox3.Tss = tisb3.GetString(); m_descriptionBox4.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor; m_descriptionBox4.WritingSystemCode = m_cache.LangProject.DefaultUserWritingSystem; m_descriptionBox4.StyleSheet = stylesheet; ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create(); tisb4.AppendTsString(m_cache.MakeUserTss(" ")); //this is the default for m_descriptionBox4 m_descriptionBox4.Tss = tisb4.GetString(); m_deleteButton.Enabled = obj.Object.CanDelete; label2.Visible = m_deleteButton.Enabled; }
/// <summary> /// Return the Abbreviation for the specified CmPossibility if one exists for ws (or '???' if it has no name /// or hvo is 0). /// </summary> /// <param name="cache"></param> /// <param name="hvo"></param> /// <param name="ws"></param> /// <returns></returns> public static ITsString TSSAbbrforWS(FdoCache cache, int hvo, int ws) { ITsString tss = null; if (hvo != 0) { tss = cache.LangProject.GetMagicStringAlt(ws, hvo, (int)CmPossibility.CmPossibilityTags.kflidAbbreviation); } if (tss == null || tss.Length == 0) { tss = cache.MakeUserTss(Strings.ksQuestions); } return tss; }
private static ITsString BestAlternative(FdoCache cache, int hvo, int wsMagic, int flid, string defValue) { ITsString tss = null; if (hvo != 0) tss = cache.LangProject.GetMagicStringAlt(wsMagic, hvo, flid); if (tss == null || tss.Length == 0) tss = cache.MakeUserTss(defValue); return tss; }
/// <summary> /// The user abbreviation we'd like to see typically for this writing system. /// Currently this is the user writing system of the Abbr field, or if that /// is empty, the ICU code. /// We will probably change this (when everything is using it) to try /// the analysis writing systems in order, then the user ws. /// </summary> public static ITsString UserAbbr(FdoCache cache, int hvo) { ITsString result = cache.MainCacheAccessor.get_MultiStringAlt(hvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, cache.DefaultUserWs); if (result != null && result.Length != 0) return result; ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor; IWritingSystem ws = wsf.get_EngineOrNull(hvo); if (ws == null) return cache.MakeUserTss(Strings.ksStars); else return cache.MakeUserTss(ws.get_UiName(cache.DefaultUserWs)); }
public RuleFormulaVc(FdoCache cache, XCore.Mediator mediator) { m_cache = cache; m_mediator = mediator; // use Doulos SIL because it supports the special characters that are needed for // multiline brackets ITsPropsBldr tpb = TsPropsBldrClass.Create(); tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Charis SIL"); m_bracketProps = tpb.GetTextProps(); tpb = TsPropsBldrClass.Create(); tpb.SetIntPropValues((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); tpb.SetIntPropValues((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); m_pileProps = tpb.GetTextProps(); m_empty = m_cache.MakeUserTss(""); m_infinity = m_cache.MakeUserTss("\u221e"); m_leftBracketUpHook = m_cache.MakeUserTss("\u23a1"); m_leftBracketExt = m_cache.MakeUserTss("\u23a2"); m_leftBracketLowHook = m_cache.MakeUserTss("\u23a3"); m_rightBracketUpHook = m_cache.MakeUserTss("\u23a4"); m_rightBracketExt = m_cache.MakeUserTss("\u23a5"); m_rightBracketLowHook = m_cache.MakeUserTss("\u23a6"); m_leftBracket = m_cache.MakeUserTss("["); m_rightBracket = m_cache.MakeUserTss("]"); m_questions = m_cache.MakeUserTss("???"); m_leftParen = m_cache.MakeUserTss("("); m_rightParen = m_cache.MakeUserTss(")"); m_x = m_cache.MakeUserTss("X"); m_zwSpace = m_cache.MakeUserTss("\u200b"); }
// Make a string representing a WfiAnalysis, suitable for use in a combo box item. static internal ITsString MakeAnalysisStringRep(int hvoWa, FdoCache fdoCache, bool fUseStyleSheet, int wsVern) { // ITsTextProps boldItalicAnalysis = BoldItalicAnalysis(fdoCache); // ITsTextProps italicAnalysis = ItalicAnalysis(fdoCache, Sandbox.SandboxVc.krgbRed); ITsTextProps posTextProperties = PartOfSpeechTextProperties(fdoCache, true, fUseStyleSheet); ITsTextProps formTextProperties = FormTextProperties(fdoCache, fUseStyleSheet, wsVern); ITsTextProps glossTextProperties = GlossTextProperties(fdoCache, true, fUseStyleSheet); ITsStrBldr tsb = TsStrBldrClass.Create(); ISilDataAccess sda = fdoCache.MainCacheAccessor; int cmorph = fdoCache.GetVectorSize(hvoWa, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles); if (cmorph == 0) return fdoCache.MakeUserTss(ITextStrings.ksNoMorphemes); bool fRtl = fdoCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsVern).RightToLeft; int start = 0; int lim = cmorph; int increment = 1; if (fRtl) { start = cmorph - 1; lim = -1; increment = -1; } for (int i = start; i != lim; i += increment) { int hvoMb = fdoCache.GetVectorItem(hvoWa, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles, i); int hvoMf = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph); ITsString tssForm = null; if (hvoMf != 0) { int hvoEntry = fdoCache.GetOwnerOfObject(hvoMf); int hvoLexemeForm = sda.get_ObjectProp(hvoEntry, (int) LexEntry.LexEntryTags.kflidLexemeForm); if (hvoLexemeForm != 0) { tssForm = sda.get_MultiStringAlt(hvoLexemeForm, (int) MoForm.MoFormTags.kflidForm, wsVern); } if (tssForm == null || tssForm.Length == 0) { tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoEntry, (int)LexEntry.LexEntryTags.kflidCitationForm, wsVern); } if (tssForm.Length == 0) { // If there isn't a lexeme form OR citation form use the form of the morph. tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoMf, (int)MoForm.MoFormTags.kflidForm, wsVern); } } else // no MoForm linked to this bundle, use its own form. { tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidForm, wsVern); } int ichForm = tsb.Length; tsb.ReplaceTsString(ichForm, ichForm, tssForm); tsb.SetProperties(ichForm, tsb.Length,formTextProperties); // add category (part of speech) int hvoMsa = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa); tsb.Replace(tsb.Length, tsb.Length, " ", null); int ichMinMsa = tsb.Length; string interlinName = ksMissingString; if (hvoMsa != 0) { IMoMorphSynAnalysis msa = MoMorphSynAnalysis.CreateFromDBObject(fdoCache, hvoMsa); interlinName = msa.InterlinearAbbr; } tsb.Replace(ichMinMsa, ichMinMsa, interlinName, posTextProperties); //add sense int hvoSense = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense); tsb.Replace(tsb.Length, tsb.Length, " ", null); int ichMinSense = tsb.Length; if (hvoSense != 0) { ITsString tssGloss = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoSense, (int)LexSense.LexSenseTags.kflidGloss, fdoCache.DefaultAnalWs); tsb.Replace(ichMinSense, ichMinSense, tssGloss.Text, glossTextProperties); } else tsb.Replace(ichMinSense, ichMinSense, ksMissingString, glossTextProperties); // Enhance JohnT: use proper seps. tsb.Replace(tsb.Length, tsb.Length, ksPartSeparator, null); } // Delete the final separator. (Enhance JohnT: this needs to get smarter when we do // real seps.) int ichFrom = tsb.Length - ksPartSeparator.Length; if (ichFrom < 0) ichFrom = 0; tsb.Replace(ichFrom, tsb.Length, "", null); return tsb.GetString(); }