This project is read-only.

How to get active function name?

Feb 16, 2012 at 6:39 AM


In my application I used MoveVertexFunction,AddShapeFunction functions.

I followed the below steps to do this.

  •   Added the functions to Map.MapFunctions.
  • Map.FunctionMode = FunctionMode.None;
  • Activate the function.

My question is : if I set the MapFunctionMode to None and activate one of the above functions, how to get the active function name (there are two functions with function Mode = None in the above case)


Thanks in advance




Feb 16, 2012 at 10:29 PM

Ok, so you've done something like this...

            if (_Painter == null)
                _Painter = new MapFunctionMeasure(App.Map);
            if (!App.Map.MapFunctions.Contains(_Painter))
            App.Map.FunctionMode = FunctionMode.None;


There's nothing that prevents multiple map functions from being active at the same time, but there is an Enabled property
(think "Activated")... 

if(_Painter.Enabled) {...}
else if (_YourOtherFunction.Enabled {...}

There is also an event that fires when the map function is activated...

    _Painter.FunctionActivated+=new EventHandler(_Painter_FunctionActivated);
Feb 17, 2012 at 7:41 AM
Edited Feb 17, 2012 at 7:48 AM


Thank you for your reply. Now I am able to work with Mapfunctions.

But MapFunction.Enabled property is not set to false in Deactivate() for the Mapfunction "AddShapeFunction" in DotSpatial.Plugins.ShapeEditor

Deactivate Function code in AddShapeFunction.cs

/// <summary>
/// Allows for new behavior during deactivation.
/// </summary>
protected override void OnDeactivate()
    if (_standBy) { return; }
    // Don't completely deactivate, but rather go into standby mode
    // where we draw only the content that we have actually locked in.
    _standBy = true;
    if (_coordinateDialog != null) { _coordinateDialog.Hide(); }
    if (_coordinates != null && _coordinates.Count > 1)
        LineString ls = new LineString(_coordinates);
        FeatureSet fs = new FeatureSet(FeatureType.Line);
        fs.Features.Add(new Feature(ls));
        MapLineLayer gll = new MapLineLayer(fs)
                                    Symbolizer =
                                            ScaleMode = ScaleMode.Symbolic,
                                            Smoothing = true
                                    MapFrame = Map.MapFrame
        _tempLayer = gll;


In the Activate function, it is calling base.OnActivate() function, which sets the Enable Propery of the MapFunction to True. But in Deactivate function there is no code to set the enabled property to False and is not calling base.OnDeactivate() function.  

Activate Function code in AddShapeFunction.cs

/// <summary>
/// Forces this function to begin collecting points for building a new shape.
/// </summary>
protected override void OnActivate()

Feb 23, 2012 at 1:07 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.