Beispiel #1
0
        private void AdjustControlAndDialogHeight(Control control, int preferredHeight)
        {
            int tbNewHeight = Math.Max(preferredHeight, control.Height);

            FontHeightAdjuster.GrowDialogAndAdjustControls(this, tbNewHeight - control.Height, control);
            control.Height = tbNewHeight;
        }
Beispiel #2
0
 // Grow the dialog's height by delta.
 // Adjust any controls that need it.
 // (Duplicated in BaseGoDlg...)
 private void GrowDialogAndAdjustControls(int delta, Control grower)
 {
     if (delta == 0)
     {
         return;
     }
     m_delta += delta;
     FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, grower);
 }
Beispiel #3
0
        private void AdjustHeightAndPositions(SIL.FieldWorks.Common.Widgets.FwTextBox fwtb)
        {
            int oldHeight = fwtb.Height;
            int newHeight = Math.Max(oldHeight, fwtb.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                fwtb.Height = newHeight;
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, fwtb);
            }
        }
Beispiel #4
0
        private void AdjustHeightAndPositions(MSAGroupBox msagb)
        {
            int oldHeight = msagb.Height;
            int newHeight = Math.Max(oldHeight, msagb.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                msagb.AdjustInternalControlsAndGrow();
                Debug.Assert(msagb.Height == msagb.PreferredHeight);
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, msagb);
            }
        }
Beispiel #5
0
        public void AdjustInternalControlsAndGrow()
        {
            int nHeightWanted = m_fwcbAffixTypes.PreferredHeight;
            int delta         = nHeightWanted - m_fwcbAffixTypes.Height;

            if (delta > 0)
            {
                this.Height            += delta;
                m_fwcbAffixTypes.Height = nHeightWanted;
                FontHeightAdjuster.GrowDialogAndAdjustControls(m_groupBox, delta, m_fwcbAffixTypes);
            }
            nHeightWanted = m_tcMainPOS.PreferredHeight;
            delta         = nHeightWanted - m_tcMainPOS.Height;
            if (delta > 0)
            {
                m_tcMainPOS.Height = nHeightWanted;
                this.Height       += delta;
                FontHeightAdjuster.GrowDialogAndAdjustControls(m_groupBox, delta, m_tcMainPOS);
            }
            int nWanted1 = m_fwcbSlots.PreferredHeight;
            int delta1   = nWanted1 - m_fwcbSlots.Height;
            int nWanted2 = m_tcSecondaryPOS.PreferredHeight;
            int delta2   = nWanted2 - m_tcSecondaryPOS.Height;

            delta = Math.Max(delta1, delta2);
            if (delta > 0)
            {
                if (delta1 > 0)
                {
                    m_fwcbSlots.Height = nWanted1;
                }
                if (delta2 > 0)
                {
                    m_tcSecondaryPOS.Height = nWanted2;
                }
                this.Height += delta;
                if (delta1 == delta)
                {
                    FontHeightAdjuster.GrowDialogAndAdjustControls(m_groupBox, delta, m_fwcbSlots);
                }
                else
                {
                    FontHeightAdjuster.GrowDialogAndAdjustControls(m_groupBox, delta, m_tcSecondaryPOS);
                }
            }
        }
Beispiel #6
0
        private LabeledMultiStringControl ReplaceTextBoxWithMultiStringBox(TextBox tb,
                                                                           IVwStylesheet stylesheet)
        {
            Debug.Assert(Cache != null, "Need a cache to setup a MultiStringBox.");
            tb.Hide();
            if (m_uiWss.Count == 0)
            {
                return(null);
            }
            var ms = new LabeledMultiStringControl(Cache, m_uiWss, stylesheet);

            ms.Location       = tb.Location;
            ms.Width          = tb.Width;
            ms.Anchor         = tb.Anchor;
            ms.AccessibleName = tb.AccessibleName;

            // Grow the dialog and move all lower controls down to make room.
            Controls.Remove(tb);
            ms.TabIndex = tb.TabIndex;                  // assume the same tab order as the 'designed' control
            Controls.Add(ms);
            FontHeightAdjuster.GrowDialogAndAdjustControls(this, ms.Height - tb.Height, ms);
            return(ms);
        }
Beispiel #7
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;
                }
            }
        }
        public void SetDlgInfo(Mediator mediator, WindowParams wp, List <IReversalIndexEntry> filteredEntries)
        {
            CheckDisposed();

            Debug.Assert(filteredEntries != null && filteredEntries.Count > 0);

            m_mediator    = mediator;
            m_cache       = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            m_ws          = (filteredEntries[0] as ReversalIndexEntry).ReversalIndex.WritingSystemRAHvo;
            m_owningIndex = (filteredEntries[0] as ReversalIndexEntry).Owner;
            // Don't bother filtering out the current entry -- we don't do it for lex entries, why
            // do it here? (SFM 4/23/2009 Why? because it causes a crash, so uncommented)
            foreach (IReversalIndexEntry rie in filteredEntries)
            {
                ExtantReversalIndexEntryInfo eriei = new ExtantReversalIndexEntryInfo();
                eriei.ID = rie.Hvo;
                m_filteredEntries.Add(eriei);
            }
            // End SFM edit

            btnOK.Text  = wp.m_btnText;
            Text        = wp.m_title;
            label1.Text = wp.m_label;

            m_tbForm.Font = new Font(
                m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_ws).DefaultSerif,
                10);
            m_tbForm.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_tbForm.StyleSheet           = FontHeightAdjuster.StyleSheetFromMediator(mediator);
            m_tbForm.WritingSystemCode    = m_ws;
            m_tbForm.AdjustStringHeight   = false;
            m_tsf                 = TsStrFactoryClass.Create();
            m_tbForm.Tss          = m_tsf.MakeString("", m_ws);
            m_tbForm.TextChanged += new EventHandler(m_tbForm_TextChanged);

            btnInsert.Visible = false;
            btnHelp.Visible   = true;

            switch (Text)
            {
            case "Find Reversal Entry":
                m_helpTopic = "khtpFindReversalEntry";
                break;

            case "Move Reversal Entry":
                m_helpTopic = "khtpMoveReversalEntry";
                break;
            }
            if (m_helpTopic != null && FwApp.App != null)            // FwApp.App could be null during tests
            {
                this.helpProvider = new System.Windows.Forms.HelpProvider();
                this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
                this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(m_helpTopic, 0));
                this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
            }
            Debug.Assert(m_mediator != null);
            ReplaceMatchingItemsControl();

            // Adjust things if the form box needs to grow to accommodate its style.
            int oldHeight = m_tbForm.Height;
            int newHeight = Math.Max(oldHeight, m_tbForm.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta != 0)
            {
                m_tbForm.Height = newHeight;
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_tbForm);
            }
        }
Beispiel #9
0
        private void SetBottomMessage()
        {
            int    userWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;
            string sBase;

            if (m_obj != null && m_obj.Hvo > 0)
            {
                sBase = FdoUiStrings.ksMergeXIntoY;
            }
            else
            {
                sBase = FdoUiStrings.ksMergeXIntoSelection;
            }
            ITsStrBldr tsb = TsStringUtils.MakeStrBldr();

            tsb.ReplaceTsString(0, tsb.Length, TsStringUtils.MakeString(sBase, userWs));
            // Replace every "{0}" with the headword we'll be merging, and make it bold.
            ITsString tssFrom = TsStringUtils.MakeString(m_mainObj.ToString(), m_mainObj.WS);
            string    sTmp    = tsb.Text;
            int       ich     = sTmp.IndexOf("{0}", StringComparison.Ordinal);
            int       cch     = tssFrom.Length;

            while (ich >= 0 && cch > 0)
            {
                tsb.ReplaceTsString(ich, ich + 3, tssFrom);
                tsb.SetIntPropValues(ich, ich + cch,
                                     (int)FwTextPropType.ktptBold,
                                     (int)FwTextPropVar.ktpvEnum,
                                     (int)FwTextToggleVal.kttvForceOn);
                sTmp = tsb.Text;
                ich  = sTmp.IndexOf("{0}", StringComparison.Ordinal);                   // in case localization needs more than one.
            }
            int cLines = 1;

            if (m_obj != null && m_obj.Hvo > 0)
            {
                // Replace every "{1}" with the headword we'll be merging into.
                ITsString tssTo = TsStringUtils.MakeString(m_obj.ToString(), m_obj.WS);
                ich = sTmp.IndexOf("{1}", StringComparison.Ordinal);
                cch = tssTo.Length;
                while (ich >= 0 && cch > 0)
                {
                    tsb.ReplaceTsString(ich, ich + 3, tssTo);
                    tsb.SetIntPropValues(ich, ich + cch,
                                         (int)FwTextPropType.ktptBold,
                                         (int)FwTextPropVar.ktpvEnum,
                                         (int)FwTextToggleVal.kttvForceOn);
                    sTmp = tsb.Text;
                    ich  = sTmp.IndexOf("{1}", StringComparison.Ordinal);
                }
                // Replace every "{2}" with a newline character.
                ich = sTmp.IndexOf("{2}", StringComparison.Ordinal);
                while (ich >= 0)
                {
                    tsb.ReplaceTsString(ich, ich + 3, TsStringUtils.MakeString(StringUtils.kChHardLB.ToString(), userWs));
                    sTmp = tsb.Text;
                    ich  = sTmp.IndexOf("{2}", StringComparison.Ordinal);
                    ++cLines;
                }
            }
            else
            {
                // Replace every "{1}" with a newline character.
                ich = sTmp.IndexOf("{1}", StringComparison.Ordinal);
                while (ich >= 0)
                {
                    tsb.ReplaceTsString(ich, ich + 3, TsStringUtils.MakeString(StringUtils.kChHardLB.ToString(), userWs));
                    sTmp = tsb.Text;
                    ich  = sTmp.IndexOf("{1}", StringComparison.Ordinal);
                    ++cLines;
                }
            }
            m_fwTextBoxBottomMsg.Tss = tsb.GetString();
            int oldHeight = m_fwTextBoxBottomMsg.Height;
            int newHeight = m_fwTextBoxBottomMsg.PreferredHeight;

            // Having newlines in the middle of the string messes up the height calculation.
            // See FWR-2308.  The adjustment may not be perfect, but is better than just showing
            // the text before the first newline.
            if (newHeight < 30)
            {
                newHeight *= cLines;
            }
            if (newHeight != m_fwTextBoxBottomMsg.Height)
            {
                int delta = newHeight - oldHeight;
                Size = MinimumSize;
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_fwTextBoxBottomMsg);
                m_fwTextBoxBottomMsg.Height = newHeight;
            }
        }