Esempio n. 1
0
        public void SelectPitch()
        {
            SelectListWindow selectListWindow = new SelectListWindow
            {
                Owner = _owner,
                Title = "Select Pitch"
            };

            foreach (JObject gameDate in _tournament["gameDates"])
            {
                string gameDateName = ((DateTime)(gameDate["date"]["value"])).ToString("ddd MMM dd yyyy");
                foreach (JObject pitch in gameDate["pitches"])
                {
                    selectListWindow.Items.Add(new SelectItem((string)(pitch["id"]["value"]), gameDateName + " " + (string)pitch["name"]));
                }
            }

            if (selectListWindow.ShowDialog() == true)
            {
                _pitchId = selectListWindow.SelectedId;

                foreach (JObject gameDate in _tournament["gameDates"])
                {
                    foreach (JObject pitch in gameDate["pitches"])
                    {
                        if ((string)(pitch["id"]["value"]) == _pitchId)
                        {
                            _gameDate   = gameDate;
                            _gameDateId = (string)_gameDate["id"]["value"];
                            _pitch      = pitch;
                            break;
                        }
                    }
                }

                if (_pitch != null)
                {
                    AddGames();
                }
            }
        }
Esempio n. 2
0
        private void SelectTournament()
        {
            SelectListWindow selectListWindow = new SelectListWindow
            {
                Owner = _owner,
                Title = "Select Tournament"
            };

            foreach (JObject tournament in _tournaments["tournaments"])
            {
                selectListWindow.Items.Add(new SelectItem((string)(tournament["id"]["value"]), (string)tournament["name"]));
            }

            if (selectListWindow.ShowDialog() == true)
            {
                _tournamentId = selectListWindow.SelectedId;

                ProcessingWindow.ShowProcessing(_owner, "Listing Games...");

                // List Pitches
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += delegate {
                    _tournament = GetRequestAsJObject("/data/tournament/" + _tournamentId);
                };
                worker.RunWorkerCompleted += delegate
                {
                    ProcessingWindow.HideProcessing();
                    if (_tournament != null)
                    {
                        SelectPitch();
                    }
                    else
                    {
                        MessageBox.Show("Unable to list Games.");
                    }
                };
                worker.RunWorkerAsync();
            }
        }