Пример #1
0
 private void OnStylusStuff(object sender, StylusEventArgs args)
 {
     if (args.RoutedEvent == UIElement.PreviewStylusUpEvent ||
         (args.RoutedEvent == UIElement.PreviewStylusDownEvent && args.Source == null) ||
         (args.RoutedEvent == UIElement.PreviewStylusMoveEvent && args.Source == null && args.InAir))
     {
         _pts.Remove(args.StylusDevice.Id);
         MultitouchWindow.ClearPhysicalReferenceFrame(args.StylusDevice);
         MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff);
         _processor.ProcessUp((uint)args.StylusDevice.Id, ToDrawingPointF(args.GetPosition(_attachedElement)));
     }
     else if (args.RoutedEvent == UIElement.PreviewStylusDownEvent)
     {
         System.Windows.Point pt = args.GetPosition(_attachedElement);
         _pts.Add(args.StylusDevice.Id, pt);
         MultitouchWindow.PushPhysicalReferenceFrame(args.StylusDevice, this);
         MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff);
         _processor.ProcessDown((uint)args.StylusDevice.Id, ToDrawingPointF(pt));
     }
     else if (args.RoutedEvent == UIElement.PreviewStylusMoveEvent)
     {
         if (!_pts.ContainsKey(-1))
         {
             return;
         }
         //_processor.ProcessMove((uint)args.StylusDevice.Id, ToDrawingPointF(args.GetPosition(_attachedElement)));
     }
 }
Пример #2
0
        private void OnMouseStuff(object sender, MouseEventArgs args)
        {
            if (args.RoutedEvent == UIElement.PreviewMouseUpEvent ||
                (args.RoutedEvent == UIElement.PreviewMouseLeftButtonDownEvent && args.Source == null) ||
                (args.RoutedEvent == UIElement.PreviewMouseMoveEvent && args.Source == null && args.LeftButton == MouseButtonState.Released))
            {
                if (!_pts.ContainsKey(-1))
                {
                    return;
                }

                _pts.Remove(-1);
                MultitouchWindow.RemoveMouseListener(_attachedElement, OnMouseStuff);
                MultitouchWindow.ClearPhysicalReferenceFrame(args.MouseDevice);
                _processor.ProcessUp(unchecked ((uint)-1), ToDrawingPointF(args.GetPosition(_attachedElement)));
            }
            else if (args.RoutedEvent == UIElement.PreviewMouseDownEvent)
            {
                _pts[-1] = args.GetPosition(_attachedElement);
                MultitouchWindow.AddMouseListener(_attachedElement, OnMouseStuff);
                MultitouchWindow.PushPhysicalReferenceFrame(args.MouseDevice, this);
                _processor.ProcessDown(unchecked ((uint)-1), ToDrawingPointF(_pts[-1]));
            }
            else if (args.RoutedEvent == UIElement.PreviewMouseMoveEvent)
            {
                if (!_pts.ContainsKey(-1))
                {
                    return;
                }

                //_processor.ProcessMove(unchecked((uint)-1), ToDrawingPointF(args.GetPosition(_attachedElement)));
            }
        }