const string attributeBindingRegex = @"({)([^}]*)(})"; // Regular expression to identify attribute bindings public static string ConvertExpressionWithFieldNames(PopupItem item, string formatter) { if (!string.IsNullOrEmpty(formatter)) { StringBuilder sb = new StringBuilder(); string[] splitStringArray = Regex.Split(formatter, attributeBindingRegex); bool isAttributeName = false; foreach (string str in splitStringArray) { if (str == "{") { isAttributeName = true; continue; } if (str == "}") { isAttributeName = false; continue; } if (isAttributeName && item.Graphic.Attributes.ContainsKey(str)) { var temp = MapTipsHelper.GetFieldValue(item, str); sb.AppendFormat("{0}", temp); } else if (!isAttributeName) { sb.AppendFormat("{0}", str); } } return(sb.ToString().Replace("$LINEBREAK$", "<br/>").Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("'", "'").Replace(""", "\"")); } return(null); }
public async Task <IActionResult> PutPopupItem(int id, PopupItem popupItem) { if (id != popupItem.Id) { return(BadRequest()); } _context.Entry(popupItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PopupItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void AddDisabledItem(GUIContent content, bool isOn) { PopupItem i = new PopupItem(content, isOn, null); i.isDisabled = true; Items.Add(i); }
/// <summary> /// Modifies the source data before passing it to the target for display in the UI. /// </summary> /// <param name="value">The source data being passed to the target.</param> /// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param> /// <param name="parameter">An optional parameter to be used in the converter logic.</param> /// <param name="culture">The culture of the conversion.</param> /// <returns> /// The value to be passed to the target dependency property. /// </returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IDictionary <string, object> dict = null; PopupItem popupitem = null; if (value is PopupItem) { popupitem = value as PopupItem; if (popupitem != null && popupitem.Graphic != null) { dict = popupitem.Graphic.Attributes; } } if (dict != null) { string fieldName = parameter as string; if (!string.IsNullOrEmpty(fieldName)) { object o = MapTipsHelper.GetFieldValue(popupitem, fieldName); if (o != null) { return(o.ToString()); } } } return(null); }
public void AddSeparator() { PopupItem i = new PopupItem(null, false, null); i.isSeparator = true; Items.Add(i); }
void IncrementPopup(GameObject foodObject) { if (mouseOverPrefab != null) { PopupItem popup = GetOrCreatePopup(foodObject); popup.Count++; } }
private static void OnPopupItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var target = (PopupCommandBase)d; var oldPopupItem = (PopupItem)e.OldValue; PopupItem newPopupItem = target.PopupItem; target.OnPopupItemChanged(oldPopupItem, newPopupItem); }
/// <summary> /// Adds a new item entry to the list. /// </summary> /// <param name="text"></param> public void AddItem(string text, PopupItem.OnSelectEvent onSelect) { PopupItem item = new PopupItem(text, onSelect, this); itemList.Add(item); if (itemList.Count == 1) { item.Selected = true; } } // end of LoadLevelPopup AddItem()
public async Task <ActionResult <PopupItem> > PostPopupItem(PopupItem popupItem) { var popup = await _context.Popup.FindAsync(popupItem.Popup.Id); popupItem.Popup = popup; _context.PopupItem.Add(popupItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPopupItem", new { id = popupItem.Id }, popupItem)); }
public void Handle(ShowPopup message) { if (!PopupIsOpen) { PopupWidth = message.Width; PopupHeight = message.Height; PopupItem = message.Popup; PopupItem.Activate(); PopupIsOpen = true; } }
private void dotNetBarManager1_PopupOpen(object sender, DevComponents.DotNetBar.PopupOpenEventArgs e) { BaseItem item = sender as BaseItem; if (item == null) { return; } if (item.Name == "bTabContext") { // Enable/Disable the document related menu items based on where user right-clicked... TabItem tab = TabItemFromPoint(tabStrip1.PointToClient(Control.MousePosition)); // If no tab is under the mouse disable document related items... if (tab == null) { item.SubItems["bClose"].Enabled = false; item.SubItems["bSave"].Enabled = false; } else { item.SubItems["bClose"].Enabled = true; item.SubItems["bSave"].Enabled = true; // Make sure that tab under the mouse is active tab tabStrip1.SelectedTab = tab; } } else if (item.Name == "bDockContext") { Bar bar = dotNetBarManager1.Bars["barTaskList"]; // Display our context menu only if user clicks on the bar caption or tab strip control if (!bar.GrabHandleRect.Contains(bar.PointToClient(Control.MousePosition)) && bar.DockTabControl != null && !bar.DockTabControl.Bounds.Contains(bar.PointToClient(Control.MousePosition))) { e.Cancel = true; return; } item.SubItems.Clear(); ButtonItem contextItem = null; foreach (BaseItem dockItem in bar.Items) { contextItem = new ButtonItem(dockItem.Name, dockItem.Text); contextItem.GlobalItem = false; contextItem.Click += new EventHandler(this.DockContextClick); item.SubItems.Add(contextItem); contextItem.Checked = dockItem.Visible; } contextItem = new ButtonItem("bc_tabnavigation", "Tab Navigation"); contextItem.Checked = bar.TabNavigation; contextItem.BeginGroup = true; contextItem.Click += new EventHandler(this.DockContextClick); item.SubItems.Add(contextItem); PopupItem popup = item as PopupItem; } }
private static void StandardView_Closed(object sender, EventArgs e) { PopupItem popupItem = sender as PopupItem; popupItem.Closed -= StandardView_Closed; StandardWindow window = new StandardWindow(); window.Show(); window.Activate(); window.Show(popupItem); }
PopupItem GetOrCreatePopup(GameObject foodObject) { PopupItem popup; if (!popups.TryGetValue(foodObject, out popup)) { popup = new PopupItem(Instantiate(mouseOverPrefab, canvas.transform)); Food food = foodObject.GetComponent <Food>(); popup.Text.text = food.Name; popups.Add(foodObject, popup); return(popup); } return(popup); }
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); } } }
private void FTree_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { FTree.SelectedNode = FTree.GetNodeAt(e.Location); if (FTree.SelectedNode != null) { ContextMenuBar menu = (FTree.SelectedNode.Tag as Base).GetContextMenu(); if (menu != null) { PopupItem item = menu.Items[0] as PopupItem; item.PopupMenu(FTree.PointToScreen(e.Location)); } } } }
/// <summary> /// Modifies the source data before passing it to the target for display in the UI. /// </summary> /// <param name="value">The source data being passed to the target.</param> /// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param> /// <param name="parameter">An optional parameter to be used in the converter logic.</param> /// <param name="culture">The culture of the conversion.</param> /// <returns> /// The value to be passed to the target dependency property. /// </returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IDictionary <string, object> dict = null; PopupItem popupitem = null; if (value is PopupItem) { popupitem = value as PopupItem; if (popupitem != null && popupitem.Graphic != null) { dict = popupitem.Graphic.Attributes; } } if (dict != null) { object fieldValue = null; string fieldName = parameter as string; if (!string.IsNullOrEmpty(fieldName)) { fieldValue = MapTipsHelper.GetFieldValue(popupitem, fieldName); } if (fieldValue != null) { string fieldUrl = MapTipsHelper.ExtractHyperlinkValue(fieldValue, true); if (String.IsNullOrEmpty(fieldUrl)) { return(null); } Uri targetUri = null; if (!Uri.TryCreate(fieldUrl, UriKind.Absolute, out targetUri)) { return(null); } return(fieldUrl); } } return(null); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (FPageDesigner.Locked) { return; } if (e.Button == MouseButtons.Right && Designer.SelectedObjects.Count > 0 && Designer.SelectedObjects[0] is BandBase) { ContextMenuBar menu = Designer.SelectedObjects[0].GetContextMenu(); if (menu != null) { PopupItem item = menu.Items[0] as PopupItem; item.PopupMenu(PointToScreen(e.Location)); } } }
public static PopupItem GetPopupItem(Graphic graphic, Layer layer, IEnumerable <FieldInfo> fields, LayerInformation layerInfo, string layerName, string title = null, int?layerId = null) { if (layerInfo != null || layer is GraphicsLayer) { PopupItem popupItem = new PopupItem() { Graphic = graphic, Layer = layer, Title = title, LayerName = layerName, }; if (layerId.HasValue) { popupItem.LayerId = layerId.Value; } if (layerInfo != null) { GetMappedAttributes(graphic.Attributes, layerInfo); } popupItem.FieldInfos = MapTipsHelper.ToFieldSettings(fields); MapTipsHelper.GetTitle(popupItem, layerInfo); bool hasContent = true; DataTemplate dt = MapTipsHelper.BuildMapTipDataTemplate(popupItem, out hasContent, layerInfo); if (!hasContent) { popupItem.DataTemplate = null; } else if (dt != null) { popupItem.DataTemplate = dt; } if (hasContent || (!string.IsNullOrWhiteSpace(popupItem.Title))) { return(popupItem); } } return(null); }
public void UpdateUserTitle() { if (m_PopupList.activeSelf != true) { return; } if (PlayerRole.Instance.TitleManager.GetAllTitle() == null) { return; } ClearGrid(); m_PopupItemList.Clear(); foreach (KeyValuePair <byte, byte> map in PlayerRole.Instance.TitleManager.GetAllTitle()) { if (FishConfig.Instance.m_TitleInfo.m_TileMap.ContainsKey(map.Key) != true) { continue; } PopupItem item = new PopupItem(); item.m_Obj = GameObject.Instantiate(m_PopupListItem) as GameObject; item.m_Obj.SetActive(true); item.m_Title = item.m_Obj.transform.GetChild(0).GetComponent <UILabel>(); item.m_SelectBg = item.m_Obj.transform.GetChild(1).gameObject; item.m_Title.text = FishConfig.Instance.m_TitleInfo.m_TileMap[map.Key].TitleName; item.m_TitleID = FishConfig.Instance.m_TitleInfo.m_TileMap[map.Key].TitleID; m_UIGrid.AddChild(item.m_Obj.transform); item.m_Obj.transform.localScale = Vector3.one; m_PopupItemList.Add(item); UIEventListener.Get(item.m_Obj).onClick = OnClickTitle; } if (m_PopupItemList.Count == 0) { m_UITitleTips.text = StringTable.GetString("Title_Tips"); m_UITitleTips.gameObject.SetActive(true); } else { m_UITitleTips.gameObject.SetActive(false); } }
private Tween <float> GetItemTween(PopupItem popupItem, int index) { //Debug.Log(index + ":" + popupItem.RT.anchoredPosition.y); var tween = Tween <float> .Obtain(); tween.SetEasing(TweenEasingFunctions.Linear); tween.SetStartValue(25f); tween.SetEndValue(popupItem.RT.anchoredPosition.y); //tween.OnSyncStartValue(() => { return 25f; }); //tween.OnSyncEndValue(() => { return popupItem.RT.anchoredPosition.y; }); tween.SetDuration(index * m_DropSpeed); tween.SetLoopType(TweenLoopType.None); tween.OnExecute((float y) => { var pos = popupItem.RT.anchoredPosition; pos.y = y; popupItem.RT.anchoredPosition = pos; }); return(tween); }
void _popupInfo_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "PopupItem") { // If the last used (old) item in the model is not null then remove the event handler which was // attached since it is likely to be a different item now. if (_oldPopupItem != null) { _oldPopupItem.PropertyChanged -= PopupItem_PropertyChanged; } // If the currently selected item is not null, then we want to listen for when a property of // this object changes so establish the event handler. if (_popupInfo.PopupItem != null) { _popupInfo.PopupItem.PropertyChanged += PopupItem_PropertyChanged; } // Whatever the now current item is, store it as the last used (old) item so we can unhook // event handlers when it is changed. _oldPopupItem = _popupInfo.PopupItem; } }
public static List <PopupItem> GetPopupItems(IEnumerable <Graphic> graphics, Layer layer, int?layerId = null) { List <PopupItem> popupItems = new List <PopupItem>(); IEnumerable <FieldInfo> fields = null; LayerInformation layerInfo = null; if (layer is GraphicsLayer) { fields = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetFields(layer as GraphicsLayer); } else if (layerId != null) { Collection <LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer); if (layerInfos != null) { layerInfo = layerInfos.FirstOrDefault(l => l.ID == layerId); if (layerInfo != null) { fields = layerInfo.Fields; } } } string layerName = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerName(layer); foreach (Graphic graphic in graphics) { PopupItem popupItem = GetPopupItem(graphic, layer, fields, layerInfo, layerName); if (popupItem != null) { popupItems.Add(popupItem); } } return(popupItems); }
void reportResults(IdentifyEventArgs args) { if (doNotShowResults) { removeBusyIndicator(); return; } if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { Layer layer = (args.UserState as UserState).Layer; Collection <LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer); foreach (IdentifyResult result in args.IdentifyResults) { LayerInformation layerInfo = layerInfos.FirstOrDefault(l => l.ID == result.LayerId); if (layerInfo != null) { PopupItem popupItem = PopupHelper.GetPopupItem(result.Feature, layer, layerInfo.Fields, layerInfo, result.LayerName, result.Value.ToString(), result.LayerId); if (popupItem != null) { _popupInfo.PopupItems.Add(popupItem); } } } } removeBusyIndicator(); if (_popupInfo.PopupItems.Count > 0) { if (_popupInfo.SelectedIndex < 0) { _popupInfo.SelectedIndex = 0; } PopupHelper.ShowPopup(_popupInfo, clickPoint); } }
public static bool CanEditShape(PopupItem popup, ESRI.ArcGIS.Client.Editor editor = null) { if (editor == null) { editor = FindEditorInVisualTree(); } var featureLayer = popup.Layer as FeatureLayer; if (popup == null || popup.Graphic == null || featureLayer == null || featureLayer.LayerInfo == null || !featureLayer.IsGeometryUpdateAllowed(popup.Graphic) || !(LayerProperties.GetIsEditable(featureLayer)) || editor == null || editor.EditVertices == null || !editor.EditVerticesEnabled || View.Instance.Map == null) { return(false); } return(true); }
public static void ShowStandard(PopupItem topitem) { topitem.Closed += StandardView_Closed; topitem.Close(); }
public CallElement(int level, string name, PopupItem item) { base.level = level; content = new GUIContent(name, item.image); action = item.action; }
protected virtual void OnPopupItemChanged(PopupItem oldPopupItem, PopupItem newPopupItem) { RefreshCommand(); }
public static object GetFieldValue(PopupItem popupItem, string fieldName) { if (string.IsNullOrEmpty(fieldName) || popupItem == null || popupItem.Graphic == null || popupItem.Graphic.Attributes == null || popupItem.FieldInfos == null) { return(null); } Layer layer = popupItem.Layer; FeatureLayer featureLayer = layer as FeatureLayer; Collection <LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer); // Try to find feature layer from layer info foreach (LayerInformation item in layerInfos) { if (item.ID == popupItem.LayerId) { featureLayer = item.FeatureLayer; break; } } // Try to find field information from field settings collection (which are FieldInfo objects) FieldInfo fldInfo = null; foreach (FieldSettings fld in popupItem.FieldInfos) { if (fld.Name.ToLower().Equals(fieldName.ToLower())) { fldInfo = fld as FieldInfo; break; } } if (fldInfo == null) { return(null); } // Create local variable for attributes to improve performance since collection is referenced multiple // times in logic below. IDictionary <string, object> attributes = popupItem.Graphic.Attributes; // If the field is a subdomain type, then lookup the value and return if (FieldInfo.GetDomainSubTypeLookup(featureLayer, fldInfo) != DomainSubtypeLookup.None) { return(GetDomainValue(featureLayer, attributes, fldInfo)); } // Try to extract value from field using Name and then DisplayName object fieldValue = null; if (!attributes.TryGetValue(fldInfo.Name, out fieldValue)) { if (!attributes.TryGetValue(fldInfo.DisplayName, out fieldValue)) { return(null); } } // Special formatting if the field type is Currency or Date/Time if (fldInfo.FieldType == FieldType.Currency) { CurrencyFieldValue currencyFieldValue = fieldValue as CurrencyFieldValue; if (currencyFieldValue != null) { fieldValue = currencyFieldValue.FormattedValue; } } else if (fldInfo.FieldType == FieldType.DateTime) { DateTimeFieldValue dateFieldValue = fieldValue as DateTimeFieldValue; if (dateFieldValue != null) { fieldValue = dateFieldValue.FormattedValue; } } return(fieldValue); }
public static DataTemplate BuildMapTipDataTemplate(PopupItem popupItem, out bool hasContent, LayerInformation layerInfo = null) { hasContent = false; if (popupItem == null || popupItem.Graphic == null || popupItem.Graphic.Attributes == null || popupItem.Layer == null) { return(null); } Layer layer = popupItem.Layer; string popupDataTemplatesXaml = null; #region Get from developer override/webmap override //First get from developer override IDictionary <int, string> templates = ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetPopupDataTemplates(layer); //then if defined in web map if (templates == null && ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsePopupFromWebMap(layer)) { templates = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetWebMapPopupDataTemplates(layer); } if (templates != null) { if (layer is GraphicsLayer) { popupDataTemplatesXaml = (templates.ContainsKey(-1)) ? templates[-1] : null; } else { popupDataTemplatesXaml = (templates.ContainsKey(layerInfo.ID)) ? templates[layerInfo.ID] : null; } } #endregion DataTemplate dt = null; StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(popupDataTemplatesXaml)) { // Use popup data template xaml. hasContent = true; sb.Append(popupDataTemplatesXaml); } else { sb.Append("<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" "); sb.Append("xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" "); sb.Append("xmlns:mapping=\"http://schemas.esri.com/arcgis/mapping/2009\" "); sb.Append("xmlns:local=\"clr-namespace:ESRI.ArcGIS.Mapping.Controls;assembly=ESRI.ArcGIS.Mapping.Controls\" >"); sb.Append("<Grid HorizontalAlignment=\"Stretch\"><Grid.Resources>"); sb.Append("<mapping:LabelAttributeConverter x:Key=\"LabelAttributeConverter\" />"); sb.Append("<mapping:UrlLocationAttributeConverter x:Key=\"UrlLocationAttributeConverter\" />"); sb.Append("<mapping:UrlDescriptionAttributeConverter x:Key=\"UrlDescriptionAttributeConverter\" />"); sb.Append("</Grid.Resources>"); if (popupItem.FieldInfos != null) { // Grid with three columns: sb.Append("<Grid.ColumnDefinitions>"); sb.Append("<ColumnDefinition Width=\"2*\"/>"); sb.Append("<ColumnDefinition Width=\"Auto\"/>"); sb.Append("<ColumnDefinition Width=\"3*\" />"); sb.Append("</Grid.ColumnDefinitions>"); string gridRowDefinitions = string.Empty; StringBuilder content = new StringBuilder(); int numRows = 0; foreach (FieldSettings field in popupItem.FieldInfos) { // If field is not to be displayed, skip this field if (!field.VisibleOnMapTip) { continue; } hasContent = true; gridRowDefinitions += "<RowDefinition Height=\"Auto\" />"; numRows++; // Apply alternating row background to every other row if (numRows % 2 == 0) { content.AppendFormat(@"<Rectangle Fill=""{{StaticResource BackgroundTextColorBrush}}"" HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Grid.ColumnSpan=""3"" Grid.Row=""{0}"" Opacity=""0.15"" />", numRows - 1); } if (!string.IsNullOrEmpty(field.DisplayName)) { // This is where we will eventually add code that uses an expression to plug in the actual // value for a field name when curly braces are detected (or something). content.AppendFormat(@"<Grid Grid.Row=""{0}""><TextBlock Grid.Column=""0"" Text=""{1}"" Margin=""5,2"" Opacity="".6"" VerticalAlignment=""Center"" TextWrapping=""Wrap"" /></Grid>", numRows - 1, PopupInfo.SafeXML(field.DisplayName)); } // Process this field regardless of value. We need to create a control that has binding so that as // the value changes during editing the control will adapt and display null and not-null values // properly. object o = GetFieldValue(popupItem, field.Name); StringBuilder element = GetFieldValueElement(field, o, numRows - 1); if (element != null) { content.Append(element); } // Column separator content.AppendFormat(@"<Rectangle Fill=""{{StaticResource BackgroundTextColorBrush}}"" HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Grid.Column=""1"" Grid.Row=""{0}"" Opacity=""0.3"" Width=""1""/>", numRows - 1); } #region Add Open Item hyperlink if (layer is CustomGraphicsLayer) { ESRI.ArcGIS.Client.Application.Layout.Converters.LocalizationConverter converter = new Client.Application.Layout.Converters.LocalizationConverter(); gridRowDefinitions += "<RowDefinition Height=\"Auto\" />"; numRows++; content.AppendFormat("<HyperlinkButton Content=\"{0}\" Grid.ColumnSpan=\"2\" Grid.Row=\"{1}\" CommandParameter=\"{{Binding}}\"><HyperlinkButton.Command><local:OpenItemCommand/></HyperlinkButton.Command></HyperlinkButton>", converter.Get("OpenItem"), numRows - 1); } #endregion if (!string.IsNullOrEmpty(gridRowDefinitions)) { sb.AppendFormat("<Grid.RowDefinitions>{0}</Grid.RowDefinitions>", gridRowDefinitions); } sb.Append(content.ToString()); } sb.Append("</Grid></DataTemplate>"); } try { dt = (DataTemplate)System.Windows.Markup.XamlReader.Load(sb.ToString()); } catch { /* No content */ } return(dt); }
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; } } } }
public static void GetTitle(PopupItem popupItem, LayerInformation info) { if (popupItem == null) { return; } string titleExpression = string.Empty; string title = string.Empty; Layer layer = popupItem.Layer; #region Get from developer override/webmap override //First get from developer override IDictionary <int, string> titleExpressions = ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetPopupTitleExpressions(layer); //then if defined in web map if (titleExpressions == null && ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsePopupFromWebMap(layer)) { titleExpressions = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetWebMapPopupTitleExpressions(layer); } if (titleExpressions != null) { if (layer is GraphicsLayer) { titleExpression = (titleExpressions.ContainsKey(-1)) ? titleExpressions[-1] : null; } else { titleExpression = (titleExpressions.ContainsKey(popupItem.LayerId)) ? titleExpressions[popupItem.LayerId] : null; } } #endregion #region Get title from expression if (!string.IsNullOrWhiteSpace(titleExpression)) { title = ConvertExpressionWithFieldNames(popupItem, titleExpression); } #endregion if (string.IsNullOrWhiteSpace(title)) { if (layer is GraphicsLayer) //get from display field set in layer configuration { #region Get from display field - Graphics layer string displayFieldName = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetDisplayField(layer as GraphicsLayer); if (!string.IsNullOrWhiteSpace(displayFieldName)) { object o = GetFieldValue(popupItem, displayFieldName); title = (o != null) ? o.ToString() : string.Empty; if (string.IsNullOrWhiteSpace(popupItem.TitleExpression)) { titleExpression = "{" + displayFieldName + "}"; } } #endregion } else if (!ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsePopupFromWebMap(layer)) { #region Get from display field - dynamic layer if (!string.IsNullOrEmpty(info.DisplayField))//get from display field set in layer configuration { object o = GetFieldValue(popupItem, info.DisplayField); title = (o != null) ? o.ToString() : string.Empty; titleExpression = "{" + info.DisplayField + "}"; } #endregion } } if (title != null) { title = title.Trim(); } popupItem.Title = title; popupItem.TitleExpression = titleExpression; }