ThinkGeo.com    |     Documentation    |     Premium Support

InMemoryFeatureLayer consumes mouse event

 I note that in the requested features, someone has asked for some mouse events to be added to the InMemoryFeatureLayer class. While this is not a big deal for me, I would like to ask (very niclely) that the InMemoryFeatureLayer stop stealing my PreviewMouseDown event. It seems that when I click on a polygon in this layer, my PreviewMouseDown event is no longer fired. My crude way of getting around this is to add an EMPTY InMemoryFeatureLayer over the top of it, and then my PreviewMouseDown event is fired. Is this a bug?



Hi  David,
 
We couldn’t create the scenario you met, would you please post your code for us to test?  Here is a sample code shows the PreviewMouseDown Event fires correctly.
 

        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(0, 100, 100, 0);
            wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);

            InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
            inMemoryLayer.InternalFeatures.Add("Polygon", new Feature(BaseShape.CreateShapeFromWellKnownData("POLYGON((10 60,40 70,30 85, 10 60))")));
          
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
            inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
           
            wpfMap1.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(wpfMap1_PreviewMouseDown);
            LayerOverlay inMemoryFeatureOverlay = new LayerOverlay();
            inMemoryFeatureOverlay.TileType = TileType.SingleTile;
            inMemoryFeatureOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer);
            wpfMap1.Overlays.Add("InMemoryOverlay", inMemoryFeatureOverlay);
            wpfMap1.Refresh();
        }

        void wpfMap1_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MessageBox.Show("event happens");
        }

 
Regards,
Edgar

 I'll see what I can do over the next couple of days.



Alright, waiting for your news.