Пример #1
0
        /// <summary>
        /// Nézetmodell frissítése.
        /// </summary>
        private void Refresh()
        {
            Fields.Clear();

            for (Int32 x = 0; x < TableSize; x++) // inicializáljuk a mezőket
            {
                for (Int32 y = 0; y < TableSize; y++)
                {
                    Fields.Add(new TicTacToeField
                    {
                        Player             = PlayerToField(_model[0, 0]),
                        X                  = x,
                        Y                  = y,
                        FieldChangeCommand = new DelegateCommand(param =>
                        {
                            try
                            {
                                _model.StepGame((param as TicTacToeField).X, (param as TicTacToeField).Y);
                                // ha mezőre lépünk, akkor lépünk a játékban
                            }
                            catch { }
                        })
                    });
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Nézetmodell frissítése.
 /// </summary>
 private void Refresh()
 {
     Fields.Clear();
     //Debug.WriteLine("kaktusz");
     for (int x = 0; x < TableSize; x++) // inicializáljuk a mezőket
     {
         for (int y = 0; y < TableSize; y++)
         {
             Fields.Add(new TicTacToeField
             {
                 Player             = PlayerToField(_model.GetField(x, y)),
                 X                  = x,
                 Y                  = y,
                 FieldChangeCommand = new DelegateCommand(param =>
                 {
                     try
                     {
                         _model.StepGame((param as TicTacToeField).X, (param as TicTacToeField).Y);
                         // ha mezőre lépünk, akkor lépünk a játékban
                     } catch { }
                 }),
                 BackColor = "white"
             });;
         }
     }
 }
        /// <summary>
        /// Initializes the viewmodel.
        /// </summary>
        private void InitBoard()
        {
            Fields.Clear();

            for (Int32 x = 0; x < 3; x++)
            {
                for (Int32 y = 0; y < 3; y++)
                {
                    Fields.Add(new TicTacToeField
                    {
                        Player             = PlayerToField(_model[x, y]),
                        Col                = x,
                        Row                = y,
                        FieldChangeCommand = new DelegateCommand(param =>
                        {
                            _model.StepGame((param as TicTacToeField).Col, (param as TicTacToeField).Row);
                        })
                    });
                }
            }
        }