예제 #1
0
 public void SetValue(int x, int y, int value)
 {
     lock (BoardLayout)
     {
         Cell cell = BoardLayout[x, y];
         cell.SetValue(value);
     }
 }
예제 #2
0
        /// <summary>
        /// when cube Changed
        /// </summary>
        private void UpdateStatus()
        {
            this.bordGrid.Children.Clear();
            this.bordGrid.ColumnDefinitions.Clear();
            this.bordGrid.RowDefinitions.Clear();
            for (int i = 0; i < Cube; i++)
            {
                this.bordGrid.RowDefinitions.Add(new RowDefinition());
                this.bordGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            if (emptyposition == null)
            {
                emptyposition = new List <int>(capacity);
            }
            if (Cells == null)
            {
                Cells = new List <Cell>(capacity);
            }

            this.emptyposition.Clear();
            this.Cells.Clear();

            for (int i = 0; i < capacity; i++)
            {
                int  positionx = i / Cube;
                int  positiony = i % Cube;
                Cell cell      = new Cell();
                cell.SetValue(Cell.DisplayProperty, this.DisplayNumber);
                cell.SetValue(Cell.ValueProperty, 0);
                cell.SetValue(Grid.RowProperty, positionx);
                cell.SetValue(Grid.ColumnProperty, positiony);

                this.emptyposition.Add(i);
                this.Cells.Add(cell);
                this.bordGrid.Children.Add(cell);
            }
            NewGame();
        }