예제 #1
0
        /// <summary>
        /// Converts <see cref="PointerRoutedEventArgs" /> to <see cref="OxyMouseEventArgs" /> for a mouse event.
        /// </summary>
        /// <param name="e">The <see cref="PointerRoutedEventArgs" /> instance containing the event data.</param>
        /// <param name="relativeTo">The <see cref="UIElement" /> that the event is relative to.</param>
        /// <returns>A <see cref="OxyMouseEventArgs" /> containing the converted event arguments.</returns>
        public static OxyMouseEventArgs ToMouseEventArgs(this PointerRoutedEventArgs e, UIElement relativeTo)
        {
            var point = e.GetCurrentPoint(relativeTo);

            return(new OxyMouseEventArgs
            {
                Position = point.Position.ToScreenPoint(),
                ModifierKeys = e.GetModifierKeys(),
            });
        }
예제 #2
0
        /// <summary>
        /// Converts <see cref="PointerRoutedEventArgs" /> to <see cref="OxyMouseEventArgs" /> for a touch event.
        /// </summary>
        /// <param name="e">The <see cref="ManipulationCompletedRoutedEventArgs" /> instance containing the event data.</param>
        /// <param name="relativeTo">The <see cref="UIElement" /> that the event is relative to.</param>
        /// <returns>A <see cref="OxyMouseEventArgs" /> containing the converted event arguments.</returns>
        public static OxyTouchEventArgs ToTouchEventArgs(this PointerRoutedEventArgs e, UIElement relativeTo)
        {
            var point = e.GetCurrentPoint(relativeTo);

            var eventArgs = new OxyTouchEventArgs
            {
                Position     = point.Position.ToScreenPoint(),
                ModifierKeys = e.GetModifierKeys(),
            };

            return(eventArgs);
        }
예제 #3
0
        /// <summary>
        /// Converts <see cref="PointerRoutedEventArgs" /> to <see cref="OxyMouseEventArgs" /> for a mouse down event.
        /// </summary>
        /// <param name="e">The <see cref="PointerRoutedEventArgs" /> instance containing the event data.</param>
        /// <param name="relativeTo">The <see cref="UIElement" /> that the event is relative to.</param>
        /// <returns>A <see cref="OxyMouseDownEventArgs" /> containing the converted event arguments.</returns>
        public static OxyMouseDownEventArgs ToMouseDownEventArgs(this PointerRoutedEventArgs e, UIElement relativeTo)
        {
            var point = e.GetCurrentPoint(relativeTo);

            int clickCount = 1;

            if (MouseButtonHelper.IsDoubleClick(relativeTo, point.Position))
            {
                clickCount = 2;
            }

            return(new OxyMouseDownEventArgs
            {
                ChangedButton = point.Properties.GetPressedMouseButton(),
                Position = point.Position.ToScreenPoint(),
                ModifierKeys = e.GetModifierKeys(),
                ClickCount = clickCount
            });
        }