private void UpdatePlayerScoreLabels() { for (int i = 0; i < gameWorld.Players.Count; ++i) { Label scoreLabel = ScoreStackPanel.FindName(string.Format("Score{0}Label", i)) as Label; scoreLabel.Content = string.Format("{0}: {1}", gameWorld.Players[i].Name, gameWorld.Players[i].Score); } }
private void Load() { Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog(); openFileDlg.InitialDirectory = @"D:\"; openFileDlg.Filter = "gdy|*.gdy"; if (openFileDlg.ShowDialog() == true) { try { FileStream fs = new FileStream(openFileDlg.FileName.ToString(), FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); gameWorld = (GameWorld)bf.Deserialize(fs); fs.Close(); } catch (Exception e) { throw new Exception(e.Message); } UpdateScoreListView(); UpdateDinnerListView(); UpdateNameLabels(); for (int i = 0; i < gameWorld.Players.Count; ++i) { Label scoreLabel = ScoreStackPanel.FindName(string.Format("Score{0}Label", i)) as Label; scoreLabel.Content = string.Format("{0}: 0", gameWorld.Players[i].Name); } for (int i = gameWorld.Players.Count; i < 6; ++i) { Label scoreLabel = ScoreStackPanel.FindName(string.Format("Score{0}Label", i)) as Label; scoreLabel.Content = ""; } UpdatePlayerScoreLabels(); } }
private void CreateGameWorld(List <string> players, int FAN) { int numPlayer = players.Count; gameWorld = new GameWorld(players, FAN); UpdateScoreListView(); UpdateDinnerListView(); UpdateNameLabels(); for (int i = 0; i < players.Count; ++i) { Label scoreLabel = ScoreStackPanel.FindName(string.Format("Score{0}Label", i)) as Label; scoreLabel.Content = string.Format("{0}: 0", players[i]); } for (int i = players.Count; i < 6; ++i) { Label scoreLabel = ScoreStackPanel.FindName(string.Format("Score{0}Label", i)) as Label; scoreLabel.Content = ""; } }