コード例 #1
0
ファイル: Window1.xaml.cs プロジェクト: davidkwoods/Resources
        //Move a given game from the graphical display to memory.
        //This method pulls the values from each graphical element of the game's
        //StackPanel and stores the data in memory for easier access.
        private void CopyDisplayToData(StackPanel displayGroup, int gameNumber)
        {
            UIElementCollection members = displayGroup.Children;
            System.Windows.Controls.RadioButton scheduled = members[0] as System.Windows.Controls.RadioButton;
            System.Windows.Controls.RadioButton inProgress = members[1] as System.Windows.Controls.RadioButton;
            System.Windows.Controls.RadioButton final = members[2] as System.Windows.Controls.RadioButton;
            System.Windows.Controls.CheckBox halftime = members[5] as System.Windows.Controls.CheckBox;
            System.Windows.Controls.TextBox homeScore = (members[4] as StackPanel).Children[0] as System.Windows.Controls.TextBox;
            TextBlock homeTeam = (members[4] as StackPanel).Children[1] as TextBlock;
            System.Windows.Controls.TextBox awayScore = (members[3] as StackPanel).Children[0] as System.Windows.Controls.TextBox;
            TextBlock awayTeam = (members[3] as StackPanel).Children[1] as TextBlock;

            MMODGame tempGame = new MMODGame();
            if ((bool)scheduled.IsChecked)
            {
                tempGame.State = SCHEDULED;
            }
            else if ((bool)inProgress.IsChecked)
            {
                tempGame.State = INPROGRESS;
                if ((bool)halftime.IsChecked)
                {
                    tempGame.State = HALFTIME;
                }
            }
            else
            {
                tempGame.State = FINAL;
                gamesCompleted++;
            }
            tempGame.HomeScore = int.Parse(homeScore.Text);
            tempGame.HomeTeam = homeTeam.Text;
            tempGame.AwayScore = int.Parse(awayScore.Text);
            tempGame.AwayTeam = awayTeam.Text;
            tempGame.ID = games[gameNumber].ID;
            games[gameNumber].Clone(tempGame);
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: davidkwoods/Resources
        //Loads bracket data from XElements extracted from the xml file to the
        //List<MMODGame> where they're stored in memory.
        private void LoadXmlToData(IEnumerable<XElement> xmlGames)
        {
            MMODGame tempGame = new MMODGame();
            int gameNumber = 0;
            //Games are assumed to be in order, since the numbers won't necessarily be.
            foreach (XElement game in xmlGames)
            {
                XElement home = game.Element("hometeam");
                XElement away = game.Element("awayteam");

                //Rather than hard-code all the teams with their information, I take them from the bracket.xml file as I load it.
                if (!teams.ContainsKey(home.Value))
                {
                    teams.Add(home.Value, new Team(home.Value, home.Attribute("abbr").Value, int.Parse(home.Attribute("id").Value), int.Parse(home.Attribute("seed").Value)));
                }
                if (!teams.ContainsKey(away.Value))
                {
                    teams.Add(away.Value, new Team(away.Value, away.Attribute("abbr").Value, int.Parse(away.Attribute("id").Value), int.Parse(away.Attribute("seed").Value)));
                }

                try { tempGame.HomeScore = int.Parse(home.Attribute("score").Value); }
                catch { tempGame.HomeScore = 0; }
                try { tempGame.AwayScore = int.Parse(away.Attribute("score").Value); }
                catch { tempGame.AwayScore = 0; }
                tempGame.HomeTeam = home.Value;
                tempGame.AwayTeam = away.Value;
                tempGame.State = game.Attribute("status").Value.ToUpper();
                tempGame.ID = int.Parse(game.Attribute("id").Value);

                games[gameNumber].Clone(tempGame);
                gameNumber++;
            }
        }
コード例 #3
0
ファイル: Window1.xaml.cs プロジェクト: davidkwoods/Resources
 public void Clone(MMODGame input)
 {
     homeScore = input.HomeScore;
     awayScore = input.AwayScore;
     homeTeam = input.HomeTeam;
     awayTeam = input.AwayTeam;
     state = input.State;
     id = input.id;
 }