/// <summary>
        ///
        /// </summary>
        /// <param name="posList"></param>
        /// <param name="mediator"></param>
        /// <param name="launchedFromInsertMenu"></param>
        /// <param name="subItemOwner"></param>
        public void SetDlginfo(ICmPossibilityList posList, Mediator mediator, bool launchedFromInsertMenu, IPartOfSpeech subItemOwner)
        {
            CheckDisposed();

            m_subItemOwner           = subItemOwner;   // May be null, which is fine.
            m_posList                = posList;
            m_launchedFromInsertMenu = launchedFromInsertMenu;
            m_mediator               = mediator;
            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("masterCatListDlgLocation");
                object szWnd  = m_mediator.PropertyTable.GetValue("masterCatListDlgSize");
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
            Debug.Assert(posList != null);
            m_cache = posList.Cache;
            LoadMasterCategories(posList.ReallyReallyAllPossibilities);
        }
Exemple #2
0
        public DictionaryConfigurationDlg(Mediator mediator)
        {
            m_mediator = mediator;
            InitializeComponent();

            m_preview.Dock     = DockStyle.Fill;
            m_preview.Location = new Point(0, 0);
            previewDetailSplit.Panel1.Controls.Add(m_preview);
            manageConfigs_treeDetailButton_split.IsSplitterFixed = true;
            treeDetail_Button_Split.IsSplitterFixed = true;
            this.MinimumSize = new Size(m_grpConfigurationManagement.Width + 3, manageConfigs_treeDetailButton_split.Height);

            m_helpTopicProvider = mediator.HelpTopicProvider;
            m_helpProvider      = new HelpProvider {
                HelpNamespace = m_helpTopicProvider.HelpFile
            };
            m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(HelpTopic));
            m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            m_helpProvider.SetShowHelp(this, true);

            // Restore the location and size from last time we called this dialog.
            if (m_mediator != null && m_mediator.PropertyTable != null)
            {
                object locWnd = m_mediator.PropertyTable.GetValue("DictionaryConfigurationDlg_Location");
                object szWnd  = m_mediator.PropertyTable.GetValue("DictionaryConfigurationDlg_Size");
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
        }
Exemple #3
0
        ///***********************************************************************************
        /// <summary>
        /// Load the top, left, width, and height of the window from the registry, use default
        /// application parameters if not present in registry. This should be called from
        /// OnLayout; it takes effect in the first call AFTER EndInit.
        /// </summary>
        ///***********************************************************************************
        public void LoadWindowPosition()
        {
            if (m_fInInit)
            {
                return;
            }
            if (m_fHaveLoadedPosition)
            {
                return;
            }
            m_fHaveLoadedPosition = true;
            CheckDisposed();

            RegistryKey key = SettingsKey;

            int iLeft = (int)key.GetValue(Parent.GetType().Name + "Left", (Parent is Form ?
                                                                           ((Form)Parent).DesktopBounds.Left : Parent.Left));

            int iTop = (int)key.GetValue(Parent.GetType().Name + "Top", (Parent is Form ?
                                                                         ((Form)Parent).DesktopBounds.Top : Parent.Top));

            int iWidth = (int)key.GetValue(Parent.GetType().Name + "Width", (Parent is Form ?
                                                                             ((Form)Parent).DesktopBounds.Width : Parent.Width));

            int iHeight = (int)key.GetValue(Parent.GetType().Name + "Height", (Parent is Form ?
                                                                               ((Form)Parent).DesktopBounds.Height : Parent.Height));

            Rectangle rect = new Rectangle(iLeft, iTop, iWidth, iHeight);

            if (Parent is Form)
            {
                Form parent = Parent as Form;
                ScreenUtils.EnsureVisibleRect(ref rect);
                if (rect != parent.DesktopBounds)
                {
                    // this means we loaded values from the registry - or the form is to big
                    parent.StartPosition = FormStartPosition.Manual;
                }
                parent.DesktopLocation = new Point(rect.X, rect.Y);

                // we can't set the width and height on the form yet - if we do it won't
                // resize our child controls
                m_normalLeft       = rect.X;
                m_normalTop        = rect.Y;
                parent.Width       = m_normalWidth = rect.Width;
                parent.Height      = m_normalHeight = rect.Height;
                parent.WindowState = (FormWindowState)SettingsKey.GetValue(
                    parent.GetType().Name + sWindowState, parent.WindowState);
            }
            else
            {
                // Set parent dimensions based upon possible adjustments in EnsureVisibleRect
                Parent.Top    = rect.Top;
                Parent.Left   = rect.Left;
                Parent.Width  = rect.Width;
                Parent.Height = rect.Height;
            }
        }
        public UploadToWebonaryDlg(UploadToWebonaryController controller, UploadToWebonaryModel model, Mediator mediator)
        {
            InitializeComponent();

            if (MiscUtils.IsUnix)
            {
                MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height + m_additionalMinimumHeightForMono);
            }

            m_controller = controller;
            Mediator     = mediator;
            Model        = model;
            LoadFromModel();

            m_helpTopicProvider = mediator.HelpTopicProvider;

            // When a link is clicked, open a web page to the URL.
            explanationLabel.LinkClicked += (sender, args) =>
            {
                using (Process.Start(((LinkLabel)sender).Text.Substring(args.Link.Start, args.Link.Length)))
                {}
            };

            // Restore the location and size from last time we called this dialog.
            if (Mediator != null && Mediator.PropertyTable != null)
            {
                object locWnd = Mediator.PropertyTable.GetValue("UploadToWebonaryDlg_Location");
                object szWnd  = Mediator.PropertyTable.GetValue("UploadToWebonaryDlg_Size");
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }

            // Start with output log area not shown by default
            // When a user clicks Publish, it is revealed. This is done within the context of having a resizable table of controls, and having
            // the output log area be the vertically growing control when a user increases the height of the dialog
            this.Shown += (sender, args) => { this.Height = this.Height - outputLogTextbox.Height; };

            // Handle localizable explanation area with link.
            var explanationText           = xWorksStrings.toApplyForWebonaryAccountExplanation;
            var explanationTextLink       = xWorksStrings.toApplyForWebonaryAccountLink;
            var explanationTextLinkStart  = explanationText.IndexOf("{", StringComparison.Ordinal);
            var explanationTextLinkLength = explanationTextLink.Length;

            explanationLabel.Text = string.Format(explanationText, explanationTextLink);
            // Don't blow up if a localization didn't allow for the link.
            if (explanationTextLinkStart < 0)
            {
                explanationTextLinkStart  = 0;
                explanationTextLinkLength = 0;
            }
            explanationLabel.LinkArea = new LinkArea(explanationTextLinkStart, explanationTextLinkLength);
        }
        /// <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);
            }
        }
Exemple #6
0
        /// <summary>
        /// Set up the dlg in preparation to showing it.
        /// </summary>
        /// <param name="cache">FDO cache.</param>
        /// <param name="wp">Strings used for various items in this dialog.</param>
        public void SetDlgInfo(FdoCache cache, Mediator mediator, WindowParams wp, DummyCmObject mainObj, List <DummyCmObject> mergeCandidates,
                               string guiControl, string helpTopic)
        {
            CheckDisposed();

            Debug.Assert(cache != null);

            m_mediator = mediator;
            m_cache    = cache;
            m_mainObj  = mainObj;
            m_tsf      = TsStrFactoryClass.Create();

            m_fwTextBoxBottomMsg.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_fwTextBoxBottomMsg.WritingSystemCode    = m_cache.LangProject.DefaultUserWritingSystem;

            InitBrowseView(guiControl, mergeCandidates);

            // Get location to the stored values, if any.
            object locWnd = m_mediator.PropertyTable.GetValue("mergeDlgLocation");
            // 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");
            // 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;
            }

            Text        = wp.m_title;
            label2.Text = wp.m_label;

            m_helpTopic = helpTopic;

            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);
            }
        }
        private void ResetWindowLocationAndSize()
        {
            // Get location to the stored values, if any.
            object locWnd = m_mediator.PropertyTable.GetValue(m_sWindowKeyLocation);
            object szWnd  = m_mediator.PropertyTable.GetValue(m_sWindowKeySize);

            if (locWnd != null && szWnd != null)
            {
                Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                ScreenUtils.EnsureVisibleRect(ref rect);
                DesktopBounds = rect;
                StartPosition = FormStartPosition.Manual;
            }
        }
Exemple #8
0
 private void RestoreWindowPosition(XCore.Mediator mediator)
 {
     m_mediator = mediator;
     if (mediator != null)
     {
         // Reset window location.
         // Get location to the stored values, if any.
         object locWnd = m_mediator.PropertyTable.GetValue("phonFeatListDlgLocation");
         object szWnd  = m_mediator.PropertyTable.GetValue("phonFeatListDlgSize");
         if (locWnd != null && szWnd != null)
         {
             Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
             ScreenUtils.EnsureVisibleRect(ref rect);
             DesktopBounds = rect;
             StartPosition = FormStartPosition.Manual;
         }
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="posList"></param>
        /// <param name="mediator"></param>
        /// <param name="launchedFromInsertMenu"></param>
        /// <param name="subItemOwner"></param>
        public void SetDlginfo(ICmPossibilityList posList, Mediator mediator, bool launchedFromInsertMenu, IPartOfSpeech subItemOwner)
        {
            CheckDisposed();

            m_subItemOwner           = subItemOwner;   // May be null, which is fine.
            m_posList                = posList;
            m_launchedFromInsertMenu = launchedFromInsertMenu;
            m_mediator               = mediator;
            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("masterCatListDlgLocation");
                object szWnd  = m_mediator.PropertyTable.GetValue("masterCatListDlgSize");
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
                m_helpTopicProvider = m_mediator.HelpTopicProvider;
                if (m_helpTopicProvider != null)
                {
                    helpProvider = new HelpProvider();
                    helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                    helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                    helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
                }
            }
            m_bnHelp.Enabled = (m_helpTopicProvider != null);

            Debug.Assert(posList != null);
            m_cache = posList.Cache;
            var posSet = new Set <IPartOfSpeech>();

            foreach (IPartOfSpeech pos in posList.ReallyReallyAllPossibilities)
            {
                posSet.Add(pos);
            }
            LoadMasterCategories(posSet);
        }
        private void MoveWindowToPreviousPosition()
        {
            // Get location to the stored values, if any.
            object locWnd = m_mediator.PropertyTable.GetValue("mergeDlgLocation");
            // 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 = Size;

            if (locWnd != null && szWnd != null)
            {
                Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                ScreenUtils.EnsureVisibleRect(ref rect);
                DesktopBounds = rect;
                StartPosition = FormStartPosition.Manual;
            }
        }
Exemple #11
0
        public void RestoreWindowSettings(string id, System.Windows.Forms.Form form)
        {
            object state = Get(id, "windowState");

            //don't bother restoring the program to the minimized state.
            if (state != null && ((System.Windows.Forms.FormWindowState)state) !=
                System.Windows.Forms.FormWindowState.Minimized)
            {
                form.WindowState = (System.Windows.Forms.FormWindowState)state;
            }

            object location = Get(id, "windowLocation");
            object size     = Get(id, "windowSize");

            if (location != null)
            {
                form.Location = (System.Drawing.Point)location;
                // The location restoration only works if the window startposition is set to
                // "manual" because the window is not visible yet, and the location will be
                // changed when it is Show()n.
                form.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
            }
            if (size != null)
            {
                form.Size = (System.Drawing.Size)size;
            }

            // Fix the stored position in case it is off the screen.  This can happen if the
            // user has removed a second monitor, or changed the screen resolution downward,
            // since the last time he ran the program.  (See LT-1078.)
            Rectangle rcNewWnd = form.DesktopBounds;

//			Rectangle rcScrn = System.Windows.Forms.Screen.FromRectangle(rcNewWnd).WorkingArea;
            ScreenUtils.EnsureVisibleRect(ref rcNewWnd);
            form.DesktopBounds = rcNewWnd;
        }
Exemple #12
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;
                }
            }
        }
Exemple #13
0
        protected virtual void SetDlgInfo(FdoCache cache, WindowParams wp, Mediator mediator, int ws)
        {
            CheckDisposed();

            Debug.Assert(cache != null);
            m_cache = cache;
            m_tsf   = cache.TsStrFactory;           // do this very early, other initializers may depend on it.

            m_mediator = mediator;

            if (m_mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgLocation");
                object szWnd  = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgSize");
                if (locWnd != null && szWnd != null)
                {
                    var rect = new Rectangle((Point)locWnd, (Size)szWnd);

                    //grow it if it's too small.  This will happen when we add new controls to the dialog box.
                    if (rect.Width < m_btnHelp.Left + m_btnHelp.Width + 30)
                    {
                        rect.Width = m_btnHelp.Left + m_btnHelp.Width + 30;
                    }

                    if (rect.Height < m_btnHelp.Top + m_btnHelp.Height + 50)
                    {
                        rect.Height = m_btnHelp.Top + m_btnHelp.Height + 50;
                    }

                    //rect.Height = 600;

                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }

                m_helpTopicProvider = m_mediator.HelpTopicProvider;
                if (m_helpTopicProvider != null)
                {
                    m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                    SetHelpButtonEnabled();
                }
            }

            SetupBasicTextProperties(wp);

            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            InitializeMatchingObjects(cache, mediator);
            // Set font, writing system factory, and writing system code for the Lexical Form
            // edit box.  Also set an empty string with the proper writing system.
            m_tbForm.Font = new Font(cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName, 10);
            m_tbForm.WritingSystemFactory = cache.WritingSystemFactory;
            m_tbForm.WritingSystemCode    = ws;
            m_tbForm.AdjustStringHeight   = false;
            m_tbForm.Tss        = m_tsf.MakeString("", ws);
            m_tbForm.StyleSheet = stylesheet;

            // Setup the fancy message text box.
            // Note: at 120DPI (only), it seems to be essential to set at least the WSF of the
            // bottom message even if not using it.
            SetupBottomMsg();
            SetBottomMessage();
            m_fwTextBoxBottomMsg.BorderStyle = BorderStyle.None;

            m_analHvos.UnionWith(cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Select(wsObj => wsObj.Handle));
            List <int> vernList = cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Select(wsObj => wsObj.Handle).ToList();

            m_vernHvos.UnionWith(vernList);
            LoadWritingSystemCombo();
            int            iWs = vernList.IndexOf(ws);
            IWritingSystem currentWs;

            if (iWs < 0)
            {
                List <int> analList = cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Select(wsObj => wsObj.Handle).ToList();
                iWs = analList.IndexOf(ws);
                if (iWs < 0)
                {
                    currentWs = cache.ServiceLocator.WritingSystemManager.Get(ws);
                    m_cbWritingSystems.Items.Add(currentWs);
                    SetCbWritingSystemsSize();
                }
                else
                {
                    currentWs = cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems[iWs];
                }
            }
            else
            {
                currentWs = cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems[iWs];
            }
            Debug.Assert(currentWs != null && currentWs.Handle == ws);

            m_skipCheck = true;
            m_cbWritingSystems.SelectedItem = currentWs;
            m_skipCheck = false;
            // Don't hook this up until AFTER we've initialized it; otherwise, it can
            // modify the contents of the form as a side effect of initialization.
            // Also, doing that triggers laying out the dialog prematurely, before
            // we've set WSF on all the controls.
            m_cbWritingSystems.SelectedIndexChanged += m_cbWritingSystems_SelectedIndexChanged;


            // 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;
                m_panel1.Height += delta;
                GrowDialogAndAdjustControls(delta, m_panel1);
            }
        }