示例#1
0
        private void EditRequested(WorldVariableViewModel viewModel)
        {
            using (var worldVariableController = _controllerFactory.Create <IWorldVariableController>())
            {
                WorldVariableViewModel currentViewModel = View.SelectedVariables.Single();
                WorldVariableViewModel editedViewModel  = currentViewModel.Clone();

                while (true)
                {
                    editedViewModel = worldVariableController.ShowEditView(View, editedViewModel);

                    if (editedViewModel == null)
                    {
                        return;
                    }
                    if (!currentViewModel.Name.Equals(editedViewModel.Name) && !IsVariableNameUnique(editedViewModel.Name))
                    {
                        continue;
                    }

                    View.ReplaceVariable(currentViewModel, editedViewModel);
                    return;
                }
            }
        }
示例#2
0
        public void AddVariable(WorldVariableViewModel viewModel)
        {
            viewModel.ThrowIfNull(nameof(viewModel));

            _worldVariableViewModels.Add(viewModel);

            RefreshFilter(true);
        }
示例#3
0
        public void ReplaceVariable(WorldVariableViewModel currentViewModel, WorldVariableViewModel editedViewModel)
        {
            currentViewModel.ThrowIfNull(nameof(currentViewModel));
            editedViewModel.ThrowIfNull(nameof(editedViewModel));

            _worldVariableViewModels.Remove(currentViewModel);
            _worldVariableViewModels.Add(editedViewModel);

            RefreshFilter(true);
        }
示例#4
0
        private void NewRequested()
        {
            using (var worldVariableController = _controllerFactory.Create <IWorldVariableController>())
            {
                WorldVariableViewModel viewModel = null;

                while (true)
                {
                    viewModel = worldVariableController.ShowNewView(View, viewModel, View.CategoryFilter);

                    if (viewModel == null)
                    {
                        return;
                    }
                    if (!IsVariableNameUnique(viewModel.Name))
                    {
                        continue;
                    }

                    View.AddVariable(viewModel);
                    return;
                }
            }
        }