private void Map_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("manifestation")) { Point dropPosition = e.GetPosition(Map); Manifestation manifToDrop = e.Data.GetData("manifestation") as Manifestation; Manifestation underlyingManifestation = ClickedManifestation((int)dropPosition.X, (int)dropPosition.Y); if (underlyingManifestation != null && underlyingManifestation.Id != manifToDrop.Id) { MessageBox.Show($"Unable to place manifestation \"{manifToDrop.Name}\" on given position because manifestation \"{underlyingManifestation.Name}\" is in the way. Please try draging manifestation \"{manifToDrop.Name}\" to a different position.", "Overlapping manifestations not allowed", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (manifToDrop.MapCoordinates.Count > 0 && AvailableMaifs.Contains(manifToDrop)) { MessageBoxResult choince = MessageBox.Show($"Manifestation \"{manifToDrop.Id}\" is already placed on another map. Do you want do move it to this map?", $"Change location of {manifToDrop.Id}", MessageBoxButton.YesNoCancel); if (choince != MessageBoxResult.Yes) { return; } } ShowManifPointer(manifToDrop, (int)dropPosition.X, (int)dropPosition.Y); } }
private void ShowManifPointer(Manifestation manif, int x, int y) { MapToShow.PlaceManifAtPos(manif, x, y); if (AvailableMaifs.Contains(manif)) { manifsOnMap.Add(manif); AvailableMaifs.Remove(manif); } drawManifPointers(); Repository.GetInstance().SaveData(); }