void TextEditorControl_CompletionRequest(object sender, CompletionEventArgs e) { if (this.TextEditorControl.CompletionWindowVisible) return; // e.Key contains the key that the user wants to insert and which triggered // the CompletionRequest.e.Key == '\0' means that the user triggered the CompletionRequest by pressing <Ctrl> + <Space>. if (e.Key == '\0') { // The user has requested the completion window by pressing <Ctrl> + <Space>. this.TextEditorControl.ShowCompletionWindow(new CodeCompletionDataProvider(), e.Key, false); } else if (char.IsLetter(e.Key)) { // The user is typing normally. // -> Show the completion to provide suggestions. Automatically close the window if the // word the user is typing does not match the completion data. (Last argument.) this.TextEditorControl.ShowCompletionWindow(new CodeCompletionDataProvider(), e.Key, true); } }
private void TextArea_KeyPress(object sender, KeyPressEventArgs keyEventArgs) { if (_inHandleKeyPress) return; // First, let all subscribers handle the key event. OnTextAreaKeyPress(keyEventArgs); if (keyEventArgs.Handled) return; _inHandleKeyPress = true; try { char ch = keyEventArgs.KeyChar; if (CompletionWindowVisible) { // Forward key event to completion window if (completionWindow.ProcessKeyEvent(ch)) keyEventArgs.Handled = true; } if (EnableMethodInsight && (ch == '(' || ch == ',')) { // Request insight window InsightEventArgs e = new InsightEventArgs(ch); OnInsightRequest(e); } else if (!keyEventArgs.Handled && EnableCompletion) { // Request completion window CompletionEventArgs e = new CompletionEventArgs(ch); OnCompletionRequest(e); } } //catch (Exception exception) //{ // // TODO: Log exception //} finally { _inHandleKeyPress = false; } }
/// <summary> /// Raises the <see cref="CompletionRequest" /> event. /// </summary> /// <param name="e"><see cref="CompletionEventArgs" /> object that provides the arguments for the event.</param> protected virtual void OnCompletionRequest(CompletionEventArgs e) { EventHandler<CompletionEventArgs> handler = CompletionRequest; if (handler != null) handler(this, e); }