private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
{
if (isAdd)
return;
// open the feature dialog on tap of a feature
if (e.Gesture == GestureType.Tap)
{
IEnumerable<Graphic> graphics = e.DirectlyOver(10, new GraphicsLayer[] { featureLayer } );
foreach (Graphic graphic in graphics)
{
// if editable, make the editable fields enabled. Otherwise disable them
if (featureLayer.IsUpdateAllowed(graphic))
{
RotationTB.IsEnabled = true;
DescriptionTB.IsEnabled = true;
DateTB.IsEnabled = true;
TypeButton.IsEnabled = true;
}
else
{
RotationTB.IsEnabled = false;
DescriptionTB.IsEnabled = false;
DateTB.IsEnabled = false;
TypeButton.IsEnabled = false;
}
// show the attribute page for the first of the graphics returned
FeatureInfoPage.IsOpen = true;
ApplicationBar.IsVisible = false;
FeatureInfoPage.DataContext = graphic;
// select the type value in the ListBoxes to match the graphic's attributes
var typeMatches = FeatureTypeListBox.Items.Where(a => (a as TemplateItem).ID.Equals(graphic.Attributes["eventtype"]));
if (typeMatches.Any())
FeatureTypeListBox.SelectedItem = typeMatches.First();
return;
}
}
// move a held feature
if (e.Gesture == GestureType.Hold)
{
IEnumerable<Graphic> graphics = e.DirectlyOver(10, new GraphicsLayer[] { featureLayer } );
foreach (Graphic graphic in graphics)
{
if (graphic != null && !graphic.Selected && featureLayer.IsUpdateAllowed(graphic))
{
Editor editor = LayoutRoot.Resources["MyEditor"] as Editor;
if (featureLayer.IsUpdateAllowed(graphic))
{
if (editor.EditVertices.CanExecute(null))
editor.EditVertices.Execute(null);
}
else
if (editor.CancelActive.CanExecute(null))
editor.CancelActive.Execute(null);
}
featureLayer.ClearSelection();
graphic.Select();
}
}
}