Example #1
0
		/// <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);
		}