diff --git a/Desktop/Program.cs b/Desktop/Program.cs index 3ac3c77..6105b88 100644 --- a/Desktop/Program.cs +++ b/Desktop/Program.cs @@ -11,7 +11,7 @@ namespace Desktop // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new ChessBoardExample.Form1()); + Application.Run(new ChessBoardExample.ChessBoardExample()); } } } \ No newline at end of file diff --git a/Desktop/Solutions/Form1.Designer.cs b/Desktop/Solutions/ChessBoardExample.Designer.cs similarity index 96% rename from Desktop/Solutions/Form1.Designer.cs rename to Desktop/Solutions/ChessBoardExample.Designer.cs index a9185e9..f2e4391 100644 --- a/Desktop/Solutions/Form1.Designer.cs +++ b/Desktop/Solutions/ChessBoardExample.Designer.cs @@ -1,6 +1,6 @@ namespace ChessBoardExample { - partial class Form1 + partial class ChessBoardExample { /// /// Required designer variable. diff --git a/Desktop/Solutions/Form1.cs b/Desktop/Solutions/ChessBoardExample.cs similarity index 92% rename from Desktop/Solutions/Form1.cs rename to Desktop/Solutions/ChessBoardExample.cs index 2167823..af1640c 100644 --- a/Desktop/Solutions/Form1.cs +++ b/Desktop/Solutions/ChessBoardExample.cs @@ -1,14 +1,14 @@ namespace ChessBoardExample { - public partial class Form1 : Form + public partial class ChessBoardExample : Form { - const int gridSize = 12; // 每个小方块大小为40像素 + const int gridSize = 32; // 每个小方块大小为40像素 const int step = 3; // 递进 Dictionary chessboardDict = new Dictionary(); HashSet redPanelsSet = new HashSet(); - public Form1() + public ChessBoardExample() { InitializeComponent(); InitializeChessboard(); @@ -29,6 +29,8 @@ if (redPanelsSet.Count > 0) SetOriginalCells(); else CheckRedCells(5, 9); }); + + Size = new Size(562, 562); } private void InitializeChessboard() @@ -128,10 +130,11 @@ } } - private void OnCellMouseEnter(object sender, System.EventArgs e) + private void OnCellMouseEnter(object? sender, System.EventArgs e) { try { + if (sender is null) return; // 获取当前鼠标进入区域对应格子位置; string[] s = ((Panel)sender).Name.Split('_'); int x = int.Parse(s[0]); @@ -145,7 +148,7 @@ } } - private void OnCellMouseLeave(object sender, EventArgs e) + private void OnCellMouseLeave(object? sender, EventArgs e) { SetOriginalCells(); } diff --git a/Desktop/Solutions/Form1.resx b/Desktop/Solutions/ChessBoardExample.resx similarity index 100% rename from Desktop/Solutions/Form1.resx rename to Desktop/Solutions/ChessBoardExample.resx