/// <summary>
        /// Method triggered when MouseUp event is fired on the TreeListView. Raises MouseUp event.</summary>
        /// <param name="e">Mouse event arguments</param>
        protected virtual void OnMouseUp(MouseEventArgs e)
        {
            MouseUp.Raise(this, e);

            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            if (CommandService == null)
            {
                return;
            }

            if (ContextMenuCommandProviders == null)
            {
                return;
            }

            IEnumerable <object> commands =
                ContextMenuCommandProviders.GetCommands(
                    View,
                    m_treeListViewAdapter.LastHit);

            Point screenPoint = TreeListView.Control.PointToScreen(new Point(e.X, e.Y));

            CommandService.RunContextMenu(commands, screenPoint);
        }
Exemple #2
0
        /// <summary>
        /// Method called during a MouseUp event on the underlying PropertyGrid. Displays the
        /// context menu.</summary>
        /// <param name="e">Mouse event args from the PropertyGrid MouseUp event</param>
        protected virtual void OnPropertyGridMouseUp(MouseEventArgs e)
        {
            if (CommandService != null)
            {
                // if no property is specified, return the whole property editing context
                Point clientPt = new Point(e.X, e.Y);
                IPropertyEditingContext context;
                object target = m_propertyGrid.GetDescriptorAt(clientPt, out context);
                if (target == null)
                {
                    target = GetContext();
                }

                IEnumerable <object> commands = m_contextMenuCommandProviders.GetCommands(context, target)
                                                .Where(x => !IsStandardEditCommand(x)); // filter out standard edit commands as they are not applicable for property editing,
                // even if the current active context supports IInstancingContext.

                Point screenPoint = m_propertyGrid.PointToScreen(clientPt);

                CommandService.RunContextMenu(commands, screenPoint);
            }
        }