private void SelectedWellsTreeView_OnSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (e.RemovedItems.Count > 0) { Graphic g = e.RemovedItems[0] as Graphic; g.UnSelect(); g.SetZIndex(0); } if (e.AddedItems.Count > 0) { Graphic g = e.AddedItems[0] as Graphic; g.Select(); g.SetZIndex(1); //Relationship query RelationshipParameter relationshipParameters = new RelationshipParameter() { ObjectIds = new int[] { Convert.ToInt32(g.Attributes[SelectedWellsTreeView.Tag as string]) }, OutFields = new string[] { "OBJECTID, API_NUMBER, ELEVATION, FORMATION, TOP" }, RelationshipId = 3, OutSpatialReference = MyMap.SpatialReference }; queryTask.ExecuteRelationshipQueryAsync(relationshipParameters); } }
/// <summary> /// Open FeatureDataForm to Edit Attributes /// </summary> private void OpenFeatureDataEditor(FeatureLayer layer, Graphic graphic) { if (featureEditor.ClearSelection.CanExecute(null)) { featureEditor.ClearSelection.Execute(null); } graphic.Select(); dataEditorForm.FeatureLayer = layer; dataEditorForm.GraphicSource = graphic; dataEditorWindow.Title = layer.LayerInfo.Name; if (layer.LayerInfo.HasAttachments) { attachmentEditor.GraphicSource = graphic; attachmentEditor.FeatureLayer = layer; attachmentEditor.Visibility = Visibility.Visible; } else { attachmentEditor.Visibility = Visibility.Collapsed; } FloatingPopup.Show(dataEditorWindow); //Show Attribute Editing Window at Feature Geometry's Centroid //FloatingPopup.Show(dataEditorWindow, MapControl.MapToScreen(graphic.Geometry.Extent.GetCenter())); }
private void SelectedWellsTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (e.OldValue != null) { Graphic g = e.OldValue as Graphic; g.UnSelect(); g.SetZIndex(0); } if (e.NewValue != null) { Graphic g = e.NewValue as Graphic; g.Select(); g.SetZIndex(1); //Relationship query RelationshipParameter relationshipParameters = new RelationshipParameter() { ObjectIds = new int[] { Convert.ToInt32(g.Attributes[SelectedWellsTreeView.Tag as string]) }, OutFields = new string[] { "OBJECTID, API_NUMBER, ELEVATION, FORMATION, TOP" }, RelationshipId = 3, OutSpatialReference = MyMap.SpatialReference }; queryTask.ExecuteRelationshipQueryAsync(relationshipParameters); } }
/// <summary> /// Set selection. /// </summary> /// <param name="graphic">Graphic to set selection.</param> public void DoSelect(Graphic graphic) { int zIndex = graphic.GetZIndex(); graphic.Select(); zIndex = zIndex ^ SELECTEDZINDEX; graphic.SetZIndex(zIndex); }
private void LeftFeatureLink_MouseEnter(object sender, MouseEventArgs e) { if (sender is SimpleLinkButton) { SimpleLinkButton fLink = sender as SimpleLinkButton; if (!fLink.IsActive) { Graphic feature = (Graphic)fLink.Tag; if (feature != null) { feature.Select(); } } } }
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 vertexLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs args) { Graphic graphic = args.Graphic; if (graphic.Geometry is MapPoint) //Moving point { DraggingVertex = graphic; args.Handled = true; //Prevent map from reacting to mouse event DraggingVertex.Select(); StartTracking(); fromPoint = new MapPoint((graphic.Geometry as MapPoint).X, (graphic.Geometry as MapPoint).Y); } else if (graphic.Geometry is Polyline) //Adding vertex { Polyline line = graphic.Geometry as Polyline; Point pScreen = args.GetPosition(MyMap); MapPoint pMap = MyMap.ScreenToMap(pScreen); MapPoint snap = FindPointOnLineClosestToPoint(line.Paths[0][0], line.Paths[0][1], pMap); args.Handled = true; PointCollection pnts = graphic.Attributes["PointCollection"] as PointCollection; Graphic parent = graphic.Attributes["Feature"] as Graphic; //Add new vertex and immediately start tracking it if (snapVertex != null) { vertexLayer.Graphics.Remove(snapVertex); } DraggingVertex = AddVertexToEditLayer(parent, vertexLayer, snap); DraggingVertex.Select(); args.Handled = true; //Prevent map from reacting to mouse event StartTracking(); DraggingVertex.Attributes.Add("PointCollection", pnts); int index = pnts.IndexOf(line.Paths[0][0]); pnts.Insert(index + 1, snap); vertexLayer.Graphics.Remove(graphic); AddHoverLineSegment(pnts, line.Paths[0][0], snap, parent); AddHoverLineSegment(pnts, snap, line.Paths[0][1], parent); OnGeometryEdit(graphic, snap, null, Action.VertexAdded); fromPoint = new MapPoint(snap.X, snap.Y); } }
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); } }