Пример #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);
        }
Пример #2
0
        private MCoordsDd GetMCoords(Coords coords)
        {
            Dd startX = new Dd(coords.StartX);
            Dd endX   = new Dd(coords.EndX);
            Dd startY = new Dd(coords.StartY);
            Dd endY   = new Dd(coords.EndY);

            PointDd start = new PointDd(startX, startY);
            PointDd end   = new PointDd(endX, endY);

            MCoordsDd result = new MCoordsDd(start, end);

            return(result);
        }
Пример #3
0
        private FCoordsResult GetResult(int jobId, MCoordsDd mCoordsDd)
        {
            Coords coords = new Coords
                            (
                mCoordsDd.Start().X().GetStringVal(),
                mCoordsDd.End().X().GetStringVal(),
                mCoordsDd.Start().Y().GetStringVal(),
                mCoordsDd.End().Y().GetStringVal()
                            );

            FCoordsResult result = new FCoordsResult(jobId, coords);

            return(result);
        }
Пример #4
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);
        }