Select to view content in your preferred language

About Editor_EditCompleted ...

5473
31
02-23-2011 06:47 AM
MarcoRosa
Emerging Contributor
Hi to all,
i'm using the editor tool and Editor_EditCompleted event: after selection this event it's fired 2 times , the first time e.Action value is "Select" , the second time the value is "Cancel".
It's correct this behaviour ?

Thank u very much
GP
0 Kudos
31 Replies
JenniferNery
Esri Regular Contributor
I cannot replicate the issue when using the Editing samples:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsExplicitSave. EditCompleted is fired once after Select command is completed, EditEventArgs.Action = Editor.EditAction.Select.

In your code, do you call Cancel command? Maybe you have something like this in your code?
if (editor.CancelActive.CanExecute(null))
 editor.CancelActive.Execute(null);

This is similar to clicking "CancelAction" button in the above sample link and will result to e.Action == EditAction.Cancel.

CancelActive may also be triggered when, you activate another Command. For example when you click "New Selection" button and then click "Add to Selection" button. The previous command will be cancelled and as a result will fire EditCompleted with e.Action == EditAction.Cancel.
0 Kudos
MarcoRosa
Emerging Contributor
Hi Jennifer , i verified that event Editor_EditCompleted is fired only one time if u have just one layer on
LayerIDs properties but not if u have 2 for example:

If u have 2 feature layers like following ( my ) case :

<esri:Editor x:Key="MyEditor" Map="{Binding ElementName=MyMap}" LayerIDs="Zone,Comuni"
                         SelectionMode="Point" ContinuousMode="True" EditCompleted="Editor_EditCompleted"  />

In particular the events it's fired 2 times for first layer , one time for second (not in the same order).
I have used to test this a esri sample , no methods editor.CancelActive.Execute(null) in source code.

Now if have 3 layers ( LayerIDs="Zone,Zone2,Comuni" ) i observer that the event it's fired 3 times for one of 3 layers , 2 times for the second e 1 time for the last. (not always in the same order).

I dont' understand why it's appens

Thank's GP
0 Kudos
JenniferNery
Esri Regular Contributor
I cannot replicate the issue with v2.1 and up.
When I make a selection on multiple layers using Editor.Select. Editor.EditCompleted event is fired once for EditAction.Select, regardless if my selection includes features from both layers. I confirmed this using the following code:
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e)
{
 if (e.Action == Editor.EditAction.Select)
  foreach (var edit in e.Edits)
   System.Diagnostics.Debug.WriteLine(edit.Layer.ID);
}

And it my Output window, I see both layer IDs. I also placed a breakpoint on EditCompleted to see if I'll hit it for an EditAction.Cancel, but I didn't.

What version of the API are you using? You are noticing that EditAction.Cancel is fired after Editor.EditAction.Select when you have more than one layer?
0 Kudos
MarcoRosa
Emerging Contributor
Hi jennifer , sorry per very late in my response, i've tried the same code witj api 2.0 and api 2.1.
Looks like correct behaviour with the old api version 2.0 In this case i've the editcompleted_event fired once when i select an object on feature layer, with the 2.1 api the same code fires twice the editcompleted event ... first time with e.Action = select second time e.Action = Cancel

It's correct that ?
thanks again GP
0 Kudos
JenniferNery
Esri Regular Contributor
Hi.

I have the following test. Please try it out and let me know how I could reproduce the issue you are experiencing.
XAML-code:
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

 <Grid x:Name="LayoutRoot" Background="White" >
  <Grid.Resources>
   <esri:Editor x:Key="MyEditor" EditCompleted="Editor_EditCompleted" Map="{Binding ElementName=MyMap}"/>
  </Grid.Resources>
  <esri:Map x:Name="MyMap" Extent="-63043237.1870117,-29260415.7409668,36029344.3774414,36661048.8306274">
   <esri:FeatureLayer ID="Point" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0" />
   <esri:FeatureLayer ID="Line" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/1"/>
   <esri:FeatureLayer ID="Area" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2"/>
  </esri:Map>
  <Button DataContext="{StaticResource MyEditor}" Content="Select" Command="{Binding Select}" VerticalAlignment="Top" HorizontalAlignment="Center"/>
 </Grid>


Here, all I'm doing is printing to my Output Window the e.Action. Running this test against v2.1 Final. I only see Select printed in my Output Window.
Code-behind:
private void Editor_EditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e)
{
 System.Diagnostics.Debug.WriteLine(e.Action);
}
0 Kudos
AndyWright
Frequent Contributor
I'm using the 2.2 beta version of the API and I'm seeing very similar behavior, except the Select action value fires 1, 2, or 3 times.  The Cancel action never fires.  I haven't picked up on the pattern yet, so it seems to be somewhat arbitrary to me.  What is even more interesting is that I draw three graphics on the map - a square, a circle, and a diamond.  On the select event I check to see what the symbol is on the selected graphic and every once in a while it will be one step behind.  For example, I select the circle first and it reports circle, then I select the square and it reports square, then I select the diamond and it reports square, then I select the circle and it reports diamond.  Very weird.  This happens consistently though.

I'm not quite sure what is going on, but it makes it next to impossible to do anything useful with the selected graphic since you're never quite sure which one it is going to be.  I even tried tying into the PropertyChanged event on my graphics layer and reacting to a change in the SelectedGraphics property.  The same thing happens there. 

Jennifer, I'm still not able to upload a zip file less than 2 MB for some reason.  Can I e-mail you the zip file containing my DOTNET project?  I think it's very important for you or someone on your side to see this behavior as you haven't been able to replicate it yet.
0 Kudos
JenniferNery
Esri Regular Contributor
Hi Andy. I'd be glad to look at your code. Please try to strip it down so you may copy-paste or attach only the important parts (i.e. Editor, Layer definition -in XAML/code-behind). Have you tried the code-snippet in post# 5? Would you be able to tell me what other settings I need to add to my FeatureLayer or Editor to be able to reproduce the issue? Also, try to clean the solution if you want to attach it in a zipped file (I think just the code files is sufficient). Thank you for trying out our beta. I would really like to get this resolved if we can figure out what's wrong.
0 Kudos
MarcoRosa
Emerging Contributor
Hi jennifer, iìve tried your code. here the results:

1) i've verified thah your code fire only one time the event on select

2) i've a little difference in my code, i've set the the ContinuousMode="True". I've verified that parameter is the reason for the event to fires 2 times. U can try this.

So , this at point 2) is also good for me, with a work around e've solved my problem, the only think i have to solve now is the following:

i have 2 feature layers on map. i have also set the editor by code .... add and remove tools.
when i click on map i can salect a poligon on each layer. I would like to understand on which layer im' working against not when i select a poligon but when i remove the selected objects from one of 2 layer.
Infact, the e.edits return a Layer not null when i add the selection , null when i remove the selection.

Hope to be my explanation good.
Thanks again

GP
0 Kudos
AndyWright
Frequent Contributor
Jennifer,

I've done everything you said, my zip file is 1.3MB in size, and I still can't upload it to your site.  There are too many files in the project to copy-paste stuff up here.  Can I send it to you in an e-mail?

I've also reported this as a bug to the Silverlight Beta team and uploaded a copy of my project there.  Maybe you can get it from them.  It's BUG-000011.  I know that I also had ContinuousMode set to True in my project, so gporta is obviously on to something there.

Let me know what you think Jennifer.  Thanks ...

Andy
0 Kudos