ThinkGeo.com    |     Documentation    |     Premium Support

Stop/Interrupt Drawing

MapSuite Support,



Is there a way to stop/interrupt the drawing process before it completes?



My application not only has its own UI, it is also interfaced (TCP/IP) to another application which also causes the map to react to what the user is doing in this other application.



This other application provides the ability for the user to efficiently select data, which then causes the map to invoke a CenterAt.



My dilemma is that the users are selecting data, in this other application, so fast that the map refresh for a CenterAt cannot keep up with the user.  So what I would like to do is prior to doing any CenterAt stop/interrupt whatever drawing is currently taking place prior to issuing the new CenterAt.



Suggestions are welcome.



Regards,

Dennis


Hi Dennis,



Firstly, I want to confirm with you that if
there any overlay has TileType is SingleTile? In general, the drawing stuff
will complete in another thread if the TileType is MultipleTile, so the
CenterAt should be executed in main thread once it is called. In this way, the CenterAt
has higher priority than drawing stuff in MultipleTile. 


 


In the other hand, there is an event named
Drawing in layer and overlay, and it will be fired before drawing the layer(Overlay),
we can cancel the drawing stuff with below code:




private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
    WorldMapKitWmsWpfOverlay worldOverlay = new WorldMapKitWmsWpfOverlay();
 
    worldOverlay.Drawing += worldOverlay_Drawing;
}
 
private void worldOverlay_Drawing(object sender, DrawingOverlayEventArgs e)
{
    e.Cancel = true;
}


 


Hope this would be helpful for you and any
other question please feel free to let us know.


 


Regards,


Kevin



Kevin,



All LayerOverlays are MultipleTile.  I will have to check and ensure my CenterAt is done from the UI Thread.



Is there any way to stop the draw after it has started and before it has completed?



Regards,

Dennis


Hi Dennis,



Currently, I can only find the event named "StartingThread" may be fit for your case, please try the below codes:




private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;
            Map1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
            WorldMapKitWmsWpfOverlay worldOverlay = new WorldMapKitWmsWpfOverlay();
            Map1.Overlays.Add("WMK", worldOverlay);
 
            foreach (Overlay overlay in Map1.Overlays.OfType<TileOverlay>()
                                .Where((to => to.TileType != TileType.SingleTile && to.IsVisible)))
            {
                TileOverlay tileOverlay = overlay as TileOverlay;
                tileOverlay.StartingThread += tileOverlay_StartingThread;
            }
            Map1.Refresh(); 
        }
 
        private bool stopDrawing = false; 
 
        void tileOverlay_StartingThread(object sender, StartingThreadTileOverlayEventArgs e)
        {
            e.UsingCustomThreading = stopDrawing;
        }
 
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            stopDrawing = true;
        }
 
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            stopDrawing = false;
        }

Thanks,



Troy