Exemplo n.º 1
0
        public void LabelAbbreviations()
        {
            m_dtree.Initialize(Cache, false, m_layouts, m_parts);
            m_dtree.StringTbl = m_stringTable;
            m_dtree.ShowObject(m_entry, "Abbrs", null, m_entry, false);

            Assert.AreEqual(3, m_dtree.Controls.Count);
            // 1) Test that labels that are not in "LabelAbbreviations" stringTable
            //		are abbreviated by being truncated to 4 characters.
            Assert.AreEqual("CitationForm", (m_dtree.Controls[0] as Slice).Label);
            string abbr1 = m_stringTable.GetString((m_dtree.Controls[0] as Slice).Label, "LabelAbbreviations");

            Assert.AreEqual(abbr1, "*" + (m_dtree.Controls[0] as Slice).Label + "*");                   // verify it's not in the table.
            Assert.AreEqual("Cita", (m_dtree.Controls[0] as Slice).Abbreviation);                       // verify truncation took place.
            // 2) Test that a label in "LabelAbbreviations" defaults to its string table entry.
            Assert.AreEqual("Citation Form", (m_dtree.Controls[1] as Slice).Label);
            string abbr2 = m_stringTable.GetString((m_dtree.Controls[1] as Slice).Label, "LabelAbbreviations");

            Assert.IsFalse(abbr2 == "*" + (m_dtree.Controls[1] as Slice).Label + "*");             // verify it IS in the table
            Assert.AreEqual(abbr2, (m_dtree.Controls[1] as Slice).Abbreviation);                   // should be identical
            // 3) Test that a label with an "abbr" attribute overrides default abbreviation.
            Assert.AreEqual("Citation Form", (m_dtree.Controls[2] as Slice).Label);
            Assert.AreEqual((m_dtree.Controls[2] as Slice).Abbreviation, "!?");
            Assert.IsFalse(abbr2 == (m_dtree.Controls[2] as Slice).Abbreviation);
        }
Exemplo n.º 2
0
 public void InBaseFile()
 {
     Assert.AreEqual("orng", m_table.GetString("orange"));
 }
		public void SetStringTableValues(StringTable stringTable)
		{
			CheckDisposed();

			m_sStem = stringTable.GetString("Stem", "Linguistics/Morphology/TemplateTable");

			m_sSlotChooserTitle = stringTable.GetString("SlotChooserTitle", "Linguistics/Morphology/TemplateTable");
			m_sSlotChooserInstructionalText = stringTable.GetString("SlotChooserInstructionalText", "Linguistics/Morphology/TemplateTable");
			m_sObligatorySlot = stringTable.GetString("ObligatorySlot", "Linguistics/Morphology/TemplateTable");
			m_sOptionalSlot = stringTable.GetString("OptionalSlot", "Linguistics/Morphology/TemplateTable");

			m_sNewSlotName = stringTable.GetString("NewSlotName", "Linguistics/Morphology/TemplateTable");
			m_sUnnamedSlotName = stringTable.GetString("UnnamedSlotName", "Linguistics/Morphology/TemplateTable");

			m_sInflAffixChooserTitle = stringTable.GetString("InflAffixChooserTitle", "Linguistics/Morphology/TemplateTable");
			m_sInflAffixChooserInstructionalTextReq = stringTable.GetString("InflAffixChooserInstructionalTextReq", "Linguistics/Morphology/TemplateTable");
			m_sInflAffixChooserInstructionalTextOpt = stringTable.GetString("InflAffixChooserInstructionalTextOpt", "Linguistics/Morphology/TemplateTable");
			m_sInflAffix = stringTable.GetString("InflAffix", "Linguistics/Morphology/TemplateTable");

		}
Exemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create the mediator if it doesn't already exist.  Ensure that the string table in
		/// the mediator is loaded from the Flex string table.
		/// </summary>
		/// <param name="mediator"></param>
		/// <param name="fRestoreStringTable">output flag that we should restore the original string table</param>
		/// <param name="stOrig">output is the original string table</param>
		/// ------------------------------------------------------------------------------------
		protected static Mediator EnsureValidMediator(Mediator mediator,
			out bool fRestoreStringTable, out StringTable stOrig)
		{
			if (mediator == null)
			{
				mediator = new Mediator();
				fRestoreStringTable = false;
				stOrig = null;
			}
			else
			{
				try
				{
					stOrig = mediator.StringTbl;
					// Check whether this is the Flex string table: look for a lexicon type
					// string and compare the value with what is produced when it's not found.
					string s = stOrig.GetString("MoCompoundRule-Plural", "AlternativeTitles");
					fRestoreStringTable = (s == "*MoCompoundRule-Plural*");
				}
				catch
				{
					stOrig = null;
					fRestoreStringTable = true;
				}
			}
			if (fRestoreStringTable || stOrig == null)
			{
				string dir = Path.Combine(FwDirectoryFinder.FlexFolder, "Configuration");
				mediator.StringTbl = new StringTable(dir);
			}
			return mediator;
		}
Exemplo n.º 5
0
		/// <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;
		}
Exemplo n.º 6
0
		/// <summary>
		/// The type of items contained in this list.
		/// </summary>
		/// <param name="stringTbl">string table containing mappings for list item names.</param>
		/// <returns></returns>
		public string ItemsTypeName(StringTable stringTbl)
		{
			string owningFieldName = Cache.MetaDataCacheAccessor.GetFieldName((uint)this.OwningFlid);
			string itemsTypeName = stringTbl.GetString(owningFieldName, "PossibilityListItemTypeNames");
			if (itemsTypeName != "*" + owningFieldName + "*")
				return itemsTypeName;
			if (this.PossibilitiesOS.Count > 0)
				return stringTbl.GetString(this.PossibilitiesOS[0].GetType().Name, "ClassNames");
			else
				return itemsTypeName;
		}
Exemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The name for the type of CmPossibility. Subclasses may override.
		/// </summary>
		/// <param name="strTable">string table containing mappings for list item names.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public virtual string ItemTypeName(StringTable strTable)
		{
			int ownerHvo = this.OwnerHVO;
			ICmPossibilityList owningList = this.OwningList;
			string owningFieldName =
				Cache.MetaDataCacheAccessor.GetFieldName((uint)owningList.OwningFlid);
			string itemsTypeName = (owningList as CmPossibilityList).ItemsTypeName(strTable);
			if (itemsTypeName != "*" + owningFieldName + "*")
				return itemsTypeName;
			return strTable.GetString(this.GetType().Name, "ClassNames");
		}
Exemplo n.º 8
0
		/// <summary>
		///
		/// </summary>
		/// <param name="tbl"></param>
		/// <param name="group"></param>
		/// <param name="key"></param>
		/// <param name="result"></param>
		/// <returns>true if we found a value associated with the given key. false if result is in *{key}* format.</returns>
		public static bool TryFindString(StringTable tbl, string group, string key, out string result)
		{
			result = tbl.GetString(key, group);
			return FoundStringTableString(key, result);
		}