コード例 #1
0
        // Touch move event handler.
        /// <summary>
        /// 在move过程判断具体的手势(zoom,pan,rotate)
        /// </summary>
        /// <param name="drawingCanvas"></param>
        /// <param name="e"></param>
        public void TouchMoveHandler(DrawingCanvas drawingCanvas, TouchEventArgs e)
        {
            GraphicsPolyLine polyLine;

            if (_activeStrokes.TryGetValue(e.TouchDevice.Id, out polyLine))
            {
                TouchPoint touchPoint = e.GetTouchPoint(drawingCanvas);
                Point      p          = touchPoint.Position;
                polyLine.AddPoint(p);
                if (e.TouchDevice.Id == GestureData.FirstDeviceId)
                {
                    GestureData.FirstFingerCurPoint = p;
                }
                if (e.TouchDevice.Id == GestureData.SecondDeviceId)
                {
                    GestureData.SecFingerCurPoint = p;
                }
                //polyLine.AddToCanvas(drawingCanvas);
                //判断出具体手势,然后根据手势,在case中按照相应的比例绘画图像。
                if (GestureData.IsGesture)
                {
                    GestureId gestureId   = HelperFunctions.getGestureId(drawingCanvas, e);
                    bool      hasSelected = HelperFunctions.hasSelected(drawingCanvas);
                    System.Diagnostics.Debug.WriteLine("hasSelected:{0}", hasSelected);
                    switch (gestureId)
                    {
                    case GestureId.ZOOM:
                        if (hasSelected)
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                if (b.IsOption)
                                {
                                    b.Zoom(GestureData.ZoomScale, GestureData.StartCenterPointInTwoFingers);
                                }
                            }
                        }
                        else
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                b.Zoom(GestureData.ZoomScale, GestureData.StartCenterPointInTwoFingers);
                            }
                        }
                        break;

                    case GestureId.PAN:
                        if (hasSelected)
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                if (b.IsOption)
                                {
                                    b.Move(GestureData.Panx, GestureData.Pany);
                                }
                            }
                        }
                        else
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                b.Move(GestureData.Panx, GestureData.Pany);
                            }
                        }
                        break;

                    case GestureId.RORATE:
                        if (hasSelected)
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                if (b.IsOption)
                                {
                                    b.Rotate(GestureData.RotateAngle, GestureData.StartCenterPointInTwoFingers);
                                }
                            }
                        }
                        else
                        {
                            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
                            {
                                b.Rotate(GestureData.RotateAngle, GestureData.StartCenterPointInTwoFingers);
                            }
                        }
                        break;

                    case GestureId.ERASE:
                        break;

                    default:
                        break;
                    }
                }
            }
            System.Diagnostics.Debug.WriteLine("Touchmove");
        }