Esempio n. 1
0
 public PlacedTetraStick(TetraStick tetraStick, Coords location, Orientation orientation, ReflectionMode reflectionMode)
 {
     TetraStick = tetraStick;
     Location = location;
     Orientation = orientation;
     ReflectionMode = reflectionMode;
     _lazyWidth = new Lazy<int>(CalculateWidth);
     _lazyHeight = new Lazy<int>(CalculateHeight);
     _lazyInteriorJunctionPoints = new Lazy<IImmutableList<Coords>>(CalculateInteriorJunctionPoints);
     _lazyLines = new Lazy<IEnumerable<IImmutableList<Coords>>>(CalculateLines);
 }
Esempio n. 2
0
        private Coords ApplyOrientation(Coords coords)
        {
            switch (Orientation)
            {
                case Orientation.North:
                    return coords;

                case Orientation.South:
                    return new Coords(Width - coords.X, Height - coords.Y);

                case Orientation.East:
                    return new Coords(coords.Y, Height - coords.X);

                case Orientation.West:
                    return new Coords(Width - coords.Y, coords.X);

                default:
                    throw new InvalidOperationException($"Unknown orientation, \"{Orientation}\".");
            }
        }
Esempio n. 3
0
        private Coords ApplyReflectionMode(Coords coords)
        {
            switch (ReflectionMode)
            {
                case ReflectionMode.Normal:
                    return coords;

                case ReflectionMode.MirrorY:
                    return new Coords(Width - coords.X, coords.Y);

                default:
                    throw new InvalidOperationException($"Unknown reflection mode, \"{ReflectionMode}\".");
            }
        }
Esempio n. 4
0
 private Coords ApplyLocation(Coords coords)
 {
     return new Coords(Location.X + coords.X, Location.Y + coords.Y);
 }
Esempio n. 5
0
 private Point CoordsToInsetUpperRightVertical(Coords coords)
 {
     return new Point(
         coords.X * _sw + GridLineHalfThickness + TetraStickHalfThickness,
         (5 - coords.Y) * _sh + GridLineHalfThickness + TetraStickInset);
 }
Esempio n. 6
0
 private Coords ApplyTransform(Coords coords)
 {
     return ApplyLocation(
         ApplyReflectionMode(
             ApplyOrientation(coords)));
 }
Esempio n. 7
0
 private Point CoordsToInsetLowerLeftVertical(Coords coords)
 {
     return new Point(
         coords.X * _sw + GridLineHalfThickness - TetraStickHalfThickness,
         (5 - coords.Y) * _sh + GridLineHalfThickness - TetraStickInset);
 }
Esempio n. 8
0
 private Point CoordsToInsetUpperRightHorizontal(Coords coords)
 {
     return new Point(
         coords.X * _sw + GridLineHalfThickness - TetraStickInset,
         (5 - coords.Y) * _sh + GridLineHalfThickness - TetraStickHalfThickness);
 }
Esempio n. 9
0
        private void AddLineUpVertical(PathSegmentCollection segments, Coords coords1, Coords coords2)
        {
            segments.Add(new LineSegment
            {
                Point = CoordsToInsetUpperRightVertical(coords2)
            });

            segments.Add(new LineSegment
            {
                Point = CoordsToInsetLowerLeftVertical(coords1)
            });
        }
Esempio n. 10
0
 private void AddEndCapTop(PathSegmentCollection segments, Coords coords)
 {
     segments.Add(new ArcSegment
     {
         Point = CoordsToInsetUpperLeftVertical(coords),
         Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness)
     });
 }
Esempio n. 11
0
 private void AddEndCapRight(PathSegmentCollection segments, Coords coords)
 {
     segments.Add(new ArcSegment
     {
         Point = CoordsToInsetUpperRightHorizontal(coords),
         Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness)
     });
 }
Esempio n. 12
0
 private void AddEndCapBottom(PathSegmentCollection segments, Coords coords)
 {
     segments.Add(new ArcSegment
     {
         Point = CoordsToInsetLowerRightVertical(coords),
         Size = new Size(TetraStickHalfThickness, TetraStickHalfThickness)
     });
 }
Esempio n. 13
0
        private void AddCornerUpThenRight(PathSegmentCollection segments, Coords coords)
        {
            segments.Add(new ArcSegment
            {
                Point = CoordsToInsetLowerLeftHorizontal(coords),
                Size = new Size(TetraStickSmallCornerRadius, TetraStickSmallCornerRadius),
                SweepDirection = SweepDirection.Clockwise
            });

            segments.Add(new ArcSegment
            {
                Point = CoordsToInsetUpperLeftVertical(coords),
                Size = new Size(TetraStickLargeCornerRadius, TetraStickLargeCornerRadius)
            });
        }