/// <summary> /// Shows the completion window. /// </summary> /// <param name="parent">The parent.</param> /// <param name="control">The text editor control.</param> /// <param name="fileName">Name of the file.</param> /// <param name="completionDataProvider">The completion data provider.</param> /// <param name="firstChar">The first char.</param> /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param> /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param> /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param> /// <returns>The code completion window.</returns> public static CompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically) { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) return null; CompletionWindow codeCompletionWindow = new CompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth, closeAutomatically); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
void OnCompletionWindowClosed(object sender, EventArgs e) { if (completionWindow != null) { completionWindow.Closed -= OnCompletionWindowClosed; completionWindow.Dispose(); completionWindow = null; } }
/// <summary> /// Shows the completion window. /// </summary> /// <param name="completionDataProvider">The completion data provider.</param> /// <param name="ch">The character that was typed - or <c>'\0'</c> if no character was typed.</param> /// <param name="closeAutomatically"><c>true</c> to close the completion wnidow automatically.</param> public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch, bool closeAutomatically) { completionDataProvider.PreSelection = String.Empty; // Make default pre-selection string previousWord = TextHelper.GetWordBeforeCaret(ActiveTextAreaControl.TextArea); if (!String.IsNullOrEmpty(previousWord)) { char lastChar = previousWord[previousWord.Length - 1]; if (TextHelper.IsLetterDigitOrUnderscore(lastChar)) completionDataProvider.PreSelection = previousWord; } completionWindow = CompletionWindow.ShowCompletionWindow(ParentForm, this, "", completionDataProvider, ch, true, false, closeAutomatically); if (completionWindow != null) completionWindow.Closed += OnCompletionWindowClosed; }