コード例 #1
0
        public bool AddCharacter(out Character newCharacter)
        {
            bool ret = false;

            newCharacter = null;
            AddEditCharacterViewModel vm     = new AddEditCharacterViewModel(new Character(), CharacterViewMode.Add);
            AddEditCharacter          window = new AddEditCharacter(vm);

            vm.SavedClicked = new Action(() => window.Close());

            window.ShowDialog();

            if (vm.SavedSelected == true)
            { // Save
                ret = SouthParkViewModelFactory.GetInstance().CharacterProvider.AddCharacter(vm.TargetCharacter);

                newCharacter = vm.TargetCharacter;
            }

            return(ret);
        }
コード例 #2
0
        public bool EditCharacter(Character selectedCharacter)
        {
            bool      ret  = false;
            Character temp = new Character();

            MiscUtilities.Copy(temp, selectedCharacter);

            AddEditCharacterViewModel vm     = new AddEditCharacterViewModel(temp, CharacterViewMode.Edit);
            AddEditCharacter          window = new AddEditCharacter(vm);

            vm.SavedClicked = new Action(() => window.Close());

            window.ShowDialog();

            if (vm.SavedSelected == true)
            { // Save
                ret = SouthParkViewModelFactory.GetInstance().CharacterProvider.UpdateCharacter(selectedCharacter, vm.TargetCharacter);
            }

            return(ret);
            //MessageBox.Show($"Edit : {selectedCharacter.FirstName}");
        }