コード例 #1
0
        private void keyHandler_AcceptAutoCompleteAdvice(object sender, EventArgs e)
        {
            if (AutoCompleteList.HasAdvice &&
                NeedCurrentToken != null)
            {
                int    currentCursorPos = SyntaxTextBox.SelectionStart;
                string advice           = AutoCompleteList.Advice;

                var currentTokenArgs = new NeedCurrentTokenEventArgs();
                NeedCurrentToken.Invoke(this, currentTokenArgs);

                int tokenStartPos = currentTokenArgs.Token.StartPos;

                if (currentTokenArgs.Token.Text != ".")
                {
                    SyntaxTextBox.SetTextWithoutEvents(SyntaxTextBox.Text.Substring(0, tokenStartPos) + advice);
                    SyntaxTextBox.SelectionLength = 0;
                    SyntaxTextBox.SelectionStart  = tokenStartPos + advice.Length;
                }
                else
                {
                    SyntaxTextBox.SetTextWithoutEvents(SyntaxTextBox.Text + advice);
                    SyntaxTextBox.SelectionLength = 0;
                    SyntaxTextBox.SelectionStart  = tokenStartPos + 1 + advice.Length;
                }
            }
        }
コード例 #2
0
        private void UpdateAutoCompleteList(ParseResult parseResult)
        {
            if (!AutoCompleteList.HasItems)
            {
                return;
            }

            var token            = parseResult.CurrentToken;
            int idxOfMatchingOne = FindBestMatchingItemIndex(token);

            AutoCompleteList.SelectIndex(idxOfMatchingOne);

            AutoCompleteList.UpperLeftCornerRelativeToToolTipParent = RelativeAutoCompleteListPos;
            AutoCompleteList.ShowAtPosition(AutoCompleteListPosition);
            SyntaxTextBox.Focus();
        }