public CompassPoint GetNextLeftPoint(CompassPoint currentPoint) { CompassPoint result = CompassPoint.N; switch (currentPoint) { case CompassPoint.N: result = CompassPoint.W; break; case CompassPoint.E: result = CompassPoint.N; break; case CompassPoint.S: result = CompassPoint.E; break; case CompassPoint.W: result = CompassPoint.S; break; } return(result); }
public static double CalcRadianForEllipse(CompassPoint point, Rect rect) { var angleIncrement = 360.0 / 16.0; var i = getPointIntegerValue(point); return(i * angleIncrement * (Math.PI / 180)); }
private void BuildWindChart() { // radar chart requires all compass points to be added in order // but data is not sorted and some compass points may be missing windEntries.Clear(); List <string> compassPoints = new List <string> { "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW" }; foreach (string p in compassPoints) { CompassPoint point = SolWeather.WindDirection.CompassPoints.Find(x => x.CompassPointName.Equals(p, StringComparison.OrdinalIgnoreCase)); if (point != null) { windEntries.Add(new ChartEntry(point.Count) { Label = point.CompassPointName, Color = SKColor.Parse(Color.DarkGoldenrod.ToHex()), TextColor = SKColor.Parse(ThemeHelper.GetThemeColor("textColor").ToHex()) }); } else { windEntries.Add(new ChartEntry(0) { Label = p, Color = SKColor.Parse(Color.DarkGoldenrod.ToHex()), TextColor = SKColor.Parse(ThemeHelper.GetThemeColor("textColor").ToHex()) }); } } }
public List <Connection> GetConnections(CompassPoint compassPoint) { var connections = new List <Connection>(); // TODO: This is needlessly expensive, traversing as it does the entire project's element list. foreach (var element in Project.Current.Elements) { if (!(element is Connection)) { continue; } var connection = (Connection)element; foreach (var vertex in connection.VertexList) { var port = vertex.Port; if (port == null || port.Owner != this || !(port is CompassPort)) { continue; } var compassPort = (CompassPort)vertex.Port; if (compassPort.CompassPoint == compassPoint) { // found a connection with a vertex joined to our room's port at the given compass point connections.Add(connection); } } } return(connections); }
public void Land(Map map, int x, int y, CompassPoint direction) { _mapX = map.X; _mapY = map.Y; X = x; Y = y; Direction = direction; }
/// <summary> /// Get the geometric opposite of a compass point on the compass rose. /// </summary> /// <param name="point"></param> /// <returns></returns> public static CompassPoint GetOpposite(CompassPoint point) { for (var index = 0; index < (CompassPoint.Max - CompassPoint.Min + 1) / 2; ++index) { point = RotateClockwise(point); } return(point); }
private CompassPoint ParseCompassPoint(string stringCompassPoint) { CompassPoint givenDirection; Assert.That(CompassPoint.TryParse(stringCompassPoint, false, out givenDirection), Is.Not.False); return(givenDirection); }
public void Land(Map map, int x, int y, CompassPoint direction) { _mapX = map.X; _mapY = map.Y; X = x; Y = y; Direction = direction; }
public void Should_perform_battle_move_spin_to_right(CompassPoint oldHeading, CompassPoint newHeading) { robot.Position.Heading = oldHeading; robot.PerformBattleMove(RobotMove.R); robot.Position.Heading.Should().Be.EqualTo(newHeading); robot.Position.Location.X.Should().Be.EqualTo(1); robot.Position.Location.Y.Should().Be.EqualTo(2); }
public RobotMoved(string name, Guid id, int version, int xPosition, int yPosition, CompassPoint compassPoint) { Name = name; Id = id; Version = version; XPosition = xPosition; YPosition = yPosition; CompassPoint = compassPoint; }
public void Attribute(string localName, CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteAttributeString(localName, name); } }
/// <summary> /// Rotate a point anti-clockwise to find its neighbour on that side. /// </summary> public static CompassPoint RotateAntiClockwise(CompassPoint point) { point = (CompassPoint)((int)point - 1); if (point < CompassPoint.Min) { point = CompassPoint.Max; } return(point); }
/// <summary> /// Rotate a point clockwise to find its neighbour on that side. /// </summary> public static CompassPoint RotateClockwise(CompassPoint point) { point = (CompassPoint)((int)point + 1); if (point > CompassPoint.Max) { point = CompassPoint.Min; } return(point); }
public RobotAdded(Guid id, int version, int xCoordinate, int yCoordinate, CompassPoint compassPoint, string name) { Id = id; Version = version; XCoordinate = xCoordinate; YCoordinate = yCoordinate; CompassPoint = compassPoint; Name = name; }
public void Value(CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteValue(name); } }
/// <summary> /// Get the compass point which is the opposite of the given point, /// for the purpose of connecting rooms during automapping. /// </summary> /// <remarks> /// Treating the room as a box, and mapping compass points onto it, /// the automap opposite is the corresponding point on the opposite /// side of the box. /// </remarks> public static CompassPoint GetAutomapOpposite(CompassPoint point) { switch (point) { case CompassPoint.North: return(CompassPoint.South); case CompassPoint.NorthNorthEast: return(CompassPoint.SouthSouthEast); // vertical case CompassPoint.NorthEast: return(CompassPoint.SouthWest); case CompassPoint.EastNorthEast: return(CompassPoint.WestNorthWest); // horizontal case CompassPoint.East: return(CompassPoint.West); case CompassPoint.EastSouthEast: return(CompassPoint.WestSouthWest); // horizontal case CompassPoint.SouthEast: return(CompassPoint.NorthWest); case CompassPoint.SouthSouthEast: return(CompassPoint.NorthNorthEast); // vertical case CompassPoint.South: return(CompassPoint.North); case CompassPoint.SouthSouthWest: return(CompassPoint.NorthNorthWest); // vertical case CompassPoint.SouthWest: return(CompassPoint.NorthEast); case CompassPoint.WestSouthWest: return(CompassPoint.EastSouthEast); // horizontal case CompassPoint.West: return(CompassPoint.East); case CompassPoint.WestNorthWest: return(CompassPoint.EastNorthEast); // horizontal case CompassPoint.NorthWest: return(CompassPoint.SouthEast); case CompassPoint.NorthNorthWest: return(CompassPoint.SouthSouthWest); // vertical default: Debug.Assert(false, "Opposite compass point not found."); return(CompassPoint.North); } }
public void Element(string localName, CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteElementString(localName, name); } }
public static double GetAngleInRadians(CompassPoint point) { switch (point) { case CompassPoint.North: return(Math.PI * 1.5); case CompassPoint.NorthNorthEast: return(Math.PI * (5.0 / 3.0)); case CompassPoint.NorthEast: return(Math.PI * (7.0 / 4.0)); case CompassPoint.EastNorthEast: return(Math.PI * (11.0 / 6.0)); case CompassPoint.East: return(2.0 * Math.PI); case CompassPoint.EastSouthEast: return(Math.PI / 6.0); case CompassPoint.SouthEast: return(Math.PI / 4.0); case CompassPoint.SouthSouthEast: return(Math.PI / 3.0); case CompassPoint.South: return(Math.PI / 2.0); case CompassPoint.SouthSouthWest: return(Math.PI * (2.0 / 3.0)); case CompassPoint.SouthWest: return(Math.PI * 0.75); case CompassPoint.WestSouthWest: return(Math.PI * (5.0 / 6.0)); case CompassPoint.West: return(Math.PI); case CompassPoint.WestNorthWest: return(Math.PI * (7.0 / 6.0)); case CompassPoint.NorthWest: return(Math.PI * 1.25); case CompassPoint.NorthNorthWest: return(Math.PI * (4.0 / 3.0)); default: throw new ArgumentOutOfRangeException(nameof(point), point, null); } }
public Vector GetCorner(CompassPoint point) { switch (point) { case CompassPoint.North: return(new Vector(X + Width / 2, Y)); case CompassPoint.NorthNorthEast: return(new Vector(X + Width * 3 / 4, Y)); case CompassPoint.NorthEast: return(new Vector(X + Width, Y)); case CompassPoint.EastNorthEast: return(new Vector(X + Width, Y + Height / 4)); case CompassPoint.East: return(new Vector(X + Width, Y + Height / 2)); case CompassPoint.EastSouthEast: return(new Vector(X + Width, Y + Height * 3 / 4)); case CompassPoint.SouthEast: return(new Vector(X + Width, Y + Height)); case CompassPoint.SouthSouthEast: return(new Vector(X + Width * 3 / 4, Y + Height)); case CompassPoint.South: return(new Vector(X + Width / 2, Y + Height)); case CompassPoint.SouthSouthWest: return(new Vector(X + Width / 4, Y + Height)); case CompassPoint.SouthWest: return(new Vector(X, Y + Height)); case CompassPoint.WestSouthWest: return(new Vector(X, Y + Height * 3 / 4)); case CompassPoint.West: return(new Vector(X, Y + Height / 2)); case CompassPoint.WestNorthWest: return(new Vector(X, Y + Height / 4)); case CompassPoint.NorthWest: return(new Vector(X, Y)); case CompassPoint.NorthNorthWest: return(new Vector(X + Width / 4, Y)); default: throw new InvalidOperationException(); } }
private static int getPointIntegerValue(CompassPoint point) { switch (point) { case CompassPoint.North: return(12); case CompassPoint.NorthNorthEast: return(13); case CompassPoint.NorthEast: return(14); case CompassPoint.EastNorthEast: return(15); case CompassPoint.East: return(0); case CompassPoint.EastSouthEast: return(1); case CompassPoint.SouthEast: return(2); case CompassPoint.SouthSouthEast: return(3); case CompassPoint.South: return(4); case CompassPoint.SouthSouthWest: return(5); case CompassPoint.SouthWest: return(6); case CompassPoint.WestSouthWest: return(7); case CompassPoint.West: return(8); case CompassPoint.WestNorthWest: return(9); case CompassPoint.NorthWest: return(10); case CompassPoint.NorthNorthWest: return(11); default: throw new ArgumentOutOfRangeException(nameof(point), point, null); } }
public CompassPoint ToCompassPoint(CompassPoint defaultValue) { CompassPoint point; if (CompassPointHelper.FromName(Text, out point)) { return(point); } return(defaultValue); }
public static RobotMemento Create(int coordinateX, int coordinateY, CompassPoint CompassPoint, string name) { return(new RobotMemento { CoordinartesX = coordinateX, CoordinartesY = coordinateY, CompassPoint = CompassPoint, Name = name }); }
void PositionRelativeTo(Room room, Room existing, CompassPoint existingCompassPoint, out Vector delta) { delta = CompassPointHelper.GetAutomapDirectionVector(existingCompassPoint); delta.X *= Settings.PreferredDistanceBetweenRooms + room.Width; delta.Y *= Settings.PreferredDistanceBetweenRooms + room.Height; var newRoomCenter = existing.InnerBounds.Center + delta; room.Position = Settings.Snap(new Vector(newRoomCenter.X - room.Width / 2, newRoomCenter.Y - room.Height / 2)); }
bool Move(Grid <char> grid, Stack <Point> candidates, CompassPoint dir) { var ch = grid[candidates.Peek()]; while (candidates.Any() && candidates.Pop() is var tile) { if (grid.Neighbors[tile][dir] is var target && grid[target] == '.') { Clear.Push(tile); Step.Push(target); }
public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle) { Source = source; Target = target; VisualCompassPoint = visualCompassPoint; Conditional = connectionStyle == ConnectionStyle.Dashed; AssignPrimaryPriority(); AssignPrimaryDirection(); AssignSecondaryDirection(connectionText); }
public Port PortAt(CompassPoint compassPoint) { foreach (CompassPort port in PortList) { if (port.CompassPoint == compassPoint) { return(port); } } return(null); }
public void TurnLeft() { if (CompassPoint == CompassPoint.North) { CompassPoint = CompassPoint.West; } else { CompassPoint = CompassPoint - 1; } }
public void TurnRight() { if (CompassPoint == CompassPoint.West) { CompassPoint = CompassPoint.North; } else { CompassPoint = CompassPoint + 1; } }
public void TurnLeft() { if (CompassPoint == CompassPoint.North) { CompassPoint = CompassPoint.West; } else { CompassPoint = CompassPoint - 1; } }
public void TurnRight() { if (CompassPoint == CompassPoint.West) { CompassPoint = CompassPoint.North; } else { CompassPoint = CompassPoint + 1; } }
public static bool ToName(CompassPoint point, out string name) { var index = (int)point; if (index >= 0 && index < Names.Length) { name = Names[index]; return(true); } name = string.Empty; return(false); }
public static bool FromName(string name, out CompassPoint point) { for (var index = 0; index < Names.Length; ++index) { if (StringComparer.InvariantCultureIgnoreCase.Compare(name ?? string.Empty, Names[index]) == 0) { point = (CompassPoint)index; return(true); } } point = CompassPoint.North; return(false); }
public void When_reports_Direction_then_Direction_matches_initialDirection(string direction) { var map = new Map(10, 10); var rover = new Rover(); CompassPoint givenDirection; Assert.That(CompassPoint.TryParse(direction, false, out givenDirection), Is.Not.False); rover.Land(map, 0, 0, givenDirection); Assert.That(rover.Direction, Is.EqualTo(givenDirection)); }
public void MoveForwardFacing(CompassPoint direction) { switch (direction) { case (CompassPoint.North): MoveNorth(); break; case (CompassPoint.East): MoveEast(); break; case (CompassPoint.South): MoveSouth(); break; case (CompassPoint.West): MoveWest(); break; } }
private bool TryMoveRoomForTidyConnection(Room source, CompassPoint targetCompassPoint, Room target) { var sourceArbitrary = source.ArbitraryAutomappedPosition; var sourcePosition = source.Position; Vector delta; PositionRelativeTo(source, target, targetCompassPoint, out delta); if (AnyRoomsIntersect(source)) { // didn't work; restore previous position source.Position = sourcePosition; source.ArbitraryAutomappedPosition = sourceArbitrary; return false; } // that's better return true; }
private void TryMoveRoomsForTidyConnection(Room source, CompassPoint sourceCompassPoint, Room target, CompassPoint targetCompassPoint) { if (source.ArbitraryAutomappedPosition && !source.IsConnected) { if (TryMoveRoomForTidyConnection(source, targetCompassPoint, target)) { return; } } if (target.ArbitraryAutomappedPosition && !target.IsConnected) { TryMoveRoomForTidyConnection(target, sourceCompassPoint, source); } }
public Vector GetCorner(CompassPoint point) { switch (point) { case CompassPoint.North: return new Vector(X + Width / 2, Y); case CompassPoint.NorthNorthEast: return new Vector(X + Width * 3 / 4, Y); case CompassPoint.NorthEast: return new Vector(X + Width, Y); case CompassPoint.EastNorthEast: return new Vector(X + Width, Y + Height / 4); case CompassPoint.East: return new Vector(X + Width, Y + Height / 2); case CompassPoint.EastSouthEast: return new Vector(X + Width, Y + Height * 3 / 4); case CompassPoint.SouthEast: return new Vector(X + Width, Y + Height); case CompassPoint.SouthSouthEast: return new Vector(X + Width * 3 / 4, Y + Height); case CompassPoint.South: return new Vector(X + Width / 2, Y + Height); case CompassPoint.SouthSouthWest: return new Vector(X + Width / 4, Y + Height); case CompassPoint.SouthWest: return new Vector(X, Y + Height); case CompassPoint.WestSouthWest: return new Vector(X, Y + Height * 3 / 4); case CompassPoint.West: return new Vector(X, Y + Height / 2); case CompassPoint.WestNorthWest: return new Vector(X, Y + Height / 4); case CompassPoint.NorthWest: return new Vector(X, Y); case CompassPoint.NorthNorthWest: return new Vector(X + Width / 4, Y); default: throw new InvalidOperationException(); } }
public ResizeHandle(CompassPoint compassPoint, ISizeable owner) { mCompassPoint = compassPoint; mOwner = owner; }
/// <summary> /// Approximately match two directions, allowing for aesthetic rearrangement by the user. /// </summary> /// <remarks> /// Two compass points match if they are on the same side of a box representing the room. /// </remarks> private bool ApproximateDirectionMatch(CompassPoint one, CompassPoint two) { return CompassPointHelper.GetAutomapDirectionVector(one) == CompassPointHelper.GetAutomapDirectionVector(two); }
public void Element(string localName, CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteElementString(localName, name); } }
/// <summary> /// Get the geometric opposite of a compass point on the compass rose. /// </summary> /// <param name="point"></param> /// <returns></returns> public static CompassPoint GetOpposite(CompassPoint point) { for (var index = 0; index < (CompassPoint.Max - CompassPoint.Min + 1)/2; ++index) { point = RotateClockwise(point); } return point; }
/// <summary> /// "Round" the compass point to the nearest cardinal or ordinal direction. /// </summary> public static CompassPoint GetNearestCardinalOrOrdinal(CompassPoint compassPoint) { return GetCompassPointFromAutomapDirectionVector(GetAutomapDirectionVector(compassPoint)); }
/// <summary> /// Get the compass point which is the opposite of the given point, /// for the purpose of connecting rooms during automapping. /// </summary> /// <remarks> /// Treating the room as a box, and mapping compass points onto it, /// the automap opposite is the corresponding point on the opposite /// side of the box. /// </remarks> public static CompassPoint GetAutomapOpposite(CompassPoint point) { switch (point) { case CompassPoint.North: return CompassPoint.South; case CompassPoint.NorthNorthEast: return CompassPoint.SouthSouthEast; // vertical case CompassPoint.NorthEast: return CompassPoint.SouthWest; case CompassPoint.EastNorthEast: return CompassPoint.WestNorthWest; // horizontal case CompassPoint.East: return CompassPoint.West; case CompassPoint.EastSouthEast: return CompassPoint.WestSouthWest; // horizontal case CompassPoint.SouthEast: return CompassPoint.NorthWest; case CompassPoint.SouthSouthEast: return CompassPoint.NorthNorthEast; // vertical case CompassPoint.South: return CompassPoint.North; case CompassPoint.SouthSouthWest: return CompassPoint.NorthNorthWest; // vertical case CompassPoint.SouthWest: return CompassPoint.NorthEast; case CompassPoint.WestSouthWest: return CompassPoint.EastSouthEast; // horizontal case CompassPoint.West: return CompassPoint.East; case CompassPoint.WestNorthWest: return CompassPoint.EastNorthEast; // horizontal case CompassPoint.NorthWest: return CompassPoint.SouthEast; case CompassPoint.NorthNorthWest: return CompassPoint.SouthSouthWest; // vertical default: Debug.Assert(false, "Opposite compass point not found."); return CompassPoint.North; } }
/// <summary> /// Get the direction delta (where x and y are range -1 to 1) in which /// we would place a new room given a connection in the given direction. /// </summary> /// <remarks> /// Two compass points have the same direction vector if they are mapped /// onto the the same side of a box drawn to represent the room. /// </remarks> public static Vector GetAutomapDirectionVector(CompassPoint compassPoint) { switch (compassPoint) { case CompassPoint.NorthNorthWest: case CompassPoint.North: case CompassPoint.NorthNorthEast: return new Vector(0, -1); case CompassPoint.NorthEast: return new Vector(1, -1); case CompassPoint.EastNorthEast: case CompassPoint.East: case CompassPoint.EastSouthEast: return new Vector(1, 0); case CompassPoint.SouthEast: return new Vector(1, 1); case CompassPoint.SouthSouthEast: case CompassPoint.South: case CompassPoint.SouthSouthWest: return new Vector(0, 1); case CompassPoint.SouthWest: return new Vector(-1, 1); case CompassPoint.WestSouthWest: case CompassPoint.West: case CompassPoint.WestNorthWest: return new Vector(-1, 0); case CompassPoint.NorthWest: return new Vector(-1, -1); default: Debug.Assert(false, "Direction vector not found."); return new Vector(0, -1); } }
public CompassPoint ToCompassPoint(CompassPoint defaultValue) { CompassPoint point; if (CompassPointHelper.FromName(Text, out point)) { return point; } return defaultValue; }
private void PositionRelativeTo(Room room, Room existing, CompassPoint existingCompassPoint, out Vector delta) { delta = CompassPointHelper.GetAutomapDirectionVector(existingCompassPoint); delta.X *= Settings.PreferredDistanceBetweenRooms + room.Width; delta.Y *= Settings.PreferredDistanceBetweenRooms + room.Height; var newRoomCenter = existing.InnerBounds.Center + delta; room.Position = Settings.Snap(new Vector(newRoomCenter.X - room.Width/2, newRoomCenter.Y - room.Height/2)); }
private Connection FindConnection(Room source, Room target, CompassPoint? directionFromSource, out bool wrongWay) { foreach (var element in Project.Current.Elements) { if (element is Connection) { var connection = (Connection) element; CompassPoint fromDirection, toDirection; var fromRoom = connection.GetSourceRoom(out fromDirection); var toRoom = connection.GetTargetRoom(out toDirection); if (fromRoom == source && toRoom == target && (directionFromSource == null || ApproximateDirectionMatch(directionFromSource.Value, fromDirection))) { // the two rooms are connected already in the given direction, A to B or both ways. wrongWay = false; return connection; } if (fromRoom == target && toRoom == source && (directionFromSource == null || ApproximateDirectionMatch(directionFromSource.Value, toDirection))) { // the two rooms are connected already in the given direction, B to A or both ways. wrongWay = connection.Flow == ConnectionFlow.OneWay; return connection; } } } wrongWay = false; return null; }
public Vector GetCorner(CompassPoint point, RoomShape myRmShape = RoomShape.SquareCorners, CornerRadii corners = null) { bool isOctagonal = (myRmShape == RoomShape.Octagonal); bool isRounded = (myRmShape == RoomShape.RoundedCorners); bool isEllipse = (myRmShape == RoomShape.Ellipse); double angleInRadians; if (myRmShape == RoomShape.Ellipse) { angleInRadians = CompassPointHelper.CalcRadianForEllipse(point, this); return new Vector(Center.X + (float)((Width/2.0) * Math.Cos(angleInRadians)), Center.Y + (float)((Height / 2.0) * Math.Sin(angleInRadians))); } if (myRmShape == RoomShape.Ellipse) { if (point == CompassPoint.NorthEast || point == CompassPoint.NorthWest || point == CompassPoint.SouthWest || point == CompassPoint.SouthEast) { angleInRadians = CompassPointHelper.CalcRadianForEllipse(point, this); if (point == CompassPoint.NorthEast) { var rect = new Rect(X + Width, Y , (float) corners.TopRight, (float) corners.TopRight); return new Vector((rect.Center.X - (float) (corners.TopRight/2.0)) - (float) ((corners.TopRight/2.0)*Math.Cos(angleInRadians)), (rect.Center.Y + (float)(corners.TopLeft / 4.0)) + (float) ((corners.TopRight/2.0)*Math.Sin(angleInRadians))); } if (point == CompassPoint.NorthWest) { var rect = new Rect(X, Y, (float) corners.TopLeft, (float) corners.TopLeft); return new Vector((rect.Center.X - (float) (corners.TopLeft/2.0)) - (float) ((corners.TopLeft/2.0)*Math.Cos(angleInRadians)), (rect.Center.Y + (float)(corners.TopLeft / 4.0)) + (float) ((corners.TopLeft/2.0)*Math.Sin(angleInRadians))); } if (point == CompassPoint.SouthWest) { var rect = new Rect(X, Y + Height, (float) corners.BottomLeft, (float) corners.BottomLeft); return new Vector((rect.Center.X - (float)(corners.BottomLeft / 2.0)) - (float)((corners.BottomLeft/2.0)*Math.Cos(angleInRadians)), (rect.Center.Y - (float)(corners.BottomLeft / 2.0)) - (float) ((corners.BottomLeft/2.0)*Math.Sin(angleInRadians))); } if (point == CompassPoint.SouthEast) { var rect = new Rect(X + Width, Y + Height, (float) corners.BottomRight, (float) corners.BottomRight); return new Vector((rect.Center.X - (float)(corners.BottomRight/2.0)) - (float) ((corners.BottomRight/2.0)*Math.Cos(angleInRadians)), (rect.Center.Y - (float)(corners.BottomRight/2.0 )) - (float) ((corners.BottomRight/2.0)*Math.Sin(angleInRadians))); } } } switch (point) { case CompassPoint.North: return new Vector(X + Width/2, Y); case CompassPoint.NorthNorthEast: return new Vector(X + Width*3/4, Y); case CompassPoint.NorthEast: if (isOctagonal) return new Vector (X + Width * 7/8, Y + Height * 1/8); if (isRounded) return new Vector((float)(X + Width - 0.25 * corners.TopLeft), (float)(Y + 0.25 * corners.TopLeft)); return new Vector(X + Width, Y); case CompassPoint.EastNorthEast: return new Vector(X + Width, Y + Height/4); case CompassPoint.East: return new Vector(X + Width, Y + Height/2); case CompassPoint.EastSouthEast: return new Vector(X + Width, Y + Height*3/4); case CompassPoint.SouthEast: if (isOctagonal) return new Vector (X + Width * 7/8, Y + Height * 7/8); if (isRounded) return new Vector((float)(X + Width - 0.25 * corners.TopLeft), (float)(Y + Height - 0.25 * corners.TopLeft)); return new Vector(X + Width, Y + Height); case CompassPoint.SouthSouthEast: return new Vector(X + Width*3/4, Y + Height); case CompassPoint.South: return new Vector(X + Width/2, Y + Height); case CompassPoint.SouthSouthWest: return new Vector(X + Width/4, Y + Height); case CompassPoint.SouthWest: if (isOctagonal) return new Vector (X + Width * 1/8, Y + Height * 7/8); if (isRounded) return new Vector((float)(X + 0.3 * corners.TopLeft), (float)(Y + Height - 0.3 * corners.TopLeft)); return new Vector(X, Y + Height); case CompassPoint.WestSouthWest: return new Vector(X, Y + Height*3/4); case CompassPoint.West: return new Vector(X, Y + Height/2); case CompassPoint.WestNorthWest: return new Vector(X, Y + Height/4); case CompassPoint.NorthWest: if (isOctagonal) return new Vector (X + Width * 1/8, Y + Height * 1/8); if (isRounded) return new Vector((float)(X + 0.3 * corners.TopLeft), (float)(Y + 0.3 * corners.TopLeft)); return new Vector(X, Y); case CompassPoint.NorthNorthWest: return new Vector(X + Width/4, Y); default: throw new InvalidOperationException(); } }
/// <summary> /// Rotate a point anti-clockwise to find its neighbour on that side. /// </summary> public static CompassPoint RotateAntiClockwise(CompassPoint point) { point = (CompassPoint) ((int) point - 1); if (point < CompassPoint.Min) { point = CompassPoint.Max; } return point; }
public void Attribute(string localName, CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteAttributeString(localName, name); } }
public Room GetTargetRoom(out CompassPoint targetCompassPoint) { if (m_vertexList.Count > 1) { var port = m_vertexList[m_vertexList.Count - 1].Port; if (port is Room.CompassPort) { var compassPort = (Room.CompassPort) port; targetCompassPoint = compassPort.CompassPoint; return compassPort.Owner as Room; } } targetCompassPoint = CompassPoint.North; return null; }
/// <summary> /// Rotate a point clockwise to find its neighbour on that side. /// </summary> public static CompassPoint RotateClockwise(CompassPoint point) { point = (CompassPoint) ((int) point + 1); if (point > CompassPoint.Max) { point = CompassPoint.Min; } return point; }
public Room GetSourceRoom(out CompassPoint sourceCompassPoint) { if (m_vertexList.Count > 0) { var port = m_vertexList[0].Port; if (port is Room.CompassPort) { var compassPort = (Room.CompassPort) port; sourceCompassPoint = compassPort.CompassPoint; return port.Owner as Room; } } sourceCompassPoint = CompassPoint.North; return null; }
public static bool ToName(CompassPoint point, out string name) { var index = (int) point; if (index >= 0 && index < Names.Length) { name = Names[index]; return true; } name = string.Empty; return false; }
public static bool SetAlignmentFromCardinalOrOrdinalDirection(XStringFormat format, CompassPoint compassPoint) { switch (compassPoint) { case CompassPoint.North: case CompassPoint.NorthEast: format.LineAlignment = XLineAlignment.Far; format.Alignment = XStringAlignment.Near; break; case CompassPoint.East: case CompassPoint.SouthEast: case CompassPoint.South: format.LineAlignment = XLineAlignment.Near; format.Alignment = XStringAlignment.Near; break; case CompassPoint.West: case CompassPoint.SouthWest: format.LineAlignment = XLineAlignment.Near; format.Alignment = XStringAlignment.Far; break; case CompassPoint.NorthWest: format.LineAlignment = XLineAlignment.Far; format.Alignment = XStringAlignment.Far; break; default: return false; } return true; }
private static int getPointIntegerValue(CompassPoint point) { switch (point) { case CompassPoint.North: return 12; case CompassPoint.NorthNorthEast: return 13; case CompassPoint.NorthEast: return 14; case CompassPoint.EastNorthEast: return 15; case CompassPoint.East: return 0; case CompassPoint.EastSouthEast: return 1; case CompassPoint.SouthEast: return 2; case CompassPoint.SouthSouthEast: return 3; case CompassPoint.South: return 4; case CompassPoint.SouthSouthWest: return 5; case CompassPoint.SouthWest: return 6; case CompassPoint.WestSouthWest: return 7; case CompassPoint.West: return 8; case CompassPoint.WestNorthWest: return 9; case CompassPoint.NorthWest: return 10; case CompassPoint.NorthNorthWest: return 11; default: throw new ArgumentOutOfRangeException(nameof(point), point, null); } }
public static double CalcRadianForEllipse(CompassPoint point, Rect rect) { var angleIncrement = 360.0/16.0; var i = getPointIntegerValue(point); return (i * angleIncrement) * (Math.PI / 180); }
public static bool FromName(string name, out CompassPoint point) { for (var index = 0; index < Names.Length; ++index) { if (StringComparer.InvariantCultureIgnoreCase.Compare(name ?? string.Empty, Names[index]) == 0) { point = (CompassPoint) index; return true; } } point = CompassPoint.North; return false; }
public void Value(CompassPoint value) { string name; if (CompassPointHelper.ToName(value, out name)) { Writer.WriteValue(name); } }
public Exit(Location source, Location target, CompassPoint visualCompassPoint, string connectionText, ConnectionStyle connectionStyle) { Source = source; Target = target; VisualCompassPoint = visualCompassPoint; Conditional = connectionStyle == ConnectionStyle.Dashed; assignPrimaryPriority(); assignSecondaryDirection(connectionText); if (SecondaryDirection != null) PrimaryDirection = (AutomapDirection)SecondaryDirection; else assignPrimaryDirection(); }