internal static OnClickPopupInfo GetPopup(IEnumerable<Graphic> graphics, Layer layer, int? layerId = null) { OnClickPopupInfo popupInfo = new OnClickPopupInfo(); OnClickPopupControl.PopupInfo = popupInfo; if (graphics != null && layer != null) { foreach (PopupItem popupItem in GetPopupItems(graphics, layer, layerId)) popupInfo.PopupItems.Add(popupItem); if (popupInfo.SelectedIndex < 0 && popupInfo.PopupItems.Count > 0) popupInfo.SelectedIndex = 0; } return popupInfo; }
/// <summary> /// Executes edit values command if that is the mode we are in /// </summary> /// <param name="popupInfo"></param> public static void SyncPreviousDisplayMode(OnClickPopupInfo popupInfo) { if (popupInfo == null || popupInfo.PopupItem == null) return; InfoWindow win = popupInfo.Container as InfoWindow; if (win==null || OnClickPopupControl==null) return; // find the edit values command associated with the active tool EditValuesCommand editValues = OnClickPopupControl.GetEditValuesToolCommand(); bool isEditable = LayerProperties.GetIsEditable(popupInfo.PopupItem.Layer); if (isEditable) { if (editValues == null) { //if we were showing edit values panel, show that again if (_wasEditingValues && popupInfo != null && popupInfo.Container is InfoWindow) { win.Dispatcher.BeginInvoke(() => { EditValuesCommand cmd = new EditValuesCommand(); cmd.Execute(popupInfo); }); } } else { if (_wasEditingValues) { win.Dispatcher.BeginInvoke(() => { editValues.Execute(popupInfo); }); } else { editValues.BackToOriginalContent(popupInfo); } } } else if(editValues !=null) { editValues.BackToOriginalContent(popupInfo); } }
public static void EditShape(OnClickPopupInfo popupInfo, ESRI.ArcGIS.Client.Editor editor = null, bool dismissPopup = false) { if (popupInfo == null) return; if (editor == null) editor = FindEditorInVisualTree(); PopupItem popup = popupInfo.PopupItem; if (popup == null && popupInfo.PopupItems != null && popupInfo.PopupItems.Count >= 1) popup = popupInfo.PopupItems[0]; if (!CanEditShape(popup, editor)) return; Graphic graphic = popup.Graphic; var featureLayer = popup.Layer as FeatureLayer; if (featureLayer != null && featureLayer.LayerInfo != null) { // Dismiss popup so it does not get in the way of shape edits InfoWindow container = popupInfo.Container as InfoWindow; if (container != null && dismissPopup) container.IsOpen = false; if (featureLayer.LayerInfo.GeometryType == GeometryType.Polygon || featureLayer.LayerInfo.GeometryType == GeometryType.Polyline || featureLayer.LayerInfo.GeometryType == GeometryType.MultiPoint) { EditGeometry(graphic, featureLayer); } else if (featureLayer.LayerInfo.GeometryType == Client.Tasks.GeometryType.Point) { // edit point using Editor EditPoint(editor, graphic); } } }
static void layer_EndSaveEdits(object sender, Client.Tasks.EndEditEventArgs e) { EditShape(_viewModel); // let go of the viewmodel _viewModel = null; }
internal void BackToOriginalContent(OnClickPopupInfo popupInfo) { if (_OriginalPopupContent != null) { InfoWindow win = popupInfo.Container as InfoWindow; if (win != null) { Dispatcher.BeginInvoke(() => { win.Content = _OriginalPopupContent; PopupHelper.SetDisplayMode(PopupHelper.DisplayMode.ReadOnly); }); } } }
/// <summary> /// Checks whether the QueryRelatedRecords tool can be used. Layer must have a relationship associated /// with it for the tool to be enabled. /// </summary> /// <param name="parameter">OnClickPopupInfo from clicked layer</param> public bool CanExecute(object parameter) { popupInfo = parameter as OnClickPopupInfo; if (popupWindow != null && popupInfo.PopupItem != null) { // If the pop-up item (and therefore pop-up) changes, then verify whether the // KeepOnMap View should still be included in the pop-up. popupWindow = popupInfo.Container as InfoWindow; popupInfo.PropertyChanged += PopupItem_PropertyChanged; } return popupInfo != null && popupInfo.PopupItem != null && popupInfo.PopupItem.Layer is FeatureLayer && ((FeatureLayer)popupInfo.PopupItem.Layer).LayerInfo != null && ((FeatureLayer)popupInfo.PopupItem.Layer).LayerInfo.Relationships != null && ((FeatureLayer)popupInfo.PopupItem.Layer).LayerInfo.Relationships.Count() > 0 && MapApplication.Current != null && MapApplication.Current.Map != null && MapApplication.Current.Map.Layers != null && MapApplication.Current.Map.Layers.Contains(popupInfo.PopupItem.Layer) && popupInfo.PopupItem.Graphic != null; }
public static EditValuesCommand ShowPopup(OnClickPopupInfo popupInfo, MapPoint anchorPoint) { if (popupInfo.Container is InfoWindow) { ((InfoWindow)popupInfo.Container).Show(anchorPoint); SyncPreviousDisplayMode(popupInfo); if (OnClickPopupControl != null) return OnClickPopupControl.GetEditValuesToolCommand(); } return null; }
private static void ShowPopup(OnClickPopupInfo popupInfo, Geometry geometry) { if (popupInfo.Container is InfoWindow) { MapPoint anchorPoint = GetLastPoint(geometry); if (anchorPoint != null) ShowPopup(popupInfo, anchorPoint); } }