Select to view content in your preferred language

After putting measure action in code, which code show meansure action is completed?

1228
4
02-23-2011 11:09 AM
DanDong
Deactivated User
Hi all,

I have put the measure action in code-behind.

MyMeasureAction m = new MyMeasureAction();  //initialize a MyMeasureAction class
            m.MeasureMode = ESRI.ArcGIS.Client.Actions.MeasureAction.Mode.Polygon;  //MeasureMode is polygon
            m.DisplayTotals = false;    //do not display total distance
            m.FillSymbol = LayoutRoot.Resources["DrawFillSymbol"] as FillSymbol;
            m.DistanceUnit = ESRI.ArcGIS.Client.Actions.DistanceUnit.Feet;
            m.MapUnits = ESRI.ArcGIS.Client.Actions.DistanceUnit.Feet;  //the unit of the map is Feet
            m.Attach(MyMap);    //bind this action to MyMap
            m.Execute();    //execute this action


But I don't know which piece of codes show that the measure action is completed. Dose it exist some function like measreCompleted event? I didn't find it in API.

Since I want to return the cursor to hand shape and return to pan mode after finishing this measure action, I want to know where I can add the codes....
Thank you all!:)
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
You are right, there is no event raised when MeasureAction is complete. If you notice in the SDK sample, measure is completed when a DoubleClick is detected. This is when graphics are cleared from the map, which might be a good time to re-enable the pan cursor.

Point lastClick;
private void Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
 Point pt = e.GetPosition(null);
 if (Math.Abs(pt.X - lastClick.X) < 2 && Math.Abs(pt.Y - lastClick.Y) < 2)
 {
  //TODO: change cursor here
 }
 lastClick = pt;
}
0 Kudos
DanDong
Deactivated User
You are right, there is no event raised when MeasureAction is complete. If you notice in the SDK sample, measure is completed when a DoubleClick is detected. This is when graphics are cleared from the map, which might be a good time to re-enable the pan cursor.

Point lastClick;
private void Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
 Point pt = e.GetPosition(null);
 if (Math.Abs(pt.X - lastClick.X) < 2 && Math.Abs(pt.Y - lastClick.Y) < 2)
 {
  //TODO: change cursor here
 }
 lastClick = pt;
}


Thank you Jennifer! I also try to change cursor shape in LayerCollectionChanged event. That also works.
0 Kudos
DidarBultanov
Emerging Contributor
You are right, there is no event raised when MeasureAction is complete. If you notice in the SDK sample, measure is completed when a DoubleClick is detected. This is when graphics are cleared from the map, which might be a good time to re-enable the pan cursor.

Point lastClick;
private void Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
 Point pt = e.GetPosition(null);
 if (Math.Abs(pt.X - lastClick.X) < 2 && Math.Abs(pt.Y - lastClick.Y) < 2)
 {
  //TODO: change cursor here
 }
 lastClick = pt;
}

how to make that graphics would be kept on the maps?
Tanks
0 Kudos
JenniferNery
Esri Regular Contributor
It is by design that the graphics created by MeasureAction are removed from the map upon completion.

However, this related thread might help preserve the graphics on the map: http://forums.arcgis.com/threads/13902-about-after-using-measure-behavior-the-graph-can-t-stay-in-th...
0 Kudos