/// <summary>
        /// Set up the dlg in preparation to showing it.
        /// </summary>
        /// <param name="cache">FDO cache.</param>
        public void SetDlgInfo(FdoCache cache, Mediator mediator, ILexEntry entry)
        {
            CheckDisposed();

            Debug.Assert(cache != null);

            m_mediator = mediator;
            m_cache    = cache;
            m_entry    = entry;
            m_tsf      = TsStrFactoryClass.Create();
            IVwStylesheet stylesheet = SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.StyleSheetFromMediator(mediator);

            // We want to do this BEFORE the text gets set, to avoid overriding its height properties.
            // However, because of putting multiple lines in the box, we also need to do it AFTER we set the text
            // (in SetBottomMessage) so it adjusts to the resulting even greater height.
            m_fwTextBoxBottomMsg.AdjustForStyleSheet(this, null, stylesheet);
            Font f = SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.GetFontForNormalStyle(
                m_cache.LangProject.DefaultVernacularWritingSystem, stylesheet, m_cache.LanguageWritingSystemFactoryAccessor);

            foreach (IMoForm allo in entry.AlternateFormsOS)
            {
                ListViewItem lvi = m_lvAlloOptions.Items.Add(allo.Form.VernacularDefaultWritingSystem);
                lvi.Tag = allo;
                lvi.UseItemStyleForSubItems = true;
                lvi.Font = f;
            }
            m_lvAlloOptions.Font = f;
            // Get location to the stored values, if any.
            object locWnd = m_mediator.PropertyTable.GetValue("swapDlgLocation");
            // And when I do this, it works the first time, but later times the window is
            // too small and doesn't show all the controls. Give up on smart location for now.
            //object szWnd = this.Size;
            object szWnd = null;             // suppresses the smart location stuff.

            if (locWnd != null && szWnd != null)
            {
                Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                ScreenUtils.EnsureVisibleRect(ref rect);
                DesktopBounds = rect;
                StartPosition = FormStartPosition.Manual;
            }
            m_lvAlloOptions.Items[0].Selected = true;
            Text        = LexEdStrings.ksSwapLexWithAllo;
            label2.Text = LexEdStrings.ksAlternateForms;

            // Determine the help file to use, if any
            m_helpTopic = "khtpSwapLexemeWithAllomorph";

            if (m_helpTopic != null && FwApp.App != null)            // FwApp.App could be null for testing
            {
                helpProvider = new System.Windows.Forms.HelpProvider();
                helpProvider.HelpNamespace = FwApp.App.HelpFile;
                helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(m_helpTopic, 0));
                helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
            }
        }
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);
        }