コード例 #1
0
ファイル: Hints.cs プロジェクト: WendyH/HMSEditor
        private void LayoutHint(Hint hint)
        {
            if (hint.Inline || hint.Range.Start.iLine >= tb.LinesCount - 1)
            {
                if (hint.Range.Start.iLine < tb.LineInfos.Count - 1)
                {
                    hint.HostPanel.Top = tb.LineInfos[hint.Range.Start.iLine + 1].startY - hint.TopPadding - hint.HostPanel.Height - tb.VerticalScroll.Value;
                }
                else
                {
                    hint.HostPanel.Top = tb.TextHeight + tb.Paddings.Top - hint.HostPanel.Height - tb.VerticalScroll.Value;
                }
            }
            else
            {
                hint.HostPanel.Top = tb.LineInfos[hint.Range.Start.iLine + 1].startY - tb.VerticalScroll.Value;
            }

            if (hint.Dock == DockStyle.Fill)
            {
                hint.Width          = tb.ClientSize.Width - tb.LeftIndent - 2;
                hint.HostPanel.Left = tb.LeftIndent;
            }
            else
            {
                var p1 = tb.PlaceToPoint(hint.Range.Start);
                var p2 = tb.PlaceToPoint(hint.Range.End);
                var cx = (p1.X + p2.X) / 2;
                hint.HostPanel.Left = Math.Max(tb.LeftIndent, cx - hint.HostPanel.Width / 2);
            }
        }
コード例 #2
0
ファイル: Hints.cs プロジェクト: mainframe-projects/Canal
        private void LayoutHint(Hint hint)
        {
            if (hint.Inline)
            {
                if (hint.Range.Start.iLine < tb.LineInfos.Count - 1)
                {
                    hint.HostPanel.Top = tb.LineInfos[hint.Range.Start.iLine + 1].startY - hint.TopPadding - hint.HostPanel.Height - tb.VerticalScroll.Value;
                }
                else
                {
                    hint.HostPanel.Top = tb.TextHeight + tb.Paddings.Top - hint.HostPanel.Height - tb.VerticalScroll.Value;
                }
            }
            else
            {
                if (hint.Range.Start.iLine > tb.LinesCount - 1)
                {
                    return;
                }
                if (hint.Range.Start.iLine == tb.LinesCount - 1)
                {
                    var y = tb.LineInfos[hint.Range.Start.iLine].startY - tb.VerticalScroll.Value + tb.CharHeight;

                    if (y + hint.HostPanel.Height + 1 > tb.ClientRectangle.Bottom)
                    {
                        hint.HostPanel.Top = Math.Max(0, tb.LineInfos[hint.Range.Start.iLine].startY - tb.VerticalScroll.Value - hint.HostPanel.Height);
                    }
                    else
                    {
                        hint.HostPanel.Top = y;
                    }
                }
                else
                {
                    hint.HostPanel.Top = tb.LineInfos[hint.Range.Start.iLine + 1].startY - tb.VerticalScroll.Value;
                    if (hint.HostPanel.Bottom > tb.ClientRectangle.Bottom)
                    {
                        hint.HostPanel.Top = tb.LineInfos[hint.Range.Start.iLine + 1].startY - tb.CharHeight - hint.TopPadding - hint.HostPanel.Height - tb.VerticalScroll.Value;
                    }
                }
            }

            if (hint.Dock == DockStyle.Fill)
            {
                hint.Width          = tb.ClientSize.Width - tb.LeftIndent - 2;
                hint.HostPanel.Left = tb.LeftIndent;
            }
            else
            {
                var p1 = tb.PlaceToPoint(hint.Range.Start);
                var p2 = tb.PlaceToPoint(hint.Range.End);
                var cx = (p1.X + p2.X) / 2;
                var x  = cx - hint.HostPanel.Width / 2;
                hint.HostPanel.Left = Math.Max(tb.LeftIndent, x);
                if (hint.HostPanel.Right > tb.ClientSize.Width)
                {
                    hint.HostPanel.Left = Math.Max(tb.LeftIndent, x - (hint.HostPanel.Right - tb.ClientSize.Width));
                }
            }
        }
コード例 #3
0
        void DoAutocomplete(FastColoredTextBox tb)
        {
            visibleItems.Clear();
            selectedItemIndex    = 0;
            VerticalScroll.Value = 0;
            //get fragment around caret
            Range  fragment = tb.Selection.GetFragment(Menu.SearchPattern);
            string text     = fragment.Text;
            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            //
            if (text.Length >= Menu.MinFragmentLength && tb.Selection.Start == tb.Selection.End)
            {
                Menu.Fragment = fragment;
                bool foundSelected = false;
                //build popup menu
                foreach (var item in sourceItems)
                {
                    item.Parent = Menu;
                    CompareResult res = item.Compare(text);
                    if (res != CompareResult.Hidden)
                    {
                        visibleItems.Add(item);
                    }
                    if (res == CompareResult.VisibleAndSelected && !foundSelected)
                    {
                        foundSelected     = true;
                        selectedItemIndex = visibleItems.Count - 1;
                    }
                }

                if (foundSelected)
                {
                    AdjustScroll();
                    DoSelectedVisible();
                }
            }

            //show popup menu
            if (Count > 0)
            {
                if (!Menu.Visible)
                {
                    //prevSelection = tb.Selection.Start;
                    Menu.Show(tb, point);
                }
                else
                {
                    Invalidate();
                }
            }
            else
            {
                Menu.Close();
            }
        }
コード例 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (target == null)
            {
                return;
            }

            Point car = PointToClient(target.PointToScreen(target.PlaceToPoint(target.Selection.Start)));

            Size fontSize = TextRenderer.MeasureText("W", Font);

            int column = 0;

            e.Graphics.FillRectangle(new LinearGradientBrush(new Rectangle(0, 0, Width, Height), BackColor, BackColor2, 270), new Rectangle(0, 0, Width, Height));

            float columnWidth = target.CharWidth;
            var   sf          = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Near;

            var zeroPoint = target.PositionToPoint(0);

            zeroPoint = PointToClient(target.PointToScreen(zeroPoint));

            using (var pen = new Pen(TickColor))
                using (var textBrush = new SolidBrush(ForeColor))
                {
                    for (float x = zeroPoint.X; x < Right; x += columnWidth, ++column)
                    {
                        if (column % 10 == 0)
                        {
                            e.Graphics.DrawString(column.ToString(), Font, textBrush, x, 0f, sf);
                        }

                        e.Graphics.DrawLine(pen, (int)x, fontSize.Height + (column % 5 == 0 ? 1 : 3), (int)x, Height - 4);
                    }
                }

            using (var pen = new Pen(TickColor))
            {
                e.Graphics.DrawLine(pen, new Point(car.X - 3, Height - 3), new Point(car.X + 3, Height - 3));
            }

            using (var pen = new Pen(CaretTickColor))
            {
                e.Graphics.DrawLine(pen, new Point(car.X - 2, fontSize.Height + 3), new Point(car.X - 2, Height - 4));
                e.Graphics.DrawLine(pen, new Point(car.X, fontSize.Height + 1), new Point(car.X, Height - 4));
                e.Graphics.DrawLine(pen, new Point(car.X + 2, fontSize.Height + 3), new Point(car.X + 2, Height - 4));
            }
        }
コード例 #5
0
ファイル: DocumentMap.cs プロジェクト: Guido1234/CodeLibrary
        protected override void OnPaint(PaintEventArgs e)
        {
            if (target == null)
            {
                return;
            }

            var zoom = this.Scale * 100 / target.Zoom;

            if (zoom <= float.Epsilon)
            {
                return;
            }

            //calc startPlace
            var r = target.VisibleRange;

            if (startPlace.iLine > r.Start.iLine)
            {
                startPlace.iLine = r.Start.iLine;
            }
            else
            {
                var endP = target.PlaceToPoint(r.End);
                endP.Offset(0, -(int)(ClientSize.Height / zoom) + target.CharHeight);
                var pp = target.PointToPlace(endP);
                if (pp.iLine > startPlace.iLine)
                {
                    startPlace.iLine = pp.iLine;
                }
            }
            startPlace.iChar = 0;
            //calc scroll pos
            var linesCount = target.Lines.Count;
            var sp1        = (float)r.Start.iLine / linesCount;
            var sp2        = (float)r.End.iLine / linesCount;

            //scale graphics
            e.Graphics.ScaleTransform(zoom, zoom);
            //draw text
            var size = new SizeF(ClientSize.Width / zoom, ClientSize.Height / zoom);

            target.DrawText(e.Graphics, startPlace, size.ToSize());

            //draw visible rect
            var p0 = target.PlaceToPoint(startPlace);
            var p1 = target.PlaceToPoint(r.Start);
            var p2 = target.PlaceToPoint(r.End);
            var y1 = p1.Y - p0.Y;
            var y2 = p2.Y + target.CharHeight - p0.Y;

            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            using (var brush = new SolidBrush(Color.FromArgb(50, ForeColor)))
                using (var pen = new Pen(brush, 1 / zoom))
                {
                    var rect = new Rectangle(0, y1, (int)((ClientSize.Width - 1) / zoom), y2 - y1);
                    e.Graphics.FillRectangle(brush, rect);
                    e.Graphics.DrawRectangle(pen, rect);
                }

            //draw scrollbar
            if (scrollbarVisible)
            {
                e.Graphics.ResetTransform();
                e.Graphics.SmoothingMode = SmoothingMode.None;

                using (var brush = new SolidBrush(Color.FromArgb(200, ForeColor)))
                {
                    var rect = new RectangleF(ClientSize.Width - 3, ClientSize.Height * sp1, 2,
                                              ClientSize.Height * (sp2 - sp1));
                    e.Graphics.FillRectangle(brush, rect);
                }
            }

            needRepaint = false;
        }
コード例 #6
0
        // > By WendyH ------------------------------------------


        internal void DoAutocomplete(bool forced)
        {
            if (tb.IsDisposed)
            {
                return;
            }
            if (!Menu.Enabled || !this.Enabled)
            {
                Menu.Close(); return;
            }
            if (tb.CheckInTheStringOrComment())
            {
                return;
            }
            if (!forced && Menu.AfterComplete)
            {
                Menu.AfterComplete = false; return;
            }
            visibleItems.Clear();
            FocussedItemIndex    = 0;
            VerticalScroll.Value = 0;
            //some magic for update scrolls
            AutoScrollMinSize -= new Size(1, 0);
            AutoScrollMinSize += new Size(1, 0);
            //get fragment around caret

            //Range fragment = tb.Selection.GetFragment(Menu.SearchPattern);
            Range  fragment = tb.Selection.GetFragmentLookedLeft();
            string text     = fragment.Text;
            // < By WendyH ------------------------
            bool doNotGetFromSourceItems = false; bool showTypes = false;

            if (text.Length == 0)
            {
                if (tb.ToolTip4Function.Visible && (HMS.CurrentParamType.Length > 0))
                {
                    if (HMS.CurrentParamType == "boolean")
                    {
                        visibleItems.AddRange(HMS.ItemsBoolean); doNotGetFromSourceItems = true; Menu.Fragment = fragment;
                    }
                    else if (HMS.HmsTypes.ContainsName(HMS.CurrentParamType))
                    {
                        HMSClassInfo info = HMS.HmsTypes[HMS.CurrentParamType];
                        visibleItems.AddRange(info.MemberItems);
                        doNotGetFromSourceItems = true;
                        Menu.Fragment           = fragment;
                    }
                }
                else
                {
                    text = tb.Selection.GetVariableForEqual(Menu.SearchPattern);
                    if (text.Length > 0)
                    {
                        doNotGetFromSourceItems = true;
                        forced    = true;
                        showTypes = true;
                    }
                }
            }
            // > By WendyH ------------------------
            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            // By WendyH
            if (tb.ToolTip4Function.Visible)
            {
                Rectangle b = tb.ToolTip4Function.Bounds;
                point.Y += b.Height + 4;
            }
            //
            if (forced || (text.Length >= Menu.MinFragmentLength &&
                           tb.Selection.IsEmpty && /*pops up only if selected range is empty*/
                           (tb.Selection.Start > fragment.Start || text.Length == 0 /*pops up only if caret is after first letter*/)))
            {
                Menu.Fragment = fragment;
                bool foundSelected = false;
                //build popup menu
                // < By WendyH -------------------------------------
                string lastword = GetLastSelectedWord(text);
                if (showTypes)
                {
                    SetVisibleTypes(text);
                }
                else
                {
                    int indexDot = text.IndexOf(".");
                    if (indexDot > 0)
                    {
                        SetVisibleMethods(text);
                        doNotGetFromSourceItems = true;
                        Menu.Fragment.ShiftStart(text.LastIndexOf('.') + 1);
                    }
                    else
                    {
                        foundSelected = GetActiveLastwordInVisibleItems(text, lastword);
                    }
                }
                // > By WendyH -------------------------------------
                if (!doNotGetFromSourceItems)
                {
                    AutocompleteItems notExacctly = new AutocompleteItems();
                    foreach (var item in sourceItems)
                    {
                        item.Parent = Menu;
                        CompareResult res = item.Compare(text);
                        if (res != CompareResult.Hidden)
                        {
                            visibleItems.Add(item);
                        }
                        else if (item.NotExactlyCompare(text) == CompareResult.Visible)
                        {
                            notExacctly.Add(item);
                        }
                        if (lastword.Length > 0)
                        {
                            if (item.MenuText == lastword)
                            {
                                foundSelected     = true;
                                FocussedItemIndex = visibleItems.Count - 1;
                            }
                        }
                        else if (res == CompareResult.VisibleAndSelected && !foundSelected)
                        {
                            foundSelected     = true;
                            FocussedItemIndex = visibleItems.Count - 1;
                        }
                        if (visibleItems.Count > 150)
                        {
                            break;
                        }
                    }
                    visibleItems.AddRange(notExacctly);
                }

                if (foundSelected)
                {
                    AdjustScroll();
                    //DoSelectedVisible();
                }
            }
            if ((visibleItems.Count == 1) && (visibleItems[0].MenuText != null) && (visibleItems[0].MenuText.ToLower() == text.ToLower()))
            {
                return;
            }
            //show popup menu
            if (Count > 0)
            {
                if (!Menu.Visible)
                {
                    CancelEventArgs args = new CancelEventArgs();
                    //// By WendyH
                    //Point ps = tb.PointToScreen(point);
                    //if (ps.Y + Menu.Height + (tb.CharHeight * 3) > SystemInformation.VirtualScreen.Bottom) {
                    //	int size = Math.Min(MaximumSize.Height, ItemHeight * visibleItems.Count) + 5;
                    //	point.Y -= (size + tb.CharHeight);
                    //	Rectangle b = tb.ToolTip4Function.Bounds;
                    //	if (tb.ToolTip4Function.Active) point.Y -= (b.Height + 4);
                    //}
                    Menu.OnOpening(args);
                    if (!args.Cancel)
                    {
                        Menu.Show(tb, point);
                    }
                }
                else
                {
                    Invalidate();
                    DoSelectedVisible();
                }
            }
            else
            {
                Menu.Close();
            }
        }
コード例 #7
0
        internal void DoAutocomplete(bool forced)
        {
            if (!Menu.Enabled)
            {
                Menu.Close();
                return;
            }

            visibleItems.Clear();
            FocussedItemIndex    = 0;
            VerticalScroll.Value = 0;
            //get fragment around caret
            Range  fragment = tb.Selection.GetFragment(Menu.SearchPattern);
            string text     = fragment.Text;
            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            //
            if (forced || (text.Length >= Menu.MinFragmentLength &&
                           tb.Selection.IsEmpty    /*pops up only if selected range is empty*/
                           &&
                           (tb.Selection.Start > fragment.Start || text.Length == 0
                            /*pops up only if caret is after first letter*/)))
            {
                Menu.Fragment = fragment;
                bool foundSelected = false;
                //build popup menu
                foreach (var item in sourceItems)
                {
                    item.Parent = Menu;
                    CompareResult res = item.Compare(text);
                    if (res != CompareResult.Hidden)
                    {
                        visibleItems.Add(item);
                    }
                    if (res == CompareResult.VisibleAndSelected && !foundSelected)
                    {
                        foundSelected     = true;
                        FocussedItemIndex = visibleItems.Count - 1;
                    }
                }

                if (foundSelected)
                {
                    AdjustScroll();
                    DoSelectedVisible();
                }
            }

            //show popup menu
            if (Count > 0)
            {
                if (!Menu.Visible)
                {
                    CancelEventArgs args = new CancelEventArgs();
                    Menu.OnOpening(args);
                    if (!args.Cancel)
                    {
                        Menu.Show(tb, point);
                    }
                }
                else
                {
                    Invalidate();
                }
            }
            else
            {
                Menu.Close();
            }
        }
コード例 #8
0
        internal void DoAutocomplete(bool forced)
        {
            if (!Menu.Enabled)
            {
                Menu.Close();
                return;
            }

            visibleItems.Clear();
            FocussedItemIndex    = 0;
            VerticalScroll.Value = 0;
            //some magic for update scrolls
            AutoScrollMinSize -= new Size(1, 0);
            AutoScrollMinSize += new Size(1, 0);
            //get fragment around caret
            Range  fragment = tb.Selection.GetFragment(Menu.SearchPattern);
            string text     = fragment.Text;
            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            //
            if (forced || (text.Length >= Menu.MinFragmentLength &&
                           tb.Selection.IsEmpty && /*pops up only if selected range is empty*/
                           (tb.Selection.Start > fragment.Start || text.Length == 0 /*pops up only if caret is after first letter*/)))
            {
                Menu.Fragment = fragment;
                //bool foundSelected = false;
                AutocompleteItem foundItem = null;
                //build popup menu
                foreach (var item in sourceItems)
                {
                    item.Parent = Menu;
                    CompareResult res = item.Compare(text);
                    if (res != CompareResult.Hidden)
                    {
                        visibleItems.Add(item);
                    }

                    if (res == CompareResult.VisibleAndSelected && foundItem != null)
                    {
                        foundItem = item;
                        //FocussedItemIndex = visibleItems.Count - 1;
                    }
                }

                visibleItems.Sort((AutocompleteItem a, AutocompleteItem b) => {
                    var indexA = a.Text.IndexOf(text, StringComparison.InvariantCultureIgnoreCase);
                    var indexB = b.Text.IndexOf(text, StringComparison.InvariantCultureIgnoreCase);

                    if (indexA == indexB)
                    {
                        if (a.Text.Length == b.Text.Length)
                        {
                            return(string.Compare(a.Text, b.Text, true));
                        }

                        return(a.Text.Length - b.Text.Length);
                    }
                    else
                    {
                        if (indexA == -1)
                        {
                            return(1);
                        }

                        if (indexB == -1)
                        {
                            return(-1);
                        }
                    }

                    return(indexA - indexB);
                });

                if (foundItem != null)
                {
                    FocussedItemIndex = visibleItems.IndexOf(foundItem);

                    AdjustScroll();
                    DoSelectedVisible();
                }
            }

            //show popup menu
            if (Count > 0)
            {
                if (!Menu.Visible)
                {
                    CancelEventArgs args = new CancelEventArgs();
                    Menu.OnOpening(args);
                    if (!args.Cancel)
                    {
                        Menu.Show(tb, point);
                    }
                }

                DoSelectedVisible();
                Invalidate();
            }
            else
            {
                Menu.Close();
            }
        }
コード例 #9
0
        internal void DoAutocomplete(bool forced)
        {
            if (!this.Menu.Enabled)
            {
                this.Menu.Close();
                return;
            }

            visibleItems.Clear();
            this.FocussedItemIndex    = 0;
            this.VerticalScroll.Value = 0;
            //some magic for update scrolls
            this.AutoScrollMinSize -= new Size(1, 0);
            this.AutoScrollMinSize += new Size(1, 0);
            //get fragment around caret
            Range fragment      = tb.Selection.GetFragment(this.Menu.SearchPattern);
            var   line          = tb.GetLine(tb.Selection.FromLine).Text;
            var   column        = tb.Selection.Start.iChar;
            var   text          = fragment.Text;
            var   fragmentStart = fragment.Start.iChar;

            System.Diagnostics.Debug.WriteLine($"Autocomplete: \"{text}\", {fragmentStart}, \"{line}\", {column}");
            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            //
            if (forced || (text.Length >= this.Menu.MinFragmentLength &&
                           tb.Selection.IsEmpty && /*pops up only if selected range is empty*/
                           (tb.Selection.Start > fragment.Start || text.Length == 0 /*pops up only if caret is after first letter*/)))
            {
                //this.Menu.Fragment = fragment;
                //this.Menu.FragmentStart = fragmentStart;
                //this.Menu.EditLine = line;
                //this.Menu.CursorColumn = column;
                bool foundSelected = false;
                //build popup menu
                var items = new List <AutocompleteItem>();
                foreach (var creator in autocompleteCreators)
                {
                    foreach (var item in creator.CreateItems(tb.Selection.FromLine, tb.Selection.Start.iChar))
                    {
                        items.Add(item);
                    }
                }

                // Sorting: MatchWeight first. If MatchWeight is the same, compare the text.
                items.Sort((f, s) => (f.MatchWeight == s.MatchWeight) ? String.Compare(f.Text, s.Text) : ((f.MatchWeight < s.MatchWeight) ? -1 : 1));
                var maxItem = items.OrderByDescending(i => i.MatchWeight).FirstOrDefault();
                if (maxItem != null)
                {
                    foundSelected          = true;
                    this.FocussedItemIndex = items.IndexOf(maxItem);
                }
                visibleItems.AddRange(items);

                if (foundSelected)
                {
                    this.AdjustScroll();
                    this.DoSelectedVisible();
                }
            }

            //show popup menu
            if (this.Count > 0)
            {
                if (!this.Menu.Visible)
                {
                    CancelEventArgs args = new CancelEventArgs();
                    this.Menu.OnOpening(args);
                    if (!args.Cancel)
                    {
                        this.Menu.Show(tb, point);
                    }
                }

                this.DoSelectedVisible();
                this.Invalidate();
            }
            else
            {
                this.Menu.Close();
            }
        }
コード例 #10
0
        internal void DoAutocomplete(bool forced)
        {
            if (!Menu.Enabled)
            {
                Menu.Close();
                return;
            }

            visibleItems.Clear();
            FocussedItemIndex    = 0;
            VerticalScroll.Value = 0;
            //some magic for update scrolls
            AutoScrollMinSize -= new Size(1, 0);
            AutoScrollMinSize += new Size(1, 0);

            //get fragment around caret
            Range  fragment = tb.Selection.GetFragment(Menu.SearchPattern);
            string text     = fragment.Text;

            PrepareOpeningEventArgs args = new PrepareOpeningEventArgs(false, text, fragment.Start);

            Menu.OnPrepareOpening(args);
            if (args.Cancel)
            {
                Menu.Close();
                return;
            }


            //calc screen point for popup menu
            Point point = tb.PlaceToPoint(fragment.End);

            point.Offset(2, tb.CharHeight);
            //
            if (forced || (text.Length >= Menu.MinFragmentLength &&
                           tb.Selection.IsEmpty && /*pops up only if selected range is empty*/
                           (tb.Selection.Start > fragment.Start || text.Length == 0 /*pops up only if caret is after first letter*/)))
            {
                Menu.Fragment = fragment;
                bool foundSelected = false;
                //build popup menu
                foreach (var item in sourceItems)
                {
                    item.Parent = Menu;
                    CompareResult res = item.Compare(text);
                    if (res != CompareResult.Hidden)
                    {
                        visibleItems.Add(item);
                    }
                    if (res == CompareResult.VisibleAndSelected && !foundSelected)
                    {
                        foundSelected     = true;
                        FocussedItemIndex = visibleItems.Count - 1;
                    }
                }

                if (foundSelected)
                {
                    AdjustScroll();
                    DoSelectedVisible();
                }
                var sortingArgs = new PrepareSortingEventArgs(visibleItems, text);
                Menu.OnPrepareSorting(sortingArgs);
                visibleItems = sortingArgs.FilteredItems;
            }

            //show popup menu (only if at least one item that is not the already existing text)
            if ((Count > 1) ||
                ((Count == 1) &&
                 (visibleItems[0].Text.Length > text.Length)))
            {
                if (!Menu.Visible)
                {
                    CancelEventArgs args2 = new CancelEventArgs();
                    Menu.OnOpening(args2);
                    if (!args.Cancel)
                    {
                        Menu.Show(tb, point);
                    }
                }
                else
                {
                    Invalidate();
                }
            }
            else
            {
                Menu.Close();
            }
        }