示例#1
0
        void OnTouchFrameReported(object sender, TouchFrameEventArgs args)
        {
            TouchPoint touchPoint = args.GetPrimaryTouchPoint(this);

            if (touchPoint != null && touchPoint.Action == TouchAction.Down)
            {
                args.SuspendMousePromotionUntilTouchUp();
            }

            if (touchPoint != null && touchPoint.TouchDevice.DirectlyOver is Rectangle)
            {
                Rectangle rectangle = (touchPoint.TouchDevice.DirectlyOver as Rectangle);

                // This DataContext is an object of type Student
                object dataContext = rectangle.DataContext;
                studentDisplay.DataContext = dataContext;

                if (touchPoint.Action == TouchAction.Down)
                {
                    studentDisplay.Visibility = Visibility.Visible;
                }

                else if (touchPoint.Action == TouchAction.Up)
                {
                    studentDisplay.Visibility = Visibility.Collapsed;
                }
            }
        }
示例#2
0
        void OnTouchFrameReported(object sender, TouchFrameEventArgs args)
        {
            TouchPoint primaryTouchPoint = args.GetPrimaryTouchPoint(null);

            if (primaryTouchPoint != null && primaryTouchPoint.Action == TouchAction.Down)
            {
                args.SuspendMousePromotionUntilTouchUp();
            }

            TouchPointCollection touchPoints = args.GetTouchPoints(inkPresenter);

            foreach (TouchPoint touchPoint in touchPoints)
            {
                Point pt = touchPoint.Position;
                int   id = touchPoint.TouchDevice.Id;

                switch (touchPoint.Action)
                {
                case TouchAction.Down:
                    Stroke stroke = new Stroke();
                    stroke.DrawingAttributes.Color  = appSettings.Foreground;
                    stroke.DrawingAttributes.Height = appSettings.StrokeWidth;
                    stroke.DrawingAttributes.Width  = appSettings.StrokeWidth;
                    stroke.StylusPoints.Add(new StylusPoint(pt.X, pt.Y));

                    inkPresenter.Strokes.Add(stroke);
                    activeStrokes.Add(id, stroke);
                    break;

                case TouchAction.Move:
                    activeStrokes[id].StylusPoints.Add(new StylusPoint(pt.X, pt.Y));
                    break;

                case TouchAction.Up:
                    activeStrokes[id].StylusPoints.Add(new StylusPoint(pt.X, pt.Y));
                    activeStrokes.Remove(id);

                    TitleAndAppbarUpdate();
                    break;
                }
            }
        }