public int CompareTo(ICorner other) { // Order matters here if (m_Location.Y < other.GetLocation().Y) { return(-1); } if (m_Location.Y > other.GetLocation().Y) { return(1); } if (m_Location.X < other.GetLocation().X) { return(-1); } if (m_Location.X > other.GetLocation().X) { return(1); } return(0); }
public int CompareTo(ICorner other) { // these must be run in other. // Do not consolidate these. if (m_Location.Y < other.GetLocation().Y) { return(-1); } if (m_Location.Y > other.GetLocation().Y) { return(1); } if (m_Location.X < other.GetLocation().X) { return(-1); } if (m_Location.X > other.GetLocation().X) { return(1); } return(0); }
public TestTile(ICorner c1, ICorner c2, ICorner c3, ICorner c4) { C1 = c1; C2 = c2; C3 = c3; C4 = c4; }
internal bool IsAdjacentTo(ICorner c) { bool bOk = false; if (!Equals(c)) { if (GetLocation().X == c.GetLocation().X) { bOk = (Math.Abs(GetLocation().Y - c.GetLocation().Y) == difference); } else if (GetLocation().Y == c.GetLocation().Y) { bOk = (Math.Abs(GetLocation().X - c.GetLocation().X) == difference); } } return(bOk); }
internal bool IsAdjacentTo(ICorner c) { bool bOk = false; if (!Equals(c)) { if (Location.X == c.Location.X) { bOk = (Math.Abs(Location.Y - c.Location.Y) == 1); } else if (Location.Y == c.Location.Y) { bOk = (Math.Abs(Location.X - c.Location.X) == 1); } } return(bOk); }
public void Paint(IPointCornerFactory factory) { IPoint point = factory.GetPoint(); ICorner corner = factory.GetCorner(); corner.LeftUp(); point.Line(width - 2); corner.RightUp(); Console.Write("\n"); for (int i = 0; i < height - 2; i++) { point.Line(width); Console.Write("\n"); } corner.LeftDown(); point.Line(width - 2); corner.RightDown(); Console.Write("\n"); }
public ICorner ClosestCornerFromGraphicsPoint(Point p) { ICorner nearest = null; int dist = int.MaxValue; for (int row = 0; row < m_Rows; row++) { foreach (ICorner c in m_CornerRows[row]) { int temp = Distance(p, this.GetGraphicsPoint(c)); if (temp < dist) { dist = temp; nearest = c; } } } return(nearest); }
public Point GetGraphicsPoint(ICorner corner) { int SpacingX = m_Graphics.GetDpiX() / m_PointsPerInch; int SpacingY = m_Graphics.GetDpiY() / m_PointsPerInch; for (int row = 0; row < m_Rows; row++) { for (int index = 0; index < m_Columns; index++) { if (corner.Equals(m_CornerRows[row][index])) { int x = (SpacingX * index + SpacingX); int y = (SpacingY * row + SpacingY); return(new Point(x, y)); } } } throw new ArgumentOutOfRangeException("corner"); }
void m_InkPicture_Stroke(object sender, InkCollectorStrokeEventArgs e) { m_Move = null; e.Cancel = true; InkPicture ip = sender as InkPicture; Graphics g = null; lock (ip.Image) { g = Graphics.FromImage(ip.Image); } List <ICorner> corners = new List <ICorner>(); foreach (Point p in e.Stroke.GetPoints()) { Point clientP = StrokePointToClientPoint(g, p); ICorner c = m_GameBoard.ClosestCornerFromGraphicsPoint(clientP); if (!corners.Contains(c)) { corners.Add(c); } } if (corners.Count == 2) { try { Line l = new Line(corners[0] as Corner, corners[1] as Corner); m_Move = new Move(l, this); } catch (ArgumentException) { /* the line sucks - eat it */ } } m_Waiter.Set(); }
public bool Equals(ICorner other) { return(m_Location == other.GetLocation()); }
public bool Equals(ICorner other) => m_Location == other.GetLocation();