private void ProcessExplicitContextMenuRequest(Point?location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
            {
                ReleaseCapture(true);
            }

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount   = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
            {
                location = _currentMousePoint;
            }

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType <IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs <Point>(location.Value));

            ContextMenuProvider = null;
        }
Example #2
0
	    private void ProcessExplicitContextMenuRequest(Point? location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
                ReleaseCapture(true);

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
                location = _currentMousePoint;

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType<IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs<Point>(location.Value));

            ContextMenuProvider = null;
        }