Пример #1
0
        private void battleListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_currentBattle != null)
            {
                if (_currentBattle.IsDirty)
                {
                    switch (MessageBox.Show("Save current battle?", "Battle Builder", MessageBoxButton.YesNoCancel))
                    {
                    case MessageBoxResult.Cancel:
                        return;

                    case MessageBoxResult.Yes:
                        _repo.SaveChanges(_currentBattle.GetType());
                        break;

                    case MessageBoxResult.No:
                        _currentBattle.IsDirty = false;
                        _repo.RevertBattleChanges(_currentBattle.Id);

                        break;
                    }
                }
            }

            if (!_isLoading)
            {
                _isListChanging = true;
                _currentBattle  = _repo.LoadBattleGraph((int)battleListBox.SelectedValue);
                _battleViewSource.ObjectInstance = _currentBattle;
                _availableSamurais = _repo.SamuraisNotInBattle(_currentBattle.Id);
                samuraisNotInBattle.ItemsSource = _availableSamurais;

                _isListChanging = false;
            }
        }