private void MainForm_MouseClick(object sender, MouseEventArgs e) { if (run) { return; } if (modified) { Drawer.CreateChessField(graphicsObj); } run = true; int X = e.X; int Y = e.Y; if (X < Drawer.SideOfSquare || X > Drawer.Width - Drawer.SideOfSquare || Y < Drawer.SideOfSquare || Y > Drawer.Width - Drawer.SideOfSquare) { return; } X -= (int)Drawer.SideOfSquare; Y -= (int)Drawer.SideOfSquare; X = (int)(X / Drawer.SideOfSquare); Y = (int)(Y / Drawer.SideOfSquare); Algorithm.Initialize(X, Y); Drawer.PrintLvl(graphicsObj, X, Y, 0); while (Algorithm.DrawNextLvl(ref graphicsObj)) { Thread.Sleep(1300); } Algorithm.ClearMtx(); modified = true; run = false; }
public static bool DrawNextLvl(ref Graphics graphics_in) { List <Point> pts = new List <Point>(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (matrix[i, j] == lvl) { pts.AddRange(GetNextPoints(i, j)); } } } if (pts.Count == 0) { return(false); } ++lvl; foreach (var point in pts) { matrix[point.X, point.Y] = lvl; Drawer.PrintLvl(graphics_in, point.X, point.Y, lvl); } return(true); }