private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { MyDrawObject.IsEnabled = false; if (MyDrawObject.DrawMode == DrawMode.Point) { ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; point.SpatialReference = MyMap.SpatialReference; System.Windows.Point screenPnt = MyMap.MapToScreen(point); // Account for difference between Map and application origin GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual); System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt); IEnumerable <Graphic> selected = parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt); if (selected.ToArray().Length <= 0) { MyDrawObject.IsEnabled = true; return; } selectedGraphic = selected.ToList()[0] as Graphic; selectedGraphic.Select(); MyDrawObject.DrawMode = DrawMode.Polyline; MyDrawObject.IsEnabled = true; InfoTextBlock.Text = LayoutRoot.Resources["EndText"] as string; } else { ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline; polyline.SpatialReference = MyMap.SpatialReference; GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.ReshapeCompleted += GeometryService_ReshapeCompleted; geometryService.Failed += GeometryService_Failed; geometryService.ReshapeAsync(selectedGraphic.Geometry, polyline); } }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { MyDrawObject.IsEnabled = false; if (MyDrawObject.DrawMode == DrawMode.Point) { ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; point.SpatialReference = MyMap.SpatialReference; System.Windows.Point screenPnt = MyMap.MapToScreen(point); // Account for difference between Map and application origin GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual); System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt); IEnumerable<Graphic> selected = parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt); if (selected.ToArray().Length <= 0) { MyDrawObject.IsEnabled = true; return; } selectedGraphic = selected.ToList()[0] as Graphic; selectedGraphic.Select(); MyDrawObject.DrawMode = DrawMode.Polyline; MyDrawObject.IsEnabled = true; InfoTextBlock.Text = LayoutRoot.Resources["EndText"] as string; } else { ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline; polyline.SpatialReference = MyMap.SpatialReference; GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.ReshapeCompleted += GeometryService_ReshapeCompleted; geometryService.Failed += GeometryService_Failed; geometryService.ReshapeAsync(selectedGraphic.Geometry, polyline); } }