<esri:Editor x:Key="MyEditor"
Map="{Binding ElementName=MyMap}"
LayerIDs="CensusDemographics"
SelectionMode="Rectangle"
ContinuousMode="True"
EditCompleted="Editor_EditCompleted"/>
<Button x:Name="SelectButton"
Margin="2"
Content="New"
Command="{Binding Select}"
CommandParameter="New"
Click="SelectButton_Click"
></Button>
private void Editor_EditCompleted(object sender, Editor.EditEventArgs e)
{
Editor editor = sender as Editor;
if (editor.ContinuousMode) return; // for this case, remove highlight when other button is clicked.
foreach (var edits in e.Edits)
{
if (e.Action == Editor.EditAction.Select)
{
SelectButton.Background = new SolidColorBrush(Colors.LightGray);
}
}
}
private void SelectButton_Click(object sender, RoutedEventArgs e)
{
//if Editor is Continuous, remove highlight on other buttons before this code
Button b = sender as Button;
b.Background = new SolidColorBrush(Colors.Yellow);
}
I can't believe that the editor turns off just because the user clicks somewhere other than the selectable layer, and on the flip side, if they want to turn off the selection process they have to click somewhere other than this layer.
public MainPage()
{
InitializeComponent();
editor = this.LayoutRoot.Resources["MyEditor"] as Editor;
if (editor != null)
editor.EditCompleted += new EventHandler<Editor.EditEventArgs>(editor_EditCompleted);
}
Editor editor;
void editor_EditCompleted(object sender, Editor.EditEventArgs e)
{
if (editor.ContinuousMode) return;
foreach (var edits in e.Edits)
{
if (e.Action == Editor.EditAction.Select)
ResetButtonHighlights();
}
}
private void ResetButtonHighlights()
{
SelectButton.Background = new SolidColorBrush(Colors.LightGray);
AddSelectButton.Background = new SolidColorBrush(Colors.LightGray);
RemoveSelectButton.Background = new SolidColorBrush(Colors.LightGray);
ClearSelectionButton.Background = new SolidColorBrush(Colors.LightGray);
EnableKeyboardButton.Background = new SolidColorBrush(Colors.LightGray);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!editor.ContinuousMode)
ResetButtonHighlights();
Button b = sender as Button;
b.Background = new SolidColorBrush(Colors.Yellow);
}
Oh I think I get what you are talking about now. You are looking for an event that will fire when the command is no longer active.
EditorActivated only fires when you activate a command and EditCompleted event only fires when you have successfully executed the command.
For the case when you try to make a selection on an area without graphics, no selection is made, the command did not execute successfully so EditCompleted is not raised.
I'm afraid that using only these two events cannot get you what you wanted.
Jennifer