Drag and Drop Issue on Mapbox?

Topics: SharpMap Project, SharpMap v0.9 / v1.x
Feb 22, 2015 at 2:37 PM
Edited Feb 22, 2015 at 9:06 PM
Hello,

Here is my scenario:

I have subscribed to Mapbox's mousedown and mousemove events. After detecting that the mouse moved while the left button is pressed, the DoDragDrop is called (mapbox.DoDragDrop).

The "dragging" starts in MapBox and the "drop" will be done on a separate Control. Please assume for now that all the necessary setup on the other Control is OK. AllowDrop = true, DragEnter, DragDrop, etc.

There is no problem on the actual drag and drop operation. However, it seems that the MapBox is not refreshed even after calling the Refresh() method. Currently, since I also subscribed to the QueryContinueDrag event, the Refresh() method is called in the QueryContinueDrag event of Mapbox (mapBox_QueryContinueDrag).

The result is that after the drag drop operation, the map is refreshed but it just shows a blank. The images on the layers are not shown anymore. I think also the Background Layers are not showing up.

So far, I have only tried calling the Refresh() function in other places indicating completed Drag and Drop operation. I am unsuccessful so far.

The version of SharpMap is v1.1.

Any help would be greatly appreciated.

Thank you very much.
Coordinator
Feb 23, 2015 at 10:34 AM
I don't know what it is that you are trying to drag to a different control, but could it be that you changed the viewport unintendedly?
Feb 23, 2015 at 10:30 PM
Hello FObermaier,

Basically, I have a VectorLayer with a Symbol (for example: a red-filled Circle image). My application should be able drag that circle image from the Map (Mapbox) to a ListView located on a separate panel within the application.

Once the circle image is successfully dropped into the ListView, the VectorLayer is removed from the Map, and the map is refreshed to show that the circle image is now removed.

The drag and drop operation is successful except when the map is refreshed, the Mapbox just shows a blank.

The mapbox is updated only when the map is clicked.

I apologize but I am not familiar with viewports. I think I did not changed anything related to a viewport.

Your help will be greatly appreciated.

Thank you very much.
Coordinator
Feb 24, 2015 at 9:20 PM
Do you see the map during the pan operation, or does it change in any way?
If it changes, try storing the current map.Envelope when starting to drag and restore it when you have dropped (Map.ZoomToBox(env))
Do you still have Layers in Map.Layers and/or Map.BackgroundLayers?
Feb 26, 2015 at 10:37 PM
Hello FObermaier,
FObermaier:
Do you see the map during the pan operation, or does it change in any way?
After the drag-drop operation, I tried zooming in and out on the mapbox using the mouse wheel. I can see the loading bar on the top left, but, the mapbox remains blank.
But, when I clicked on the mapbox, the mapbox displays the layers, and surprisingly, the layers are already zoomed in or out.

I also tried the following:
1) calling the mouse click event manually
2) calling the SetFocus() because I thought it is a focus issue

Both still results to a blank mapbox.
FObermaier:
If it changes, try storing the current map.Envelope when starting to drag and restore it when you have dropped (Map.ZoomToBox(env))
I tried this as well. The mapbox still remains blank.
FObermaier:
Do you still have Layers in Map.Layers and/or Map.BackgroundLayers?
Yes. I verified this. I still have 2 VectorLayers.
One of the VectorLayers has a symbol that serves as a overlay. This layer changes the size of the symbol based on the zoom level.

Your help will be greatly appreciated.

Thank you very much.
Coordinator
Feb 27, 2015 at 6:13 AM
Have you tried MapBox.Invalidate();

If that does not help, could you share your project or setup a prototype that demonstrates your issue?
Mar 3, 2015 at 11:56 PM
FObermaier wrote:
Have you tried MapBox.Invalidate();

If that does not help, could you share your project or setup a prototype that demonstrates your issue?
Hello FObermaier,

Good day.

I have also tried your suggestion above (MapBox.Invalidate()). The result is still the same.

I will setup a prototype that will demonstrate my issue. I will send it as soon as it is available.

For the meantime, maybe this Call Stack trace will provide an idea to the issue. The trace below is when executing a drag from one point to another point within the MapBox control. The call to Refresh() seems to not show all the layers on the MapBox.
SharpMap.UI.dll!SharpMap.Forms.MapBox.Refresh() Line 1198   C#
FireAssetsTracker.exe!FireAssetsTracker.Map.Display.MapDisplaySharpMap.mapBox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) Line 247    C#
System.Windows.Forms.dll!System.Windows.Forms.DropTarget.System.Windows.Forms.UnsafeNativeMethods.IOleDropTarget.OleDrop(object pDataObj, int grfKeyState, System.Windows.Forms.UnsafeNativeMethods.POINTSTRUCT pt, ref int pdwEffect) + 0x126 bytes    
[Native to Managed Transition]  
[Managed to Native Transition]  
System.Windows.Forms.dll!System.Windows.Forms.Control.DoDragDrop(object data, System.Windows.Forms.DragDropEffects allowedEffects) + 0x187 bytes    
FireAssetsTracker.exe!FireAssetsTracker.Map.Display.MapDisplaySharpMap.mapBox_MouseMove(GeoAPI.Geometries.Coordinate worldPos, System.Windows.Forms.MouseEventArgs imagePos) Line 801 + 0x32 bytes  C#
SharpMap.UI.dll!SharpMap.Forms.MapBox.OnMouseMove(System.Windows.Forms.MouseEventArgs e) Line 1357  C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseMove(ref System.Windows.Forms.Message m) + 0x8f bytes  
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0xe5c bytes 
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x14c bytes    
====

The trace below is when executing a mouse click on the Mapbox. Only at this event that the MapBox displays the layers. Including the "dragged" layer.

FireAssetsTracker.exe!FireAssetsTracker.Map.Display.MapDisplaySharpMap.mapBox_MouseUp(GeoAPI.Geometries.Coordinate worldPos, System.Windows.Forms.MouseEventArgs imagePos) Line 656 C#
SharpMap.UI.dll!SharpMap.Forms.MapBox.OnMouseUp(System.Windows.Forms.MouseEventArgs e) Line 1771    C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) + 0x48b bytes 
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0xe14 bytes 
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x14c bytes    
[Native to Managed Transition]  
[Managed to Native Transition]  
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) + 0x681 bytes    
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x57c bytes  
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x6f bytes    
FireAssetsTracker.exe!FireAssetsTracker.Program.Main() Line 19  C#