/** * Adds map coordinates to a manifestation based on the position on current map when dropped upon. * Manifestation pointer must be deisplayed on all maps showing the area dropped upon. * The map coordinates are added for the main map first, then for all submaps containing * the drop area. * * Parameters: * Manifestation manif - dropped manifestation for which the map coordinates are * calculated, * int x - x position of drop action on current map * int y - y position of drop action on current map */ public void PlaceManifAtPos(Manifestation manif, int x, int y) { Map parent = ParentMapOffset.ParentMap; if (parent != null) { //pass manifestation to according position on the main map parent.PlaceManifAtPos(manif, x + ParentMapOffset.X, y + ParentMapOffset.Y); } else { //place or move manif on main (current) map first PlaceOrMoveManifOnPos(manif, x, y); //place or move manif on submaps containing the new position foreach (Map submap in ChildMaps) { //check if submap contains new position int xOffset = submap.ParentMapOffset.X; int yOffset = submap.ParentMapOffset.Y; if (x >= xOffset && x <= xOffset + submap.Width && y >= yOffset && y <= yOffset + submap.Heigth) { //place or move manif to according position on submap submap.PlaceOrMoveManifOnPos(manif, x - xOffset, y - yOffset); } else { //if submap does not contain new position remove the submap coordinates //from manifestation if present manif.RemoveCoordinatesForMap(submap.Id); } } } }
public bool AddManifestation(Manifestation newManif) { if (FindManifestation(newManif.Id) != null) { return(false); } Manifestations.Add(newManif); SaveData(); return(true); }
public bool DeleteManifestation(string id) { Manifestation target = FindManifestation(id); if (target == null) { return(false); } Manifestations.Remove(target); SaveData(); return(true); }
public void showManifestationEditView(string manifId) { model.Manifestation target = model.Repository.GetInstance().FindManifestation(manifId); if (target == null) { return; } AddManifestationView view = new AddManifestationView(this, true); view.DataContext = target; model.Repository.GetInstance().SelectedType = target.Type; model.Repository.GetInstance().SelectedLabels = target.Labels; view.comboBoxTypes.SelectedIndex = Repository.GetInstance().ManifestationTypes.IndexOf(Repository.GetInstance().FindManifestationType(target.Type.Id)); //view.label.SelectedIndex = Repository.GetInstance().Labels.IndexOf(Repository.GetInstance().FindLabel(target.Labels.FirstOrDefault().Id)); view.SelectedLabels = new System.Collections.ObjectModel.ObservableCollection <model.Label>(); foreach (model.Label lab in target.Labels) { view.SelectedLabels.Add(lab); } view.AlcoholCons = nameof(target.Alcohol); view.PriceCat = nameof(target.Prices); view.IsOut = nameof(target.IsOutside); view.idInput.Text = target.Id; view.idInput.IsEnabled = false; view.nameInput.Text = target.Name; view.descriptionInput.Text = target.Description; view.priceCategory.SelectedIndex = (int)target.Prices; view.isItOutside.SelectedIndex = target.IsOutside ? 0 : 1; view.alcoholConsumption.SelectedIndex = (int)target.Alcohol; view.textBoxIconPath.Text = target.IconPath; view.datePicker1.Text = target.Date.ToString(); view.smokingAllowed.IsChecked = target.SmokingAllowed; view.peopleWithSpecialSupport.IsChecked = target.SupportHandicaped; view.autoGenerateId.Visibility = Visibility.Collapsed; view.autoGenerateIdLabel.Visibility = Visibility.Collapsed; view.AddOrEditBtn.Content = "Confirm changes"; MainContent.Content = view; }
public bool UpdateManifestation(Manifestation newManifestationData) { Manifestation target = FindManifestation(newManifestationData.Id); if (target == null) { return(false); } target.Name = newManifestationData.Name; target.Type = newManifestationData.Type; target.Labels = newManifestationData.Labels; target.SmokingAllowed = newManifestationData.SmokingAllowed; target.SupportHandicaped = newManifestationData.SupportHandicaped; target.Prices = newManifestationData.Prices; target.Alcohol = newManifestationData.Alcohol; target.IconPath = newManifestationData.IconPath; target.Description = newManifestationData.Description; target.Date = newManifestationData.Date; target.IsOutside = newManifestationData.IsOutside; SaveData(); return(true); }
private void PlaceOrMoveManifOnPos(Manifestation manif, int x, int y) { //current map coordinates to be added or updated Coordinates mapCoords = null; //check if manif is already placed on current map foreach (Coordinates c in manif.MapCoordinates) { if (c.ParentMap.Id == Id) { mapCoords = c; break; } } //if manif is not on map add new coordinates, else update old coordinates if (mapCoords == null) { mapCoords = new Coordinates(); mapCoords.ParentMap = this; manif.MapCoordinates.Add(mapCoords); } mapCoords.X = x; mapCoords.Y = y; }