Beispiel #1
0
        public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            if (touchingImage == null || touchingImageRect == RectangleF.Empty)
            {
                touchingImage      = null;
                touchingImageRect  = RectangleF.Empty;
                touchingImageIndex = -1;
                //base.TouchesEnded(touches, evt);
                return;
            }

            var touchLocation = ((UITouch)evt.TouchesForView(this).AnyObject).LocationInView(this);
            var touchFrame    = new RectangleF(touchLocation.X, touchLocation.Y, 1, 1);

            if (touchFrame.IntersectsWith(touchingImageRect))
            {
                int touchedImageIndex = touchingImageIndex;

                touchingImage      = null;
                touchingImageRect  = RectangleF.Empty;
                touchingImageIndex = -1;

                //Fire off delegate
                if (this.ImageTapped != null)
                {
                    this.ImageTapped(touchedImageIndex);
                }
            }

            SetNeedsDisplay();
        }
Beispiel #2
0
        public override void TouchesCancelled(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesCancelled(touches, evt);

            touchingImage     = null;
            touchingImageRect = RectangleF.Empty;

            SetNeedsDisplay();
        }
Beispiel #3
0
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            var touchLocation = ((UITouch)evt.TouchesForView(this).AnyObject).LocationInView(this);
            var touchFrame    = new RectangleF(touchLocation.X, touchLocation.Y, 1, 1);

            int across = this.Bounds.Size.Width > 320 ? 6 : 4;
            int row    = 0;
            int col    = 0;

            int imgOn = 0;

            foreach (var img in Images)
            {
                float x       = col * ImageWidth + col * Padding + Padding;
                float y       = row * ImageHeight + row * Padding + Padding;
                var   imgRect = new RectangleF(x, y, ImageWidth, ImageHeight);

                if (touchFrame.IntersectsWith(imgRect))
                {
                    touchingImage      = img;
                    touchingImageRect  = imgRect;
                    touchingImageIndex = imgOn;
                    SetNeedsDisplay();
                    break;
                }

                col++;
                if (col >= across)
                {
                    row++;
                    col = 0;
                }
                imgOn++;
            }
        }