AdjustForStyleSheet() public method

Assumes the control is part of a form and should use a stylesheet. This becomes the stylesheet of the text box. If, as a result, the preferred height of this becomes greater than its actual height, the height of this is adjusted to suit. In addition, if grower is not null (grower is typically a containing panel), the height of grower is increased by the same amount. Also, the height of the indicated form is increased, and any top level controls which need it are adjusted appropriately.
public AdjustForStyleSheet ( Form parent, Control grower, IVwStylesheet stylesheet ) : void
parent System.Windows.Forms.Form The parent.
grower System.Windows.Forms.Control The grower.
stylesheet IVwStylesheet The stylesheet.
return void
Esempio n. 1
0
 private void SetFontInfo()
 {
     // Set writing system factory and code for the two edit boxes.
     m_tbWordForm.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
     m_tbWordForm.WritingSystemCode    = m_cache.LangProject.DefaultVernacularWritingSystem;
     m_tbWordForm.Text = "";
     m_tbWordForm.AdjustForStyleSheet(this, m_pnlWord, m_mediator);
 }
 private void SetupAndShowHeaderPanel(XmlNode node, RecordBar treeBarControl)
 {
     if (!treeBarControl.HasHeaderControl)
     {
         m_titleBar = new PaneBar { Dock = DockStyle.Top };
         var headerPanel = new Panel { Visible = false };
         headerPanel.Controls.Add(m_titleBar);
         m_btnCancelSearch = new FwCancelSearchButton();
         m_btnCancelSearch.Init();
         m_btnCancelSearch.Click += m_btnCancelSearch_Click;
         headerPanel.Controls.Add(m_btnCancelSearch);
         m_textSearch = CreateSearchBox();
         m_textSearch.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
         headerPanel.Controls.Add(m_textSearch);
         m_textSearch.AdjustForStyleSheet(m_stylesheet);
         headerPanel.Height = SetHeaderPanelHeight();
         treeBarControl.AddHeaderControl(headerPanel);
         // Keep the text box from covering the cancel search button
         m_textSearch.Width = headerPanel.Width - m_btnCancelSearch.Width;
         m_btnCancelSearch.Location = new Point(headerPanel.Width - m_btnCancelSearch.Width, m_textSearch.Location.Y);
         SetInfoBarText(node, m_titleBar);
     }
     treeBarControl.ShowHeaderControl();
 }
Esempio n. 3
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;
                }
            }
        }