private static void OnEditorEditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e) { FindEditorInVisualTree(); if (_editor == null || _widget == null) return; if (EditorConfiguration.Current.ShowAttributesOnAdd && e.Action == ESRI.ArcGIS.Client.Editor.EditAction.Add) { foreach (ESRI.ArcGIS.Client.Editor.Change change in e.Edits) { var layer = change.Layer as FeatureLayer; if (layer != null && change.Graphic != null && View.Instance != null && View.Instance.Map != null) { OnClickPopupInfo vm = MapApplication.Current.GetPopup(change.Graphic, layer); if (vm != null) { PopupItem localPopupItem = vm.PopupItem; if (localPopupItem == null && vm.PopupItems != null && vm.PopupItems.Count >= 1) localPopupItem = vm.PopupItems[0]; if (localPopupItem != null && localPopupItem.Graphic != null && localPopupItem.Graphic.Geometry != null) { MapPoint popupAnchor = null; MapPoint pt = localPopupItem.Graphic.Geometry as MapPoint; if (pt != null) { // This is a point feature. Show the popup just above it and ignore edit handles Point screenPoint = View.Instance.Map.MapToScreen(pt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else if (localPopupItem.Graphic.Geometry is Polygon) { if (_editor.MoveEnabled || _editor.RotateEnabled || _editor.ScaleEnabled) { // editing is enabled Envelope env = localPopupItem.Graphic.Geometry.Extent; MapPoint tmpPt = new MapPoint(env.XMax - ((env.XMax - env.XMin) / 2.0), env.YMax); // Show the popup at the top/center of the graphic extent minus 4pixels Point screenPoint = View.Instance.Map.MapToScreen(tmpPt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else { // no edit handles - position to northern most vertex popupAnchor = GetNorthernMostPointPolygon(localPopupItem.Graphic.Geometry as Polygon); } } else if (localPopupItem.Graphic.Geometry is Polyline) { if (_editor.MoveEnabled || _editor.RotateEnabled || _editor.ScaleEnabled) { // editing is enabled Envelope env = localPopupItem.Graphic.Geometry.Extent; MapPoint tmpPt = new MapPoint(env.XMax - ((env.XMax - env.XMin) / 2.0), env.YMax); // Show the popup at the top/center of the graphic extent minus 4pixels Point screenPoint = View.Instance.Map.MapToScreen(tmpPt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else { // no edit handles - position to northern most vertex popupAnchor = GetNorthernMostPointPolyline(localPopupItem.Graphic.Geometry as Polyline); } } // Show the identify popup if (popupAnchor != null && vm.Container !=null) { EditValuesCommand cmd = PopupHelper.ShowPopup(vm, popupAnchor); vm.Container.Dispatcher.BeginInvoke(() => { if (cmd==null) cmd = new EditValuesCommand(); cmd.Execute(vm); }); _viewModel = vm; // wait until layer edits are done before editing the shape if (layer.AutoSave) { layer.EndSaveEdits -= layer_EndSaveEdits; layer.EndSaveEdits += layer_EndSaveEdits; } else { // in case auto save is off, wait until the popup has loaded vm.Container.Loaded -= OnIdentifyPopupLoaded; vm.Container.Loaded += OnIdentifyPopupLoaded; } } } } break; } } } }
private static void OnEditorEditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e) { FindEditorInVisualTree(); if (_editor == null || _widget == null) { return; } if (EditorConfiguration.Current.ShowAttributesOnAdd && e.Action == ESRI.ArcGIS.Client.Editor.EditAction.Add) { foreach (ESRI.ArcGIS.Client.Editor.Change change in e.Edits) { var layer = change.Layer as FeatureLayer; if (layer != null && change.Graphic != null && View.Instance != null && View.Instance.Map != null) { OnClickPopupInfo vm = MapApplication.Current.GetPopup(change.Graphic, layer); if (vm != null) { PopupItem localPopupItem = vm.PopupItem; if (localPopupItem == null && vm.PopupItems != null && vm.PopupItems.Count >= 1) { localPopupItem = vm.PopupItems[0]; } if (localPopupItem != null && localPopupItem.Graphic != null && localPopupItem.Graphic.Geometry != null) { MapPoint popupAnchor = null; MapPoint pt = localPopupItem.Graphic.Geometry as MapPoint; if (pt != null) { // This is a point feature. Show the popup just above it and ignore edit handles Point screenPoint = View.Instance.Map.MapToScreen(pt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else if (localPopupItem.Graphic.Geometry is Polygon) { if (_editor.MoveEnabled || _editor.RotateEnabled || _editor.ScaleEnabled) { // editing is enabled Envelope env = localPopupItem.Graphic.Geometry.Extent; MapPoint tmpPt = new MapPoint(env.XMax - ((env.XMax - env.XMin) / 2.0), env.YMax); // Show the popup at the top/center of the graphic extent minus 4pixels Point screenPoint = View.Instance.Map.MapToScreen(tmpPt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else { // no edit handles - position to northern most vertex popupAnchor = GetNorthernMostPointPolygon(localPopupItem.Graphic.Geometry as Polygon); } } else if (localPopupItem.Graphic.Geometry is Polyline) { if (_editor.MoveEnabled || _editor.RotateEnabled || _editor.ScaleEnabled) { // editing is enabled Envelope env = localPopupItem.Graphic.Geometry.Extent; MapPoint tmpPt = new MapPoint(env.XMax - ((env.XMax - env.XMin) / 2.0), env.YMax); // Show the popup at the top/center of the graphic extent minus 4pixels Point screenPoint = View.Instance.Map.MapToScreen(tmpPt); popupAnchor = View.Instance.Map.ScreenToMap(new Point(screenPoint.X, screenPoint.Y - 4)); } else { // no edit handles - position to northern most vertex popupAnchor = GetNorthernMostPointPolyline(localPopupItem.Graphic.Geometry as Polyline); } } // Show the identify popup if (popupAnchor != null && vm.Container != null) { EditValuesCommand cmd = PopupHelper.ShowPopup(vm, popupAnchor); vm.Container.Dispatcher.BeginInvoke(() => { if (cmd == null) { cmd = new EditValuesCommand(); } cmd.Execute(vm); }); _viewModel = vm; // wait until layer edits are done before editing the shape if (layer.AutoSave) { layer.EndSaveEdits -= layer_EndSaveEdits; layer.EndSaveEdits += layer_EndSaveEdits; } else { // in case auto save is off, wait until the popup has loaded vm.Container.Loaded -= OnIdentifyPopupLoaded; vm.Container.Loaded += OnIdentifyPopupLoaded; } } } } break; } } } }