public WpfPresentationSource(UIElement rootElement, IWpfValueConverter converter) { this.RootElement = rootElement; this.converter = converter; RootElement.IsRootElement = true; MouseDevice = new MouseDevice(this); KeyboardDevice = new KeyboardDevice(this); container = new wpf::System.Windows.Controls.Canvas { Background = wpf::System.Windows.Media.Brushes.Transparent }; container.PreviewMouseMove += OnContainerMouseMove; container.PreviewMouseDown += OnContainerMouseDown; container.PreviewMouseUp += OnContainerMouseUp; container.PreviewMouseWheel += (sender, e) => e.Handled = MouseDevice.ProcessRawEvent(new RawMouseWheelEventArgs(e.Delta, converter.ConvertBack(e.GetPosition(container)), GetTimestamp())); MouseDevice.CursorChanged += (sender, e) => container.Cursor = converter.Convert(MouseDevice.Cursor); container.Cursor = converter.Convert(MouseDevice.Cursor); window = new wpf::System.Windows.Window { UseLayoutRounding = true, Content = container }; window.Activated += (sender, e) => MouseDevice.Activate(); window.Deactivated += (sender, e) => MouseDevice.Deactivate(); window.SizeChanged += (sender, e) => SetRootElementSize(); window.PreviewKeyDown += (sender, e) => e.Handled = KeyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(converter.ConvertBack(e.Key), converter.ConvertBack(e.KeyStates), e.IsRepeat, GetTimestamp())); window.PreviewKeyUp += (sender, e) => e.Handled = KeyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(converter.ConvertBack(e.Key), converter.ConvertBack(e.KeyStates), e.IsRepeat, GetTimestamp())); window.Show(); container.Children.Add(((IWpfRenderElement)rootElement.GetRenderElement(WpfRenderElementFactory.Default)).WpfElement); SetRootElementSize(); MouseDevice.Activate(); KeyboardDevice.Activate(); }
public MouseButtonEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition, MouseButton changedButton, MouseButtonState buttonState, int clickCount) : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition) { this.ChangedButton = changedButton; this.ButtonState = buttonState; this.ClickCount = clickCount; }
/// <summary> /// Initializes a new instance of the MouseEventArgs class. /// </summary> /// <param name="mouse"> /// The logical Mouse device associated with this event. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="stylusDevice"> /// The stylus device that was involved with this event. /// </param> public MouseEventArgs(MouseDevice mouse, int timestamp, StylusDevice stylusDevice) : base(mouse, timestamp) { if( mouse == null ) { throw new System.ArgumentNullException("mouse"); } _stylusDevice = stylusDevice; }
/// <summary> /// Initializes a new instance of the MouseButtonEventArgs class. /// </summary> /// <param name="mouse"> /// The logical Mouse device associated with this event. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="button"> /// The mouse button whose state is being described. /// </param> public MouseButtonEventArgs(MouseDevice mouse, int timestamp, MouseButton button) : base(mouse, timestamp) { MouseButtonUtilities.Validate(button); _button = button; _count = 1; }
public MouseHookEventArgs(MouseDevice device, int timestamp) : base(device, timestamp) { // System.Windows.Input.InputManager.Current.PrimaryMouseDevice // NOTE: How or should I use an Input.InputManager.Current.PrimaryMouseDevice to figure out the current mouse device? // IS that device updated globaly? Does it throw off events? What if their are two devices, should I rely on simple input devices? // currently, the MouseDevice is a Dispatcher Object, which means its tied to a particular thread, which means that I probably can't // thread the hook manager and use LINQ to events the way I'd like to... Or should I just screw it all and add a dependency to win // forms? I really hate win forms, and having a dependency on it. If I can remove the dependency on a single mouse input device (IE // multi-user touch apps that need this kind of statistics tracking) and still retain the ability to filter and determin the exact // and full raw data, that becomes extreamly valuble later when I want to run statistics or add data processing hooks. }
public MouseWheel(MouseDevice mouseDevice = null, int id = 0) { Current = this; _mouseDevice = mouseDevice; Id = id; Name = GetName(); _activeTransferCase = _stdResTransferCase = new MouseWheelSingleShaftTransferCase(0); Next = _activeTransferCase; if (s_newWheel != null) s_newWheel(this, EventArgs.Empty); }
public void MouseDeviceCaptureTest() { Border child1 = new Border { Background = Brushes.Transparent, Width = 100, Height = 100 }; Border child2 = new Border { Background = Brushes.Transparent, Width = 100, Height = 100 }; Border child3 = new Border { Background = Brushes.Transparent, Width = 100, Height = 100 }; StackPanel panel = new StackPanel { IsRootElement = true }; panel.Children.Add(child1); panel.Children.Add(child2); MouseEventArgs lastArgs = null; panel.MouseMove += (sender, e) => lastArgs = e; TestPresentationSource presentationSource = new TestPresentationSource(); presentationSource.RootElement = panel; panel.Measure(Size.Infinity); panel.Arrange(new Rect(panel.DesiredSize)); MouseDevice mouseDevice = new MouseDevice(presentationSource); mouseDevice.Activate(); mouseDevice.ProcessRawEvent(new RawMouseEventArgs(new Point(50, 50), 0)); Assert.AreEqual(child1, lastArgs.Source); Assert.AreEqual(child1, mouseDevice.HitTarget); Assert.AreEqual(null, mouseDevice.CaptureTarget); Assert.AreEqual(child1, mouseDevice.Target); mouseDevice.ProcessRawEvent(new RawMouseEventArgs(new Point(50, 150), 0)); Assert.AreEqual(child2, lastArgs.Source); Assert.AreEqual(child2, mouseDevice.HitTarget); Assert.AreEqual(null, mouseDevice.CaptureTarget); Assert.AreEqual(child2, mouseDevice.Target); mouseDevice.Capture(child2); mouseDevice.ProcessRawEvent(new RawMouseEventArgs(new Point(50, 50), 0)); Assert.AreEqual(child2, lastArgs.Source); Assert.AreEqual(child1, mouseDevice.HitTarget); Assert.AreEqual(child2, mouseDevice.CaptureTarget); Assert.AreEqual(child2, mouseDevice.Target); mouseDevice.ReleaseCapture(); mouseDevice.ProcessRawEvent(new RawMouseEventArgs(new Point(50, 50), 0)); Assert.AreEqual(child1, lastArgs.Source); Assert.AreEqual(child1, mouseDevice.HitTarget); Assert.AreEqual(null, mouseDevice.CaptureTarget); Assert.AreEqual(child1, mouseDevice.Target); }
public void MouseDeviceButtonTest() { Border element = new Border { Background = Brushes.Transparent, Width = 100, Height = 100, IsRootElement = true }; element.Measure(Size.Infinity); element.Arrange(new Rect(element.DesiredSize)); int eventIndex = 0; int previewMouseDownIndex = 0; int previewMouseUpIndex = 0; int mouseDownIndex = 0; int mouseUpIndex = 0; element.PreviewMouseDown += (sender, e) => previewMouseDownIndex = ++eventIndex; element.PreviewMouseUp += (sender, e) => previewMouseUpIndex = ++eventIndex; element.MouseDown += (sender, e) => mouseDownIndex = ++eventIndex; element.MouseUp += (sender, e) => mouseUpIndex = ++eventIndex; TestPresentationSource presentationSource = new TestPresentationSource(); presentationSource.RootElement = element; MouseDevice mouseDevice = new MouseDevice(presentationSource); mouseDevice.Activate(); mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Pressed, new Point(10, 10), 0)); Assert.AreEqual(MouseButtonState.Pressed, mouseDevice.GetButtonState(MouseButton.Left)); Assert.AreEqual(1, previewMouseDownIndex); Assert.AreEqual(2, mouseDownIndex); mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Released, new Point(10, 10), 0)); Assert.AreEqual(MouseButtonState.Released, mouseDevice.GetButtonState(MouseButton.Left)); Assert.AreEqual(3, previewMouseUpIndex); Assert.AreEqual(4, mouseUpIndex); mouseDevice.ProcessRawEvent(new RawMouseButtonEventArgs(MouseButton.Left, MouseButtonState.Pressed, new Point(10, 10), 0)); Assert.AreEqual(MouseButtonState.Pressed, mouseDevice.GetButtonState(MouseButton.Left)); Assert.AreEqual(5, previewMouseDownIndex); Assert.AreEqual(6, mouseDownIndex); mouseDevice.Deactivate(); Assert.AreEqual(MouseButtonState.Released, mouseDevice.GetButtonState(MouseButton.Left)); Assert.AreEqual(7, previewMouseUpIndex); Assert.AreEqual(8, mouseUpIndex); }
public PresentationSource(UIElement rootElement, IHtmlValueConverter converter) { this.RootElement = rootElement; this.converter = converter; RootElement.IsRootElement = true; MouseDevice = new MouseDevice(this); KeyboardDevice = new KeyboardDevice(this); window = System.Html.Window.Instance; MouseDevice.CursorChanged += (sender, e) => System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor); System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor); System.Html.Window.OnKeydown = OnKeyDown; System.Html.Window.OnKeyup = OnKeyUp; System.Html.Window.OnKeypress = PreventKeyboardHandled; System.Html.Window.OnMousemove = OnMouseMove; System.Html.Window.OnMousedown = OnMouseDown; System.Html.Window.OnMouseup = OnMouseUp; System.Html.Window.OnScroll = OnMouseWheel; System.Html.Window.OnFocus = e => MouseDevice.Activate(); System.Html.Window.OnBlur = e => MouseDevice.Deactivate(); System.Html.Window.OnResize = e => SetRootElementSize(); System.Html.Window.OnClick = PreventMouseHandled; System.Html.Window.OnDblclick = PreventMouseHandled; System.Html.Window.OnContextmenu = PreventMouseHandled; System.Html.Window.AddEventListener("wheel", OnMouseWheel); SetRootElementSize(); System.Html.Window.Document.Body.Style.Overflow = "hidden"; System.Html.Window.Document.Body.AppendChild(((HtmlRenderElement)RootElement.GetRenderElement(HtmlRenderElementFactory.Default)).HtmlElement); MouseDevice.Activate(); KeyboardDevice.Activate(); }
public MouseEventArgs(MouseDevice mouse, int timestamp) : base (default(InputDevice), default(int)) { }
internal static IInputElement GlobalHitTest(PresentationSource inputSource, Point pt) { return(MouseDevice.GlobalHitTest(pt, inputSource)); }
/// <summary> /// Creates and setups event listeners for a new gesture engine. /// </summary> /// <param name="device">The touch device that caused started the potential gesture</param> /// <returns>The newly created engine</returns> protected IGestureEngine CreateAndSetupGestureEngine(MouseDevice device) { var engine = _engineCreator(); engine.MouseDevice = device; engine.GestureAborted += engine_GestureAborted; engine.GestureCompleted += engine_GestureCompleted; engine.GestureStarted += engine_GestureStarted; return engine; }
Point? GetMousePoint(MouseDevice device) { if (wpfTextView == null) return null; var mousePos = Mouse.PrimaryDevice.GetPosition(wpfTextView.VisualElement); mousePos.X += wpfTextView.ViewportLeft; mousePos.Y += wpfTextView.ViewportTop; return mousePos; }
public QueryCursorEventArgs (MouseDevice mouse, int timestamp, StylusDevice stylusDevice) : base (mouse, timestamp) { }
public void OnMouseRightUp(Mogre.Vector2 point, MouseDevice mouseDevice) { if (ActiveViewport == null) return; Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); if (PointIsInRect(point, rect)) { ActiveViewport.OnMouseRightUp(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice); } }
public MouseWheelEventArgs(MouseDevice mouse, int timestamp, int delta) : base(default(MouseDevice), default(int)) { }
public MouseButtonEventArgs (MouseDevice mouse, int timestamp, MouseButton button) : base (mouse, timestamp) { }
internal MouseButtonState GetMouseButtonState(MouseButton mouseButton, MouseDevice mouseDevice) { return(StylusDeviceImpl.GetMouseButtonState(mouseButton, mouseDevice)); }
public QueryCursorEventArgs(MouseDevice mouse, int timestamp, StylusDevice stylusDevice) : base(default(MouseDevice), default(int)) { }
/// <summary> /// Gets the current position of the mouse in screen co-ords /// </summary> /// <param name="mouseDevice"> /// The MouseDevice that is making the request /// </param> /// <returns> /// The current mouse location in screen co-ords /// </returns> /// <remarks> /// This is the hook where the Input system (via the MouseDevice) can call back into /// the Stylus system when we are processing Stylus events instead of Mouse events /// </remarks> internal Point GetMouseScreenPosition(MouseDevice mouseDevice) { return(StylusDeviceImpl.GetMouseScreenPosition(mouseDevice)); }
public MouseEventArgs(MouseDevice mouse, int timestamp) : base(default(InputDevice), default(int)) { }
private static IInputElement LocalHitTest(Point pt, PresentationSource inputSource) { return(MouseDevice.LocalHitTest(false, pt, inputSource)); }
public MouseEventArgs (MouseDevice mouse, int timestamp) : base (mouse, timestamp) { }
public MouseEventArgs (MouseDevice mouse, int timestamp, StylusDevice stylusDevice) : base (mouse, timestamp) { this.stylusDevice = stylusDevice; }
public static CanvasPosition CanvasFromMouse(MouseDevice m, System.Windows.IInputElement c) { var mousePos = m.GetPosition(c); return new CanvasPosition { X = mousePos.X, Y = mousePos.Y }; }
internal abstract Point GetMouseScreenPosition(MouseDevice mouseDevice);
/// <summary> /// Initializes a new instance of the MouseWheelEventArgs class. /// </summary> /// <param name="mouse"> /// The Mouse device associated with this event. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="delta"> /// How much the mouse wheel turned. /// </param> public MouseWheelEventArgs(MouseDevice mouse, int timestamp, int delta) : base(mouse, timestamp) { _delta = delta; }
/// <summary> /// Gets the current state of the specified button /// </summary> /// <param name="mouseButton"> /// The mouse button to get the state of /// </param> /// <param name="mouseDevice"> /// The MouseDevice that is making the request /// </param> /// <returns> /// The state of the specified mouse button /// </returns> /// <remarks> /// This is the hook where the Input system (via the MouseDevice) can call back into /// the Stylus system when we are processing Stylus events instead of Mouse events /// </remarks> internal abstract MouseButtonState GetMouseButtonState(MouseButton mouseButton, MouseDevice mouseDevice);
public MouseButtonEventArgs (MouseDevice mouse, int timestamp, MouseButton button, StylusDevice stylusDevice) : base (mouse, timestamp, stylusDevice) { }
public MouseWheelEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition, int delta) : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition) { this.Delta = delta; }
public void OnMouseRightDown(Mogre.Vector2 point, MouseDevice mouseDevice) { ViewportEditor vp = GetViewportEditorFromPoint(point); if (vp != null) { ActiveViewport = vp; Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); ActiveViewport.OnMouseRightDown(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice); } }
public QueryCursorEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition) : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition) { // }
public void OnMouseWheel(Mogre.Vector2 point, float delta, MouseDevice mouseDevice) { if (ActiveViewport == null) return; Mogre.Vector4 rect = new Mogre.Vector4(); ActiveViewport.GetRect(ref rect); if (this.activeDragData != null) { foreach (KeyValuePair<object, IDragDropHandler> handler in this.dragDropHandlers) { if (handler.Key == this.activeDragData.Source) { handler.Value.OnDragWheel(this.activeDragData, ActiveViewport.Handle as Mogre.Viewport, delta); return; } } } ActiveViewport.OnMouseWheel(point - new Mogre.Vector2(rect.x, rect.y), delta, mouseDevice); }
internal MouseButtonState GetMouseButtonState(MouseButton mouseButton, MouseDevice mouseDevice) { if (mouseButton == MouseButton.Left) { return _stylusLogic.GetMouseLeftOrRightButtonState(true); } if (mouseButton == MouseButton.Right) { return _stylusLogic.GetMouseLeftOrRightButtonState(false); } // can defer back to the mouse device that called you and it will call Win32 return mouseDevice.GetButtonStateFromSystem(mouseButton); }
public MouseButtonEventArgs(MouseDevice mouse, int timestamp, MouseButton button, StylusDevice stylusDevice) : base(default(MouseDevice), default(int)) { }
public QueryCursorEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition) : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition) { // }
/// <summary> /// Initializes a new instance of the MouseWheelEventArgs class. /// </summary> /// <param name="mouse"> /// The Mouse device associated with this event. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="delta"> /// How much the mouse wheel turned. /// </param> public MouseWheelEventArgs(MouseDevice mouse, int timestamp, int delta) : base(mouse, timestamp) { _delta = delta; }
void BeginDragMove(MouseDevice device) { if (device == null) { device = Mouse.PrimaryDevice; } if (device.LeftButton != MouseButtonState.Pressed) { return; } if (this.WindowState == WindowState.Maximized) { device.Capture(this.mover); this.mover.MouseMove += OnMoverMouseMove; this.mover.LostMouseCapture += OnMoverLostCapture; this.mover.MouseLeftButtonUp += OnMoverMouseLeftButtonUp; this.moveStartPoint = device.GetPosition(this); } else { this.inDragMove = true; this.DragMove(); this.inDragMove = false; } }
public MouseButtonEventArgs(MouseDevice mouse, int timestamp, MouseButton button, StylusDevice stylusDevice) : base (default(MouseDevice), default(int)) { }
void SetPrimaryMouseDevice(MouseDevice mouseDevice) { this.mouseDevice = mouseDevice; }
public MouseEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition) : base(routedEvent, originalSource, mouseDevice, timestamp) { this.MouseDevice = mouseDevice; this.AbsolutePosition = absolutePosition; this.LeftButton = mouseDevice.GetButtonState(MouseButton.Left); this.MiddleButton = mouseDevice.GetButtonState(MouseButton.Middle); this.RightButton = mouseDevice.GetButtonState(MouseButton.Right); this.XButton1 = mouseDevice.GetButtonState(MouseButton.XButton1); this.XButton2 = mouseDevice.GetButtonState(MouseButton.XButton2); }
public MouseWheelEventArgs(MouseDevice mouse, int timestamp, int delta) : base (default(MouseDevice), default(int)) { }
/// <summary> /// Gets the current position of the mouse in screen co-ords /// </summary> /// <param name="mouseDevice"> /// The MouseDevice that is making the request /// </param> /// <returns> /// The current mouse location in screen co-ords /// </returns> /// <remarks> /// This is the hook where the Input system (via the MouseDevice) can call back into /// the Stylus system when we are processing Stylus events instead of Mouse events /// </remarks> internal Point GetMouseScreenPosition(MouseDevice mouseDevice) { if (mouseDevice == null) { // return the last location this stylus device promoted a mouse for. return _lastMouseScreenLocation; } else { // The mouse device now caches the last location seen from the last input // report so we can just call back to them to get the location. We don't // need to return our cached location currrently. return mouseDevice.GetScreenPositionFromSystem(); } }
public MouseWheelEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition, int delta) : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition) { this.Delta = delta; }