Ejemplo n.º 1
0
        /// <summary>
        /// Sent when one or more fingers touches the screen.
        /// </summary>
        /// <param name="touches">Set containing the touches as objects of type <see cref="T:UIKit.UITouch" />.</param>
        /// <param name="evt"><para>The UIEvent that encapsulates all of the touches and the event information.</para>
        /// <para tool="nullallowed">This parameter can be <see langword="null" />.</para></param>
        /// <remarks><para>
        /// The <paramref name="touches" /> set containing all of the touch events.
        /// </para>
        /// <para>
        /// If your application tracks the touches starting with this
        /// method, it should also override both the <see cref="M:UIKit.UIResponder.TouchesEnded(Foundation.NSSet,&#xA;     UIKit.UIEvent)" /> and <see cref="M:UIKit.UIResponder.TouchesCancelled(Foundation.NSSet,&#xA;     UIKit.UIEvent)" /> methods to track the end of
        /// the touch processing.
        /// </para>
        /// <para>
        /// UIViews by default only receive a single touch event at
        /// once, if you want to receive multiple touches at the same
        /// time, set the <see cref="P:UIView.MultipleTouchEnabled" /> property
        /// to true.
        /// </para>
        /// <para>
        /// If you only want to handle a single touch, the following idiom can be used:
        /// </para>
        /// <example>
        ///   <code lang="C#"><![CDATA[
        /// public override void TouchesBegan (NSSet touches, UIEvent evt)
        /// {
        /// var touch = touches.AnyObject as UITouch;
        /// Console.WriteLine (touch);
        /// }
        /// ]]></code>
        /// </example>
        /// <para>
        /// If you want to handle multiple touches, you can use this idiom:
        /// </para>
        /// <example>
        ///   <code lang="C#"><![CDATA[
        /// public override void TouchesBegan (NSSet touches, UIEvent evt)
        /// {
        /// foreach (UITouch touch in touches.ToArray<UITouch> ()){
        /// Console.WriteLine (touch);
        /// }
        /// }
        /// ]]></code>
        /// </example></remarks>
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            _indexCount++;

            var path = new UIBezierPath
            {
                LineWidth = PenWidth
            };

            var touch = (UITouch)touches.AnyObject;

            _previousPoint = touch.PreviousLocationInView(this);

            var newPoint = touch.LocationInView(this);

            path.MoveTo(newPoint);

            InvokeOnMainThread(SetNeedsDisplay);

            _currentPath = path;

            var line = new VESLine
            {
                Path  = _currentPath,
                Color = CurrentLineColor,
                Index = _indexCount
            };

            _lines.Add(line);
        }
 public override void TouchesBegan(NSSet touches, UIEvent evt)
 {
     IndexCount++;
     var path = new UIBezierPath
     {
         LineWidth = PenWidth
     };
     var touch = (UITouch)touches.AnyObject;
     PreviousPoint = touch.PreviousLocationInView(this);
     var newPoint = touch.LocationInView(this);
     path.MoveTo(newPoint);
     InvokeOnMainThread(SetNeedsDisplay);
     CurrentPath = path;
     var line = new VESLine
     {
         Path = CurrentPath,
         Color = CurrentLineColor,
         Index = IndexCount
     };
     Lines.Add(line);
     PointerDown = true;
     PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs.
          PointerEventType.Down, PreviousPoint.ToPoint(), newPoint.ToPoint(), PointerDown));
 }