protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            Button button = FindViewById <Button> (Resource.Id.myButton);

            FrameLayout mainFrameLayout = FindViewById <FrameLayout> (Resource.Id.Main_frameLayout);

            customImageView = new ScalableImageView(this);
            mainFrameLayout.AddView(customImageView, 0);

            pageToast = Toast.MakeText(this, "", ToastLength.Short);

            customImageView.OnFlingLeft += delegate {
                ShowPageToast($"Left {++flingCount}");
            };

            customImageView.OnFlingRight += delegate {
                ShowPageToast($"Right {++flingCount}");
            };

            customImageView.SetImageResource(Resource.Drawable.sample);

            MemoryPressure();
        }
Exemplo n.º 2
0
            public bool OnTouch(View v, MotionEvent evnt)
            {
                imgView = (ScalableImageView)v;
                flingGestureDetector.OnTouchEvent(evnt);
                mScaleDetector.OnTouchEvent(evnt);
                PointF curr = new PointF(evnt.GetX(), evnt.GetY());

                switch (evnt.Action)
                {
                case MotionEventActions.Down:
                    last.Set(curr);
                    start.Set(last);
                    currentState = State.DRAG;
                    //mode = TouchImageView.DRAG;
                    break;

                case MotionEventActions.Move:
                    //if (mode == DRAG)
                    if (currentState == State.DRAG)
                    {
                        float deltaX    = curr.X - last.X;
                        float deltaY    = curr.Y - last.Y;
                        float fixTransX = imgView.getFixDragTrans(deltaX, imgView.viewWidth, imgView.origWidth * imgView.saveScale);
                        float fixTransY = imgView.getFixDragTrans(deltaY, imgView.viewHeight, imgView.origHeight * imgView.saveScale);
                        imgView.matrix.PostTranslate(fixTransX, fixTransY);
                        imgView.fixTrans();
                        last.Set(curr.X, curr.Y);
                    }
                    break;

                case MotionEventActions.Up:
                    //mode = NONE;
                    currentState = State.NONE;
                    int xDiff = (int)Math.Abs(curr.X - start.X);
                    int yDiff = (int)Math.Abs(curr.Y - start.Y);
                    if (xDiff < CLICK && yDiff < CLICK)
                    {
                        PerformClick();
                    }
                    break;

                case MotionEventActions.PointerUp:
                    //mode = NONE;
                    currentState = State.NONE;
                    break;
                }

                imgView.ImageMatrix = imgView.matrix;
                Invalidate();
                //return true; // indicate event was handled
                return(false);
            }
Exemplo n.º 3
0
 public ScaleListener(ScalableImageView imgView)
 {
     this.imgView = imgView;
 }