Exemple #1
0
        public void ZoomInShouldWork()
        {
            FCoordsMath fCoordsMath = new FCoordsMath();
            PointDd     start       = new PointDd(new Dd(2), new Dd(-1));
            PointDd     end         = new PointDd(new Dd(4), new Dd(1));

            MCoordsDd    coords       = new MCoordsDd(start, end);
            SizeInt      samplePoints = new SizeInt(100, 100);
            RectangleInt area         = new RectangleInt(new PointInt(40, 40), new SizeInt(20, 20));

            MCoordsDd result = fCoordsMath.ZoomIn(coords, samplePoints, area);
        }
Exemple #2
0
        public FCoordsResult GetNewCoords(FJobRequest fJobRequest)
        {
            FCoordsResult result = null;

            if (fJobRequest.RequestType != FJobRequestType.TransformCoords)
            {
                throw new ArgumentException("The request type must be TransformCoords.");
            }

            if (!fJobRequest.TransformType.HasValue)
            {
                throw new ArgumentException("The transform type cannot be null.");
            }

            MCoordsDd curCoords = GetMCoords(fJobRequest.Coords);

            switch (fJobRequest.TransformType)
            {
            case TransformType.In:
                qdDotNet.SizeInt sizeInt = new qdDotNet.SizeInt(fJobRequest.SamplePoints.W, fJobRequest.SamplePoints.H);

                qdDotNet.RectangleInt area = new qdDotNet.RectangleInt(
                    new qdDotNet.PointInt(fJobRequest.Area.Point.X, fJobRequest.Area.Point.Y),
                    new qdDotNet.SizeInt(fJobRequest.Area.Size.W, fJobRequest.Area.Size.H));

                MCoordsDd newCoords = _fCoordsMath.ZoomIn(curCoords, sizeInt, area);
                result = GetResult(fJobRequest.JobId, newCoords);
                break;

            case TransformType.Out:
                double amount = GetAmount(fJobRequest.Area.Point.X);
                newCoords = _fCoordsMath.ZoomOut(curCoords, amount);
                result    = GetResult(fJobRequest.JobId, newCoords);
                break;

            case TransformType.Right:
                amount    = GetAmount(fJobRequest.Area.Point.X);
                newCoords = _fCoordsMath.ShiftRight(curCoords, amount);
                result    = GetResult(fJobRequest.JobId, newCoords);
                break;

            case TransformType.Left:
                amount    = GetAmount(fJobRequest.Area.Point.X);
                newCoords = _fCoordsMath.ShiftRight(curCoords, -amount);
                result    = GetResult(fJobRequest.JobId, newCoords);
                break;

            case TransformType.Down:
                amount    = GetAmount(fJobRequest.Area.Point.X);
                newCoords = _fCoordsMath.ShiftUp(curCoords, -amount);
                result    = GetResult(fJobRequest.JobId, newCoords);
                break;

            case TransformType.Up:
                amount    = GetAmount(fJobRequest.Area.Point.X);
                newCoords = _fCoordsMath.ShiftUp(curCoords, amount);
                result    = GetResult(fJobRequest.JobId, newCoords);
                break;

            default:
                Debug.WriteLine($"Transform Type: {fJobRequest.TransformType} is not supported.");
                break;
            }

            return(result);
        }