async void ContextActionsRenderer_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.T && Keyboard.Modifiers == ModifierKeys.Control) { if (popup == null) popup = new ContextActionsBulbPopup(editorView.TextArea); if (popup.IsOpen && popup.ViewModel != null && popup.ViewModel.Actions != null && popup.ViewModel.Actions.Count > 0) { popup.IsDropdownOpen = true; popup.Focus(); } else { ClosePopup(); // Popup is not shown but user explicitely requests it var popupVM = BuildPopupViewModel(); this.cancellationTokenSourceForPopupBeingOpened = new CancellationTokenSource(); var cancellationToken = cancellationTokenSourceForPopupBeingOpened.Token; try { await popupVM.LoadActionsAsync(cancellationToken); if (popupVM.Actions.Count == 0) await popupVM.LoadHiddenActionsAsync(cancellationToken); } catch (OperationCanceledException) { return; } if (cancellationToken.IsCancellationRequested) return; this.cancellationTokenSourceForPopupBeingOpened = null; if (popupVM.Actions.Count == 0 && popupVM.HiddenActions.Count == 0) return; this.popup.ViewModel = popupVM; this.popup.IsDropdownOpen = true; this.popup.IsHiddenActionsExpanded = popupVM.Actions.Count == 0; this.popup.OpenAtLineStart(this.Editor); this.popup.Focus(); } } }
public ActionCommandConverter(ContextActionsBulbPopup owner) { _owner = owner; }
async void TimerMoveTick(object sender, EventArgs e) { if (!delayMoveTimer.IsEnabled) return; ClosePopup(); // Don't show the context action popup when the caret is outside the editor boundaries var textView = this.editorView.TextArea.TextView; Rect editorRect = new Rect((Point)textView.ScrollOffset, textView.RenderSize); Rect caretRect = this.editorView.TextArea.Caret.CalculateCaretRectangle(); if (!editorRect.Contains(caretRect)) return; // Don't show the context action popup when the text editor is invisible, i.e., the Forms Designer is active. if (PresentationSource.FromVisual(textView) == null) return; ContextActionsBulbViewModel popupVM = BuildPopupViewModel(); this.cancellationTokenSourceForPopupBeingOpened = new CancellationTokenSource(); var cancellationToken = cancellationTokenSourceForPopupBeingOpened.Token; try { await popupVM.LoadActionsAsync(cancellationToken); } catch (OperationCanceledException) { LoggingService.Debug("Cancelled loading context actions."); return; } if (cancellationToken.IsCancellationRequested) return; this.cancellationTokenSourceForPopupBeingOpened = null; if (popupVM.Actions.Count == 0) return; if (popup == null) popup = new ContextActionsBulbPopup(editorView.TextArea); this.popup.ViewModel = popupVM; this.popup.OpenAtLineStart(this.Editor); }