4
4
using System . ComponentModel ;
5
5
using System . Windows . Forms ;
6
6
7
- namespace Sudoku
8
- {
7
+ namespace Sudoku {
9
8
/// <summary>
10
9
/// Summary description for About.
11
10
/// </summary>
12
- public class About : System . Windows . Forms . Form
13
- {
11
+ public class About : System . Windows . Forms . Form {
14
12
#region private stuff
15
13
16
14
private System . Windows . Forms . Button btnOK ;
@@ -20,8 +18,7 @@ public class About : System.Windows.Forms.Form
20
18
private System . ComponentModel . Container components = null ;
21
19
#endregion
22
20
#region public About()
23
- public About ( )
24
- {
21
+ public About ( ) {
25
22
//
26
23
// Required for Windows Form Designer support
27
24
//
@@ -35,115 +32,101 @@ public About()
35
32
/// <summary>
36
33
/// Clean up any resources being used.
37
34
/// </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 ) {
44
38
components . Dispose ( ) ;
45
39
}
46
40
}
47
- base . Dispose ( disposing ) ;
41
+ base . Dispose ( disposing ) ;
48
42
}
49
43
#endregion
50
44
#region Windows Form Designer generated code
51
45
/// <summary>
52
46
/// Required method for Designer support - do not modify
53
47
/// the contents of this method with the code editor.
54
48
/// </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 ) ;
87
80
88
81
}
89
82
#endregion
90
83
#region Global Variables
91
84
int count = 0 ;
92
85
int _left = 28 ;
93
86
int _top = 35 ;
94
- int [ , ] _grid = new int [ 9 , 9 ] ;
87
+ int [ , ] _grid = new int [ 9 , 9 ] ;
95
88
SudokuGrid grid = new SudokuGrid ( ) ;
96
- int [ , , ] gridHints = new int [ 9 , 9 , 9 ] ;
89
+ int [ , , ] gridHints = new int [ 9 , 9 , 9 ] ;
97
90
Pen _penThick = new Pen ( Color . Black , 3 ) ;
98
- Rectangle [ , ] _boardArray = new Rectangle [ 9 , 9 ] ;
91
+ Rectangle [ , ] _boardArray = new Rectangle [ 9 , 9 ] ;
99
92
Font _sudukoFont = new Font ( "Arial" , 10 , FontStyle . Regular ) ;
100
93
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 ) ;
102
95
#endregion
103
96
#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 ) {
108
99
_grid = grid . GenerateGrid ( ) ;
109
100
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 ) {
114
103
if ( r == 0 )
115
104
r = new Random ( ) . Next ( ) ;
116
105
if ( r % 2 == 1 )
117
106
_grid [ row , col ] = 0 ;
118
107
r /= 2 ;
119
108
}
120
109
}
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 ) {
125
112
if ( r == 0 )
126
113
r = new Random ( ) . Next ( ) ;
127
114
if ( r % 2 == 1 )
128
115
_grid [ row , col ] = 0 ;
129
116
r /= 2 ;
130
117
}
131
118
}
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 ) {
136
121
if ( r == 0 )
137
122
r = new Random ( ) . Next ( ) ;
138
123
if ( r % 2 == 1 )
139
124
_grid [ row , col ] = 0 ;
140
125
r /= 2 ;
141
126
}
142
127
}
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 ) {
147
130
if ( r == 0 )
148
131
r = new Random ( ) . Next ( ) ;
149
132
if ( r % 2 == 1 )
@@ -153,12 +136,9 @@ void DrawSudokuGrid(Graphics g)
153
136
}
154
137
if ( r % 2 == 0 )
155
138
_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 ) {
162
142
_grid [ 8 - row , 8 - col ] = 0 ;
163
143
_grid [ 8 - col , row ] = 0 ;
164
144
_grid [ col , 8 - row ] = 0 ;
@@ -171,14 +151,12 @@ void DrawSudokuGrid(Graphics g)
171
151
// draw square
172
152
g . DrawRectangle ( _penThick , _board ) ;
173
153
174
- int spacingX = _board . Width / 9 ;
175
- int spacingY = _board . Height / 9 ;
154
+ int spacingX = _board . Width / 9 ;
155
+ int spacingY = _board . Height / 9 ;
176
156
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 ) ;
182
160
}
183
161
}
184
162
g . FillRectangle ( Brushes . Yellow , _boardArray [ 0 , 3 ] ) ;
@@ -234,81 +212,65 @@ void DrawSudokuGrid(Graphics g)
234
212
g . FillRectangle ( Brushes . Yellow , _boardArray [ 8 , 7 ] ) ;
235
213
g . FillRectangle ( Brushes . Yellow , _boardArray [ 8 , 8 ] ) ;
236
214
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 ) ;
242
218
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 ) ;
247
221
g . DrawLine ( Pens . Black , _board . Left + spacingX * i , _board . Top , _board . Left + spacingX * i , _board . Bottom ) ;
248
222
}
249
223
}
250
224
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 ++ ) {
255
227
int val = _grid [ row , col ] ;
256
228
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 {
263
232
DrawGridHints ( g , row , col ) ;
264
233
}
265
- }
234
+ }
266
235
}
267
236
}
268
237
#endregion
269
238
#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 ;
274
242
int length ;
275
243
string hints = "" ;
276
244
string hintss = "" ;
277
245
string hintsss = "" ;
278
- for ( int i = 0 ; i < 9 ; i ++ )
279
- {
246
+ for ( int i = 0 ; i < 9 ; i ++ ) {
280
247
if ( gridHints [ row , col , i ] != 0 )
281
248
hints = hints + gridHints [ row , col , i ] . ToString ( ) + "," ;
282
249
}
283
250
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 ) ;
287
253
}
288
254
System . Drawing . Brush brush = Brushes . Maroon ;
289
- if ( hints . Length == 1 )
290
- {
255
+ if ( hints . Length == 1 ) {
291
256
brush = Brushes . Blue ;
292
257
}
293
- if ( hints . Length > 8 )
294
- {
258
+ if ( hints . Length > 8 ) {
295
259
length = hints . Length - 8 ;
296
260
hintss = hints . Remove ( 0 , 8 ) ;
297
261
hints = hints . Remove ( 8 , length ) ;
298
- if ( hintss . Length > 8 )
299
- {
262
+ if ( hintss . Length > 8 ) {
300
263
hintsss = hintss . Remove ( 0 , 8 ) ;
301
264
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 ( ) ) ;
303
266
}
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 ( ) ) ;
305
268
}
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 ( ) ) ;
307
270
}
308
271
#endregion
309
272
#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 ) {
312
274
String S1 = "by Tony Brix" ;
313
275
314
276
String S3 = "Special Thanks to" ;
0 commit comments