Ejemplo n.º 1
0
        private MessagePreviewResult NotifyGetMessageEvent(ref Message msg)
        {
            MessagePreviewResult    result           = MessagePreviewResult.NotProcessed;
            List <IMessageListener> currentListeners = new List <IMessageListener>(this.listeners);

            foreach (IMessageListener listener in currentListeners)
            {
                if ((listener.DesiredHook & InstalledHook.GetMessage) == 0)
                {
                    continue;
                }

                MessagePreviewResult singleResult = listener.PreviewMessage(ref msg);
                if ((singleResult & MessagePreviewResult.Processed) == MessagePreviewResult.Processed)
                {
                    result |= MessagePreviewResult.Processed;
                }
                if ((singleResult & MessagePreviewResult.NoDispatch) == MessagePreviewResult.NoDispatch)
                {
                    result |= MessagePreviewResult.NoDispatch;
                }
                if ((singleResult & MessagePreviewResult.NoContinue) == MessagePreviewResult.NoContinue)
                {
                    result |= MessagePreviewResult.NoContinue;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        private MessagePreviewResult NotifyListener(IKeyboardListener listener, Control target, Message msg)
        {
            MessagePreviewResult result = MessagePreviewResult.NotProcessed;
            Keys keyData;

            switch (msg.Msg)
            {
            case NativeMethods.WM_KEYDOWN:
            case NativeMethods.WM_SYSKEYDOWN:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData));
                break;

            case NativeMethods.WM_CHAR:
            case NativeMethods.WM_SYSCHAR:
                KeyPressEventArgs e = new KeyPressEventArgs((char)((ushort)((long)msg.WParam)));
                result = listener.OnPreviewKeyPress(target, e);
                break;

            case NativeMethods.WM_KEYUP:
            case NativeMethods.WM_SYSKEYUP:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData));
                break;
            }

            return(result);
        }
Ejemplo n.º 3
0
        private MessagePreviewResult NotifyGetMessageEvent(ref Message msg)
        {
            MessagePreviewResult messagePreviewResult1 = MessagePreviewResult.NotProcessed;

            foreach (IMessageListener messageListener in new List <IMessageListener>((IEnumerable <IMessageListener>) this.listeners))
            {
                if ((messageListener.DesiredHook & InstalledHook.GetMessage) != InstalledHook.None)
                {
                    MessagePreviewResult messagePreviewResult2 = messageListener.PreviewMessage(ref msg);
                    if ((messagePreviewResult2 & MessagePreviewResult.Processed) == MessagePreviewResult.Processed)
                    {
                        messagePreviewResult1 |= MessagePreviewResult.Processed;
                    }
                    if ((messagePreviewResult2 & MessagePreviewResult.NoDispatch) == MessagePreviewResult.NoDispatch)
                    {
                        messagePreviewResult1 |= MessagePreviewResult.NoDispatch;
                    }
                    if ((messagePreviewResult2 & MessagePreviewResult.NoContinue) == MessagePreviewResult.NoContinue)
                    {
                        messagePreviewResult1 |= MessagePreviewResult.NoContinue;
                        break;
                    }
                }
            }
            return(messagePreviewResult1);
        }
Ejemplo n.º 4
0
        private MessagePreviewResult NotifyListener(
            IKeyboardListener listener,
            Control target,
            Message msg)
        {
            MessagePreviewResult messagePreviewResult = MessagePreviewResult.NotProcessed;

            switch (msg.Msg)
            {
            case 256:
            case 260:
                Keys keyData1 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData1));
                break;

            case 257:
            case 261:
                Keys keyData2 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData2));
                break;

            case 258:
            case 262:
                KeyPressEventArgs e = new KeyPressEventArgs((char)(long)msg.WParam);
                messagePreviewResult = listener.OnPreviewKeyPress(target, e);
                break;
            }
            return(messagePreviewResult);
        }
Ejemplo n.º 5
0
        private MessagePreviewResult NotifyKeyboardEvent(
            Control target,
            Message msg)
        {
            MessagePreviewResult messagePreviewResult1 = MessagePreviewResult.NotProcessed;

            foreach (IKeyboardListener listener in this.listeners)
            {
                MessagePreviewResult messagePreviewResult2 = this.NotifyListener(listener, target, msg);
                if ((messagePreviewResult2 & MessagePreviewResult.Processed) == MessagePreviewResult.Processed)
                {
                    messagePreviewResult1 |= MessagePreviewResult.Processed;
                }
                if ((messagePreviewResult2 & MessagePreviewResult.NoDispatch) == MessagePreviewResult.NoDispatch)
                {
                    messagePreviewResult1 |= MessagePreviewResult.NoDispatch;
                }
                if ((messagePreviewResult2 & MessagePreviewResult.NoContinue) == MessagePreviewResult.NoContinue)
                {
                    messagePreviewResult1 |= MessagePreviewResult.NoContinue;
                    break;
                }
            }
            return(messagePreviewResult1);
        }
Ejemplo n.º 6
0
        MessagePreviewResult IMessageListener.PreviewMessage(
            ref Message msg)
        {
            if (this.startedProgramatically)
            {
                return(MessagePreviewResult.NotProcessed);
            }
            switch (this.State)
            {
            case RadServiceState.Initial:
            case RadServiceState.Stopped:
                RadMessageFilter.Instance.RemoveListener((IMessageListener)this);
                this.messageFilterAdded = false;
                return(MessagePreviewResult.NotProcessed);

            default:
                switch (msg.Msg)
                {
                case 162:
                case 514:
                    MessagePreviewResult messagePreviewResult = this.initialized ? MessagePreviewResult.ProcessedNoDispatch : MessagePreviewResult.Processed;
                    this.Stop(this.doCommit);
                    return(messagePreviewResult);

                case 256:
                case 260:
                    if (msg.WParam.ToInt32() == 27)
                    {
                        this.Stop(false);
                        return(MessagePreviewResult.ProcessedNoDispatch);
                    }
                    break;

                case 512:
                case 534:
                    Point mousePosition = Control.MousePosition;
                    if (mousePosition != this.beginPoint.Value)
                    {
                        this.HandleMouseMove(mousePosition);
                    }
                    return(MessagePreviewResult.ProcessedNoDispatch);
                }
                return(MessagePreviewResult.Processed);
            }
        }
Ejemplo n.º 7
0
        MessagePreviewResult IMessageListener.PreviewMessage(ref Message msg)
        {
            RadServiceState state = this.State;

            if (state == RadServiceState.Stopped || state == RadServiceState.Initial)
            {
                RadMessageFilter.Instance.RemoveListener(this);
                this.messageFilterAdded = false;
                return(MessagePreviewResult.NotProcessed);
            }

            int message = msg.Msg;

            switch (message)
            {
            case NativeMethods.WM_MOUSEMOVE:
            case NativeMethods.WM_MOVING:
                Point mousePos = Control.MousePosition;
                if (mousePos != this.beginPoint.Value)
                {
                    this.HandleMouseMove(mousePos);
                }
                return(MessagePreviewResult.ProcessedNoDispatch);

            case NativeMethods.WM_NCLBUTTONUP:
            case NativeMethods.WM_LBUTTONUP:
                MessagePreviewResult result = this.initialized ? MessagePreviewResult.ProcessedNoDispatch : MessagePreviewResult.Processed;
                this.Stop(this.doCommit);
                return(result);

            case NativeMethods.WM_KEYDOWN:
            case NativeMethods.WM_SYSKEYDOWN:
                if ((Keys)msg.WParam.ToInt32() == Keys.Escape)
                {
                    this.Stop(false);
                    return(MessagePreviewResult.ProcessedNoDispatch);
                }
                break;
            }


            return(MessagePreviewResult.Processed);
        }
Ejemplo n.º 8
0
        private MessagePreviewResult NotifyKeyboardEvent(Control target, Message msg)
        {
            MessagePreviewResult result = MessagePreviewResult.NotProcessed;

            foreach (IKeyboardListener listener in this.listeners)
            {
                MessagePreviewResult singleResult = this.NotifyListener(listener, target, msg);
                if ((singleResult & MessagePreviewResult.Processed) == MessagePreviewResult.Processed)
                {
                    result |= MessagePreviewResult.Processed;
                }
                if ((singleResult & MessagePreviewResult.NoDispatch) == MessagePreviewResult.NoDispatch)
                {
                    result |= MessagePreviewResult.NoDispatch;
                }
                if ((singleResult & MessagePreviewResult.NoContinue) == MessagePreviewResult.NoContinue)
                {
                    result |= MessagePreviewResult.NoContinue;
                    break;
                }
            }

            return(result);
        }