void ShowIntellisense(string FilterString, List<ISqlObject> ComplementaryObjects, FilteringType Filter = FilteringType.Any) { bool QualifierBehind = false; int AutoCompleteLength = 0; List<string> Data; if (IsIntellisenseOn) { AutocompleteDialog.Close(); } Data = FilterString.Split('.').ToList(); CompletionDataProvider completionDataProvider; switch (Data.Count) { case 1://filter string 1 word, so is an schema or a dbobject or a temp object(alias, #table or @table) completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, null, Data[0], null); AutoCompleteLength = Data[0].Length; break; case 2://filter string 2 word, must be an schema, object or an object, child if (DataProvider.DbObjects.Any(X => X.Schema.Equals(Data[0], StringComparison.CurrentCultureIgnoreCase))) completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, Data[0], Data[1], null); else completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, null, Data[0], Data[1]); AutoCompleteLength = Data[1].Length; QualifierBehind = true; break; case 3://filter string 3 word, must be an schema, object, child completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, Data[0], Data[1], Data[2]); AutoCompleteLength = Data[2].Length; break; default://no filter string, show empty case 0://no filter string, show empty completionDataProvider = new CompletionDataProvider(null, PopIList, null, "", null); AutoCompleteLength = 0; break; } completionDataProvider.FilteringOption = Filter; completionDataProvider.ComplementaryObjects = ComplementaryObjects; //CompletionDataProvider completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, FilterString); //SQLSCCProvider(CurChilds, Vars, DataProvider, PopIList, FilterString, CurrentFilter, FireAt); AutocompleteDialog = AutoCompleteWindow.ShowCompletionWindow( this, Query, "sql", completionDataProvider, ' ', AutoCompleteStartOffset + (FilterString.Length - AutoCompleteLength),//AutoCompleteStartOffset, AutoCompleteStartOffset + FilterString.Length,//FilterString.Length QualifierBehind ); if (AutocompleteDialog != null) { AutocompleteDialog.Closing += ISense_Closing; AutocompleteDialog.Closed += CodeCompletionWindowClosed; } }
void CodeCompletionWindowClosed(object sender, EventArgs e) { AutocompleteDialog.Closed -= CodeCompletionWindowClosed; AutocompleteDialog.Closing -= ISense_Closing; AutocompleteDialog.Dispose(); AutocompleteDialog = null; }
public static AutoCompleteWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow) { completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { return null; } AutoCompleteWindow codeCompletionWindow = new AutoCompleteWindow(completionDataProvider, parent, control, fileName, showDeclarationWindow); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }