Example #1
0
        internal void TouchesEnded(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                Vector2 location = new Vector2(touch.LocationInView(touch.View).X, touch.LocationInView(touch.View).Y);

                // Check where is the touch
                if (Visible)
                {
                    foreach (ButtonDefinition button in _buttonsDefinitions)
                    {
                        if (CheckButtonHit(button, location))
                        {
                            _buttons &= ~(int)button.Type;
                        }
                    }
                    if ((_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition, location)))
                    {
                        LeftThumbStickDefinition.Offset = Vector2.Zero;
                        _leftStick = Vector2.Zero;
                    }
                    if ((_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition, location)))
                    {
                        _rightThumbDefinition.Offset = Vector2.Zero;
                        _rightStick = Vector2.Zero;
                    }
                }
            }
        }
        public override void TouchesMoved(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            if (firstTouch)
            {
                firstTouch         = false;
                PreviousLocation   = touch.PreviousLocationInView(this);
                PreviousLocation.Y = bounds.Height - PreviousLocation.Y;
            }
            else
            {
                Location           = touch.LocationInView(this);
                Location.Y         = bounds.Height - Location.Y;
                PreviousLocation   = touch.PreviousLocationInView(this);
                PreviousLocation.Y = bounds.Height - PreviousLocation.Y;
            }

            if (_line.Points == null)
            {
                _line.Points = new List <PointF> ();
            }

            _line.Points.Add(new PointF(Location.X, Location.Y));

            RenderLineFromPoint(PreviousLocation, Location);
        }
Example #3
0
        public void actionTakeAPicture(NSObject sender, MonoTouch.UIKit.UIEvent @event)
        {
            Console.WriteLine("actionTakeAPicture");
            var u = new NSUrl("tel:" + DetailItem.Mobile);

            UIApplication.SharedApplication.OpenUrl(u);
        }
Example #4
0
 public override void TouchesEnded(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
 {
     StartLocation = Location;
     //Publish to aggregator
     _aggregator.Publish(new MovementFinished {
         FinishDateTime = DateTime.Now
     });
 }
Example #5
0
        public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            firstTouch = true;
            Location   = touch.LocationInView(this);
            Location.Y = bounds.Height - Location.Y;
        }
Example #6
0
        public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            Location = this.Frame.Location;

            var touch  = (UITouch)e.TouchesForView(this).AnyObject;
            var bounds = Bounds;

            StartLocation = touch.LocationInView(this);
            this.Frame    = new RectangleF(Location, bounds.Size);
        }
Example #7
0
        public override void TouchesEnded(NSSet touches, MonoTouch.UIKit.UIEvent evt)
        {
            var touch = (UITouch)touches.AnyObject;

            if (touch.TapCount == 1)
            {
                var endTouch = new PointF(touch.LocationInView(this).X, touch.LocationInView(this).Y);
                HandleTapAtPoint(endTouch);
            }
        }
Example #8
0
        public override void TouchesMoved(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            Location.X         += touch.LocationInView(this).X - StartLocation.X;
            Location.Y         += touch.LocationInView(this).Y - StartLocation.Y;
            this.Frame          = new RectangleF(Location, bounds.Size);
            haveBeenTouchedOnce = true;
        }
Example #9
0
        public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            this.minX = -this.Frame.Width / 2;
            this.maxX = this.Superview.Frame.Width - this.Frame.Width / 2;
            //Console.WriteLine ("Touched the object");
            location = this.Frame.Location;

            var touch  = (UITouch)e.TouchesForView(this).AnyObject;
            var bounds = Bounds;

            startLocation = touch.LocationInView(this);
            this.Frame    = new RectangleF(location, bounds.Size);
        }
Example #10
0
        public override void TouchesEnded(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            if (firstTouch)
            {
                firstTouch         = false;
                PreviousLocation   = touch.PreviousLocationInView(this);
                PreviousLocation.Y = bounds.Height - PreviousLocation.Y;
                RenderLineFromPoint(PreviousLocation, Location);
            }
        }
Example #11
0
        public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            firstTouch  = true;
            Location    = touch.LocationInView(this);
            Location.Y  = bounds.Height - Location.Y;
            _line       = new Line();
            _line.Color = Color.Selected;

            // Change back as it might have changed on recieved line
            Color.ChangeBrushColor(Color.Selected);
        }
Example #12
0
        internal void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e, iOSGameView view)
        {
            // Reset State
            //Reset();

            // Check where is the touch
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                var     point    = touch.LocationInView(touch.View);
                Vector2 location = new Vector2(point.X, point.Y);
                location = view.GetOffsetPosition(location, true);

                // Check where is the touch
                bool hitInButton = false;

                if (Visible)
                {
                    foreach (ButtonDefinition button in _buttonsDefinitions)
                    {
                        hitInButton |= UpdateButton(button, location);
                        UpdateTouch(touch, button);
                    }
                }
                if (!hitInButton)
                {
                    // check the left thumbstick
                    if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition, location)))
                    {
                        _leftThumbDefinition.InitialHit = location;
                        UpdateTouch(touch, _leftThumbDefinition);
                    }
                    else
                    {
                        // check the right thumbstick
                        if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition, location)))
                        {
                            _rightThumbDefinition.InitialHit = location;
                            UpdateTouch(touch, _rightThumbDefinition);
                        }
                        else                                 // Handle mouse
                        {
                            Mouse.State.X = (int)location.X;
                            Mouse.State.Y = (int)location.Y;
                        }
                    }
                }
            }
        }
Example #13
0
        public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent evt)
        {
            foreach (UITouch touch in touches)
            {
                var location = touch.LocationInNode(this);
                var sprite   = new SKSpriteNode("Spaceship")
                {
                    Position = location,
                };

                var action = SKAction.RotateByAngle((float)Math.PI, 1);
                sprite.RunAction(SKAction.RepeatActionForever(action));

                AddChild(sprite);
            }
        }
Example #14
0
        internal void TouchesBegan(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            // Reset State
            Reset();

            // Check where is the touch
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                Vector2 location = new Vector2(touch.LocationInView(touch.View));

                // Check where is the touch
                bool hitInButton = false;

                if (Visible)
                {
                    foreach (ButtonDefinition button in _buttonsDefinitions)
                    {
                        hitInButton |= UpdateButton(button, location);
                    }
                }
                if (!hitInButton)
                {
                    // check the left thumbstick
                    if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition, location)))
                    {
                        _leftThumbDefinition.InitialHit = location;
                    }
                    else
                    {
                        // check the right thumbstick
                        if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition, location)))
                        {
                            _rightThumbDefinition.InitialHit = location;
                        }
                        else                         // Handle mouse
                        {
                            Mouse.SetPosition((int)location.X, (int)location.Y);
                        }
                    }
                }
            }
        }
Example #15
0
        internal void TouchesEnded(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e, iOSGameView view)
        {
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                var     point    = touch.LocationInView(touch.View);
                Vector2 location = new Vector2(point.X, point.Y);
                location = view.GetOffsetPosition(location, true);

                // Check where is the touch
                if (Visible)
                {
                    var oldItem = GetTouchesObject(touch);
                    if (oldItem == null)
                    {
                        continue;
                    }
                    if (oldItem is ButtonDefinition)
                    {
                        ButtonDefinition button = (ButtonDefinition)oldItem;
                        if (CheckButtonHit(button, location))
                        {
                            _buttons &= ~(int)button.Type;
                        }
                    }
                    else if (oldItem == _leftThumbDefinition)
                    {
                        LeftThumbStickDefinition.Offset = Vector2.Zero;
                        _leftStick = Vector2.Zero;
                    }
                    else if (oldItem == _rightThumbDefinition)
                    {
                        _rightThumbDefinition.Offset = Vector2.Zero;
                        _rightStick = Vector2.Zero;
                    }
                    RemoveTouch(touch);
                }
            }
            Reset();
        }
Example #16
0
        //This event occurs when you drag it around
        public override void TouchesMoved(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            //Console.WriteLine ("Dragged the object");
            var bounds = Bounds;
            var touch  = (UITouch)e.TouchesForView(this).AnyObject;

            //Always refer to the StartLocation of the object that you've been dragging.
            var changeX = touch.LocationInView(this).X - startLocation.X;
            var newX    = location.X + changeX;

            if (newX >= minX && newX <= maxX)
            {
                location.X = newX;
                if (this.DragTarget != null)
                {
                    this.DragTarget.MoveX(changeX);
                }
            }
            //location.Y += touch.LocationInView (this).Y - startLocation.Y;


            this.Frame = new RectangleF(location, bounds.Size);
        }
Example #17
0
        internal void TouchesMoved(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e, iOSGameView view)
        {
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                var     point    = touch.LocationInView(touch.View);
                Vector2 location = new Vector2(point.X, point.Y);
                location = view.GetOffsetPosition(location, true);

                var oldItem = GetTouchesObject(touch);
                // Check if touch any button
                bool hitInButton = false;
                if (Visible)
                {
                    if (oldItem != null && oldItem is ButtonDefinition)
                    {
                        hitInButton |= UpdateButton((ButtonDefinition)oldItem, location);
                    }
                    if (!hitInButton)
                    {
                        foreach (ButtonDefinition button in _buttonsDefinitions)
                        {
                            hitInButton |= UpdateButton(button, location);
                            if (hitInButton)
                            {
                                UpdateTouch(touch, button);
                                continue;
                            }
                        }
                    }
                }

                if (!hitInButton)
                {
                    if (oldItem != null && oldItem == _leftThumbDefinition)
                    {
                        Vector2 movement = location - LeftThumbStickDefinition.InitialHit;
                        if (movement.X > 20)
                        {
                            movement.X = 20;
                        }
                        else if (movement.X < -20)
                        {
                            movement.X = -20;
                        }

                        if (movement.Y > 20)
                        {
                            movement.Y = 20;
                        }
                        else if (movement.Y < -20)
                        {
                            movement.Y = -20;
                        }
                        _leftThumbDefinition.Offset = movement;
                        _leftStick = new Vector2(movement.X / 20, movement.Y / -20);
                    }
                    else if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition, location)))
                    {
                        Vector2 movement = location - LeftThumbStickDefinition.InitialHit;

                        UpdateTouch(touch, _leftThumbDefinition);
                        LeftThumbStickDefinition.InitialHit = location;

                        // Keep the stick in the "hole"
                        float radius = (movement.X * movement.X) + (movement.Y * movement.Y);

                        if (radius <= _thumbStickRadius)
                        {
                            _leftThumbDefinition.Offset = movement;
                            _leftStick = new Vector2(movement.X / 20, movement.Y / -20);
                        }
                    }
                    else
                    {
                        // reset left thumbstick
                        if (_leftThumbDefinition != null)
                        {
                            _leftThumbDefinition.Offset = Vector2.Zero;
                            _leftStick = Vector2.Zero;
                        }


                        if (oldItem != null && oldItem == _rightThumbDefinition)
                        {
                            Vector2 movement = location - _rightThumbDefinition.InitialHit;
                            _rightThumbDefinition.Offset = movement;
                            _rightStick = new Vector2(movement.X / 20, movement.Y / -20);
                        }
                        else if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition, location)))
                        {
                            Vector2 movement = location - _rightThumbDefinition.InitialHit;

                            // Keep the stick in the "hole"
                            float radius = (movement.X * movement.X) + (movement.Y * movement.Y);
                            if (radius <= _thumbStickRadius)
                            {
                                _rightThumbDefinition.Offset = movement;
                                _rightStick = new Vector2(movement.X / 20, movement.Y / -20);
                            }
                        }
                        else
                        {
                            // reset right thumbstick
                            if (_rightThumbDefinition != null)
                            {
                                _rightThumbDefinition.Offset = Vector2.Zero;
                                _rightStick = Vector2.Zero;
                            }

                            // Handle the mouse
                            Mouse.State.X = (int)location.X;
                            Mouse.State.Y = (int)location.Y;
                        }
                    }
                }
            }
        }
Example #18
0
 internal void TouchesCancelled(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
 {
     // do nothing
 }
Example #19
0
 public override void TouchesCancelled(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
 {
 }
Example #20
0
 public override void TouchesBegan(NSSet touches, MonoTouch.UIKit.UIEvent evt)
 {
     base.TouchesBegan(touches, evt);
 }
Example #21
0
 public override void TouchesCancelled(NSSet touches, MonoTouch.UIKit.UIEvent evt)
 {
     base.TouchesCancelled(touches, evt);
 }
Example #22
0
        internal void TouchesMoved(MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
        {
            UITouch [] touchesArray = touches.ToArray <UITouch>();
            foreach (UITouch touch in touchesArray)
            {
                Vector2 location = new Vector2(touch.LocationInView(touch.View));
                // Check if touch any button
                bool hitInButton = false;
                if (Visible)
                {
                    foreach (ButtonDefinition button in _buttonsDefinitions)
                    {
                        hitInButton |= UpdateButton(button, location);
                    }
                }

                if (!hitInButton)
                {
                    if (Visible && (_leftThumbDefinition != null) && (CheckThumbStickHit(_leftThumbDefinition, location)))
                    {
                        Vector2 movement = location - LeftThumbStickDefinition.InitialHit;

                        // Keep the stick in the "hole"
                        float radius = (movement.X * movement.X) + (movement.Y * movement.Y);

                        if (radius <= _thumbStickRadius)
                        {
                            _leftThumbDefinition.Offset = movement;
                            _leftStick = new Vector2(movement.X / 20, movement.Y / -20);
                        }
                    }
                    else
                    {
                        // reset left thumbstick
                        if (_leftThumbDefinition != null)
                        {
                            _leftThumbDefinition.Offset = Vector2.Zero;
                            _leftStick = Vector2.Zero;
                        }

                        if (Visible && (_rightThumbDefinition != null) && (CheckThumbStickHit(_rightThumbDefinition, location)))
                        {
                            Vector2 movement = location - _rightThumbDefinition.InitialHit;

                            // Keep the stick in the "hole"
                            float radius = (movement.X * movement.X) + (movement.Y * movement.Y);

                            if (radius <= _thumbStickRadius)
                            {
                                _rightThumbDefinition.Offset = movement;
                                _rightStick = new Vector2(movement.X / 20, movement.Y / -20);
                            }
                        }
                        else
                        {
                            // reset right thumbstick
                            if (_rightThumbDefinition != null)
                            {
                                _rightThumbDefinition.Offset = Vector2.Zero;
                                _rightStick = Vector2.Zero;
                            }

                            // Handle the mouse
                            Mouse.SetPosition((int)location.X, (int)location.Y);
                        }
                    }
                }
            }
        }