Exemple #1
0
        public Cage(CageBox btn)
        {
            Control   = btn;
            NumName   = int.Parse(Control.Name.Remove(0, 7));
            Neighbour = new List <int>();

            // line up
            for (int i = 1; i <= ((NumName % 9 != 0) ? NumName / 9 : (NumName / 9) - 1); i++)
            {
                Neighbour.Add(NumName - 9 * i);
            }

            // line right
            for (int i = 9; i <= 81; i += 9)
            {
                if (i >= NumName)
                {
                    for (int j = NumName + 1; j <= i; j++)
                    {
                        Neighbour.Add(j);
                    }
                    break;
                }
            }

            // line down
            for (int i = 1; i < ((NumName % 9 != 0) ? 9 - (NumName / 9) : 9 - (NumName / 9) + 1); i++)
            {
                Neighbour.Add(NumName + 9 * i);
            }

            // line left
            for (int i = 9; i <= 81; i += 9)
            {
                if (i >= NumName)
                {
                    for (int j = 9; j - 1 > i - NumName; j--)
                    {
                        Neighbour.Add(NumName - 10 + j);
                    }
                    break;
                }
            }

            // 3x3 cell
            getGroup(NumName).ForEach(num => Neighbour.Add(num));


            //           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
        }
Exemple #2
0
 public Cage(Cage cage)
 {
     Control   = cage.Control;
     NumName   = cage.NumName;
     Neighbour = cage.Neighbour;
     BackColor = cage.BackColor;
     ForeColor = cage.ForeColor;
 }
Exemple #3
0
        private void Cage_MouseLeave(object sender, EventArgs e)
        {
            if (ActiveButton != null)
            {
                return;
            }

            CageBox btn = sender as CageBox;

            btn.BackColor = Color.LavenderBlush;
            int  BtnNumber = int.Parse(btn.Name.Remove(0, 7));
            Cage cell      = Cell.OfType <Cage>().Where(a => a.NumName == BtnNumber).First();

            SetColorNeighbourCell(cell, Color.LavenderBlush, true);
        }
Exemple #4
0
        private void Cage_MouseEnter(object sender, EventArgs e)
        {
            if (ActiveButton != null)
            {
                return;
            }

            PlaySound(2);

            CageBox btn = sender as CageBox;

            btn.BackColor = Color.HotPink;
            int  BtnNumber = int.Parse(btn.Name.Remove(0, 7));
            Cage cell      = Cell.OfType <Cage>().Where(a => a.NumName == BtnNumber).First();

            SetColorNeighbourCell(cell, Color.Pink, false);
        }