Skip to content

Commit 9268c19

Browse files
committed
format code
1 parent 995cf85 commit 9268c19

File tree

4 files changed

+523
-826
lines changed

4 files changed

+523
-826
lines changed

About.cs

Lines changed: 84 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
using System.ComponentModel;
55
using System.Windows.Forms;
66

7-
namespace Sudoku
8-
{
7+
namespace Sudoku {
98
/// <summary>
109
/// Summary description for About.
1110
/// </summary>
12-
public class About : System.Windows.Forms.Form
13-
{
11+
public class About : System.Windows.Forms.Form {
1412
#region private stuff
1513

1614
private System.Windows.Forms.Button btnOK;
@@ -20,8 +18,7 @@ public class About : System.Windows.Forms.Form
2018
private System.ComponentModel.Container components = null;
2119
#endregion
2220
#region public About()
23-
public About()
24-
{
21+
public About() {
2522
//
2623
// Required for Windows Form Designer support
2724
//
@@ -35,115 +32,101 @@ public About()
3532
/// <summary>
3633
/// Clean up any resources being used.
3734
/// </summary>
38-
protected override void Dispose( bool disposing )
39-
{
40-
if( disposing )
41-
{
42-
if(components != null)
43-
{
35+
protected override void Dispose(bool disposing) {
36+
if (disposing) {
37+
if (components != null) {
4438
components.Dispose();
4539
}
4640
}
47-
base.Dispose( disposing );
41+
base.Dispose(disposing);
4842
}
4943
#endregion
5044
#region Windows Form Designer generated code
5145
/// <summary>
5246
/// Required method for Designer support - do not modify
5347
/// the contents of this method with the code editor.
5448
/// </summary>
55-
private void InitializeComponent()
56-
{
57-
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About));
58-
this.btnOK = new System.Windows.Forms.Button();
59-
this.SuspendLayout();
60-
//
61-
// btnOK
62-
//
63-
this.btnOK.BackColor = System.Drawing.Color.Black;
64-
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
65-
this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
66-
this.btnOK.ForeColor = System.Drawing.Color.LightGreen;
67-
this.btnOK.Location = new System.Drawing.Point(43, 133);
68-
this.btnOK.Name = "btnOK";
69-
this.btnOK.Size = new System.Drawing.Size(75, 23);
70-
this.btnOK.TabIndex = 3;
71-
this.btnOK.Text = "OK";
72-
this.btnOK.UseVisualStyleBackColor = false;
73-
//
74-
// About
75-
//
76-
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
77-
this.BackColor = System.Drawing.Color.Gold;
78-
this.ClientSize = new System.Drawing.Size(162, 162);
79-
this.Controls.Add(this.btnOK);
80-
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
81-
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
82-
this.Name = "About";
83-
this.ShowInTaskbar = false;
84-
this.Text = "Sudoku v4.1";
85-
this.Paint += new System.Windows.Forms.PaintEventHandler(this.About_Paint);
86-
this.ResumeLayout(false);
49+
private void InitializeComponent() {
50+
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About));
51+
this.btnOK = new System.Windows.Forms.Button();
52+
this.SuspendLayout();
53+
//
54+
// btnOK
55+
//
56+
this.btnOK.BackColor = System.Drawing.Color.Black;
57+
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
58+
this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
59+
this.btnOK.ForeColor = System.Drawing.Color.LightGreen;
60+
this.btnOK.Location = new System.Drawing.Point(43, 133);
61+
this.btnOK.Name = "btnOK";
62+
this.btnOK.Size = new System.Drawing.Size(75, 23);
63+
this.btnOK.TabIndex = 3;
64+
this.btnOK.Text = "OK";
65+
this.btnOK.UseVisualStyleBackColor = false;
66+
//
67+
// About
68+
//
69+
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
70+
this.BackColor = System.Drawing.Color.Gold;
71+
this.ClientSize = new System.Drawing.Size(162, 162);
72+
this.Controls.Add(this.btnOK);
73+
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
74+
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
75+
this.Name = "About";
76+
this.ShowInTaskbar = false;
77+
this.Text = "Sudoku v4.1";
78+
this.Paint += new System.Windows.Forms.PaintEventHandler(this.About_Paint);
79+
this.ResumeLayout(false);
8780

8881
}
8982
#endregion
9083
#region Global Variables
9184
int count = 0;
9285
int _left = 28;
9386
int _top = 35;
94-
int[,] _grid = new int[9,9];
87+
int[,] _grid = new int[9, 9];
9588
SudokuGrid grid = new SudokuGrid();
96-
int [,,] gridHints = new int[9,9,9];
89+
int[,,] gridHints = new int[9, 9, 9];
9790
Pen _penThick = new Pen(Color.Black, 3);
98-
Rectangle[,] _boardArray = new Rectangle[9,9];
91+
Rectangle[,] _boardArray = new Rectangle[9, 9];
9992
Font _sudukoFont = new Font("Arial", 10, FontStyle.Regular);
10093
Font _hintsFont = new Font("Small Fonts", 4);
101-
Rectangle _board = new Rectangle(0,0, 0, 0);
94+
Rectangle _board = new Rectangle(0, 0, 0, 0);
10295
#endregion
10396
#region void DrawSudokuGrid(Graphics g)
104-
void DrawSudokuGrid(Graphics g)
105-
{
106-
if (count == 0)
107-
{
97+
void DrawSudokuGrid(Graphics g) {
98+
if (count == 0) {
10899
_grid = grid.GenerateGrid();
109100
int r = 0;
110-
for (int row = 0; row < 5; row += 2)
111-
{
112-
for (int col = 0; col < 4; col += 2)
113-
{
101+
for (int row = 0; row < 5; row += 2) {
102+
for (int col = 0; col < 4; col += 2) {
114103
if (r == 0)
115104
r = new Random().Next();
116105
if (r % 2 == 1)
117106
_grid[row, col] = 0;
118107
r /= 2;
119108
}
120109
}
121-
for (int row = 1; row < 5; row += 2)
122-
{
123-
for (int col = 1; col < 4; col += 2)
124-
{
110+
for (int row = 1; row < 5; row += 2) {
111+
for (int col = 1; col < 4; col += 2) {
125112
if (r == 0)
126113
r = new Random().Next();
127114
if (r % 2 == 1)
128115
_grid[row, col] = 0;
129116
r /= 2;
130117
}
131118
}
132-
for (int row = 0; row < 5; row += 2)
133-
{
134-
for (int col = 1; col < 4; col += 2)
135-
{
119+
for (int row = 0; row < 5; row += 2) {
120+
for (int col = 1; col < 4; col += 2) {
136121
if (r == 0)
137122
r = new Random().Next();
138123
if (r % 2 == 1)
139124
_grid[row, col] = 0;
140125
r /= 2;
141126
}
142127
}
143-
for (int row = 1; row < 5; row += 2)
144-
{
145-
for (int col = 0; col < 4; col += 2)
146-
{
128+
for (int row = 1; row < 5; row += 2) {
129+
for (int col = 0; col < 4; col += 2) {
147130
if (r == 0)
148131
r = new Random().Next();
149132
if (r % 2 == 1)
@@ -153,12 +136,9 @@ void DrawSudokuGrid(Graphics g)
153136
}
154137
if (r % 2 == 0)
155138
_grid[4, 4] = 0;
156-
for (int row = 0; row < 5; row++)
157-
{
158-
for (int col = 0; col < 4; col++)
159-
{
160-
if (_grid[row, col] == 0)
161-
{
139+
for (int row = 0; row < 5; row++) {
140+
for (int col = 0; col < 4; col++) {
141+
if (_grid[row, col] == 0) {
162142
_grid[8 - row, 8 - col] = 0;
163143
_grid[8 - col, row] = 0;
164144
_grid[col, 8 - row] = 0;
@@ -171,14 +151,12 @@ void DrawSudokuGrid(Graphics g)
171151
// draw square
172152
g.DrawRectangle(_penThick, _board);
173153

174-
int spacingX = _board.Width/9;
175-
int spacingY = _board.Height/9;
154+
int spacingX = _board.Width / 9;
155+
int spacingY = _board.Height / 9;
176156

177-
for (int col = 0; col < 9; col++)
178-
{
179-
for (int row = 0; row < 9; row++)
180-
{
181-
_boardArray[row, col] = new Rectangle(_board.Left + col*spacingX, _board.Top + row*spacingY, spacingX, spacingY);
157+
for (int col = 0; col < 9; col++) {
158+
for (int row = 0; row < 9; row++) {
159+
_boardArray[row, col] = new Rectangle(_board.Left + col * spacingX, _board.Top + row * spacingY, spacingX, spacingY);
182160
}
183161
}
184162
g.FillRectangle(Brushes.Yellow, _boardArray[0, 3]);
@@ -234,81 +212,65 @@ void DrawSudokuGrid(Graphics g)
234212
g.FillRectangle(Brushes.Yellow, _boardArray[8, 7]);
235213
g.FillRectangle(Brushes.Yellow, _boardArray[8, 8]);
236214

237-
for (int i = 0; i < 10; i++)
238-
{
239-
if (i % 3 == 0)
240-
{
241-
g.DrawLine(_penThick, _board.Left, _board.Top + spacingY * i, _board.Right, _board.Top + spacingY*i);
215+
for (int i = 0; i < 10; i++) {
216+
if (i % 3 == 0) {
217+
g.DrawLine(_penThick, _board.Left, _board.Top + spacingY * i, _board.Right, _board.Top + spacingY * i);
242218
g.DrawLine(_penThick, _board.Left + spacingX * i, _board.Top, _board.Left + spacingX * i, _board.Bottom);
243-
}
244-
else
245-
{
246-
g.DrawLine(Pens.Black, _board.Left, _board.Top + spacingY * i, _board.Right, _board.Top + spacingY*i);
219+
} else {
220+
g.DrawLine(Pens.Black, _board.Left, _board.Top + spacingY * i, _board.Right, _board.Top + spacingY * i);
247221
g.DrawLine(Pens.Black, _board.Left + spacingX * i, _board.Top, _board.Left + spacingX * i, _board.Bottom);
248222
}
249223
}
250224

251-
for (int col = 0; col < 9; col++)
252-
{
253-
for (int row = 0; row < 9; row++)
254-
{
225+
for (int col = 0; col < 9; col++) {
226+
for (int row = 0; row < 9; row++) {
255227
int val = _grid[row, col];
256228

257-
if (val != 0)
258-
{
259-
g.DrawString(val.ToString(), _sudukoFont, Brushes.Black, _board.Left + col*spacingX + 4, _board.Top + row*spacingY + 1, new StringFormat());
260-
}
261-
else
262-
{
229+
if (val != 0) {
230+
g.DrawString(val.ToString(), _sudukoFont, Brushes.Black, _board.Left + col * spacingX + 4, _board.Top + row * spacingY + 1, new StringFormat());
231+
} else {
263232
DrawGridHints(g, row, col);
264233
}
265-
}
234+
}
266235
}
267236
}
268237
#endregion
269238
#region void DrawGridHints(Graphics g, int row, int col)
270-
void DrawGridHints(Graphics g, int row, int col)
271-
{
272-
int spacingX = _board.Width/9;
273-
int spacingY = _board.Height/9;
239+
void DrawGridHints(Graphics g, int row, int col) {
240+
int spacingX = _board.Width / 9;
241+
int spacingY = _board.Height / 9;
274242
int length;
275243
string hints = "";
276244
string hintss = "";
277245
string hintsss = "";
278-
for (int i = 0; i < 9; i++)
279-
{
246+
for (int i = 0; i < 9; i++) {
280247
if (gridHints[row, col, i] != 0)
281248
hints = hints + gridHints[row, col, i].ToString() + ",";
282249
}
283250

284-
if (hints.Length > 0)
285-
{
286-
hints = hints.Remove(hints.Length - 1, 1);
251+
if (hints.Length > 0) {
252+
hints = hints.Remove(hints.Length - 1, 1);
287253
}
288254
System.Drawing.Brush brush = Brushes.Maroon;
289-
if (hints.Length == 1)
290-
{
255+
if (hints.Length == 1) {
291256
brush = Brushes.Blue;
292257
}
293-
if (hints.Length > 8)
294-
{
258+
if (hints.Length > 8) {
295259
length = hints.Length - 8;
296260
hintss = hints.Remove(0, 8);
297261
hints = hints.Remove(8, length);
298-
if (hintss.Length > 8)
299-
{
262+
if (hintss.Length > 8) {
300263
hintsss = hintss.Remove(0, 8);
301264
hintss = hintss.Remove(8, 1);
302-
g.DrawString(hintsss.ToString(), _hintsFont, brush, _board.Left + col*spacingX + 1, _board.Top + row*spacingY + 14, new StringFormat());
265+
g.DrawString(hintsss.ToString(), _hintsFont, brush, _board.Left + col * spacingX + 1, _board.Top + row * spacingY + 14, new StringFormat());
303266
}
304-
g.DrawString(hintss.ToString(), _hintsFont, brush, _board.Left + col*spacingX + 1, _board.Top + row*spacingY + 8, new StringFormat());
267+
g.DrawString(hintss.ToString(), _hintsFont, brush, _board.Left + col * spacingX + 1, _board.Top + row * spacingY + 8, new StringFormat());
305268
}
306-
g.DrawString(hints.ToString(), _hintsFont, brush, _board.Left + col*spacingX + 1, _board.Top + row*spacingY + 2, new StringFormat());
269+
g.DrawString(hints.ToString(), _hintsFont, brush, _board.Left + col * spacingX + 1, _board.Top + row * spacingY + 2, new StringFormat());
307270
}
308271
#endregion
309272
#region private void About_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
310-
private void About_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
311-
{
273+
private void About_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
312274
String S1 = "by Tony Brix";
313275
String S2 = "[email protected]";
314276
String S3 = "Special Thanks to";

0 commit comments

Comments
 (0)