How to Occure a MouseDownEvent by program

374
4
08-22-2017 09:50 PM
SK2
by
New Contributor II

I would like to occur a MouseDownEvent by program.

My program's purpose is create a Feature by MyMapView.SketchEditor.

*Current Program flow:

1. 1st Click >  MyMapView.MouseDown Event "createFeature" method add.

MyMapView.MouseDown += createFeature;

2. 2nd Click > createFeature occured.

*I would like to this flow.

1. 1st Click > MyMapView.MouseDown Event "createFeature" method add + createFeature method occured.

So I think need to MouseDownEvnet by program.

What would you suggest I do?

0 Kudos
4 Replies
dotMorten_esri
Esri Frequent Contributor

If you use the sketch editor, you don't need to use events. This should be sufficient:

var point = await mapView.SketchEditor.StartAsync(SketchCreationMode.Point);

0 Kudos
SK2
by
New Contributor II

Thank you for your comment. I'm sorry. I should have explained it more clearly.
I already wrote a program to create a feature. But something that requires much trouble to write a polyline.
Current program is requires much trouble.

Sample:

※1st Click -> Event add, 2nd Click -> Initial point drawing, 3rd Click->end point drawing

private async void MyMapView_GeoViewTapped(object sender, sri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
{
    MyMapView.MouseDown += createFeature;
    await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polyline);
}

private void createFeature(){
                   :

   //click point -> snap to near feature point
                   :
    await table.AddFeatureAsync(newFeature);
    MyMapView.MouseDown -= createFeature;
}

I think reduce trouble.So I need to add MouseDownEvnet by program.

What would you suggest I do?

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Try adding "false" to the start async call. That should auto-complete instantly.

            sketchEditor.StartAsync(Esri.ArcGISRuntime.UI.SketchCreationMode.Point, false);

Otherwise can't you just use the GeoViewTapped event?

0 Kudos
SK2
by
New Contributor II

Thank you for your comment.

I try use the GeoViewTapped event.

0 Kudos