Exemplo n.º 1
0
        public void TranslateMouseEvent(LowLevelMouseMessage Message)
        {
            // Store which mouse event occured
            MouseEvent = (MouseEvents)Message.Message;

            // Define new MouseMessageEventArgs to get handled state
            MouseMessageEventArgs args = null;

            switch (MouseEvent)
            {
                case MouseEvents.LeftButtonDown:
                    args = new MouseMessageEventArgs(MouseButtons.Left, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseDown(args);

                    break;
                case MouseEvents.LeftButtonUp:
                    args = new MouseMessageEventArgs(MouseButtons.Left, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseUp(args);

                    break;
                case MouseEvents.RightButtonDown:
                    args = new MouseMessageEventArgs(MouseButtons.Right, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseDown(args);

                    break;
                case MouseEvents.RightButtonUp:
                    args = new MouseMessageEventArgs(MouseButtons.Right, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseUp(args);

                    break;
                case MouseEvents.MiddleButtonDown:
                    args = new MouseMessageEventArgs(MouseButtons.Middle, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseDown(args);

                    break;
                case MouseEvents.MiddleButtonUp:
                    args = new MouseMessageEventArgs(MouseButtons.Middle, 1, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseUp(args);

                    break;
                case MouseEvents.Move:
                    args = new MouseMessageEventArgs(MouseButtons.None, 0, Message.Point.X, Message.Point.Y, 0, Message);
                    OnMouseMove(args);

                    break;
                default:
                    args = new MouseMessageEventArgs(MouseButtons.None, 0, 0, 0, 0, Message);	// Catch additional buttons

                    break;
            }

            // Set handled property of class to MouseMessageEventArgs handled flag to notify the main mouse intercept that one of the events handled it
            this.Handled = args.Handled;
        }
Exemplo n.º 2
0
 protected virtual void OnMouseUp(MouseMessageEventArgs args)
 {
     if (MouseUp != null) MouseUp(this, args);
 }
Exemplo n.º 3
0
 protected void MouseEventTranslator_MouseMove(object sender, MouseMessageEventArgs e)
 {
     // Only add point if we're capturing
     if (State == CaptureState.Capturing || State == CaptureState.CapturingInvalid)
         AddPoint(e.Location);
 }
Exemplo n.º 4
0
        protected void MouseEventTranslator_MouseUp(object sender, MouseMessageEventArgs e)
        {
            // Disregard all but right MouseUp events
            if (e.Button != MouseButtons.Right)
                return;

            // Replay original event if capturing was invalid, otherwise
            // successfully end the capture process and handle this MouseUp event

            switch (State)
            {
                case CaptureState.CapturingInvalid:
                    ReplyOriginalEvent();
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    break;
                case CaptureState.Capturing:
                    EndCapture();
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    e.Handled = true;
                    break;
            }
        }
Exemplo n.º 5
0
        protected void MouseEventTranslator_MouseDown(object sender, MouseMessageEventArgs e)
        {
            // Disregard all but capture button events
            if (e.Button != MouseButtons.Right)
                return;

            // Can we begin a new gesture capture
            if (State == CaptureState.Ready)
            {
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;

                // Store original mouse message
                _OriginalMessage = e.MouseMessage;

                // Try to begin capture process, if capture started then don't notify other applications of a mouse event, otherwise do
                e.Handled = TryBeginCapture(e.Location);

                if (!e.Handled)
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }
        }