Exemplo n.º 1
0
        /// <summary>
        /// Display the combo box at the specified location, or the list box pulled down from the specified location.
        /// </summary>
        /// <param name="loc"></param>
        public void Activate(Rect loc)
        {
            CheckDisposed();

            FwComboBox combo = m_combo as FwComboBox;

            if (combo != null)
            {
                combo.Location = new System.Drawing.Point(loc.left, loc.top);
                // 21 is the default height of a combo, the smallest reasonable size.
                combo.Size = new System.Drawing.Size(Math.Max(loc.right - loc.left + 30, 200), Math.Max(loc.bottom - loc.top, 50));
                if (!m_owner.Controls.Contains(combo))
                {
                    m_owner.Controls.Add(combo);
                }
            }
            else
            {
                ComboListBox c = (m_combo as ComboListBox);
                c.AdjustSize(500, 400);                 // these are maximums!
                c.LaunchingForm = m_owner.ParentForm;
                c.FormHidden   += ComboListHidden;
                c.Launch(m_owner.RectangleToScreen(loc), Screen.GetWorkingArea(m_owner));
            }
        }
Exemplo n.º 2
0
        private void LaunchFwContextMenu(Point ptLoc)
        {
            if (m_rgfmi == null || m_rgfmi.Count == 0)
            {
                return;
            }
            m_fConstructingMenu = true;
            if (m_clb == null)
            {
                m_clb = new ComboListBox();
                m_clb.SelectedIndexChanged += new EventHandler(HandleFwMenuSelection);
                m_clb.SameItemSelected     += new EventHandler(HandleFwMenuSelection);
                // Since we may initialize with TsStrings, need to set WSF.
                m_clb.WritingSystemFactory = Cache.LanguageWritingSystemFactoryAccessor;
                m_clb.DropDownStyle        = ComboBoxStyle.DropDownList;          // Prevents direct editing.
                m_clb.StyleSheet           = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);
            }
            m_clb.Items.Clear();
            for (int i = 0; i < m_rgfmi.Count; ++i)
            {
                if (m_rgfmi[i].Enabled)
                {
                    m_clb.Items.Add(m_rgfmi[i].Label);
                }
            }
            AdjustListBoxSize();
            m_clb.AdjustSize(500, 400);             // these are maximums!
            m_clb.SelectedIndex = 0;
            Rectangle boundsLauncher = new Rectangle(ptLoc, new Size(10, 10));
            Rectangle boundsScreen   = Screen.GetWorkingArea(m_inflAffixTemplateCtrl);

            m_fConstructingMenu = false;
            m_clb.Launch(boundsLauncher, boundsScreen);
        }
Exemplo n.º 3
0
        private bool PerformUpdate(object param)
        {
            CreateSearcher();
            try
            {
                m_changingSelection = true;
                try
                {
                    m_listBox.BeginUpdate();
                    m_listBox.Items.Clear();
                    // TODO: sort the results
                    foreach (ICmPossibility poss in m_searcher.Search(0, (ITsString)param))
                    {
                        // Every so often see whether the user has typed something that makes our search irrelevant.
                        if (ShouldAbort())
                        {
                            return(false);
                        }

                        var autoCompleteItem = ObjectLabel.CreateObjectLabel(m_cache, poss, m_displayNameProperty, m_displayWs);
                        if (m_listBox.Items.OfType <ObjectLabel>().All(item => !ReferenceEquals(item.Object, autoCompleteItem.Object)))
                        {
                            m_listBox.Items.Add(autoCompleteItem);
                        }
                    }
                }
                finally
                {
                    m_listBox.EndUpdate();
                }

                if (m_listBox.Items.Count > 0)
                {
                    m_listBox.AdjustSize(500, 400);
                    m_listBox.SelectedIndex = 0;
                    m_listBox.Launch(m_control.RectangleToScreen(m_control.Bounds), Screen.GetWorkingArea(m_control));
                }
                else
                {
                    m_listBox.HideForm();
                }
            }
            finally
            {
                m_changingSelection = false;
            }
            return(true);
        }