private bool ProcessMouseButtonUpMessage(MouseButtonMessage buttonMessage)
        {
            if (_activeButton != buttonMessage.Shortcut.MouseButton)
            {
                return(true);
            }

            _activeButton = 0;
            _clickCount   = 0;

            if (this.CaptureHandler != null)
            {
                if (StopHandler(this.CaptureHandler))
                {
                    if (_capturedOnThisClick && !HasMoved(buttonMessage.Location) && buttonMessage.Shortcut.MouseButton == XMouseButtons.Right)
                    {
                        _delayedContextMenuRequestPublisher.Publish(this, new ItemEventArgs <Point>(buttonMessage.Location));
                    }

                    return(true);
                }

                //Trace.WriteLine(String.Format("Release capture {0}", this.CaptureHandler.GetType()));

                ReleaseCapture(false);
                return(true);
            }

            return(false);
        }
        private bool StartCaptureHandler(MouseButtonMessage buttonMessage)
        {
            if (this.CaptureHandler == null)
            {
                return(false);
            }

            if (SuppressContextMenu(this.CaptureHandler))
            {
                _contextMenuEnabled = false;
            }

            if (CancelStartDueToDoubleClick())
            {
                Trace.WriteLine(String.Format("Double-click release {0}", this.CaptureHandler.GetType()));
                ReleaseCapture(true);

                StartNewHandler(buttonMessage);
            }
            else
            {
                Trace.WriteLine(String.Format("Start (Clicks: {0}, Count: {1})", _clickCount, _startCount));
                StartHandler(this.CaptureHandler);
                SetCursorToken();
            }

            //we only release capture on button up, so just consume.
            return(true);
        }
        private bool ProcessMouseButtonDownMessage(MouseButtonMessage buttonMessage)
        {
            this.CaptureMouseWheelHandler = null;

            //don't allow multiple buttons, it's just cleaner and easier to manage behaviour.
            if (_activeButton != 0)
            {
                _contextMenuEnabled = false;
                return(true);
            }

            _activeButton = buttonMessage.Shortcut.MouseButton;
            _clickCount   = buttonMessage.ClickCount;

            if (StartCaptureHandler(buttonMessage))
            {
                return(true);
            }

            _tile.Select();
            _contextMenuEnabled = (buttonMessage.Shortcut.MouseButton == XMouseButtons.Right);

            _startMousePoint = buttonMessage.Location;

            if (_tile.PresentationImage == null || !_tile.Enabled)
            {
                return(true);
            }

            //give unfocused graphics a chance to focus (in the case of going straight from context menu to a graphic).
            FindHandlingGraphic(TrackHandler);

            return(StartNewHandler(buttonMessage));
        }
 private bool StartNewHandler(MouseButtonMessage buttonMessage)
 {
     if (StartNewGraphicHandler())
     {
         return(true);
     }
     else
     {
         return(StartNewToolHandler(buttonMessage));
     }
 }
        private bool StartNewToolHandler(MouseButtonMessage buttonMessage)
        {
            foreach (IMouseButtonHandler handler in _shortcutManager.GetMouseButtonHandlers(buttonMessage.Shortcut))
            {
                if (CanStartNewHandler(handler) && StartHandler(handler))
                {
                    SetCapture(handler);
                    return(true);
                }
            }

            return(false);
        }
        private bool ProcessMouseButtonMessage(MouseButtonMessage buttonMessage)
        {
            this.Location = buttonMessage.Location;

            bool returnValue;

            if (buttonMessage.ButtonAction == MouseButtonMessage.ButtonActions.Down)
            {
                _selectedOnThisClick = !_tile.Selected;
                _capturedOnThisClick = this.CaptureHandler == null;
                returnValue          = ProcessMouseButtonDownMessage(buttonMessage);
                _capturedOnThisClick = _capturedOnThisClick && (this.CaptureHandler != null);
                _selectedOnThisClick = false;
            }
            else
            {
                returnValue = ProcessMouseButtonUpMessage(buttonMessage);
            }

            return(returnValue);
        }