private void ScrollBarOnValueChanged(object sender, EventArgs eventArgs) { if (_codeCompletionWindow == null) { return; } _codeCompletionWindow.Close(); }
public void CloseCompletionWindow() { if (FCompletionWindow != null && !FCompletionWindow.IsDisposed) { FCompletionWindow.Close(); } }
bool TextArea_KeyEventHandler(char ch) { if (provider != null) { if (codeCompletionWindow != null) { if (char.IsLetterOrDigit(ch) || ch == '_' || ch == '$') { if (codeCompletionWindow.ProcessKeyEvent(ch)) { return(true); } } else { codeCompletionWindow.Close(); } } if (codeCompletionWindow == null && char.IsLetterOrDigit(ch) || ch == '_') { codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(mainForm, editor, editor.FileName, provider, ch); if (codeCompletionWindow != null) { codeCompletionWindow.FormClosed += new System.Windows.Forms.FormClosedEventHandler(codeCompletionWindow_FormClosed); } } } return(false); }
/// <summary> /// Disposes of resources used by the editor. /// </summary> /// <remarks> /// This makes sure that the code completion windows is closed. /// </remarks> /// <param name="disposing">Whether or not the object is being disposed.</param> protected override void Dispose(bool disposing) { base.Dispose(disposing); if (m_ccwCodeCompletionWindow != null) { m_ccwCodeCompletionWindow.Close(); m_ccwCodeCompletionWindow.Dispose(); } }
void ShowCompletionWindow(char ch) { if (IsCodeCompletionWindowOpen) { codeCompletionWindow.Close(); } if (IsCodeCompletionEnabled) { XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(schemaCompletionDataItems, defaultSchemaCompletionData, defaultNamespacePrefix); codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(ParentForm, this, FileName, completionDataProvider, ch, XmlEditorAddInOptions.ShowSchemaAnnotation, false); if (codeCompletionWindow != null) { codeCompletionWindow.Closed += new EventHandler(CodeCompletionWindowClosed); } } }
private void ShowCompletionWindow(char ch) { if (IsCodeCompletionWindowOpen) { codeCompletionWindow.Close(); } if (IsCodeCompletionEnabled) { XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(schemaCompletionDataItems, defaultSchemaCompletionData, string.Empty /* defaultNamespacePrefix */); codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(ParentForm, this, FileName, completionDataProvider, ch, true /* showDeclarationWindow */, false); if (codeCompletionWindow != null) { codeCompletionWindow.Closed += new EventHandler(CodeCompletionWindowClosed); } } }
public void SetUpFixture() { Form parentForm = new Form(); parentForm.CreateControl(); XmlSchemaCompletionData schema = new XmlSchemaCompletionData(ResourceManager.GetXhtmlStrictSchema()); XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection(); schemas.Add(schema); provider = new XmlCompletionDataProvider(schemas, schema, String.Empty); TextEditorControl textEditor = new TextEditorControl(); completionDataItems = provider.GenerateCompletionData(@"C:\Test.xml", textEditor.ActiveTextAreaControl.TextArea, '<'); using (CodeCompletionWindow completionWindow = CodeCompletionWindow.ShowCompletionWindow(parentForm, textEditor, @"C:\Test.xml", provider, '<')) { CodeCompletionListView listView = (CodeCompletionListView)completionWindow.Controls[0]; selectedCompletionData = listView.SelectedCompletionData; completionWindow.Close(); } }
/// <summary> /// キー入力があったとき /// </summary> /// <param name="ch">入力された文字</param> /// <returns>入力をキャンセルするときはtrue</returns> bool ActiveTextArea_KeyEventHandler(char ch) { if (m_useCodeComp) //入力補完を行うとき { FileType.KrkrType type = FileType.GetKrkrType(this.FileName); if (m_codeCompletionWindow != null && !m_codeCompletionWindow.IsDisposed) { if (type == FileType.KrkrType.Kag && (ch == ' ' || ch == '=')) { //次の入力補完へ移行させるためここでは何もしない } else if (type == FileType.KrkrType.Kag && ch == ']') { //タグ入力が終了したので入力補完を終了させる m_codeCompletionWindow.Close(); return(false); } else { //入力補完リストにイベントを投げる return(m_codeCompletionWindow.ProcessKeyEvent(ch)); } } switch (type) { case FileType.KrkrType.Kag: kagKeyEventHandler(ch); break; case FileType.KrkrType.Tjs: tjsKeyEventHandler(ch); break; } } return(false); }
private void ShowIntellisense(char value) { CodeCompletionWindow completionWindow = CodeCompletionWindow.ShowCompletionWindow( ((Form)Parent.Parent), Editor, "", mCompletionDataProvider, value ); // created a new window if (completionWindow != null) { completionWindow.Closed += new EventHandler(CompletionWindow_Closed); mCompletionWindow = completionWindow; } else if (mCompletionWindow != null) { // Window creation failed because provider returns null // Close previous window too mCompletionWindow.Close(); } }
/// <summary> /// Return true to handle the keypress, return false to let the text area handle the keypress /// </summary> bool TextAreaKeyEventHandler(char key) { try { if (codeCompletionWindow != null) { // If completion window is open and wants to handle the key, don't let the text area // handle it System.Diagnostics.Debug.WriteLine("---" + key); if (codeCompletionWindow.ProcessKeyEvent(key)) { System.Diagnostics.Debug.WriteLine("---" + key + "==="); return(true); } else { if (codeCompletionWindow != null && codeCompletionWindow.dataProvider is CodeCompletionProvider) { System.Diagnostics.Debug.WriteLine("---" + key + "===inin"); ICompletionData[] data = (codeCompletionWindow.dataProvider as CodeCompletionProvider).GenerateCompletionList(key); if (data == null) { System.Diagnostics.Debug.WriteLine("---" + key + "===close"); codeCompletionWindow.Close(); //codeCompletionWindow = null; } return(false); } } } //bool insideMoScript = false; //List<KeyValuePair<int, int>> values = new List<KeyValuePair<int, int>>(); //int index = editor.Document.TextContent.IndexOf("<moscript>", 0, StringComparison.CurrentCultureIgnoreCase); //while (index != -1) //{ // int endindex = editor.Document.TextContent.IndexOf("</moscript>", index + 1, StringComparison.CurrentCultureIgnoreCase); // if (endindex != -1) // { // KeyValuePair<int, int> pair = new KeyValuePair<int, int>(index, endindex); // values.Add(pair); // } // index = editor.Document.TextContent.IndexOf("<moscript>", index + 1, StringComparison.CurrentCultureIgnoreCase); //} //foreach (KeyValuePair<int, int> pair in values) //{ // if (editor.ActiveTextAreaControl.Caret.Offset > pair.Key && editor.ActiveTextAreaControl.Caret.Offset < pair.Value) // { // insideMoScript = true; // break; // } //} //if (insideMoScript) //{ //if (key == '.') //{ // ICompletionDataProvider completionDataProvider = new CodeCompletionProviderDot(mainForm); // codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow( // mainForm, // The parent window for the completion window // editor, // The text editor to show the window for // "x.cs", // Filename - will be passed back to the provider // completionDataProvider, // Provider to get the list of possible completions // key // Key pressed - will be passed to the provider // ); // if (codeCompletionWindow != null) // { // // ShowCompletionWindow can return null when the provider returns an empty list // codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow); // } //} try { var seg = editor.Document.GetLineSegment(editor.ActiveTextAreaControl.Caret.Line); string textline = editor.Document.GetText(seg); int index = textline.IndexOf("//"); if (index != -1 && index < editor.ActiveTextAreaControl.Caret.Offset) { return(false); } } catch (Exception) { } if (char.IsLetter(key) || key == '#') { ICompletionDataProvider completionDataProvider = new CodeCompletionProvider(mainForm, key.ToString()); codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow( mainForm, // The parent window for the completion window editor, // The text editor to show the window for "x.cs", // Filename - will be passed back to the provider completionDataProvider, // Provider to get the list of possible completions key // Key pressed - will be passed to the provider ); if (codeCompletionWindow != null) { // ShowCompletionWindow can return null when the provider returns an empty list codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow); codeCompletionWindow.SetPre(); //return true; } } else if (key == '(' && mainForm.Specification != null) { //if (EnableMethodInsight && CodeCompletionOptions.InsightEnabled) { mainForm.CodeEditor.ShowInsightWindow(new MethodInsightDataProvider(mainForm)); return(false); } } if (key == ',') //&& CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled { mainForm.CodeEditor.ShowInsightWindow(new MethodInsightDataProvider(mainForm)); return(false); } // } } catch (Exception ex) { string msg = ex.Message; } return(false); }