question about using ESRI.ArcGIS.Display.RubberPoint and TrackNew();

760
3
06-06-2012 09:42 AM
AdamSlayton
New Contributor
I have a custom dialog box which has a button that when pressed runs the following function:

private void getPoint(ESRI.ArcGIS.Carto.IActiveView myView)
        {
           
            listenerTrial lt = new listenerTrial();
            ESRI.ArcGIS.Geometry.IPoint myPt = lt.GetPointFromClicks(myView);
            double x = myPt.X;
            double y = myPt.Y;
            string echo = x.ToString();
            this.textBox1.Text = echo;
            echo = y.ToString();
            this.textBox2.Text = echo;

        }

The GetPointFromClicks method from the listenerTrial Class has the following code:

public ESRI.ArcGIS.Geometry.IPoint GetPointFromClicks(ESRI.ArcGIS.Carto.IActiveView activeView)
        {

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            ESRI.ArcGIS.Display.RubberPoint ptBand = new ESRI.ArcGIS.Display.RubberPoint();
            ESRI.ArcGIS.Geometry.IGeometry geometry = ptBand.TrackNew(screenDisplay, null);

            ESRI.ArcGIS.Geometry.IPoint mPt = (ESRI.ArcGIS.Geometry.IPoint)geometry;

            return mPt;

        }

The function returns the geometry of a point, unfortuneately, it returns the the coordinates of my mouse cursor when the button on the original dialog box was clicked. 

Any thoughts on how to get the function to wait for a click on the map (myView object)

Thanks
0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
Take a look at this post for an example for an add-in
0 Kudos
AdamSlayton
New Contributor
Thanks, Ken. The sample you pointed out helped solve my issue.
0 Kudos
KenBuja
MVP Esteemed Contributor
Glad to help. Don't forget to mark the question as answered.
0 Kudos