public override void SetScaleType(ScaleType scaleType)
 {
     if (null != mAttacher)
     {
         mAttacher.SetScaleType(scaleType);
     }
     else
     {
         mPendingScaleType = scaleType;
     }
 }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_zoom_toggle:
                mAttacher.SetZoomable(!mAttacher.CanZoom());
                return(true);

            case Resource.Id.menu_scale_fit_center:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.FitCenter);
                return(true);

            case Resource.Id.menu_scale_fit_start:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.FitStart);
                return(true);

            case Resource.Id.menu_scale_fit_end:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.FitEnd);
                return(true);

            case Resource.Id.menu_scale_fit_xy:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.FitXy);
                return(true);

            case Resource.Id.menu_scale_scale_center:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.Center);
                return(true);

            case Resource.Id.menu_scale_scale_center_crop:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.CenterCrop);
                return(true);

            case Resource.Id.menu_scale_scale_center_inside:
                mAttacher.SetScaleType(Android.Widget.ImageView.ScaleType.CenterInside);
                return(true);

            case Resource.Id.menu_scale_random_animate:
            case Resource.Id.menu_scale_random:
                Random r = new Random();

                float minScale    = mAttacher.GetMinimumScale();
                float maxScale    = mAttacher.GetMaximumScale();
                float randomScale = minScale + (float.Parse(r.NextDouble().ToString()) * (maxScale - minScale));
                mAttacher.SetScale(randomScale, item.ItemId == Resource.Id.menu_scale_random_animate);

                ShowToast(SCALE_TOAST_STRING + " " + randomScale);

                return(true);

            case Resource.Id.menu_matrix_restore:
                if (mCurrentDisplayMatrix == null)
                {
                    ShowToast("You need to capture display matrix first");
                }
                else
                {
                    mAttacher.SetDisplayMatrix(mCurrentDisplayMatrix);
                }
                return(true);

            case Resource.Id.menu_matrix_capture:
                mCurrentDisplayMatrix = mAttacher.GetDisplayMatrix();
                return(true);

            case Resource.Id.extract_visible_bitmap:
                return(true);
            }
            return(base.OnOptionsItemSelected(item));
        }