Exemple #1
0
        private void CreatePopup()
        {
            if (_popup == null)
            {
                _popup = new ContextActionsBulbPopup(_editor.TextArea)
                {
                    CommandProvider = GetActionCommand,
                    Icon            = IconImage,
                };

                // TODO: workaround to refresh menu with latest document
                _popup.MenuOpened += async(sender, args) =>
                {
                    if (await LoadActionsWithCancellationAsync().ConfigureAwait(true))
                    {
                        _popup.ItemsSource = _actions;
                    }
                };

                _popup.MenuClosed += (sender, args) =>
                {
                    _editor.GetDispatcher().InvokeAsync(() => _editor.Focus(), DispatcherPriority.Background);
                };

#if AVALONIA
                ((ISetLogicalParent)_popup).SetParent(_editor.GetWindow());
#endif
            }
        }
 private void CreatePopup()
 {
     if (_popup == null)
     {
         _popup = new ContextActionsBulbPopup(_editor.TextArea)
         {
             CommandProvider = GetActionCommand
         };
         // TODO: workaround to refresh menu with latest document
         _popup.MenuOpened += async(sender, args) =>
         {
             if (await LoadActionsWithCancellationAsync().ConfigureAwait(true))
             {
                 _popup.ItemsSource = _actions;
             }
         };
         _popup.MenuClosed += (sender, args) =>
         {
             _editor.Dispatcher.InvokeAsync(() => _editor.Focus(), DispatcherPriority.Background);
         };
     }
 }