void w_ResultProvided(object sender, ResultProvidedEventArgs e) { // remove the event handler popup.ResultProvided -= w_ResultProvided; if (!e.Canceled) { int _CurrCaretIndex = TextEditor.ActiveTextAreaControl.Caret.Offset; int inputlength = (_CurrCaretIndex - _BeginCaretIndex); if (inputlength < 0) inputlength = 0; string inserttext = ""; if (e.Item is SnippetCompletionData) { SnippetCompletionData snippet = e.Item as SnippetCompletionData; TextEditor.ActiveTextAreaControl.Caret.ValidateCaretPos(); inserttext = snippet.Snippet.IndentedText(TextEditor.ActiveTextAreaControl.Caret.Position.X - inputlength, true); } if (e.Item is XmlCompletionData) { XmlCompletionData xml = e.Item as XmlCompletionData; inserttext = xml.Text; } if (_CurrCaretIndex > _BeginCaretIndex) { string prefix = Text.Substring(_BeginCaretIndex, _CurrCaretIndex - _BeginCaretIndex); if (e.ForcedAccept || e.Text.ToLowerInvariant().StartsWith(prefix.ToLowerInvariant())) { // clear the user entered text RemoveString(_BeginCaretIndex, _CurrCaretIndex - _BeginCaretIndex); // insert the selected string InsertString(inserttext, _BeginCaretIndex); // place the caret at the end of the inserted text TextEditor.ActiveTextAreaControl.TextArea.Caret.Column += inserttext.Length; } } else if (_CurrCaretIndex - _BeginCaretIndex == 0) { InsertStringAtCaret(inserttext); } } }
void RaiseResultProvidedEvent(ICompletionData item, string text, bool forcedAccept, bool cancelled) { ResultProvidedEventArgs newEventArgs = new ResultProvidedEventArgs(CodeCompletionPopup.ResultProvidedEvent, item, text, forcedAccept, cancelled); RaiseEvent(newEventArgs); }