Exemple #1
0
        private void AddBuilding()
        {
            BuildingModel     buildingModel     = new BuildingModel();
            BuildingViewModel buildingViewModel = new BuildingViewModel(buildingModel);

            buildingViewModel.PropertyChanged += BuildingViewModel_PropertyChanged;

            _locationModel.Buildings.Add(buildingModel);
            _buildings.Add(buildingViewModel);

            OnPropertyChanged(nameof(Buildings));
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of <see cref="LocationEditViewModel"/>
        /// </summary>
        public LocationEditViewModel(LocationModel locationModel)
        {
            _locationModel = new LocationModel(locationModel);

            _name = _locationModel.Name;
            if (_locationModel.Tags.Any())
            {
                _tags = String.Join(", ", _locationModel.Tags);
            }
            _description = _locationModel.Description;
            _location    = _locationModel.Location;
            _map         = _locationModel.Map;

            foreach (LocationType locationType in Enum.GetValues(typeof(LocationType)))
            {
                _locationTypeOptions.Add(locationType, locationType.ToString());
            }

            _selectedLocationType = _locationTypeOptions.FirstOrDefault(x => x.Key == _locationModel.LocationType);

            _creator = _locationModel.Creator;
            foreach (RoomModel roomModel in _locationModel.Rooms)
            {
                RoomViewModel roomViewModel = new RoomViewModel(roomModel);
                roomViewModel.PropertyChanged += RoomViewModel_PropertyChanged;
                _rooms.Add(roomViewModel);
            }

            _rulerNotes = _locationModel.RulerNotes;
            _traits     = _locationModel.Traits;
            _knownFor   = _locationModel.KnownFor;
            _conflicts  = _locationModel.Conflicts;
            foreach (BuildingModel buildingModel in _locationModel.Buildings)
            {
                BuildingViewModel buildingViewModel = new BuildingViewModel(buildingModel);
                buildingViewModel.PropertyChanged += BuildingViewModel_PropertyChanged;
                _buildings.Add(buildingViewModel);
            }

            _landmarks    = _locationModel.Landmarks;
            _environment  = _locationModel.Environment;
            _weather      = _locationModel.Weather;
            _foodAndWater = _locationModel.FoodAndWater;
            _hazards      = _locationModel.Hazards;

            _browseMapLocationCommand = new RelayCommand(obj => true, obj => BrowseMapLocation());
            _addRoomCommand           = new RelayCommand(obj => true, obj => AddRoom());
            _deleteRoomCommand        = new RelayCommand(obj => true, obj => DeleteRoom(obj as RoomViewModel));
            _addBuildingCommand       = new RelayCommand(obj => true, obj => AddBuilding());
            _deleteBuildingCommand    = new RelayCommand(obj => true, obj => DeleteBuilding(obj as BuildingViewModel));
        }
Exemple #3
0
        private void DeleteBuilding(BuildingViewModel buildingViewModel)
        {
            if (buildingViewModel != null)
            {
                string name = !String.IsNullOrWhiteSpace(buildingViewModel.Name) ? buildingViewModel.Name : "Unknown Name";
                if (_dialogService.ShowConfirmationDialog("Delete Building", $"Are you sure you want to delete {name}?", "Yes", "No", null) == true)
                {
                    buildingViewModel.PropertyChanged -= BuildingViewModel_PropertyChanged;

                    _locationModel.Buildings.Remove(buildingViewModel.BuildingModel);
                    _buildings.Remove(buildingViewModel);

                    OnPropertyChanged(nameof(Buildings));
                }
            }
        }