-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.cs
86 lines (83 loc) · 2.57 KB
/
Cell.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Demineur
{
public class Cell
{
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public Button Btn { get; set; }
public bool IsBomb { get; set; }
public bool IsShowed { get; set; }
public bool IsFlagged { get; set; }
public int nbBombsAround;
public int NbBombsAroud {
get => nbBombsAround;
set {
nbBombsAround = value;
switch (value)
{
case 1:
Btn.ForeColor = Color.Blue;
break;
case 2:
Btn.ForeColor = Color.Green;
break;
case 3:
Btn.ForeColor = Color.Red;
break;
case 4:
Btn.ForeColor = Color.Violet;
break;
case 5:
Btn.ForeColor = Color.DarkRed;
break;
case 6:
Btn.ForeColor = Color.Turquoise;
break;
case 7:
Btn.ForeColor = Color.Black;
break;
case 8:
Btn.ForeColor = Color.Gray;
break;
}
}
}
public Cell(int X, int Y, int Width, Form frm)
{
this.X = X;
this.Y = Y;
this.Width = Width;
this.IsFlagged = false;
Btn = new Button();
Btn.Name = X + "." + Y;
Btn.Font = new Font(FontFamily.GenericSansSerif, (float)8.25, FontStyle.Bold);
Btn.Size = new System.Drawing.Size(new System.Drawing.Point(Width, Width));
Btn.Location = new System.Drawing.Point(X*Width, Y * Width);
frm.Controls.Add(Btn);
}
public void Show(Image img)
{
if (!IsShowed)
{
IsShowed = true;
if (IsBomb)
{
Btn.Image = img;
}
else
{
if(NbBombsAroud != 0) Btn.Text = NbBombsAroud.ToString();
Btn.BackColor = Color.DarkGray;
}
}
}
}
}