public MainWindow()
        {
            InitializeComponent();
            SingletonDBMS.GetInstance().CreateDb();
            //MessageBox.Show(Environment.MachineName);

            List <String> games = SingletonDBMS.GetInstance().GetGamesFromDB();

            for (int i = 0; i < games.Count; i++)
            {
                this.cmBoxGame.Items.Add(games.ElementAt(i));
            }
        }
        private void ltb1_MouseDoubleClick(object sender, RoutedEventArgs e)
        {
            if (ltb1.SelectedItem != null)
            {
                Turn selectedTurn = (Turn)ltb1.SelectedItem;

                SingletonDBMS.GetInstance().GetTurnRanking(this.tournament.ListPlayers, selectedTurn.RoundNumber);

                TablesWindow win = new TablesWindow(this.tournament, (Turn)ltb1.SelectedItem, this);
                this.Hide();
                win.Show();
            }
        }
        private void btnAddTurn_Click(object sender, RoutedEventArgs e)
        {
            int  tablePlayersNumber = Int32.Parse(txbPlayersNumber.Text);
            bool italianRound       = (bool)chb1.IsChecked;

            SingletonDBMS.GetInstance().GetPartialRanking(this.tournament.ListPlayers);

            Turn turn = new Turn(italianRound, tablePlayersNumber, this.tournament.ListPlayers, this.tournament.nextRoundNumber());

            turn.svizzera();
            ltb1.Items.Add(turn);
            this.tournament.setTurn(turn);

            SingletonDBMS.GetInstance().InsertTurn(this.tournament);

            this.resetPointsPlayers();
        }
 private void OnKeyDownHandlerTxbPlayer(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         Player player = SingletonDBMS.GetInstance().GetPlayerFromDB(txbPlayer.Text);
         if (player != null)
         {
             this.listPlayers.AddLast(new Player(player.Nickname));
             ltb1.Items.Add(player);
             txbPlayer.Text = "";
         }
         else
         {
             MessageBox.Show("GIOCATORE INESISTENTE");
         }
         txbPlayer.Focus();
     }
 }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this.name    = txbName.Text;
            this.address = txbAddress.Text;
            this.game    = cmBoxGame.Text;
            this.date    = dpkData.DisplayDate;

            this.teams = (bool)chb1.IsChecked;

            this.tournament = new Tournament(this.name, this.game, this.address, this.date, this.teams, this.listPlayers.ToList <Player>());

            bool b = SingletonDBMS.GetInstance().InsertTournament(this.tournament);

            TurnsWindow win = new TurnsWindow(this.tournament, this);

            win.Show();
            this.Hide();
        }
 private void btnSavePoints_Click(object sender, RoutedEventArgs e)
 {
     SingletonDBMS.GetInstance().InsertScores(this.tournament);
     MessageBox.Show("Punteggi salvati");
     this.turn.IsSaved = true;
 }