Exemple #1
0
        private static bool IsHorizontal(OrthogonalLine.Direction direction)
        {
            if (direction == OrthogonalLine.Direction.Left || direction == OrthogonalLine.Direction.Right)
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        private static OrthogonalLine.Direction TransformDirection(OrthogonalLine.Direction originalDirection, Transformation transformation)
        {
            if (originalDirection == OrthogonalLine.Direction.Undefined)
            {
                throw new InvalidOperationException("Cannot transform direction when original direction is undefined");
            }

            switch (transformation)
            {
            case Transformation.MirrorX:
                if (IsHorizontal(originalDirection))
                {
                    return(originalDirection);
                }

                return(OrthogonalLine.GetOppositeDirection(originalDirection));

            case Transformation.MirrorY:
                if (IsHorizontal(originalDirection))
                {
                    return(OrthogonalLine.GetOppositeDirection(originalDirection));
                }

                return(originalDirection);

            case Transformation.Diagonal13:
                switch (originalDirection)
                {
                case OrthogonalLine.Direction.Top:
                    return(OrthogonalLine.Direction.Right);

                case OrthogonalLine.Direction.Right:
                    return(OrthogonalLine.Direction.Top);

                case OrthogonalLine.Direction.Bottom:
                    return(OrthogonalLine.Direction.Left);

                case OrthogonalLine.Direction.Left:
                    return(OrthogonalLine.Direction.Bottom);

                default:
                    throw new ArgumentException();
                }

            case Transformation.Diagonal24:
                switch (originalDirection)
                {
                case OrthogonalLine.Direction.Top:
                    return(OrthogonalLine.Direction.Left);

                case OrthogonalLine.Direction.Right:
                    return(OrthogonalLine.Direction.Bottom);

                case OrthogonalLine.Direction.Bottom:
                    return(OrthogonalLine.Direction.Right);

                case OrthogonalLine.Direction.Left:
                    return(OrthogonalLine.Direction.Top);

                default:
                    throw new ArgumentException();
                }
            }

            throw new ArgumentException();
        }