Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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);
        }