public void HandlePointerWheelChanged(Windows.UI.Input.PointerPoint point) { if (point.PointerDevice.PointerDeviceType == PointerDeviceType.Mouse) { HandleMouseWheel(point.Properties.MouseWheelDelta / 120.0f); } }
protected virtual void uiElement_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { if (moveD3dCanvas) { var newPosition = e.GetCurrentPoint(null); double deltaX = newPosition.Position.X - lastPos.Position.X; double deltaY = newPosition.Position.Y - lastPos.Position.Y; // Only support CompositeTransform and TranslateTransform // Is there any better way to handle this? if (uiElement.RenderTransform is CompositeTransform) { var compositeTransform = (CompositeTransform)uiElement.RenderTransform; compositeTransform.TranslateX += deltaX; compositeTransform.TranslateY += deltaY; } else if (uiElement.RenderTransform is TranslateTransform) { var translateTransform = (TranslateTransform)uiElement.RenderTransform; translateTransform.X += deltaX; translateTransform.Y += deltaY; } lastPos = newPosition; } }
public static void OnPointerPressed(RadialSlider slider, PointerRoutedEventArgs e) { slider.CapturePointer(e.Pointer); _lastPoint = e.GetCurrentPoint(slider); _isDragActive = true; e.Handled = true; }
private void MapCanvas_PointerMoved(object sender, PointerRoutedEventArgs e) { Windows.UI.Xaml.Input.Pointer ptr = e.Pointer; // Multiple, simultaneous mouse button inputs are processed here. // Mouse input is associated with a single pointer assigned when // mouse input is first detected. // Clicking additional mouse buttons (left, wheel, or right) during // the interaction creates secondary associations between those buttons // and the pointer through the pointer pressed event. // The pointer released event is fired only when the last mouse button // associated with the interaction (not necessarily the initial button) // is released. // Because of this exclusive association, other mouse button clicks are // routed through the pointer move event. if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse) { // To get mouse state, we need extended pointer details. // We get the pointer info through the getCurrentPoint method // of the event argument. Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(MapCanvas); if (ptrPt.Properties.IsLeftButtonPressed) { } if (ptrPt.Properties.IsMiddleButtonPressed) { } if (ptrPt.Properties.IsRightButtonPressed) { } } // Prevent most handlers along the event route from handling the same event again. e.Handled = true; }
public override void MouseEnter(PointerPoint p) { if(HasFocus && p.Properties.IsLeftButtonPressed) { Color = Colors.LightGray; } }
public void HandlePointerReleased(Windows.UI.Input.PointerPoint point) { if (point.PointerDevice.PointerDeviceType == PointerDeviceType.Mouse) { switch (point.Properties.PointerUpdateKind) { case PointerUpdateKind.LeftButtonReleased: HandleButtonUp(MouseButton.Left); break; case PointerUpdateKind.RightButtonReleased: HandleButtonUp(MouseButton.Right); break; case PointerUpdateKind.MiddleButtonReleased: HandleButtonUp(MouseButton.Middle); break; case PointerUpdateKind.XButton1Released: HandleButtonUp(MouseButton.Extended1); break; case PointerUpdateKind.XButton2Released: HandleButtonUp(MouseButton.Extended2); break; } } }
public void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == m_PenId) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(InkCanvas); if (m_CurrentMode == "Erase") { System.Diagnostics.Debug.WriteLine("Erasing : Pointer Released"); m_InkManager.ProcessPointerUp(pt); } else { // Pass the pointer information to the InkManager. CurrentManager.ProcessPointerUp(pt); } } else if (e.Pointer.PointerId == _touchID) { // Process touch input } _touchID = 0; m_PenId = 0; // Call an application-defined function to render the ink strokes. RefreshCanvas(); e.Handled = true; }
public static void OnPointerPressed(UIElement sender, TouchSliderC slider, PointerRoutedEventArgs e) { sender.CapturePointer(e.Pointer); _lastPoint = e.GetCurrentPoint(slider); _isDragActive = true; e.Handled = true; }
public Crossline(Color color, PointerPoint point) { this.horizontalPath = new Path(); this.verticalPath = new Path(); this.point = point; horizontalPath.Stroke = new SolidColorBrush(color); verticalPath.Stroke = new SolidColorBrush(color); LineGeometry horizontalLg = new LineGeometry(); horizontalLg.StartPoint = new Point(0, 0); horizontalLg.EndPoint = new Point(Window.Current.Bounds.Width, 0); TranslateTransform horizontalLineTrans = new TranslateTransform(); horizontalLineTrans.Y = point.Position.Y; horizontalLineTrans.X = 0; horizontalLg.Transform = horizontalLineTrans; horizontalPath.Data = horizontalLg; horizontalPath.StrokeThickness = strokeThickness; LineGeometry verticalLg = new LineGeometry(); verticalLg.StartPoint = new Point(0, 0); verticalLg.EndPoint = new Point(0, Window.Current.Bounds.Height); TranslateTransform verticalLineTrans = new TranslateTransform(); verticalLineTrans.X = point.Position.X; verticalLineTrans.Y = 0; verticalLg.Transform = verticalLineTrans; verticalPath.Data = verticalLg; verticalPath.StrokeThickness = strokeThickness; }
private void MyCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == _penID) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(MyCanvas); // Pass the pointer information to the InkManager. _inkKhaled.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(MyCanvas); // Pass the pointer information to the InkManager. _inkKhaled.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; // Call an application-defined function to render the ink strokes. e.Handled = true; _undo.Push(l); _redo.Clear(); }
public void HandlePointerMoved(Windows.UI.Input.PointerPoint pointerPoint) { if (pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Mouse) { var newPosition = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y); HandleMove(newPosition); } }
/// <summary> /// Creates a new instance of <see cref="TouchPoint"/> by given PointerPoint. /// </summary> /// <param name="point">The pointer point.</param> public TouchPoint(PointerPoint point) { Check.NotNull(point, "point"); PointerPoint = point; // Sync the disconnected point. _disconnectedPoint = new Point(point.Position.X, point.Position.Y); }
private void Corner_PointerPressed(object sender, PointerRoutedEventArgs e) { (sender as UIElement).CapturePointer(e.Pointer); Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this); // Record the start point of the pointer. pointerPositionHistory[pt.PointerId] = pt.Position; }
public override void MouseUp(PointerPoint p) { foreach (win2d_Control control in Controls) { if (control.HitTest(p.Position)) { control.MouseUp(p); } } }
public static string MakeDPadPressRecord(PointerPoint point, string dPadName) { string record = MakeDPadRecordBeginning(dPadName); double pointX = (point.Position.X / 130) * 200 - 100; double pointY = (point.Position.Y / 130) * 200 - 100; record += Convert.ToInt32(pointX).ToString() + " " + Convert.ToInt32(pointY).ToString() + '\n'; return record; }
public DrawnPoint(PointerPoint point, bool endStroke = false) { Position = point.Position.ToVector2(); EndStroke = endStroke; Time = DateTime.Now.Ticks; InContact = point.IsInContact; if (InContact && point.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) { Pressure = point.Properties.Pressure; } else { Pressure = null; } }
public static void OnPointerMoved(RadialSlider slider, PointerRoutedEventArgs e) { if (_isDragActive) { PointerPoint currentPoint = e.GetCurrentPoint(slider); double delta = _lastPoint.Position.Y - currentPoint.Position.Y; if (e.KeyModifiers != slider.SlowerKey || slider.SlowerKey == null) slider.Value = slider.Normalize(slider.Value + delta / 10 * slider.LargeChange); else slider.Value = slider.Normalize(slider.Value + delta / 10 * slider.SmallChange); _lastPoint = currentPoint; e.Handled = true; } }
// </SnippetPointerExited> // <SnippetCreateInfoPop> void createInfoPop(PointerRoutedEventArgs e) { TextBlock pointerDetails = new TextBlock(); Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(Target); pointerDetails.Name = ptrPt.PointerId.ToString(); pointerDetails.Foreground = new SolidColorBrush(Windows.UI.Colors.White); pointerDetails.Text = queryPointer(ptrPt); TranslateTransform x = new TranslateTransform(); x.X = ptrPt.Position.X + 20; x.Y = ptrPt.Position.Y + 20; pointerDetails.RenderTransform = x; Container.Children.Add(pointerDetails); }
async private void panelcanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { try { if (e.Pointer.PointerId == _penID) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(PanelCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input PointerPoint pt = e.GetCurrentPoint(PanelCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; var backMarkup = await ApplicationData.Current.RoamingFolder.CreateFileAsync("markupimage_" + App.Task.CaseNumber + this.listView.SelectedIndex, CreationCollisionOption.ReplaceExisting); if (_inkManager.GetStrokes().Count > 0) { //buffer.Seek(0); using (var os = await backMarkup.OpenAsync(FileAccessMode.ReadWrite)) { await _inkManager.SaveAsync(os); } } // Call an application-defined function to render the ink strokes. e.Handled = true; } catch (Exception ex) { //new MessageDialog(ex.Message,"Error").ShowAsync(); } }
public static void OnPointerMoved(TouchSliderC slider, PointerRoutedEventArgs e, bool fine = false) { if (_isDragActive) { PointerPoint currentPoint = e.GetCurrentPoint(slider); double delta = slider.Orientation == Windows.UI.Xaml.Controls.Orientation.Horizontal ? currentPoint.Position.X - _lastPoint.Position.X: _lastPoint.Position.Y - currentPoint.Position.Y; if (fine) slider.Value = slider.Normalize(slider.Value + delta / 10 * slider.SmallChange); else slider.Value = slider.Normalize(slider.Value + delta * slider.Maximum / slider._trackBackground.ActualHeight); _lastPoint = currentPoint; e.Handled = true; } }
private void Corner_PointerMoved(object sender, PointerRoutedEventArgs e) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this); uint ptrId = pt.PointerId; if (pointerPositionHistory.ContainsKey(ptrId) && pointerPositionHistory[ptrId].HasValue) { Point currentPosition = pt.Position; Point previousPosition = pointerPositionHistory[ptrId].Value; double xUpdate = currentPosition.X - previousPosition.X; double yUpdate = currentPosition.Y - previousPosition.Y; this.selectedRegion.UpdateCorner((sender as ContentControl).Tag as string, xUpdate, yUpdate); pointerPositionHistory[ptrId] = currentPosition; } e.Handled = true; }
// </SnippetDestroyInfoPop> // <SnippetUpdateInfoPop> void updateInfoPop(PointerRoutedEventArgs e) { foreach (var pointerDetails in Container.Children) { if (pointerDetails.GetType().ToString() == "Windows.UI.Xaml.Controls.TextBlock") { TextBlock _TextBlock = (TextBlock)pointerDetails; if (_TextBlock.Name == e.Pointer.PointerId.ToString()) { // To get pointer location details, we need extended pointer info. // We get the pointer info through the getCurrentPoint method // of the event argument. Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(Target); TranslateTransform x = new TranslateTransform(); x.X = ptrPt.Position.X + 20; x.Y = ptrPt.Position.Y + 20; pointerDetails.RenderTransform = x; _TextBlock.Text = queryPointer(ptrPt); } } } }
private static void BtnAccept_Click(PointerPoint point) { OnTransitionState(GAMESTATE.UI_DISPLAY); }
public override void MouseDown(PointerPoint p) { HasFocus = true; Color = Colors.LightGray; }
private void uc_PointerMoved(object sender, PointerRoutedEventArgs e) { if (Locomotive != null && Locomotive.IsRegisteredControl && isManipulating) { double scale = 1.0; PointerPoint newP = e.GetCurrentPoint((UIElement)sender); double dX = (newP.Position.X - p.Position.X) * scale; //dX = (Math.Abs(dX) < 1 ? 1 : Math.Abs(dX)) * Math.Sign(dX); p = newP; double newFillWidth = FillWidth + dX; newFillWidth = Math.Max(newFillWidth, 0); newFillWidth = Math.Min(newFillWidth, pnlSlider.ActualWidth); FillWidth = newFillWidth; double k = FillWidth / pnlSlider.ActualWidth; int newSpeedStep = (int)(Locomotive.MaxSpeedSteps * k); Locomotive.SpeedStep = newSpeedStep; // corrections against a little tails if (newSpeedStep == 0 && Math.Sign(dX) == -1) FillWidth = 0; if (newSpeedStep == Locomotive.MaxSpeedSteps && Math.Sign(dX) == 1) FillWidth = pnlSlider.ActualWidth; } }
private void Win2d_ScrollBar_Click(PointerPoint point) { if (Statics.HitTestRect(ScrollToTopRect, point.Position)) { if (ScrollToTop != null) { ScrollToTop(); } } else if (Statics.HitTestRect(ScrollUpRect, point.Position)) { if (ScrollUp != null) { ScrollUp(); } } if (Statics.HitTestRect(ScrollDownRect, point.Position)) { if (ScrollDown != null) { ScrollDown(); } } if (Statics.HitTestRect(ScrollToBottomRect, point.Position)) { if (ScrollToBottom != null) { ScrollToBottom(); } } }
protected virtual void uiElement_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { moveD3dCanvas = true; lastPos = e.GetCurrentPoint(null); }
private async void MaskRectangle_PointerReleased(object sender, PointerRoutedEventArgs e) { endPoint = e.GetCurrentPoint(overlapGrid); updateArea(); startPoint = endPoint = null; await captureBlock(); await doOcrTranslate(); Button_Click_1(null, null); }
private void MaskRectangle_PointerMoved(object sender, PointerRoutedEventArgs e) { endPoint = e.GetCurrentPoint(overlapGrid); updateArea(); }
private void PointerReleased(PointerPoint pointerPoint, UIElement target, Pointer pointer) { // To convert from DIPs (device independent pixels) to screen resolution pixels. var dipFactor = DisplayProperties.LogicalDpi / 96.0f; var pos = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) * dipFactor; var isTouch = pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch; _touchQueue.Enqueue((int)pointerPoint.PointerId, TouchLocationState.Released, pos, !isTouch); if (!isTouch) { // Mouse or stylus event. UpdateMouse(pointerPoint); // Release the captured pointer. if (target != null) target.ReleasePointerCapture(pointer); } }
private void ProcessMouseEvent(IntPtr rawEvent, libinput_event_type type) { var rawPointerEvent = libinput_event_get_pointer_event(rawEvent); var timestamp = libinput_event_pointer_get_time_usec(rawPointerEvent); var properties = new PointerPointProperties(); Action <PointerEventArgs>?raisePointerEvent = null; if (type == LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE) { _mousePosition = new Point( x: libinput_event_pointer_get_absolute_x_transformed(rawPointerEvent, (int)_displayInformation.ScreenWidthInRawPixels), y: libinput_event_pointer_get_absolute_y_transformed(rawPointerEvent, (int)_displayInformation.ScreenHeightInRawPixels)); raisePointerEvent = _ownerEvents.RaisePointerMoved; } else if (type == LIBINPUT_EVENT_POINTER_AXIS) { double GetAxisValue(libinput_pointer_axis axis) { var source = libinput_event_pointer_get_axis_source(rawPointerEvent); return(source == libinput_pointer_axis_source.Wheel ? libinput_event_pointer_get_axis_value_discrete(rawPointerEvent, axis) : libinput_event_pointer_get_axis_value(rawPointerEvent, axis)); } if (libinput_event_pointer_has_axis(rawPointerEvent, libinput_pointer_axis.ScrollHorizontal) != 0) { properties.IsHorizontalMouseWheel = true; properties.MouseWheelDelta = (int)GetAxisValue(libinput_pointer_axis.ScrollHorizontal); raisePointerEvent = _ownerEvents.RaisePointerWheelChanged; } else if (libinput_event_pointer_has_axis(rawPointerEvent, libinput_pointer_axis.ScrollVertical) != 0) { properties.IsHorizontalMouseWheel = false; properties.MouseWheelDelta = (int)GetAxisValue(libinput_pointer_axis.ScrollVertical); raisePointerEvent = _ownerEvents.RaisePointerWheelChanged; } } else if (type == LIBINPUT_EVENT_POINTER_BUTTON) { var button = libinput_event_pointer_get_button(rawPointerEvent); var buttonState = libinput_event_pointer_get_button_state(rawPointerEvent); if (buttonState == libinput_button_state.Pressed) { _pointerPressed.Add(button); properties.PointerUpdateKind = button switch { libinput_event_code.BTN_LEFT => LeftButtonPressed, libinput_event_code.BTN_MIDDLE => MiddleButtonPressed, libinput_event_code.BTN_RIGHT => RightButtonPressed, _ => Other }; raisePointerEvent = _ownerEvents.RaisePointerPressed; } else { _pointerPressed.Remove(button); properties.PointerUpdateKind = button switch { libinput_event_code.BTN_LEFT => LeftButtonReleased, libinput_event_code.BTN_MIDDLE => MiddleButtonReleased, libinput_event_code.BTN_RIGHT => RightButtonReleased, _ => Other }; raisePointerEvent = _ownerEvents.RaisePointerReleased; } } properties.IsLeftButtonPressed = _pointerPressed.Contains(libinput_event_code.BTN_LEFT); properties.IsMiddleButtonPressed = _pointerPressed.Contains(libinput_event_code.BTN_MIDDLE); properties.IsRightButtonPressed = _pointerPressed.Contains(libinput_event_code.BTN_RIGHT); var pointerPoint = new Windows.UI.Input.PointerPoint( frameId: (uint)timestamp, // UNO TODO: How should set the frame, timestamp may overflow. timestamp: timestamp, device: PointerDevice.For(PointerDeviceType.Mouse), pointerId: 0, rawPosition: _mousePosition, position: _mousePosition, isInContact: properties.HasPressedButton, properties: properties ); if (raisePointerEvent != null) { var args = new PointerEventArgs(pointerPoint, GetCurrentModifiersState()); RaisePointerEvent(raisePointerEvent, args); } else { this.Log().LogWarning($"Pointer event type {type} was not handled"); } } }
private void uc_PointerPressed(object sender, PointerRoutedEventArgs e) { isManipulating = true; p = e.GetCurrentPoint((UIElement)sender); }
public void SetPointer2(PointerPoint point) { _pointer2 = point; UpdateComputedValues(); }
private void ProcessTouchEvent(IntPtr rawEvent, libinput_event_type rawEventType) { var rawTouchEvent = libinput_event_get_touch_event(rawEvent); if (rawTouchEvent != IntPtr.Zero && rawEventType < LIBINPUT_EVENT_TOUCH_FRAME) { var properties = new PointerPointProperties(); var timestamp = libinput_event_touch_get_time_usec(rawTouchEvent); var pointerId = (uint)libinput_event_touch_get_slot(rawTouchEvent); Action <PointerEventArgs>?raisePointerEvent = null; Point currentPosition; if (rawEventType == LIBINPUT_EVENT_TOUCH_DOWN || rawEventType == LIBINPUT_EVENT_TOUCH_MOTION) { currentPosition = new Point( x: libinput_event_touch_get_x_transformed(rawTouchEvent, (int)_displayInformation.ScreenWidthInRawPixels), y: libinput_event_touch_get_y_transformed(rawTouchEvent, (int)_displayInformation.ScreenHeightInRawPixels)); _activePointers[pointerId] = currentPosition; } else { _activePointers.TryGetValue(pointerId, out currentPosition); _activePointers.Remove(pointerId); } if (this.Log().IsEnabled(LogLevel.Trace)) { this.Log().Trace($"ProcessTouchEvent: {rawEventType}, pointerId:{pointerId}, currentPosition:{currentPosition}, timestamp:{timestamp}"); } switch (rawEventType) { case LIBINPUT_EVENT_TOUCH_MOTION: raisePointerEvent = _ownerEvents.RaisePointerMoved; break; case LIBINPUT_EVENT_TOUCH_DOWN: properties.PointerUpdateKind = LeftButtonPressed; raisePointerEvent = _ownerEvents.RaisePointerPressed; break; case LIBINPUT_EVENT_TOUCH_UP: properties.PointerUpdateKind = LeftButtonReleased; raisePointerEvent = _ownerEvents.RaisePointerReleased; break; case LIBINPUT_EVENT_TOUCH_CANCEL: properties.PointerUpdateKind = LeftButtonReleased; raisePointerEvent = _ownerEvents.RaisePointerCancelled; break; } properties.IsLeftButtonPressed = rawEventType != LIBINPUT_EVENT_TOUCH_UP && rawEventType != LIBINPUT_EVENT_TOUCH_CANCEL; var pointerPoint = new Windows.UI.Input.PointerPoint( frameId: (uint)timestamp, // UNO TODO: How should set the frame, timestamp may overflow. timestamp: timestamp, device: PointerDevice.For(PointerDeviceType.Touch), pointerId: pointerId, rawPosition: currentPosition, position: currentPosition, isInContact: properties.HasPressedButton, properties: properties ); if (raisePointerEvent != null) { var args = new PointerEventArgs(pointerPoint, GetCurrentModifiersState()); RaisePointerEvent(raisePointerEvent, args); } else { this.Log().LogWarning($"Touch event type {rawEventType} was not handled"); } } }
public override void MouseUp(PointerPoint p) { Color = Colors.Gray; base.MouseUp(p); }
private void PointerMoved(PointerPoint pointerPoint) { // To convert from DIPs (device independent pixels) to actual screen resolution pixels. var dipFactor = DisplayProperties.LogicalDpi / 96.0f; var pos = new Vector2((float)pointerPoint.Position.X, (float)pointerPoint.Position.Y) * dipFactor; var isTouch = pointerPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Touch; var touchIsDown = pointerPoint.IsInContact; if (touchIsDown) { _touchQueue.Enqueue((int)pointerPoint.PointerId, TouchLocationState.Moved, pos, !isTouch); } if (!isTouch) { // Mouse or stylus event. UpdateMouse(pointerPoint); } }
private static void BtnRegenerate_Click(PointerPoint point) { OnTransitionState(GAMESTATE.GAME_INITIALIZE); }
private static void UpdateMouse(PointerPoint point) { // To convert from DIPs (device independent pixels) to screen resolution pixels. var dipFactor = DisplayProperties.LogicalDpi / 96.0f; var x = (int)(point.Position.X * dipFactor); var y = (int)(point.Position.Y * dipFactor); var state = point.Properties; Mouse.PrimaryWindow.MouseState.X = x; Mouse.PrimaryWindow.MouseState.Y = y; Mouse.PrimaryWindow.MouseState.ScrollWheelValue += state.MouseWheelDelta; Mouse.PrimaryWindow.MouseState.LeftButton = state.IsLeftButtonPressed ? ButtonState.Pressed : ButtonState.Released; Mouse.PrimaryWindow.MouseState.RightButton = state.IsRightButtonPressed ? ButtonState.Pressed : ButtonState.Released; Mouse.PrimaryWindow.MouseState.MiddleButton = state.IsMiddleButtonPressed ? ButtonState.Pressed : ButtonState.Released; }
internal static void PointerReleased(PointerPoint point, PointerPointProperties pointProperties) { if (CustomizationPanel.HitTest(point.Position)) { CustomizationPanel.MouseUp(point); } }
private void MaskRectangle_PointerPressed(object sender, PointerRoutedEventArgs e) { if (startPoint != null) return; startPoint = e.GetCurrentPoint(overlapGrid); endPoint = e.GetCurrentPoint(overlapGrid); updateArea(); }
private void Touch_FrameReported(PointerPoint pp, Point p) { if (pp == null) return; if (pointerId == 0) pointerId = pp.PointerId; if (pointerId == pp.PointerId) Touch_FrameReported(p); }
void HandlePointerEvent(WinRTPointerPoint p, PointerState ptrState) { var pointerType = ConvertPointerDeviceType(p.PointerDevice.PointerDeviceType); var isMouse = pointerType == PointerType.Mouse; var position = NormalizeScreenPosition(PointToVector2(p.Position)); if (isMouse) { if (ptrState == PointerState.Cancel || ptrState == PointerState.Out) { // invalidate mouse and current pointers LostFocus = true; for (int i = 0; i < MouseButtonCurrentlyDown.Length; i++) { if (MouseButtonCurrentlyDown[i]) { HandlePointerEvents(i, position, PointerState.Out, pointerType); MouseButtonCurrentlyDown[i] = false; } } } else // down/up/move { // Note: The problem here is that the PointerPressed event is not triggered twice when two button are pressed together. // That is why we are forced to continuously keep the state of all buttons of the mouse. MouseInputEvent mouseEvent; // Trigger mouse button and pointer Down events for newly pressed buttons. foreach (MouseButton button in Enum.GetValues(typeof(MouseButton))) { var buttonId = (int)button; if (!MouseButtonCurrentlyDown[buttonId] && MouseButtonIsPressed(p.Properties, button)) { lock (MouseInputEvents) { mouseEvent = new MouseInputEvent { Type = InputEventType.Down, MouseButton = button }; MouseInputEvents.Add(mouseEvent); } HandlePointerEvents(buttonId, position, PointerState.Down, pointerType); MouseButtonCurrentlyDown[buttonId] = true; } } // Trigger Move events to pointer that have changed position if (CurrentMousePosition != position) { foreach (MouseButton button in Enum.GetValues(typeof(MouseButton))) { var buttonId = (int)button; if (MouseButtonCurrentlyDown[buttonId]) { HandlePointerEvents(buttonId, position, PointerState.Move, pointerType); } } } // Trigger mouse button and pointer Up events for newly released buttons. foreach (MouseButton button in Enum.GetValues(typeof(MouseButton))) { var buttonId = (int)button; if (MouseButtonCurrentlyDown[buttonId] && !MouseButtonIsPressed(p.Properties, button)) { lock (MouseInputEvents) { mouseEvent = new MouseInputEvent { Type = InputEventType.Up, MouseButton = button }; MouseInputEvents.Add(mouseEvent); } HandlePointerEvents(buttonId, position, PointerState.Up, pointerType); MouseButtonCurrentlyDown[buttonId] = false; } } // Trigger mouse wheel events if (Math.Abs(p.Properties.MouseWheelDelta) > MathUtil.ZeroTolerance) { lock (MouseInputEvents) { mouseEvent = new MouseInputEvent { Type = InputEventType.Wheel, MouseButton = MouseButton.Middle, Value = p.Properties.MouseWheelDelta }; MouseInputEvents.Add(mouseEvent); } } } // Update mouse cursor position CurrentMousePosition = position; } else { HandlePointerEvents((int)p.PointerId, position, ptrState, pointerType); } }
private void frontBuffer_PointerPressed(object sender, PointerRoutedEventArgs e) { dragging = true; pointClicked = e.GetCurrentPoint(frontBuffer); Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1); }
private void Touch_FrameReported(PointerPoint pp) { if (pp == null) return; Touch_FrameReported(pp, pp.Position); }
private void Rectang_PointerPressed(object sender, PointerRoutedEventArgs e) { TPanel rec = (TPanel)sender; childList.ToFront(rec); rec.CapturePointer(e.Pointer); origin = e.GetCurrentPoint(null); objectInUse = rec; originMargin = rec.Margin; e.Handled = true; }