private void areaMap1_DragDrop(object sender, DragEventArgs e) { Shape2 shape = null; Area area = null; if (e.Data.GetDataPresent(typeof(Polygon2))) { shape = (Polygon2)e.Data.GetData(typeof(Polygon2)); } else { if (e.Data.GetDataPresent(typeof(Area))) { area = (Area)e.Data.GetData(typeof(Area)); } else { shape = (Circle)e.Data.GetData(typeof(Circle)); } } Point mapDropPoint = AreaMapComponent.PointToClient(new Point(e.X, e.Y)); mapDropPoint.Offset(GeoConverter.ConvertRound(AreaMapComponent.Offset * -1)); if (shape != null) { shape.Offset((new Vector2(mapDropPoint.X, mapDropPoint.Y)) * (1f / AreaMapComponent.Scaling)); shape.Clamp(0, AreaMapComponent.Dimensions.Width, 0, AreaMapComponent.Dimensions.Height); AreaMapComponent.AddShape(shape); RefreshListBox(); } else if (area != null) { //Has a picture with path relative to library if (area.ImgPath != "" && area.ImgPath != libraryUCtrl1.AreaMapComp.CurrentAreaMap.GetAbsolutePath(area.ImgPath)) { if (AreaMapComponent.CurrentAreaMap.Path != "") { area.Map = libraryUCtrl1.AreaMapComp.CurrentAreaMap; AreaMapComponent.Migrate(area, PathHelper.GetFolderPath(AreaMapComponent.CurrentAreaMap.Path)); } else { MessageBox.Show("You must save your AreaMap to be able to use library items with relative pictures !", "File not saved"); return; } } area.Center = (new Vector2(mapDropPoint.X, mapDropPoint.Y)) * (1f / AreaMapComponent.Scaling); area.Clamp(0, AreaMapComponent.Dimensions.Width, 0, AreaMapComponent.Dimensions.Height); area.SetRefCenter(); AreaMapComponent.AddArea(area); RefreshListBox(); } }