Ejemplo n.º 1
0
        public void Creat()
        {
            Random r   = new Random();
            var    ran = r.Next(0, 40);

            SubjectNum  = "题目:" + ran;
            CurrSubject = Subjects[ran];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    int       num  = int.Parse(CurrSubject[i * 9 + j]);
                    ClassCell cell = new ClassCell();
                    cell.Number = num;
                    if (num != 0)
                    {
                        cell.CellType = CellType.System;
                    }
                    this.AllCells.Add(cell);
                    Lines[i].ClassCells.Add(cell);
                    cell.CurrClassLine = Lines[i];
                    Columns[j].ClassCells.Add(cell);
                    cell.CurrClassColumn = Columns[j];
                    Palaces[(i) / 3 * 3 + (j) / 3].ClassCells.Add(cell);
                    cell.CurrClassPalace = Palaces[(i) / 3 * 3 + (j) / 3];
                }
            }
            if (GlobalModule.AppCinfig.IsOpenSudokuTabs)
            {
                AllCells.ForEach(a => a.GetTabs());
            }
        }
Ejemplo n.º 2
0
        public void ClickCell(ClassCell cell)
        {
            if (cell == null)
            {
                return;
            }

            if (BGChangecells.Count > 0)
            {
                BGChangecells.ForEach(a => a.BorderBrush = Brushes.Transparent);
                BGChangecells.Clear();
            }
            if (cell.Number != 0)
            {
                AllCells.ForEach(a =>
                {
                    if (a.Number == cell.Number || (a.Number == 0 && a.Tabs.Contains(cell.Number)))
                    {
                        a.BorderBrush = Brushes.Lime;
                        BGChangecells.Add(a);
                    }
                });
            }
            else
            {
                cell.CurrClassLine.ClassCells.ForEach(a =>
                {
                    a.BorderBrush = Brushes.Tomato;
                    BGChangecells.Add(a);
                });
                cell.CurrClassColumn.ClassCells.ForEach(a =>
                {
                    a.BorderBrush = Brushes.Tomato;
                    BGChangecells.Add(a);
                });
                cell.CurrClassPalace.ClassCells.ForEach(a =>
                {
                    a.BorderBrush = Brushes.Tomato;
                    BGChangecells.Add(a);
                });
            }
            CurrCell = null;
            if (cell.CellType == CellType.System)
            {
                return;
            }
            CurrCell             = cell;
            CurrCell.BorderBrush = Brushes.Yellow;
        }