Пример #1
0
        private void ProcessRawEvent(RawInputEventArgs e)
        {
            IInputElement element = FocusedElement;

            if (element != null)
            {
                var keyInput = e as RawKeyEventArgs;
                if (keyInput != null)
                {
                    switch (keyInput.Type)
                    {
                        case RawKeyEventType.KeyDown:
                        case RawKeyEventType.KeyUp:
                            var routedEvent = keyInput.Type == RawKeyEventType.KeyDown
                                ? InputElement.KeyDownEvent
                                : InputElement.KeyUpEvent;

                            KeyEventArgs ev = new KeyEventArgs
                            {
                                RoutedEvent = routedEvent,
                                Device = this,
                                Key = keyInput.Key,
                                Modifiers = keyInput.Modifiers,
                                Source = element,
                            };

                            IVisual currentHandler = element;
                            while (currentHandler != null && !ev.Handled && keyInput.Type == RawKeyEventType.KeyDown)
                            {
                                var bindings = (currentHandler as IInputElement)?.KeyBindings;
                                if(bindings!=null)
                                    foreach (var binding in bindings)
                                    {
                                        if(ev.Handled)
                                            break;
                                        binding.TryHandle(ev);
                                    }
                                currentHandler = currentHandler.VisualParent;
                            }

                            element.RaiseEvent(ev);
                            break;
                    }
                }
                var text = e as RawTextInputEventArgs;
                if (text != null)
                {
                    element.RaiseEvent(new TextInputEventArgs()
                    {
                        Device = this,
                        Text = text.Text,
                        Source = element,
                        RoutedEvent = InputElement.TextInputEvent
                    });
                }
            }
        }
Пример #2
0
        private void ProcessRawEvent(RawInputEventArgs e)
        {
            IInputElement element = FocusedElement;

            if (element != null)
            {
                var keyInput = e as RawKeyEventArgs;
                if (keyInput != null)
                {
                    switch (keyInput.Type)
                    {
                        case RawKeyEventType.KeyDown:
                        case RawKeyEventType.KeyUp:
                            var routedEvent = keyInput.Type == RawKeyEventType.KeyDown
                                ? InputElement.KeyDownEvent
                                : InputElement.KeyUpEvent;

                            KeyEventArgs ev = new KeyEventArgs
                            {
                                RoutedEvent = routedEvent,
                                Device = this,
                                Key = keyInput.Key,
                                Modifiers = keyInput.Modifiers,
                                Source = element,
                            };

                            element.RaiseEvent(ev);
                            break;
                    }
                }
                var text = e as RawTextInputEventArgs;
                if (text != null)
                {
                    element.RaiseEvent(new TextInputEventArgs()
                    {
                        Device = this,
                        Text = text.Text,
                        Source = element,
                        RoutedEvent = InputElement.TextInputEvent
                    });
                }
            }
        }
Пример #3
0
 private void OnInput(RawInputEventArgs obj)
 {
     var mouseEvent = obj as RawMouseEventArgs;
     if (mouseEvent != null)
         mouseEvent.Position /= ScalingFactor;
     //TODO: Transform event coordinates
     Input?.Invoke(obj);
 }
Пример #4
0
 public void Process(RawInputEventArgs e)
 {
     _rawEventReceived.OnNext(e);
     _postProcess.OnNext(e);
 }
Пример #5
0
 /// <summary>
 /// Handles input from <see cref="ITopLevelImpl.Input"/>.
 /// </summary>
 /// <param name="e">The event args.</param>
 private void HandleInput(RawInputEventArgs e)
 {
     this.inputManager.Process(e);
 }
Пример #6
0
 public void Process(RawInputEventArgs e)
 {
     this.rawEventReceived.OnNext(e);
     this.postProcess.OnNext(e);
 }