void AddUser(string user)
 {
     _users.AddObjects(new NSString(user));
     PutUsersToSettingsStore();
     _trainTapMode = TrainTapMode.UserSelect;
     ShowChooseTrainAlert(user);
 }
 void ScoreButton_Clicked(object sender, EventArgs e)
 {
     //TODO: Implement
     if (!_scoring)
     {
         _trainTapMode = TrainTapMode.Scoring;
         var alert = UIAlertController.Create("Choose a player to score", "Tap the train of the player you want to score", UIAlertControllerStyle.Alert);
         alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, _ => { }));
         PresentViewController(alert, true, () => { });
         _scoring = true;
         scoreButton.SetTitle("Cancel Scoring", UIControlState.Normal);
     }
     else
     {
         CancelScoring();
     }
 }
 void CancelScoring()
 {
     _trainTapMode = TrainTapMode.Normal;
     _scoring      = false;
     scoreButton.SetTitle("Score Round", UIControlState.Normal);
 }
        void HandleTap(int index)
        {
            switch (_trainTapMode)
            {
            case TrainTapMode.Normal:
                var train = _trains[index];
                train.Image         = _trainValues[index] ? UIImage.FromBundle("train.gif") : UIImage.FromBundle("train_selected.gif");
                _trainValues[index] = !_trainValues[index];
                break;

            case TrainTapMode.UserSelect:
                var label = _names[index];
                if (_nameMap[index] == -1)
                {
                    _nameMap[index] = (int)(_users.Count) - 1;
                    label.Text      = _users[_users.Count - 1].ToString();
                    _trainTapMode   = TrainTapMode.Normal;
                }
                else
                {
                    ShowTrainTakenAlert(_users.GetItem <NSString>((System.nuint)_nameMap[index]).ToString());
                }
                break;

            case TrainTapMode.Scoring:
                try
                {
                    var item = _users.GetItem <NSString>((nuint)_nameMap[index]);
                    NavigationController.PushViewController(new ScoringViewController(item), true);
                    CancelScoring();
                } catch (ArgumentOutOfRangeException) {
                    Console.WriteLine("Tapped empty train");
                }
                break;

            case TrainTapMode.Move:
                if (_names[index].Text != "")
                {
                    var fromName = _names[_currentMovingTrain].Text;
                    var toName   = _names[index].Text;
                    _names[_currentMovingTrain].Text = toName;
                    _names[index].Text = fromName;
                    var temp = _nameMap[index];
                    _nameMap[index] = _nameMap[_currentMovingTrain];
                    _nameMap[_currentMovingTrain] = temp;
                    var newUsers = new NSMutableArray <NSString>();
                    for (int i = 0; i < _names.Length; i++)
                    {
                        if (_names[i].Text != "")
                        {
                            newUsers.Add(new NSString(_names[i].Text));
                        }
                    }
                    _users = newUsers;
                    PutUsersToSettingsStore();
                    _trainTapMode       = TrainTapMode.Normal;
                    _currentMovingTrain = -1;
                }
                break;
            }
        }
 private void MoveTrain(int x)
 {
     _trainTapMode       = TrainTapMode.Move;
     _currentMovingTrain = x;
 }