Exemplo n.º 1
0
        /// <summary>
        /// Constructor. Requires a reference to the view holding the text editor.
        /// </summary>
        /// <param name="textEditor">Reference to the view holding the text editor. Cannot be null.</param>
        public IntellisensePresenter(ViewBase textEditor)
        {
            if (textEditor == null)
            {
                throw new ArgumentException("textEditor cannot be null.");
            }

            view = new IntellisenseView(textEditor);
            methodCompletionView = new MethodCompletionView(textEditor);

            // The way that the ItemSelected event handler works is a little complicated. If the user has half-typed
            // a word and needs completion options for it, we can't just insert the selected completion at the caret
            // - half of the word will be duplicated. Instead, we need to intercept the event, add the trigger word
            // to the event args, and call the event handler provided to us. The view is then responsible for
            // inserting the completion option at the appropriate point and removing the half-finished word.
            view.ItemSelected += ContextItemSelected;
        }