Select to view content in your preferred language

Editor class Edit_Completed EditVertices

898
2
06-16-2011 08:31 AM
Bende_Vries
Emerging Contributor
Hi,

Using version 2.2. In the editor_EditCompleted the EditVertices graphic.geometry does not show the correct result. After having moved a graphic I would expect the geometry of the changed graphic.geometry to have the value of the moved location.
I am using a graphicslayer to test this. Here is the code for the EditCompleted. The geometry in the change.Graphic.Geometry is identical to the geometry in the original graphic. Any idea what is wrong ?

void esriEditor_EditCompleted(object sender, Editor.EditEventArgs e)
        {
            switch (e.Action)
            {
                case Editor.EditAction.EditVertices:
                    if (e.Edits.Count() > 0)
                    {
                        ESRI.ArcGIS.Client.Editor.Change change = e.Edits.First();
                        if (change.Graphic != null)
                        {
                            // Replace the geometry of the original graphic with the changed geometry
                            editGraphicOriginal.Geometry = change.Graphic.Geometry;
                        }
                    }
                    break;
            }
        }
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
I cannot reproduce the issue with the following code. Place a breakpoint after setting resultGeometry, so you may compare originalGeometry versus resultGeometry. After the move, edit.Graphic.Geometry should no longer be the same as originalGeometry. Place them in your watch window so you may compare.
 xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

    <Grid x:Name="LayoutRoot" Background="White">
  <Grid.Resources>
   <esri:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
   <esri:SimpleLineSymbol x:Key="RedLineSymbol" Color="Red" Width="4" Style="Solid" />
   <esri:SimpleFillSymbol x:Key="RedFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />   
   <esri:Editor x:Key="MyEditor" Map="{Binding ElementName=MyMap}" EditCompleted="Editor_EditCompleted"/>
  </Grid.Resources>
  <esri:Map x:Name="MyMap">
  <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer"/>
  <esri:GraphicsLayer ID="MyGraphicsLayer" MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown" >
   <esri:GraphicsLayer.Graphics >
    <esri:Graphic Symbol="{StaticResource RedMarkerSymbol}" >
     <esri:MapPoint X="-140.9" Y="63.391" />
    </esri:Graphic>
    <esri:Graphic Symbol="{StaticResource RedLineSymbol}" >
     <esri:Polyline >
      <esri:Polyline.Paths>
       <esri:PointCollection>
        <esri:MapPoint X="0" Y="51.399" />
        <esri:MapPoint X="2.637" Y="48.865" />
        <esri:MapPoint X="12.568" Y="41.706" />
        <esri:MapPoint X="13.447" Y="52.483" />
        <esri:MapPoint X="21.357" Y="52.160" />
        <esri:MapPoint X="30.322" Y="59.845" />
       </esri:PointCollection>
      </esri:Polyline.Paths>
     </esri:Polyline>
    </esri:Graphic>
    <esri:Graphic Symbol="{StaticResource RedFillSymbol}">
     <esri:Polygon >
      <esri:Polygon.Rings>
       <esri:PointCollection>
        <esri:MapPoint X="110.039" Y="-20.303" />
        <esri:MapPoint X="132.539" Y="-7.0137" />
        <esri:MapPoint X="153.281" Y="-13.923" />
        <esri:MapPoint X="162.773" Y="-35.174" />
        <esri:MapPoint X="133.594" Y="-43.180" />
        <esri:MapPoint X="111.797" Y="-36.032" />
        <esri:MapPoint X="110.039" Y="-20.303" />
       </esri:PointCollection>
      </esri:Polygon.Rings>
     </esri:Polygon>
    </esri:Graphic>    
   </esri:GraphicsLayer.Graphics>
  </esri:GraphicsLayer>

  </esri:Map>
  <Button DataContext="{StaticResource MyEditor}" Command="{Binding EditVertices}"  Content="Edit" VerticalAlignment="Top" HorizontalAlignment="Center"/>
 </Grid>


private void Editor_EditCompleted(object sender, Editor.EditEventArgs e)
  {
   foreach (var edit in e.Edits)
   {
    resultGeometry = Geometry.Clone(edit.Graphic.Geometry);
   }
  }
  Geometry originalGeometry, resultGeometry;
  private void GraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e)
  {
   originalGeometry = Geometry.Clone(e.Graphic.Geometry);
  }
0 Kudos
Bende_Vries
Emerging Contributor
Jennifer,

Thanks for the quick response. I tried your sample and it works fine. So, there is nothing wrong with the EditVertices. The only difference I can see is that I use the editor from code and not from xaml. Will look further into it. Thanks again.

Ben
0 Kudos