Exemplo n.º 1
0
        /// <summary>
        /// This sets the original citation form into the dialog.
        /// </summary>
        /// <param name="tssCitationForm"></param>
        /// <param name="le"></param>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        public void SetDlgInfo(ITsString tssCitationForm, ILexEntry le, Mediator mediator, XCore.PropertyTable propertyTable)
        {
            CheckDisposed();

            Debug.Assert(tssCitationForm != null);
            Debug.Assert(le != null);

            m_le    = le;
            m_cache = le.Cache;

            IWritingSystemContainer     wsContainer = m_cache.ServiceLocator.WritingSystems;
            CoreWritingSystemDefinition defVernWs   = wsContainer.DefaultVernacularWritingSystem;
            CoreWritingSystemDefinition defAnalWs   = wsContainer.DefaultAnalysisWritingSystem;

            m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, 10);
            m_fwtbGloss.Font        = new Font(defAnalWs.DefaultFontName, 10);
            var stylesheet = FontHeightAdjuster.StyleSheetFromPropertyTable(propertyTable);

            // Set writing system factory and code for the two edit boxes.
            m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbCitationForm.WritingSystemCode    = defVernWs.Handle;
            m_fwtbCitationForm.StyleSheet           = stylesheet;
            m_fwtbCitationForm.AdjustStringHeight   = false;
            m_fwtbGloss.WritingSystemFactory        = m_cache.WritingSystemFactory;
            m_fwtbGloss.WritingSystemCode           = defAnalWs.Handle;
            m_fwtbGloss.StyleSheet         = stylesheet;
            m_fwtbGloss.AdjustStringHeight = false;
            m_fwtbCitationForm.Tss         = tssCitationForm;
            m_fwtbGloss.Text             = String.Empty;
            m_fwtbCitationForm.HasBorder = false;

            m_msaGroupBox.Initialize(m_cache, mediator, propertyTable, this, new SandboxGenericMSA());

            // get the current morph type from the lexical entry.
            IMoMorphType mmt;

            foreach (var mf in le.AlternateFormsOS)
            {
                mmt = mf.MorphTypeRA;
                if (mmt != null)
                {
                    m_msaGroupBox.MorphTypePreference = mmt;
                    break;                     // Assume the first allomorph's type is good enough.
                }
            }

            m_skipCheck = true;
            m_skipCheck = false;

            // Adjust sizes of the two FwTextBoxes if needed, and adjust the locations for the
            // controls below them.  Do the same for the MSAGroupBox.
            AdjustHeightAndPositions(m_fwtbCitationForm);
            AdjustHeightAndPositions(m_fwtbGloss);
            AdjustHeightAndPositions(m_msaGroupBox);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize the dialog before showing it.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="entry"></param>
        /// <param name="titleForEdit">Edit title appropriate to the button's context.</param>
        public void SetDlgInfo(FdoCache cache, IPersistenceProvider persistProvider,
                               Mediator mediator, ILexEntry entry, SandboxGenericMSA sandboxMsa, int hvoOriginalMsa,
                               bool useForEdit, string titleForEdit)
        {
            CheckDisposed();

            Debug.Assert(m_cache == null);
            MsaType msaType = sandboxMsa.MsaType;

            m_cache    = cache;
            m_mediator = mediator;

            if (useForEdit)
            {
                // Change the window title and the OK button text.
                Text        = titleForEdit;
                s_helpTopic = "khtpEditGrammaticalFunction";
                btnOk.Text  = LexText.Controls.LexTextControls.ks_OK;
            }
            helpProvider.HelpNamespace = mediator.HelpTopicProvider.HelpFile;
            helpProvider.SetHelpKeyword(this, mediator.HelpTopicProvider.GetHelpString(s_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

            // Set font, writing system factory, and code for the edit box.
            float          fntSize   = label1.Font.Size * 2.0F;
            IWritingSystem defVernWs = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

            m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbCitationForm.WritingSystemCode    = defVernWs.Handle;
            m_fwtbCitationForm.AdjustForStyleSheet(this, null, mediator);
            m_fwtbCitationForm.AdjustStringHeight = false;
            m_fwtbCitationForm.Tss       = entry.HeadWord;
            m_fwtbCitationForm.HasBorder = false;

            m_fwtbSenses.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbSenses.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbSenses.WritingSystemCode    = defVernWs.Handle;
            m_fwtbSenses.AdjustForStyleSheet(this, null, mediator);
            m_fwtbSenses.AdjustStringHeight = false;

            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_cache.DefaultAnalWs);
            var msaRepository = m_cache.ServiceLocator.GetInstance <IMoMorphSynAnalysisRepository>();

            if (hvoOriginalMsa != 0)
            {
                foreach (var sense in entry.AllSenses)
                {
                    if (sense.MorphoSyntaxAnalysisRA != null)
                    {
                        if (sense.MorphoSyntaxAnalysisRA == msaRepository.GetObject(hvoOriginalMsa))
                        {
                            if (tisb.Text != null)
                            {
                                tisb.Append(", ");                                      // REVIEW: IS LOCALIZATION NEEDED FOR BUILDING THIS LIST?
                            }
                            tisb.AppendTsString(sense.ShortNameTSS);
                        }
                    }
                }
            }
            m_fwtbSenses.Tss       = tisb.GetString();
            m_fwtbSenses.HasBorder = false;

            m_msaGroupBox.Initialize(m_cache, m_mediator, this, sandboxMsa);
            int oldHeight = m_msaGroupBox.Height;
            int newHeight = Math.Max(oldHeight, m_msaGroupBox.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                m_msaGroupBox.AdjustInternalControlsAndGrow();
                Debug.Assert(m_msaGroupBox.Height == m_msaGroupBox.PreferredHeight);
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_msaGroupBox);
            }

            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("msaCreatorDlgLocation");
                // JohnT: this dialog can't be resized. So it doesn't make sense to
                // remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
                // to prevent the dialog growing every time at 120 dpi. But such an override
                // makes it too small to show all the controls at the default size.
                // It's better just to use the default size until it's resizeable for some reason.
                //m_mediator.PropertyTable.GetValue("msaCreatorDlgSize");
                object szWnd = this.Size;
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
        }