Custom MapAction with WPF Map

2260
3
05-23-2011 04:08 AM
BerendVeldkamp
Occasional Contributor II
The class ESRI.ArcGIS.Mobile.WPF.Map does not have the CurrentMapAction property, which is supported by ESRI.ArcGIS.Mobile.Map. Is there a similar mechanism for the WPF version?
0 Kudos
3 Replies
MelindaFrost
Occasional Contributor
you can get to it in WPF through   map1.CurrentNavigationMode
and set it like so:
           map1.CurrentNavigationMode = ESRI.ArcGIS.Mobile.WPF.NavigationMode.Pan;
0 Kudos
BerendVeldkamp
Occasional Contributor II
Thanks, but that is not exactly what I mean. It  will only let you select one of the built-in navigation modes (pan, zoom), but I'd like to define a custom mapaction, as is possible with the Mobile.Map class.
0 Kudos
MelindaFrost
Occasional Contributor
Well MapAction is an abstract class so you would have to extend one of the existing derived classes:
            ESRI.ArcGIS.Mobile.MapActions.DragRectangleMapAction
            ESRI.ArcGIS.Mobile.MapActions.PanMapAction
            ESRI.ArcGIS.Mobile.MapActions.SelectionMapAction
            ESRI.ArcGIS.Mobile.MapActions.ZoomInMapAction
            ESRI.ArcGIS.Mobile.MapActions.ZoomInOutMapAction
            ESRI.ArcGIS.Mobile.MapActions.ZoomOutMapAction
            ESRI.ArcGIS.Mobile.Sketch.SketchTool

Please note that SketchTool is also an abstract class so you would have to extend one of it's derived classe:
               ESRI.ArcGIS.Mobile.WPF.AddVertexSketchTool
                  ESRI.ArcGIS.Mobile.WPF.DeleteVertexSketchTool
                  ESRI.ArcGIS.Mobile.WPF.EnvelopeSketchTool
                  ESRI.ArcGIS.Mobile.WPF.InsertVertexSketchTool
                  ESRI.ArcGIS.Mobile.WPF.MoveVertexSketchTool
                  ESRI.ArcGIS.Mobile.WPF.SelectGeometryTool


Here is an example using the EnvelopeSketchTool:
EnvelopeSketchTool envelopeSketchTool;
 private void btnSelectLayer_Click(object sender, RoutedEventArgs e)
        {
            setupSelectTool();
        }

       private void setupSelectTool()
       {
           
           //setup selection layer
           selectionLayer = new GraphicLayer();
           map1.MapGraphicLayers.Add(selectionLayer);
           selectionLayer.GeometryBag.Add(new ESRI.ArcGIS.Mobile.Geometries.Polygon());
           selectionLayer.SelectedGeometry = selectionLayer.GeometryBag[0];

           m_lastNavigatioMode = map1.CurrentNavigationMode;
           map1.CurrentNavigationMode = ESRI.ArcGIS.Mobile.WPF.NavigationMode.None;
           envelopeSketchTool = new EnvelopeSketchTool();
           envelopeSketchTool.AttachToSketchGraphicLayer(selectionLayer);
           envelopeSketchTool.SketchCompleted += doneSketch;
       }

        //public delegate void SelectEnvelopeCompleteEventHandler(object sender, EventArgs e);
        //public event SelectEnvelopeCompleteEventHandler OnShowBoundary;
        private void doneSketch(object sender, EventArgs e)
        {                  
            Envelope env = envelopeSketchTool.Envelope;
            //turn off once selection done
            if (envelopeSketchTool != null)
                envelopeSketchTool.DetachFromSketchGraphicLayer();
            
    //now call method to select
    SelectFeatures(env);
 }
0 Kudos