コード例 #1
0
        protected override void OnCropAdjustment(CroppingHandle handle, float distX, float distY)
        {
            if (photoView.IsCropAllowed(handle, distX, distY))
            {
                var oldCR     = photoView.CroppingRectangle;
                var distanceX = distX / photoView.Scale;
                var distanceY = distY / photoView.Scale;

                switch (handle)
                {
                case CroppingHandle.Left:
                    photoView.CroppingRectangle = new Rect((int)(oldCR.Left + distanceX), oldCR.Top, oldCR.Right, oldCR.Bottom);
                    break;

                case CroppingHandle.Right:
                    photoView.CroppingRectangle = new Rect(oldCR.Left, oldCR.Top, (int)(oldCR.Right + distanceX), oldCR.Bottom);
                    break;

                case CroppingHandle.Top:
                    photoView.CroppingRectangle = new Rect(oldCR.Left, (int)(oldCR.Top + distanceY), oldCR.Right, oldCR.Bottom);
                    break;

                case CroppingHandle.Bottom:
                    photoView.CroppingRectangle = new Rect(oldCR.Left, oldCR.Top, oldCR.Right, (int)(oldCR.Bottom + distanceY));
                    break;
                }
            }
        }
コード例 #2
0
        public bool IsCropAllowed(CroppingHandle handle, float distX, float distY)
        {
            var oldCRDisp = CroppingRectangleOnDisplay;

            //Check if it is possible?
            switch (handle)
            {
            case CroppingHandle.Left:
                return(oldCRDisp.Right - (oldCRDisp.Left + distX) > MIN_CROP_DISTANCE);

            case CroppingHandle.Right:
                return((oldCRDisp.Right + distX) - oldCRDisp.Left > MIN_CROP_DISTANCE);

            case CroppingHandle.Top:
                return(oldCRDisp.Bottom - (oldCRDisp.Top + distY) > MIN_CROP_DISTANCE);

            case CroppingHandle.Bottom:
                return((oldCRDisp.Bottom + distY) - oldCRDisp.Top > MIN_CROP_DISTANCE);
            }

            return(false);
        }
コード例 #3
0
        private (float x, float y) GetCroppingHandle(CroppingHandle handle)
        {
            var cr = CroppingRectangleOnDisplay;

            switch (handle)
            {
            case CroppingHandle.Left:
                return(cr.Left, (cr.Top + cr.Bottom) / 2);

            case CroppingHandle.Right:
                return(cr.Right, (cr.Top + cr.Bottom) / 2);

            case CroppingHandle.Top:
                return((cr.Right + cr.Left) / 2, cr.Top);

            case CroppingHandle.Bottom:
                return((cr.Right + cr.Left) / 2, cr.Bottom);

            default:
                throw new SystemException("Unsupported handle type");
            }
        }
コード例 #4
0
 protected abstract void OnCropAdjustment(CroppingHandle handle, float distanceX, float distanceY);
コード例 #5
0
 protected override void OnCropAdjustment(CroppingHandle handle, float distanceX, float distanceY)
 {
     //cropping functionality which is not supported here
 }