public static int? ShowDialog(Window owner, int gameIndex)
 {
     SecretBaseSendToWindow window = new SecretBaseSendToWindow(gameIndex);
     window.Owner = owner;
     var result = window.ShowDialog();
     if (result != null && result.Value) {
         return window.gameIndex;
     }
     return null;
 }
        public static int?ShowDialog(Window owner, int gameIndex)
        {
            SecretBaseSendToWindow window = new SecretBaseSendToWindow(gameIndex);

            window.Owner = owner;
            var result = window.ShowDialog();

            if (result != null && result.Value)
            {
                return(window.gameIndex);
            }
            return(null);
        }
        private void OnSendToClicked(object sender, RoutedEventArgs e)
        {
            if (secretBase.HasTeam)
            {
                var gameIndex = SecretBaseSendToWindow.ShowDialog(Window.GetWindow(this), gameSave.GameIndex);

                if (gameIndex.HasValue)
                {
                    if (gameIndex.Value == -1)
                    {
                        PokeManager.AddSecretBase(secretBase);
                    }
                    else
                    {
                        GBAGameSave sendToGameSave = (GBAGameSave)PokeManager.GetGameSaveAt(gameIndex.Value);
                        if (sendToGameSave.SecretBaseManager.SharedSecretBases.Count < 19)
                        {
                            if (sendToGameSave.SecretBaseManager.IsLocationInUse(secretBase.LocationID))
                            {
                                MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Cannot send this Secret Base because its location is already in use. Would you like to select a new location?", "Location in Use", MessageBoxButton.YesNo);
                                if (result2 == MessageBoxResult.Yes)
                                {
                                    byte?location = SecretBaseLocationChooser.Show(Window.GetWindow(this), secretBase.LocationID, sendToGameSave.SecretBaseManager, true);
                                    if (location.HasValue && location.Value != 0 && !sendToGameSave.SecretBaseManager.IsLocationInUse(location.Value))
                                    {
                                        SharedSecretBase newSecretBase;
                                        if (secretBase.IsPlayerSecretBase)
                                        {
                                            newSecretBase = new SharedSecretBase((PlayerSecretBase)secretBase, null);
                                        }
                                        else
                                        {
                                            newSecretBase = new SharedSecretBase((SharedSecretBase)secretBase, null);
                                        }
                                        newSecretBase.SetNewLocation(location.Value);
                                        sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)newSecretBase);
                                    }
                                }
                            }
                            else
                            {
                                if (secretBase.IsPlayerSecretBase)
                                {
                                    sendToGameSave.SecretBaseManager.AddSecretBase((PlayerSecretBase)secretBase);
                                }
                                else
                                {
                                    sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)secretBase);
                                }
                            }
                        }
                        else
                        {
                            TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Send");
                        }
                    }
                }
            }
            else
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "You cannot send a Secret Base without a Pokémon Team", "Can't Send");
            }
        }