public void OnClickedAtCell(int x, int y, MouseButtons button) { // ReSharper disable once SwitchStatementMissingSomeCases switch (button) { case MouseButtons.Right: ClearClickedPoint(); break; case MouseButtons.Left: if (ClickedPoint == null) { if (field.IsCellFilled(x, y)) { ClickedPoint = new Point(x, y); } } else if (ClickedPoint == new Point(x, y)) { ClearClickedPoint(); } else { if (game.MakeMove(ClickedPoint, new Point(x, y))) { ClearClickedPoint(); SaveGame(Filename); form.UpdateLabels(); form.UpdateButtons(); } } break; } }
public void OnHoverOverCell(Point point) { if (ClickedPoint != null) { var path = game.GetPath(ClickedPoint, point); HoveredPoint = path != null ? point : null; } else { HoveredPoint = null; } }
private void DrawPath(Graphics graphics, Point[] path) { var pen = new Pen(controller.ClickedPointColor, 5) { DashPattern = new float[] { 2, 2 } }; var start = MainGridStart; graphics.DrawLines(pen, Point.ToDrawingPoints(path.Select(p => p * CellSize + start + new Point(CellSize / 2, CellSize / 2))) .ToArray()); }
private void DrawMainBallsGrid(Graphics graphics, Point start) { foreach (var tuple in controller.GetAllCells()) { var ballPoint = tuple.Item1; var point = start + ballPoint * CellSize; var color = tuple.Item2; graphics.FillRectangle(new SolidBrush(controller.BackgroundColor), new Rectangle(point.ToDrawingPoint(), new Size(CellSize, CellSize))); if (ballPoint == controller.ClickedPoint) { BallDrawer.DrawSelectedBallAt(graphics, point, color); } else { BallDrawer.DrawBallAt(graphics, point, color); } } }
private IEnumerable <Point> GetPath(Point p1, Point p2) { return(game.GetPath(p1, p2)); }
public static void DrawSelectedBallAt(Graphics g, Point point, Color color) { DrawSelectedBallAt(g, point.X, point.Y, color); }
public void OnBallMoving(Point arg1, Point arg2) { }