Manipulating freehand-drawing

1801
5
Jump to solution
11-06-2014 07:19 PM
LinaYap1
New Contributor II

Hi,

I had been exploring on ArcGIS Runtime SDK for WPF and now currently, considering transitioning to the SDK for .NET.

One of the issue I was stumped on was - the missing VertexAdded event by MapView.Editor. Is there any ways I could obtain and manipulate vertices added while doing freehand drawing?

Thanks in advance

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnttiKajanus1
Regular Contributor II

You can provide IProgress<GeometryEditStatus> for the Editor when requesting the geometry and do stuff in the progress handler.

private async Task RequestFreehand()

{

    try

    {

        var progress = new Progress<GeometryEditStatus>();

        progress.ProgressChanged += progress_ProgressChanged;

        var geometry = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand, null, progress) as Polyline;

               

        progress.ProgressChanged -= progress_ProgressChanged;

    }

    catch (Exception ex)

    {

        MessageBox.Show(ex.ToString());

    }

}

void progress_ProgressChanged(object sender, GeometryEditStatus e)

{

    if (e.GeometryEditAction == GeometryEditAction.AddedVertex)

    {

        // Stuff

    }

}

Hope this helps. I'm a bit curious that what kind of use case you have so if you can, could you describe what you are going to do and why when the vertex is added?

View solution in original post

0 Kudos
5 Replies
AnttiKajanus1
Regular Contributor II

You can provide IProgress<GeometryEditStatus> for the Editor when requesting the geometry and do stuff in the progress handler.

private async Task RequestFreehand()

{

    try

    {

        var progress = new Progress<GeometryEditStatus>();

        progress.ProgressChanged += progress_ProgressChanged;

        var geometry = await MyMapView.Editor.RequestShapeAsync(DrawShape.Freehand, null, progress) as Polyline;

               

        progress.ProgressChanged -= progress_ProgressChanged;

    }

    catch (Exception ex)

    {

        MessageBox.Show(ex.ToString());

    }

}

void progress_ProgressChanged(object sender, GeometryEditStatus e)

{

    if (e.GeometryEditAction == GeometryEditAction.AddedVertex)

    {

        // Stuff

    }

}

Hope this helps. I'm a bit curious that what kind of use case you have so if you can, could you describe what you are going to do and why when the vertex is added?

0 Kudos
LinaYap1
New Contributor II

Thanks for the tip! Now I see it can be done this way

The use case was for reducing the number of points on-the-fly - as in, while user was adding points using freehand drawing mode, our algorithm has to already decide to retain or drop the vertex that was added.

0 Kudos
AnttiKajanus1
Regular Contributor II

I would be interested to hear more about this use case. If you have time, could you write down use case, reason behind the algorithm and what kind of outcome you are expecting / needing and mail to me? You can see my email address from my profile.

cheers,

Antti

0 Kudos
AnttiKajanus1
Regular Contributor II

Hey, did you get my mail? It seems that i have some problems to send a mail to you.

0 Kudos
LinaYap1
New Contributor II

Hi Antti,

I had not received your mail. I will mail you another address. Thanks.

Lina

0 Kudos