How do I get the instance of a MapTool?

696
4
Jump to solution
07-19-2016 08:11 AM
HoriaTudosie
Occasional Contributor II

I don't want to get a wrapper command (with GetPlugInWrapper.)

I just need to access some methods that I have defined in my inherited Tool class definition.

(I Think that I can identify the tool instance by its ID since I have just one instance (?))

internal class PickupTool : MapTool
    {
        /// <summary>
        /// Define the tool as a sketch tool that draws a rectangle in screen space on the view.
        /// </summary>
        public PickupTool()
        {
            IsSketchTool = true;
            SetSketchType(Settings.Default.GfxPickOption);
            UseSnapping = true;
            SketchOutputMode = SketchOutputMode.Screen;
        }

       public void SetSketchType(PickToolOptions gfxPickOption)
        {
            switch (gfxPickOption)
            {
                case PickToolOptions.Point:
                    SketchType = SketchGeometryType.Point;
                    Cursor = GetCursor("PointCursor.cur");
                    break;
...

From a ribbon button/menu I need to call the method in line 14.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
HoriaTudosie
Occasional Contributor II

Found a solution:

I save the instance in the module when I create it.

View solution in original post

0 Kudos
4 Replies
HoriaTudosie
Occasional Contributor II

Found a solution:

I save the instance in the module when I create it.

0 Kudos
NasirAhmad4
New Contributor II

Can you please provide detail on how you did this.

Thank you,

0 Kudos
HoriaTudosie
Occasional Contributor II

    internal class PickupTool : MapTool
   {
   /// <summary>
   /// Define the tool as a sketch tool that draws a rectangle in screen space on the view.
   /// </summary>
   public PickupTool()
   {
      IsSketchTool = true;
      SetSketchType(Settings.Default.GfxPickOption);
      UseSnapping = true;
      SketchOutputMode = SketchOutputMode.Screen;
      Module1.GfxPickupTool = this;
   }

Module1:

private PickupTool m_gfxPickupTool;

public static PickupTool GfxPickupTool
{
   get
   {
      return Current?.m_gfxPickupTool;
   }
   set
   {
      if (Current != null)
         Current.m_gfxPickupTool = value;
   }
}

Config.daml:

<tool id="GFXModule_PairTool" caption="Pair Feature" className="PickupTool" loadOnClick="true" smallImage="Images\Rings32.png" largeImage="Images\Rings32.png" condition="esri_mapping_mapPaneOrLayoutPane">
<tooltip heading="Pair">
Pair Feature from the Map<disabledText /></tooltip>
</tool>

NasirAhmad4
New Contributor II

Thank you for your quick reply.