Esempio n. 1
0
        public override void TouchesMoved(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);
            var touch = touches.First() as UITouch;

            if (touch == null)
            {
                return;
            }
            var bounds = Bounds.Ceiling();

            UIGraphics.BeginImageContextWithOptions(bounds.Size, false, 0);
            var context = UIGraphics.GetCurrentContext();

            DrawingImage?.Draw(bounds);

            var allTouches       = new List <UITouch> ();
            var coalescedTouches = evt.GetCoalescedTouches(touch);

            if (coalescedTouches != null)
            {
                allTouches = coalescedTouches.ToList();
            }
            else
            {
                allTouches.Append(touch);
            }

            foreach (var unused in touches)
            {
                DrawStroke(context, touch);
            }

            // 1
            DrawingImage = UIGraphics.GetImageFromCurrentImageContext();
            var predictedTouches = evt.GetPredictedTouches(touch);

            foreach (var t in predictedTouches)
            {
                DrawStroke(context, t);
            }
            Image = UIGraphics.GetImageFromCurrentImageContext();

            // Update image
            UIGraphics.EndImageContext();
        }