Beispiel #1
0
        private Vector3 GetOriginForTransform(ICamera camera, BoxState state)
        {
            float x      = 0;
            float y      = 0;
            var   cstart = camera.Flatten(state.OrigStart);
            var   cend   = camera.Flatten(state.OrigEnd);

            switch (Handle)
            {
            case ResizeHandle.TopLeft:
            case ResizeHandle.Top:
            case ResizeHandle.TopRight:
            case ResizeHandle.Left:
            case ResizeHandle.Right:
                y = cstart.Y;
                break;

            case ResizeHandle.BottomLeft:
            case ResizeHandle.Bottom:
            case ResizeHandle.BottomRight:
                y = cend.Y;
                break;
            }
            switch (Handle)
            {
            case ResizeHandle.Top:
            case ResizeHandle.TopRight:
            case ResizeHandle.Right:
            case ResizeHandle.BottomRight:
            case ResizeHandle.Bottom:
                x = cstart.X;
                break;

            case ResizeHandle.TopLeft:
            case ResizeHandle.Left:
            case ResizeHandle.BottomLeft:
                x = cend.X;
                break;
            }
            return(camera.Expand(new Vector3(x, y, 0)));
        }
Beispiel #2
0
        protected (Vector3, Vector3) GetWorldPositionAndScreenOffset(ICamera camera)
        {
            const int distance = 6;
            var       start    = camera.Flatten(BoxState.Start);
            var       end      = camera.Flatten(BoxState.End);
            var       mid      = (start + end) / 2;
            Vector3   center;
            Vector3   offset;

            switch (Handle)
            {
            case ResizeHandle.TopLeft:
                center = new Vector3(start.X, end.Y, 0);
                offset = new Vector3(-distance, -distance, 0);
                break;

            case ResizeHandle.Top:
                center = new Vector3(mid.X, end.Y, 0);
                offset = new Vector3(0, -distance, 0);
                break;

            case ResizeHandle.TopRight:
                center = new Vector3(end.X, end.Y, 0);
                offset = new Vector3(distance, -distance, 0);
                break;

            case ResizeHandle.Left:
                center = new Vector3(start.X, mid.Y, 0);
                offset = new Vector3(-distance, 0, 0);
                break;

            case ResizeHandle.Center:
                center = mid;
                offset = Vector3.Zero;
                break;

            case ResizeHandle.Right:
                center = new Vector3(end.X, mid.Y, 0);
                offset = new Vector3(distance, 0, 0);
                break;

            case ResizeHandle.BottomLeft:
                center = new Vector3(start.X, start.Y, 0);
                offset = new Vector3(-distance, distance, 0);
                break;

            case ResizeHandle.Bottom:
                center = new Vector3(mid.X, start.Y, 0);
                offset = new Vector3(0, distance, 0);
                break;

            case ResizeHandle.BottomRight:
                center = new Vector3(end.X, start.Y, 0);
                offset = new Vector3(distance, distance, 0);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(camera.Expand(center), offset);
        }