/// <summary>
 /// displayes statistics and deserialized or serialized the game
 ///
 /// </summary>
 /// <param name="deserialize">true deserialize, false serialize</param>
 public void State(bool deserialize)
 {
     //deserialize game from a file
     if (deserialize)
     {
         FileStream      fin;
         BinaryFormatter bf;
         bf   = new BinaryFormatter();
         fin  = File.Open(file, FileMode.Open, FileAccess.Read);
         game = (MemoryGame)bf.Deserialize(fin);
         fin.Close();
         //restore the state of board
         places = game.Places;
         InitBoard();
         for (int i = 0; i < places * places; i++)
         {
             int  j;
             char mark = game.Found(i, out j);
             if (j >= 0 && mark != Markers.Empty)
             {
                 ((Button)board.Children[i]).Content = mark;
                 ((Button)board.Children[j]).Content = ((Button)board.Children[i]).Content;
                 board.Children[i].IsEnabled         = false;
                 board.Children[j].IsEnabled         = false;
             }
         }
     }
     else   //serialize the state to a file
     {
         FileStream      fout;
         BinaryFormatter bf;
         bf   = new BinaryFormatter();
         fout = File.Open(file, FileMode.OpenOrCreate, FileAccess.Write);
         bf.Serialize(fout, game);
         fout.Flush();
         fout.Close();
     }
     result.Text = game.Statistics();
 }
 /// <summary>
 /// initialize board, textBlock and places and then call reset and initialization
 /// </summary>
 /// <param name="amount">amount of places, selected with radiobuttons</param>
 public void InitBoard(int amount)
 {
     this.places = amount;
     game        = new MemoryGame(amount);
     Reset();
 }