コード例 #1
0
        public LineSegment Reduce(EndpointKind kind)
        {
            if (!IsReducable())
            {
                throw new ArgumentException("cannot reduce line of length 1");
            }

            switch (kind)
            {
            case EndpointKind.From:
                switch (Direction)
                {
                case LineDirection.North:
                    return(new LineSegment(Id, Origin, From.Move(Vector.DeltaNorth), To, Type, Direction));

                case LineDirection.South:
                    return(new LineSegment(Id, Origin, From.Move(Vector.DeltaSouth), To, Type, Direction));

                case LineDirection.East:
                    return(new LineSegment(Id, Origin, From.Move(Vector.DeltaEast), To, Type, Direction));

                case LineDirection.West:
                    return(new LineSegment(Id, Origin, From.Move(Vector.DeltaWest), To, Type, Direction));

                default:
                    throw new ArgumentOutOfRangeException();
                }

            case EndpointKind.To:
                switch (Direction)
                {
                case LineDirection.North:
                    return(new LineSegment(Id, Origin, From, To.Move(Vector.DeltaSouth), Type, Direction));

                case LineDirection.South:
                    return(new LineSegment(Id, Origin, From, To.Move(Vector.DeltaNorth), Type, Direction));

                case LineDirection.East:
                    return(new LineSegment(Id, Origin, From, To.Move(Vector.DeltaWest), Type, Direction));

                case LineDirection.West:
                    return(new LineSegment(Id, Origin, From, To.Move(Vector.DeltaEast), Type, Direction));

                default:
                    throw new ArgumentOutOfRangeException();
                }

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
            }
        }
コード例 #2
0
ファイル: Paintable.cs プロジェクト: jacobborella/AsciiUml
 public Cursor Move(Coord delta)
 {
     return(new Cursor(Pos.Move(delta)));
 }