01.
02.
int
Anw = RandomNumberGenerator.GetInt32(minValue,maxValue);
03.
04.
int
countAnw = RandomNumberGenerator.GetInt32(2, 4);
05.
for
(
int
i = 1; i <= countAnw; i++)
06.
Nums.Add(Anw);
07.
08.
for
(
int
i = 1;i<=6-countAnw;i++)
09.
Nums.Add(RandomNumberGenerator.GetInt32((Anw<4)?0:Anw-4, Anw + 4));
10.
11.
12.
e.Graphics.DrawString($
"นับ และ วงรอบรูปที่แสดงจำนวน {Anw}"
, fontDetail,
new
SolidBrush(Color.Black), xC, yC);
13.
xC = 150;
14.
yC = yC + 50;
15.
Random r =
new
Random();
16.
int
randomIndex, number;
17.
for
(
int
i = 1; i <= 6; i+=2)
18.
{
19.
20.
randomIndex = r.Next(Nums.Count);
21.
number = Nums[randomIndex];
22.
23.
e.Graphics.DrawImage(KidsLearning.Classed.Exten.Exteaphics.ImageFromNumber(number, 150, 150), xC, yC);
24.
25.
Nums.RemoveAt(randomIndex);
26.
27.
28.
29.
xC = xC + 280;
30.
randomIndex = r.Next(Nums.Count);
31.
number = Nums[randomIndex];
32.
e.Graphics.DrawImage(KidsLearning.Classed.Exten.Exteaphics.ImageFromNumber(number, 150, 150), xC, yC);
33.
Nums.RemoveAt(randomIndex);
34.
xC = 150;
35.
yC = yC + 250;
36.
37.
}
38.