示例#1
0
        private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
        {
            if (e.Text == string.Empty)
            {
                Point pointVirtual = editControl1.PointToVirtualPosition(new Point(e.X, e.Y));

                if (pointVirtual.Y > 0)
                {
                    // Get the current line
                    ILexemLine line = editControl1.GetLine(pointVirtual.Y);

                    if (line != null)
                    {
                        // Get tokens from the current line
                        ILexem lexem = line.FindLexemByColumn(pointVirtual.X);

                        if (lexem != null)
                        {
                            IConfigLexem configLexem = lexem.Config as IConfigLexem;
                            string       formatName  = configLexem.Format.Name;
                            e.Text = "This is a " + formatName + " : " + lexem.Text;
                        }
                    }
                }
            }
        }
示例#2
0
        // Ensure that the context choice popup is displayed if the invoking lexems are "this" or "me" only
        private void editControl1_ContextChoiceBeforeOpen(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ILexem     lex;
            ILexemLine lexemLine = this.editControl1.GetLine(this.editControl1.CurrentLine);

            //Gets the index of the current word in that line
            int ind = GetContextChoiceCharIndex(lexemLine);

            if (ind <= 0)
            {
                e.Cancel = true;
                return;
            }

            lex = lexemLine.LineLexems[ind - 1] as ILexem;

            // If the count is less than '2', do not show the ContextChoice popup
            if (lexemLine.LineLexems.Count < 2)
            {
                e.Cancel = true;
            }
            else
            {
                // Display ContextChoice popup if the lexem used to invoke them is "this" or "me" only
                if ((lex.Text == "this") || (lex.Text == "me"))
                {
                    e.Cancel = false;
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
示例#3
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];
                    }
                }
            }
        }
示例#4
0
        // Returns the last index of the context choice character - '.' in the current line
        private int GetContextChoiceCharIndex(ILexemLine line)
        {
            int lastPos = -1;

            for (int i = 0; i < line.LineLexems.Count; i++)
            {
                ILexem lex = line.LineLexems[i] as ILexem;

                if (lex.Text == ".")
                {
                    lastPos = i;
                }
            }

            return(lastPos);
        }
示例#5
0
        /// <summary>
        /// Looks for the first lexeme on the left with DropContextChoiceList set to true in config
        /// </summary>
        /// <returns></returns>
        private ILexem FindDropper()
        {
            ILexemLine line = editControl1.CurrentLineInstance;

            if (line == null)
            {
                return(null);
            }

            ILexem lexem = line.FindLexemByColumn(editControl1.CurrentColumn);

            if (lexem == null)
            {
                // If we are in the virtual space in the line.
                if (editControl1.CurrentColumn > 1)
                {
                    lexem = line.FindLexemByColumn(line.LineLength);
                }

                if (lexem == null)
                {
                    return(null);
                }
            }

            // If current lexem is dropper itself
            if (lexem.Config.DropContextChoiceList)
            {
                return(lexem);
            }

            int index = line.LineLexems.IndexOf(lexem);

            while (index > 0 && !lexem.Config.DropContextChoiceList)
            {
                lexem = line.LineLexems[--index] as ILexem;
            }

            if (index <= 0)
            {
                lexem = null;
            }

            return(lexem);
        }