예제 #1
0
        /// <summary>
        /// Gets context tooltip.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
        {
            // If the text is already specified, than we should not change it. This is needed to display default tooltip for the collapsed region.
            if (e.Text != string.Empty)
            {
                return;
            }

            // Convert position of the mouse cursor to the position in text.
            Point virt = editControl1.PointToVirtualPosition(new Point(e.X, e.Y), true);

            // If there is no text in tat position, tan exit.
            if (virt.IsEmpty == true)
            {
                return;
            }

            ILexemLine line = editControl1.GetLine(virt.Y);

            if (line != null)
            {
                // Get lexem under cursor.
                ILexem lexem = line.FindLexemByColumn(virt.X);

                if (lexem != null)
                {
                    // Set text of the tooltip.
                    e.Text = GetLexemInfo(lexem) + "\n";

                    // Get stack of the lexem.
                    ConfigStack stack = line.GetStackByColumn(virt.X);

                    if (stack != null)
                    {
                        e.Text += "Stack before parsing lexem:\n";

                        while (stack.Count > 0)
                        {
                            IStackData stackItem =
                                ( IStackData )stack.Pop();

                            if (stackItem.Lexem != null)
                            {
                                e.Text += "-- " + GetLexemInfo(stackItem.Lexem) + "\n";
                            }
                        }

                        e.Text += "\n";
                    }

                    // Add description if present.
                    if (m_MethodComments.Contains(lexem.Config.ID))
                    {
                        e.Text += "Lexem contains description:\n";
                        e.Text += m_MethodComments[lexem.Config.ID];
                    }
                }
            }
        }