Example #1
0
        protected override void OnAttached()
        {
            base.OnAttached();

            attachedElement = (ScrollViewer)this.AssociatedObject;

            attachedElement.PreviewStylusDown += (s, e) =>
            {
                MultitouchWindow.SafeCaptureStylus(e.StylusDevice, attachedElement);
                _processor.ProcessDown((uint)e.StylusDevice.Id, ToDrawingPointF(e.GetPosition(attachedElement)));
            };
            attachedElement.PreviewStylusUp += (s, e) =>
            {
                MultitouchWindow.SafeCaptureStylus(e.StylusDevice, null);
                _processor.ProcessUp((uint)e.StylusDevice.Id, ToDrawingPointF(e.GetPosition(attachedElement)));
            };
            attachedElement.PreviewStylusMove += (s, e) =>
            {
                _processor.ProcessMove((uint)e.StylusDevice.Id, ToDrawingPointF(e.GetPosition(attachedElement)));
            };

            attachedElement.PreviewMouseDown += (s, e) =>
            {
                MultitouchWindow.SafeCaptureMouse(attachedElement);
                _processor.ProcessDown((uint)1 << 31, ToDrawingPointF(e.GetPosition(attachedElement)));
            };
            attachedElement.PreviewMouseUp += (s, e) =>
            {
                MultitouchWindow.SafeCaptureMouse(null);
                _processor.ProcessUp((uint)1 << 31, ToDrawingPointF(e.GetPosition(attachedElement)));
            };
            attachedElement.PreviewMouseMove += (s, e) =>
            {
                _processor.ProcessMove((uint)1 << 31, ToDrawingPointF(e.GetPosition(attachedElement)));
            };

            //Handle the ManipulationDelta and the gestures
            _processor.ManipulationDelta += ProcessManipulationDelta;
            _processor.PivotRadius        = 2;
        }
Example #2
0
        protected override void OnAttached()
        {
            _attachedElement = this.AssociatedObject;

            _attachedElement.PreviewStylusDown += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                MultitouchWindow.SafeCaptureStylus(e.StylusDevice, _attachedElement);
                e.Handled = true;
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessDown((uint)e.StylusDevice.Id, (float)pos.X, (float)pos.Y);
            };
            _attachedElement.PreviewStylusUp += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                MultitouchWindow.SafeCaptureStylus(e.StylusDevice, null);
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessUp((uint)e.StylusDevice.Id, (float)pos.X, (float)pos.Y);
            };
            _attachedElement.PreviewStylusMove += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessMove((uint)e.StylusDevice.Id, (float)pos.X, (float)pos.Y);
            };

            _attachedElement.PreviewMouseDown += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                MultitouchWindow.SafeCaptureMouse(_attachedElement);
                e.Handled = true;
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessDown(1 << 30, (float)pos.X, (float)pos.Y);
            };

            _attachedElement.PreviewMouseUp += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                MultitouchWindow.SafeCaptureMouse(null);
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessUp(1 << 30, (float)pos.X, (float)pos.Y);
            };
            _attachedElement.PreviewMouseMove += (s, e) =>
            {
                if (Container == null)
                {
                    return;
                }
                Point pos = e.GetPosition(Container);
                UpdatePivot();
                _mprocessor.ProcessMove(1 << 30, (float)pos.X, (float)pos.Y);
            };
        }